#549: Add Fluid types / tags

By: Martoph <sager1018@gmail.com>
This commit is contained in:
Bukkit/Spigot 2020-09-14 19:36:28 +10:00
parent 60074ffbfd
commit 9ff0ebcc6a
3 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package org.bukkit;
import java.util.Locale;
import org.jetbrains.annotations.NotNull;
public enum Fluid implements Keyed {
WATER,
FLOWING_WATER,
LAVA,
FLOWING_LAVA;
private final NamespacedKey key;
private Fluid() {
this.key = NamespacedKey.minecraft(this.name().toLowerCase(Locale.ROOT));
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
}

View File

@ -158,6 +158,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
return MemoryKey.getByKey(key);
}
};
/**
* Server fluids.
*
* @see Fluid
*/
Registry<Fluid> FLUID = new SimpleRegistry<>(Fluid.class);
/**
* Get the object by its key.

View File

@ -409,6 +409,18 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla item tag representing all furnace materials.
*/
Tag<Material> ITEMS_FURNACE_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("furnace_materials"), Material.class);
/**
* Key for the built in fluid registry.
*/
String REGISTRY_FLUIDS = "fluids";
/**
* Vanilla fluid tag representing lava and flowing lava.
*/
Tag<Fluid> FLUIDS_LAVA = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("lava"), Fluid.class);
/**
* Vanilla fluid tag representing water and flowing water.
*/
Tag<Fluid> FLUIDS_WATER = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("water"), Fluid.class);
/**
* Returns whether or not this tag has an entry for the specified item.