diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5fdc43f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "modules/nukkit/src/main/resources/mappings"] + path = modules/nukkit/src/main/resources/mappings + url = https://github.com/GeyserMC/mappings.git diff --git a/modules/BattleMcAPI/pom.xml b/modules/BattleMcAPI/pom.xml index 50ebbd6..3fea288 100644 --- a/modules/BattleMcAPI/pom.xml +++ b/modules/BattleMcAPI/pom.xml @@ -70,19 +70,19 @@ org.battleplugins:McAPI-* - mc.euro:BukkitAdapter + mc.euro:Version javassist:javassist - - mc.euro.bukkitadapter - org.battleplugins.bukkit.adapter - javassist org.battleplugins.alib.javassist + + mc.euro.version + org.battleplugins.util.version + diff --git a/modules/api/src/main/java/org/battleplugins/APIType.java b/modules/api/src/main/java/org/battleplugins/APIType.java deleted file mode 100644 index 6ad2f61..0000000 --- a/modules/api/src/main/java/org/battleplugins/APIType.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.battleplugins; - -public enum APIType { - - BUKKIT, - NUKKIT, - SPONGE, - // SPOUT, -} diff --git a/modules/api/src/main/java/org/battleplugins/ChatColor.java b/modules/api/src/main/java/org/battleplugins/ChatColor.java index 713300b..524cd65 100644 --- a/modules/api/src/main/java/org/battleplugins/ChatColor.java +++ b/modules/api/src/main/java/org/battleplugins/ChatColor.java @@ -4,107 +4,143 @@ import java.util.Map; import java.util.regex.Pattern; +/** + * A color utility mainly used in chat. + */ public enum ChatColor { - BLACK('0', 0x00), - DARK_BLUE('1', 0x1), - DARK_GREEN('2', 0x2), - DARK_AQUA('3', 0x3), - DARK_RED('4', 0x4), - DARK_PURPLE('5', 0x5), - GOLD('6', 0x6), - GRAY('7', 0x7), - DARK_GRAY('8', 0x8), - BLUE('9', 0x9), - GREEN('a', 0xA), - AQUA('b', 0xB), - RED('c', 0xC), - LIGHT_PURPLE('d', 0xD), - YELLOW('e', 0xE), - WHITE('f', 0xF), - MAGIC('k', 0x10, true), - BOLD('l', 0x11, true), - STRIKETHROUGH('m', 0x12, true), - UNDERLINE('n', 0x13, true), - ITALIC('o', 0x14, true), - RESET('r', 0x15); + BLACK('0'), + DARK_BLUE('1'), + DARK_GREEN('2'), + DARK_AQUA('3'), + DARK_RED('4'), + DARK_PURPLE('5'), + GOLD('6'), + GRAY('7'), + DARK_GRAY('8'), + BLUE('9'), + GREEN('a'), + AQUA('b'), + RED('c'), + LIGHT_PURPLE('d'), + YELLOW('e'), + WHITE('f'), + MAGIC('k', true), + BOLD('l', true), + STRIKETHROUGH('m', true), + UNDERLINE('n', true), + ITALIC('o', true), + RESET('r'), + NONE(Character.MIN_VALUE); public static final char COLOR_CHAR = '\u00A7'; - private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf(COLOR_CHAR) + "[0-9A-FK-OR]"); + private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + COLOR_CHAR + "[0-9A-FK-OR]"); - private final int intCode; private final char code; private final boolean isFormat; private final String toString; - private static final Map BY_ID = new HashMap<>(); private static final Map BY_CHAR = new HashMap<>(); - ChatColor(char code, int intCode) { - this(code, intCode, false); + static { + for (ChatColor color : values()) { + BY_CHAR.put(color.code, color); + } + } + + ChatColor(char code) { + this(code, false); } - ChatColor(char code, int intCode, boolean isFormat) { + ChatColor(char code, boolean isFormat) { this.code = code; - this.intCode = intCode; this.isFormat = isFormat; this.toString = new String(new char[] {COLOR_CHAR, code}); } + /** + * The color character + * + * @return the color character + */ public char getChar() { return code; } - @Override - public String toString() { - return toString; - } - + /** + * If the ChatColor is a format + * + * @return if the ChatColor is a format + */ public boolean isFormat() { return isFormat; } + /** + * If the ChatColor is a color + * + * @return the ChatColor is a format + */ public boolean isColor() { - return !isFormat && this != RESET; + return !isFormat && (this != RESET && this != NONE); } - public static ChatColor getByChar(char code) { - return BY_CHAR.get(code); + /** + * Gets the ChatColor from the given character + * + * @param character the given character + * @return the ChatColor from the given character + */ + public static ChatColor getByChar(char character) { + return getByChar(String.valueOf(character)); } - public static ChatColor getByChar(String code) { - if (code == null) - throw new NullPointerException("Code cannot be null"); - - return BY_CHAR.get(code.charAt(0)); + /** + * Gets the ChatColor from the given String + * + * @param str the given String + * @return the ChatColor from the given String + */ + public static ChatColor getByChar(String str) { + return BY_CHAR.getOrDefault(str.charAt(0), ChatColor.NONE); } - public static String stripColor(final String input) { - if (input == null) { - return null; - } - + /** + * Strips the given string from all colors and formats + * + * @param input the string to strip + * @return the given string without colors and formats + */ + public static String stripColor(String input) { return STRIP_COLOR_PATTERN.matcher(input).replaceAll(""); } + /** + * Does a string replacement replacing the color character + * with the given character + * + * @param altColorChar the alternative color code symbol + * @param textToTranslate the text to do a replacement on + * @return the string with the color and formatting replacements + */ public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) { - if (textToTranslate == null) - throw new NullPointerException("Cannot translate null text"); - char[] b = textToTranslate.toCharArray(); for (int i = 0; i < b.length - 1; i++) { - if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) { + if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) { b[i] = ChatColor.COLOR_CHAR; - b[i+1] = Character.toLowerCase(b[i+1]); + b[i + 1] = Character.toLowerCase(b[i + 1]); } } return new String(b); } + /** + * Gets the last colors in a string + * + * @param input the string to get the last colors of + * @return the last colors in a string + */ public static String getLastColors(String input) { - if (input == null) - throw new NullPointerException("Cannot get last colors from null text"); - - String result = ""; + StringBuilder result = new StringBuilder(); int length = input.length(); // Search backwards from the end as it is faster @@ -114,8 +150,8 @@ public static String getLastColors(String input) { char c = input.charAt(index + 1); ChatColor color = getByChar(c); - if (color != null) { - result = color.toString() + result; + if (color != null && color != ChatColor.NONE) { + result.insert(0, color.toString()); // Once we find a color or reset we can stop searching if (color.isColor() || color.equals(RESET)) { @@ -125,13 +161,11 @@ public static String getLastColors(String input) { } } - return result; + return result.toString(); } - static { - for (ChatColor color : values()) { - BY_ID.put(color.intCode, color); - BY_CHAR.put(color.code, color); - } + @Override + public String toString() { + return toString; } } \ No newline at end of file diff --git a/modules/api/src/main/java/org/battleplugins/Platform.java b/modules/api/src/main/java/org/battleplugins/Platform.java index c81a2e0..3843e4f 100644 --- a/modules/api/src/main/java/org/battleplugins/Platform.java +++ b/modules/api/src/main/java/org/battleplugins/Platform.java @@ -1,13 +1,14 @@ package org.battleplugins; +import mc.euro.version.Version; + import org.battleplugins.message.Message; import org.battleplugins.entity.living.player.OfflinePlayer; import org.battleplugins.entity.living.player.Player; -import org.battleplugins.inventory.Inventory; import org.battleplugins.inventory.item.ItemStack; import org.battleplugins.plugin.Plugin; import org.battleplugins.plugin.PluginManager; -import org.battleplugins.plugin.ServicePriority; +import org.battleplugins.plugin.service.ServicePriority; import org.battleplugins.world.Location; import org.battleplugins.world.World; @@ -15,72 +16,245 @@ import java.util.Optional; import java.util.UUID; +/** + * Represents a platform. Can be extended by any of the + * platforms in {@link PlatformType}. + */ public abstract class Platform { private static Platform INSTANCE; private static PluginManager pluginManager = new PluginManager(); - public static void setInstance(Platform api) { - if (INSTANCE == null){ - INSTANCE = api; + /** + * Sets the instance of this platform + * + * @param platform the platform instance + */ + public static void setInstance(Platform platform) { + if (INSTANCE == null) { + INSTANCE = platform; } } - public Location getLocation(String world, double x, double y, double z) { + /** + * Gets the location with the given {@link World}, x, y, and z + * parameters + * + * @param world the world of the location + * @param x the x coordinate + * @param y the y coordinate + * @param z the z coordinate + * @return the location with the given parameters + */ + public Location getLocation(World world, double x, double y, double z) { return getLocation(world, x, y, z, 0, 0); } - public abstract Location getLocation(String world, double x, double y, double z, float pitch, float yaw); + /** + * Gets the location with the given {@link World}, x, y, z, + * pitch and yaw parameters + * + * @param world the world of the location + * @param x the x coordinate + * @param y the y coordinate + * @param z the z coordinate + * @param pitch the pitch of the location + * @param yaw the yaw of the location + * @return the location with the given parameters + */ + public abstract Location getLocation(World world, double x, double y, double z, float pitch, float yaw); + /** + * Gets the {@link World} from the given string. Will not be + * present if the world does not exist + * + * @param world the name of the world + * @return the world from the given string + */ public abstract Optional getWorld(String world); - public abstract APIType getAPIType(); + /** + * The {@link PlatformType} + * + * @return the platform type + */ + public abstract PlatformType getType(); + // TODO: Rewrite scheduler/task API public abstract long scheduleSyncTask(Plugin plugin, Runnable runnable, long millis); + + // TODO: Rewrite scheduler/task API public abstract long scheduleRepeatingTask(Plugin plugin, Runnable runnable, long millis); + // TODO: Rewrite scheduler/task API public abstract boolean cancelTask(long id); + /** + * Gets the {@link Player} from the given name. Will not + * be present if the player with the given name + * is not currently online + * + * @param name the name of the player + * @return the player from the given name + */ public abstract Optional getPlayer(String name); + + /** + * Gets the {@link Player} from the given {@link UUID}. + * Will not be present if the player with the given UUID + * is not currently online + * + * @param uuid the UUID of the player + * @return the player from the given name + */ public abstract Optional getPlayer(UUID uuid); + /** + * Gets the {@link OfflinePlayer} from the given name. + * Will not be present if a player does not exist with + * the given name + * + * @param name the name of the offline player + * @return the offline player from the given name + */ public abstract Optional getOfflinePlayer(String name); + /** + * Gets the {@link OfflinePlayer} from the given {@link UUID}. + * Will not be present if a player does not exist with + * the given UUID + * + * @param uuid the UUID of the offline player + * @return the offline player from the given name + */ public abstract Optional getOfflinePlayer(UUID uuid); + /** + * A collection of all the online {@link Player}s + * + * @return a collection of all the online players + */ public abstract Collection getOnlinePlayers(); + /** + * A collection of all the {@link OfflinePlayer}s + * that have joined this server before + * + * @return a collection of all the offline players + */ public abstract Collection getOfflinePlayers(); + /** + * If the main thread is being used + * + * @return if the main thread is being used + */ public abstract boolean isMainThread(); + /** + * If the server is in online mode + * + * @return if the server is in online mode + */ public abstract boolean isOnlineMode(); - public abstract String getVersion(); + /** + * The version of the platform + * + * @return the version of the platform + */ + public abstract Version getVersion(); + /** + * The default {@link Message} used for this platform + * + * @return the default Message for this platform + */ public abstract Message getDefaultPlatformMessage(); + /** + * The default {@link ItemStack} used for this platform + * + * @return the default ItemStack for this platform + */ public abstract ItemStack getDefaultPlatformItemStack(); + /** + * Broadcasts a message to all the online {@link Player}s + * + * @param message the message to send + */ public static void broadcastMessage(Message message) { INSTANCE.getOnlinePlayers().forEach(player -> player.sendMessage(message)); } - public abstract Inventory createInventory(Plugin plugin, int slots, String title); + /** + * Registers a service with the server's builtin + * service provider + * + * @param clazz the class of the server + * @param service the service + * @param plugin the plugin registering the service + * @param the value + */ + public void registerService(Class clazz, T service, Plugin plugin) { + registerService(clazz, service, plugin, ServicePriority.NORMAL); + } + /** + * Registers a service with the server's builtin + * service provider + * + * @param clazz the class of the server + * @param service the service + * @param plugin the plugin registering the service + * @param priority the priority of the service + * @param the value + */ public abstract void registerService(Class clazz, T service, Plugin plugin, ServicePriority priority); + /** + * Gets the service from the given class. Will return + * empty if a service is not registered with the class + * given + * + * @param clazz the class to get the service from + * @param the value + * @return the service from the given class + */ public abstract Optional getService(Class clazz); + /** + * The {@link Registry} + * + * @return the registry + */ + public abstract Registry getRegistry(); + + /** + * The {@link PluginManager} + * + * @return the plugin manager + */ public static PluginManager getPluginManager() { return pluginManager; } - public static APIType getAPI() { - return INSTANCE.getAPIType(); + /** + * The {@link PlatformType} + * + * @return the platform type + */ + public static PlatformType getPlatformType() { + return INSTANCE.getType(); } + /** + * The platform in use + * + * @return the platform in use + */ public static Platform getPlatform() { return INSTANCE; } diff --git a/modules/api/src/main/java/org/battleplugins/PlatformType.java b/modules/api/src/main/java/org/battleplugins/PlatformType.java new file mode 100644 index 0000000..2784af2 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/PlatformType.java @@ -0,0 +1,23 @@ +package org.battleplugins; + +/** + * Represents all the available platform types. + */ +public enum PlatformType { + + /** + * The Bukkit Platform: https://bukkit.org + */ + BUKKIT, + + /** + * The Nukkit Platform: https://nukkitx.com + */ + NUKKIT, + + /** + * The Sponge Platform: https://spongepowered.org + */ + SPONGE, + // SPOUT, +} diff --git a/modules/api/src/main/java/org/battleplugins/Registry.java b/modules/api/src/main/java/org/battleplugins/Registry.java new file mode 100644 index 0000000..440f7ce --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/Registry.java @@ -0,0 +1,70 @@ +package org.battleplugins; + +import org.battleplugins.inventory.item.ItemRegistry; +import org.battleplugins.inventory.item.component.ItemComponent; +import org.battleplugins.world.block.BlockRegistry; + +import java.util.ArrayList; +import java.util.List; + +/** + * A class containing the bulk of registrations for various + * aspects of this API. + */ +public abstract class Registry { + + protected List> itemComponents = new ArrayList<>(); + protected List> builders = new ArrayList<>(); + + /** + * Returns an item component instance from + * the given component class + * + * @param componentClass the component class + * @param the value + * @return an item component instance + * @throws IllegalArgumentException if the class is not registered + */ + public T getItemComponent(Class componentClass) throws IllegalArgumentException { + for (Class componentClazz : itemComponents) { + if (!componentClazz.isAssignableFrom(componentClass)) + continue; + + try { + return componentClass.cast(componentClazz.newInstance()); + } catch (InstantiationException | IllegalAccessException ex) { + throw new IllegalArgumentException("Component class " + componentClass + " was unable to be instantiated!"); + } + } + + throw new IllegalArgumentException("Component class " + componentClass + " not registered!"); + } + + /** + * Returns a builder from the + * given builder class + * + * @param builderClass the builder class + * @param the value + * @return an builder instance + * @throws IllegalArgumentException if the class is not registered + */ + public T getBuilder(Class builderClass) { + for (Class builderClazz : builders) { + if (!builderClazz.isAssignableFrom(builderClass)) + continue; + + try { + return builderClass.cast(builderClazz.newInstance()); + } catch (InstantiationException | IllegalAccessException ex) { + throw new IllegalArgumentException("Builder class " + builderClass + " was unable to be instantiated!"); + } + } + + throw new IllegalArgumentException("Builder class " + builderClass + " not registered!"); + } + + public abstract ItemRegistry getItemRegistry(); + + public abstract BlockRegistry getBlockRegistry(); +} diff --git a/modules/api/src/main/java/org/battleplugins/command/Command.java b/modules/api/src/main/java/org/battleplugins/command/Command.java index 2c13dba..0e05c7e 100644 --- a/modules/api/src/main/java/org/battleplugins/command/Command.java +++ b/modules/api/src/main/java/org/battleplugins/command/Command.java @@ -6,14 +6,44 @@ import java.util.List; +/** + * Represents a command which executes a various task depending on + * what the user inputted. + */ @Getter @Setter @AllArgsConstructor public class Command { + /** + * The command label + * + * @param label the command label + * @return the command label + */ private String label; + + /** + * The command description + * + * @param description the command description + * @return the command description + */ private String description; + + /** + * The permission needed to run the command + * + * @param permission the permission needed to run the command + * @return the permission needed to run the command + */ private String permission; + /** + * A list of command aliases + * + * @param aliases the command aliases + * @return a list of command aliases + */ private List aliases; } diff --git a/modules/api/src/main/java/org/battleplugins/command/CommandExecutor.java b/modules/api/src/main/java/org/battleplugins/command/CommandExecutor.java index ff5ab1b..a39fb2c 100644 --- a/modules/api/src/main/java/org/battleplugins/command/CommandExecutor.java +++ b/modules/api/src/main/java/org/battleplugins/command/CommandExecutor.java @@ -1,6 +1,18 @@ package org.battleplugins.command; +/** + * A class containing a single method for executing commands. + */ public interface CommandExecutor { + /** + * Executes the given command + * + * @param sender the {@link CommandSender} of the command + * @param command the {@link Command} executed + * @param label the command label + * @param args the arguments of the command + * @return if the command was successfully executed + */ boolean onCommand(CommandSender sender, Command command, String label, String[] args); } diff --git a/modules/api/src/main/java/org/battleplugins/command/CommandSender.java b/modules/api/src/main/java/org/battleplugins/command/CommandSender.java index 808681b..46a50fb 100644 --- a/modules/api/src/main/java/org/battleplugins/command/CommandSender.java +++ b/modules/api/src/main/java/org/battleplugins/command/CommandSender.java @@ -1,12 +1,36 @@ package org.battleplugins.command; +/** + * An object capable of executing commands. + */ public interface CommandSender { + /** + * If the sender has the given permission node + * + * @param node the permission node + * @return if the sender has the given permission node + */ boolean hasPermission(String node); + /** + * Sends a message to the sender + * + * @param message the message to send + */ void sendMessage(String message); + /** + * The name of the sender + * + * @return the name of the sender + */ String getName(); + /** + * If the sender is an operator + * + * @return if the sender is an operator + */ boolean isOp(); } diff --git a/modules/api/src/main/java/org/battleplugins/command/ConsoleCommandSender.java b/modules/api/src/main/java/org/battleplugins/command/ConsoleCommandSender.java index 97b8625..8eb7e5d 100644 --- a/modules/api/src/main/java/org/battleplugins/command/ConsoleCommandSender.java +++ b/modules/api/src/main/java/org/battleplugins/command/ConsoleCommandSender.java @@ -1,5 +1,8 @@ package org.battleplugins.command; +/** + * Represents a command sender from the console. + */ public interface ConsoleCommandSender extends CommandSender { } diff --git a/modules/api/src/main/java/org/battleplugins/entity/Entity.java b/modules/api/src/main/java/org/battleplugins/entity/Entity.java index 19fd510..ce0131c 100644 --- a/modules/api/src/main/java/org/battleplugins/entity/Entity.java +++ b/modules/api/src/main/java/org/battleplugins/entity/Entity.java @@ -1,5 +1,6 @@ package org.battleplugins.entity; +import org.battleplugins.util.NamespacedKey; import org.battleplugins.world.Location; import org.battleplugins.world.World; @@ -7,32 +8,131 @@ import java.util.Optional; import java.util.UUID; +/** + * Represents an entity in a world. + */ public interface Entity { + /** + * The name of the entity + * + * @return the name of the entity + */ String getName(); + + /** + * The identifier of this entity + * + * @return the identifier of this entity + */ + default String getIdentifier() { + return getKey().toString(); + } + + /** + * The full {@link NamespacedKey} of this entity + * + * @return the full namespaced key of this entity + */ + NamespacedKey getKey(); + + /** + * The {@link UUID} of the entity + * + * @return the unique identifier of the entity + */ UUID getUniqueId(); + /** + * The {@link Location} of the entity + * + * @return the location of the entity + */ Location getLocation(); + + /** + * The {@link World} the entity is located in + * + * @return the world the entity is located in + */ World getWorld(); + /** + * Teleports the entity to the given {@link Location} + * + * @param location the location to teleport the entity to + * @return if the entity successfully teleported + */ boolean teleport(Location location); + /** + * Teleports the entity to the {@link Location} of another entity + * + * @param entity the entity to teleport to + * @return if the entity successfully teleported + */ default boolean teleport(Entity entity) { return teleport(entity.getLocation()); } + /** + * If the entity is dead + * + * @return if the entity is dead + */ boolean isDead(); + + /** + * If the entity is valid + * + * @return if the entity is valid + */ boolean isValid(); + /** + * A list of all the nearby entities + * + * @param x the radius to search in the x axis + * @param y the radius to search in the y axis + * @param z the radius to search in the z axis + * @return a list of all the nearby entities + */ List getNearbyEntities(double x, double y, double z); + /** + * If the entity has a custom name + * + * @return if the entity has a custom name + */ default boolean hasCustomName() { return getCustomName().isPresent(); } + /** + * If the entity's custom name is visible + * + * @return if the entity's custom name is visible + */ boolean isCustomNameVisible(); + + /** + * The entity's custom name + * + * @return the entity's custom name + */ Optional getCustomName(); + /** + * Sets the custom name of the entity + * + * @param customName the custom name to give to the entity + */ void setCustomName(String customName); + + /** + * Sets if the custom name of the entity (if applicable) should be visible + * + * @param visible if the custom name of the entity should be visible + */ void setCustomNameVisible(boolean visible); } diff --git a/modules/api/src/main/java/org/battleplugins/entity/living/Damageable.java b/modules/api/src/main/java/org/battleplugins/entity/living/Damageable.java index 08cd032..0709171 100644 --- a/modules/api/src/main/java/org/battleplugins/entity/living/Damageable.java +++ b/modules/api/src/main/java/org/battleplugins/entity/living/Damageable.java @@ -2,11 +2,39 @@ import org.battleplugins.entity.Entity; +/** + * Represents an entity capable of taking damage. + */ public interface Damageable { + /** + * Deals the given amount of damage to + * the {@link Entity} + * + * @param amount the amount of damage to deal + */ void damage(double amount); + + /** + * Deals the given amount of damage to + * the {@link Entity} from the given {@link Entity} source + * + * @param amount the amount of damage to deal + * @param source the source dealing the damage + */ void damage(double amount, Entity source); + /** + * The amount of health the {@link Entity} has + * + * @return the amount of health the entity has + */ double getHealth(); + + /** + * Sets the amount of health the {@link Entity} has + * + * @param health the amount of health the entity has + */ void setHealth(double health); } diff --git a/modules/api/src/main/java/org/battleplugins/entity/living/HumanEntity.java b/modules/api/src/main/java/org/battleplugins/entity/living/HumanEntity.java index d4fcfa2..71bfccd 100644 --- a/modules/api/src/main/java/org/battleplugins/entity/living/HumanEntity.java +++ b/modules/api/src/main/java/org/battleplugins/entity/living/HumanEntity.java @@ -1,8 +1,10 @@ package org.battleplugins.entity.living; -import org.battleplugins.inventory.entity.PlayerInventory; +import org.battleplugins.inventory.carrier.Carrier; -public interface HumanEntity extends LivingEntity { +/** + * Represents a human entity. + */ +public interface HumanEntity extends LivingEntity, Carrier { - PlayerInventory getInventory(); } diff --git a/modules/api/src/main/java/org/battleplugins/entity/living/LivingEntity.java b/modules/api/src/main/java/org/battleplugins/entity/living/LivingEntity.java index c13a4dc..6426b5a 100644 --- a/modules/api/src/main/java/org/battleplugins/entity/living/LivingEntity.java +++ b/modules/api/src/main/java/org/battleplugins/entity/living/LivingEntity.java @@ -2,6 +2,9 @@ import org.battleplugins.entity.Entity; +/** + * Represents a living entity (mob). + */ public interface LivingEntity extends Entity, Damageable { } diff --git a/modules/api/src/main/java/org/battleplugins/entity/living/player/GameMode.java b/modules/api/src/main/java/org/battleplugins/entity/living/player/GameMode.java deleted file mode 100644 index 5bcb30c..0000000 --- a/modules/api/src/main/java/org/battleplugins/entity/living/player/GameMode.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.battleplugins.entity.living.player; - -public enum GameMode { - - SURVIVAL(0), - CREATIVE(1), - ADVENTURE(2), - SPECTATOR(3); - - private int id; - - GameMode(int id) { - this.id = id; - } - - public int getId() { - return id; - } -} diff --git a/modules/api/src/main/java/org/battleplugins/entity/living/player/OfflinePlayer.java b/modules/api/src/main/java/org/battleplugins/entity/living/player/OfflinePlayer.java index 745fb0f..688f834 100644 --- a/modules/api/src/main/java/org/battleplugins/entity/living/player/OfflinePlayer.java +++ b/modules/api/src/main/java/org/battleplugins/entity/living/player/OfflinePlayer.java @@ -3,21 +3,72 @@ import org.battleplugins.world.Location; import java.util.Optional; +import java.util.OptionalLong; import java.util.UUID; +/** + * Represents an offline player. + */ public interface OfflinePlayer { + /** + * If the offline player is logged on + * + * @return if the offline player is logged on + */ boolean isOnline(); + /** + * The name of the offline player + * + * @return the name of the player + */ String getName(); + + /** + * The {@link UUID} of the offline player + * + * @return the unique identifier of the player + */ UUID getUniqueId(); + /** + * The {@link Player} object of the offline player. + * Will not be present if {@link #isOnline()} is false + * + * @return + */ Optional getPlayer(); - long getFirstPlayed(); - long getLastPlayed(); + /** + * When the offline player first played. Will not be + * present if {@link #hasPlayedBefore()} is false + * + * @return when the offline player first played + */ + OptionalLong getFirstPlayed(); + + /** + * When the offline player last played. Will not be + * present if {@link #hasPlayedBefore()} is false + * + * @return when the offline player last played + */ + OptionalLong getLastPlayed(); + /** + * If the offline player has played before + * + * @return if the offline player has played before + */ boolean hasPlayedBefore(); + /** + * The bed spawn location of the player. Will + * not be present if the player's bed has been + * obstructed + * + * @return the bed spawn location of the player + */ Optional getBedSpawnLocation(); } diff --git a/modules/api/src/main/java/org/battleplugins/entity/living/player/Player.java b/modules/api/src/main/java/org/battleplugins/entity/living/player/Player.java index e729cc8..58fca5a 100644 --- a/modules/api/src/main/java/org/battleplugins/entity/living/player/Player.java +++ b/modules/api/src/main/java/org/battleplugins/entity/living/player/Player.java @@ -1,24 +1,55 @@ package org.battleplugins.entity.living.player; +import org.battleplugins.entity.living.player.gamemode.GameMode; import org.battleplugins.message.Message; import org.battleplugins.command.CommandSender; import org.battleplugins.entity.living.HumanEntity; import org.battleplugins.inventory.Inventory; +/** + * Represents a player. + */ public interface Player extends CommandSender, OfflinePlayer, HumanEntity { - String getName(); + /** + * The display name of the player + * + * @return the display name of the player + */ String getDisplayName(); + /** + * Opens the given {@link Inventory} + * + * @param inventory the inventory to open + */ void openInventory(Inventory inventory); - void updateInventory(); - boolean isOnline(); + /** + * Updates the player's {@link Inventory} + */ + void updateInventory(); + /** + * Sends a {@link Message} to the player + * + * @param message the message to send + */ default void sendMessage(Message message) { message.sendMessage(this); } + /** + * The player's {@link GameMode} + * + * @return the player's gamemode + */ GameMode getGameMode(); + + /** + * Sets the player's {@link GameMode} + * + * @param gameMode the gamemode to set for the player + */ void setGameMode(GameMode gameMode); } diff --git a/modules/api/src/main/java/org/battleplugins/entity/living/player/gamemode/GameMode.java b/modules/api/src/main/java/org/battleplugins/entity/living/player/gamemode/GameMode.java new file mode 100644 index 0000000..dc1af6b --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/entity/living/player/gamemode/GameMode.java @@ -0,0 +1,28 @@ +package org.battleplugins.entity.living.player.gamemode; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.battleplugins.util.NamespacedKey; + +/** + * Represents a game mode. + */ +@Getter +@AllArgsConstructor(access = AccessLevel.PROTECTED) +public class GameMode { + + /** + * The id of the gamemode + * + * @return the id of the gamemode + */ + private int id; + + /** + * The {@link NamespacedKey} of the gamemode + * + * @return the namespaced key of the gamemode + */ + private NamespacedKey key; +} diff --git a/modules/api/src/main/java/org/battleplugins/entity/living/player/gamemode/GameModes.java b/modules/api/src/main/java/org/battleplugins/entity/living/player/gamemode/GameModes.java new file mode 100644 index 0000000..9a8eb57 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/entity/living/player/gamemode/GameModes.java @@ -0,0 +1,23 @@ +package org.battleplugins.entity.living.player.gamemode; + +import org.battleplugins.util.NamespacedKey; + +/** + * Holds all the valid GameModes. + */ +public class GameModes { + + public static final GameMode SURVIVAL = new GameMode(0, NamespacedKey.minecraft("survival")); + public static final GameMode CREATIVE = new GameMode(1, NamespacedKey.minecraft("creative")); + public static final GameMode ADVENTURE = new GameMode(2, NamespacedKey.minecraft("adventure")); + public static final GameMode SPECTATOR = new GameMode(3, NamespacedKey.minecraft("spectator")); + + /** + * An array of all the {@link GameMode}s + * + * @return an array of all the gamemodes + */ + public static GameMode[] values() { + return new GameMode[] {SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR}; + } +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/CarriedInventory.java b/modules/api/src/main/java/org/battleplugins/inventory/CarriedInventory.java new file mode 100644 index 0000000..9f19466 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/CarriedInventory.java @@ -0,0 +1,18 @@ +package org.battleplugins.inventory; + +import org.battleplugins.inventory.carrier.Carrier; + +/** + * Represents an inventory that can be carried. + * + * @param the carrier + */ +public interface CarriedInventory extends Inventory { + + /** + * The {@link Carrier} of the inventory + * + * @return the carrier of the inventory + */ + T getCarrier(); +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/Inventory.java b/modules/api/src/main/java/org/battleplugins/inventory/Inventory.java index 277de6e..4c41726 100644 --- a/modules/api/src/main/java/org/battleplugins/inventory/Inventory.java +++ b/modules/api/src/main/java/org/battleplugins/inventory/Inventory.java @@ -1,29 +1,130 @@ package org.battleplugins.inventory; +import org.battleplugins.Platform; import org.battleplugins.inventory.item.ItemStack; +import java.util.Arrays; import java.util.Optional; +/** + * Represents an ingame menu container. + */ public interface Inventory { - void addItem(ItemStack...itemStacks); + /** + * Adds the given {@link ItemStack} to the inventory + * + * @param itemStack the itemstack to add + */ + void addItem(ItemStack itemStack); + + /** + * Adds the given {@link ItemStack}s to the inventory + * + * @param itemStacks the itemstacks to add + */ + default void addItems(ItemStack... itemStacks) { + Arrays.asList(itemStacks).forEach(this::addItem); + } + + /** + * Removes the given {@link ItemStack} from the inventory + * + * @param itemStack the itemstack to remove + */ void removeItem(ItemStack itemStack); + /** + * Sets an {@link ItemStack} at the given slot + * + * @param slot the slot to set the item at + * @param item the itemstack to set + */ void setItem(int slot, ItemStack item); + + /** + * Gets an {@link ItemStack} at the given slot. Will not be + * present if the given slot is out of range + * or there is no item there + * + * @param slot the slot to get the item from + * @return an item at the given slot + */ Optional getItem(int slot); + /** + * Gets the amount of a specified {@link ItemStack} + * throughout the whole inventory + * + * @param itemStack the itemstack to get the amount of + * @return the amount of an itemstack in the inventory + */ int getItemAmount(ItemStack itemStack); + + /** + * Gets the amount of free space after + * the given {@link ItemStack} + * + * @param itemStack the itemstack to get the free space after + * @return the amount of free space after the given itemstack + */ int freeSpaceAfter(ItemStack itemStack); - boolean canFit(ItemStack itemStack); + /** + * Gets if the given {@link ItemStack} can fit in + * the inventory + * + * @param itemStack the itemstack to check + * @return if the given itemstack can fit + */ + default boolean canFit(ItemStack itemStack) { + return freeSpaceAfter(itemStack) >= 0; + } + /** + * The contents of the inventory + * + * @return the contents of the inventory + */ ItemStack[] getContents(); + /** + * Sets the contents of the inventory + * + * @param contents the contents to set + */ default void setContents(ItemStack[] contents) { for (int i = 0; i < contents.length; i++) { setItem(i, contents[i]); } } + /** + * Clears the inventory + */ void clear(); + + /** + * The inventory builder + * + * @return a new inventory builder + */ + static Builder builder() { + return Platform.getPlatform().getRegistry().getBuilder(Builder.class); + } + + interface Builder { + + Builder fromInventory(Inventory inventory, String name); + + Builder name(String name); + + Builder size(int size); + + Builder item(int slot, ItemStack item); + + Builder contents(ItemStack[] contents); + + Inventory build(); + } } diff --git a/modules/api/src/main/java/org/battleplugins/inventory/carrier/Carrier.java b/modules/api/src/main/java/org/battleplugins/inventory/carrier/Carrier.java new file mode 100644 index 0000000..365b349 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/carrier/Carrier.java @@ -0,0 +1,17 @@ +package org.battleplugins.inventory.carrier; + +import org.battleplugins.inventory.CarriedInventory; +import org.battleplugins.inventory.Inventory; + +/** + * Represents an object capable of holding an {@link Inventory}. + */ +public interface Carrier { + + /** + * The inventory of the carrier + * + * @return the inventory of the carrier + */ + CarriedInventory getInventory(); +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/carrier/block/entity/BlockEntityCarrier.java b/modules/api/src/main/java/org/battleplugins/inventory/carrier/block/entity/BlockEntityCarrier.java new file mode 100644 index 0000000..6401e3d --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/carrier/block/entity/BlockEntityCarrier.java @@ -0,0 +1,11 @@ +package org.battleplugins.inventory.carrier.block.entity; + +import org.battleplugins.inventory.carrier.Carrier; +import org.battleplugins.world.block.entity.BlockEntity; + +/** + * Represents an inventory carrier that is a {@link BlockEntity}. + * @param the value + */ +public interface BlockEntityCarrier extends Carrier { +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/entity/PlayerInventory.java b/modules/api/src/main/java/org/battleplugins/inventory/entity/PlayerInventory.java index 40b4503..183706f 100644 --- a/modules/api/src/main/java/org/battleplugins/inventory/entity/PlayerInventory.java +++ b/modules/api/src/main/java/org/battleplugins/inventory/entity/PlayerInventory.java @@ -1,17 +1,57 @@ package org.battleplugins.inventory.entity; +import org.battleplugins.entity.living.HumanEntity; +import org.battleplugins.entity.living.player.Player; +import org.battleplugins.inventory.CarriedInventory; import org.battleplugins.inventory.Inventory; import org.battleplugins.inventory.item.ItemStack; import java.util.Optional; -public interface PlayerInventory extends Inventory { +/** + * Represents an inventory for a player. + */ +public interface PlayerInventory extends CarriedInventory { + /** + * Gets the item in the main hand of the {@link Player} + * + * @return the item in the main hand of the player + */ Optional getItemInMainHand(); + + /** + * Gets the item in the offhand of the {@link Player} + * + * @return the item in the offhand of the player + */ Optional getItemInOffHand(); + /** + * Gets the item in the helmet slot of the {@link Player} + * + * @return the item in the helmet slot of the player + */ Optional getHelmet(); + + /** + * Gets the item in the chestplate slot of the {@link Player} + * + * @return the item in the chestplate slot of the player + */ Optional getChestplate(); + + /** + * Gets the item in the leggings slot of the {@link Player} + * + * @return the item in the leggings slot of the player + */ Optional getLeggings(); + + /** + * Gets the item in the boots slot of the {@link Player} + * + * @return the item in the boots slot of the player + */ Optional getBoots(); } diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/ItemMeta.java b/modules/api/src/main/java/org/battleplugins/inventory/item/ItemMeta.java deleted file mode 100644 index 302e3b3..0000000 --- a/modules/api/src/main/java/org/battleplugins/inventory/item/ItemMeta.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.battleplugins.inventory.item; - -import java.util.List; -import java.util.Optional; - -public interface ItemMeta { - - default boolean hasDisplayName() { - return getDisplayName().isPresent(); - } - - Optional getDisplayName(); - void setDisplayName(String displayName); - - default boolean hasLore() { - return getLore().isPresent(); - } - - Optional> getLore(); - void setLore(List lore); - - int getCustomModelData(); - void setCustomModelData(int modelData); - - boolean isUnbreakable(); - void setUnbreakable(boolean unbreakable); -} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/ItemRegistry.java b/modules/api/src/main/java/org/battleplugins/inventory/item/ItemRegistry.java new file mode 100644 index 0000000..3d457a0 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/ItemRegistry.java @@ -0,0 +1,45 @@ +package org.battleplugins.inventory.item; + +import org.battleplugins.Platform; +import org.battleplugins.util.NamespacedKey; + +import java.util.Optional; + +/** + * A registry containing all the items based on various + * implementations depending on the platform. + * + * Certain platforms base their implementations of items + * on different values (e.g. Bukkit is Material/identifier + * based whilst Nukkit is ID based). This class allows for + * items to be mapped from their platform implementations as + * well as from {@link NamespacedKey}'s. + * + * @param the platform implementation + */ +public interface ItemRegistry { + + ItemRegistry REGISTRY = Platform.getPlatform().getRegistry().getItemRegistry(); + + /** + * Gets the given item type from the platform + * item + * + * @param item the platform item + * @return the given item type + */ + ItemType fromPlatformItem(T item); + + /** + * Gets the item type from the given + * {@link NamespacedKey}. Returns empty if the + * item could not be found. The only reason this should + * be used is if an item type needs to be obtained + * from a string, an item is not in the {@link ItemTypes} + * class, or if a modded item (Sponge) needs to be obtained. + * + * @param namespacedKey the given {@link NamespacedKey} + * @return the item type from the given namespaced key + */ + Optional fromKey(NamespacedKey namespacedKey); +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/ItemStack.java b/modules/api/src/main/java/org/battleplugins/inventory/item/ItemStack.java index ea47217..10e17e9 100644 --- a/modules/api/src/main/java/org/battleplugins/inventory/item/ItemStack.java +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/ItemStack.java @@ -1,54 +1,98 @@ package org.battleplugins.inventory.item; import org.battleplugins.Platform; +import org.battleplugins.inventory.item.component.ItemComponent; -import java.util.List; import java.util.Map; +import java.util.Optional; +/** + * Represents items in inventories. + */ public interface ItemStack { - void setType(String type); - - String getType(); - - void setDataValue(short value); - - short getDataValue(); + /** + * The {@link ItemType} for this itemstack + * + * @return the itemtype to set + */ + ItemType getType(); + + /** + * Sets the {@link ItemType} for this itemstack + * + * @param type the itemtype to set + */ + void setType(ItemType type); + + /** + * The quantity of items in this itemstack + * + * @return the quantity of items in this itemstack + */ + int getQuantity(); + /** + * Sets the quantity of items in this itemstack + * + * @param quantity the quantity of items in this itemstack + */ void setQuantity(int quantity); - int getQuantity(); - + /** + * The enchantments applied to this itemstack + * + * @return the enchantments applied to this itemstack + */ Map getEnchantments(); - void addEnchantment(String ench, int level); - - String getCommonName(); - - String getFormattedCommonName(); - - ItemStack clone(); - - int isSpecial(); - - boolean hasItemMeta(); - - ItemMeta getItemMeta(); + /** + * Adds an enchantment to this itemstack + * + * @param enchantment the enchantment to apply + * @param level the level to set for the itemstack + */ + void addEnchantment(String enchantment, int level); + + /** + * Applies the given component to the itemstack + * + * @param componentClass the component to apply + * @param value the value of the component + * @param the value + */ + default void applyComponent(Class> componentClass, T value) { + Platform.getPlatform().getRegistry().getItemComponent(componentClass).applyComponent(this, value); + } - static ItemStack getDefaultPlatformItemStack() { - return Platform.getPlatform().getDefaultPlatformItemStack(); + /** + * Gets the value of the given component class + * + * @param componentClass the class of the component + * @param the value + * @return the value of the given component class + */ + default Optional getValue(Class> componentClass) { + return Platform.getPlatform().getRegistry().getItemComponent(componentClass).getValue(this); } + /** + * The itemstack builder + * + * @return a new itemstack builder + */ static Builder builder() { return new Builder(); } + ItemStack clone(); + class Builder { private ItemStack itemStack; Builder() { - this.itemStack = ItemStack.getDefaultPlatformItemStack(); + this.itemStack = Platform.getPlatform().getDefaultPlatformItemStack(); } public Builder fromItemStack(ItemStack itemStack) { @@ -56,16 +100,11 @@ public Builder fromItemStack(ItemStack itemStack) { return this; } - public Builder type(String type) { + public Builder type(ItemType type) { itemStack.setType(type); return this; } - public Builder data(short value) { - itemStack.setDataValue(value); - return this; - } - public Builder quantity(int quantity) { itemStack.setQuantity(quantity); return this; @@ -76,35 +115,8 @@ public Builder enchant(String enchant, int level) { return this; } - public Builder displayName(String displayName) { - if (!itemStack.hasItemMeta()) - return this; - - itemStack.getItemMeta().setDisplayName(displayName); - return this; - } - - public Builder lore(List lore) { - if (!itemStack.hasItemMeta()) - return this; - - itemStack.getItemMeta().setLore(lore); - return this; - } - - public Builder unbreakable(boolean unbreakable) { - if (!itemStack.hasItemMeta()) - return this; - - itemStack.getItemMeta().setUnbreakable(unbreakable); - return this; - } - - public Builder customModelData(int modelData) { - if (!itemStack.hasItemMeta()) - return this; - - itemStack.getItemMeta().setCustomModelData(modelData); + public Builder component(Class> component, T value) { + itemStack.applyComponent(component, value); return this; } diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/ItemType.java b/modules/api/src/main/java/org/battleplugins/inventory/item/ItemType.java new file mode 100644 index 0000000..2864a9a --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/ItemType.java @@ -0,0 +1,41 @@ +package org.battleplugins.inventory.item; + +import org.battleplugins.util.NamespacedKey; + +/** + * Represents an item type. + */ +public interface ItemType { + + /** + * The item identifier of the item + * + * @return the item identifier of the item + */ + default String getIdentifier() { + return getKey().toString(); + } + + /** + * The full namespaced key of the item + * + * @return the full namespaced key of the item + */ + NamespacedKey getKey(); + + /** + * The maximum size this item can stack to + * + * @return the maximum size this item can stack to + */ + int getMaximumStackSize(); + + /** + * If the item can be stacked + * + * @return if the item can be stacked + */ + default boolean isStackable() { + return getMaximumStackSize() > 1; + } +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/ItemTypes.java b/modules/api/src/main/java/org/battleplugins/inventory/item/ItemTypes.java new file mode 100644 index 0000000..a7318a6 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/ItemTypes.java @@ -0,0 +1,319 @@ +package org.battleplugins.inventory.item; + +import org.battleplugins.Platform; +import org.battleplugins.util.NamespacedKey; +import org.battleplugins.world.block.BlockTypes; + +import java.util.Optional; + +/** + * Holds all the valid ItemTypes. + */ +public class ItemTypes extends BlockTypes { + + public static final ItemType ACACIA_BOAT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_boat")).get(); + public static final ItemType APPLE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("apple")).get(); + public static final ItemType ARMOR_STAND = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("armor_stand")).get(); + public static final ItemType ARROW = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("arrow")).get(); + public static final ItemType BAKED_POTATO = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("baked_potato")).get(); + public static final ItemType BAT_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bat_spawn_egg")).get(); + public static final ItemType BEEF = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("beef")).get(); + public static final ItemType BEETROOT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("beetroot")).get(); + public static final ItemType BEETROOT_SEEDS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("beetroot_seeds")).get(); + public static final ItemType BEETROOT_SOUP = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("beetroot_soup")).get(); + public static final ItemType BEE_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bee_spawn_egg")).get(); + public static final ItemType BIRCH_BOAT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_boat")).get(); + public static final ItemType BLACK_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_dye")).get(); + public static final ItemType BLAZE_POWDER = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blaze_powder")).get(); + public static final ItemType BLAZE_ROD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blaze_rod")).get(); + public static final ItemType BLAZE_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blaze_spawn_egg")).get(); + public static final ItemType BLUE_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_dye")).get(); + public static final ItemType BONE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bone")).get(); + public static final ItemType BONE_MEAL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bone_meal")).get(); + public static final ItemType BOOK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("book")).get(); + public static final ItemType BOW = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bow")).get(); + public static final ItemType BOWL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bowl")).get(); + public static final ItemType BREAD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bread")).get(); + public static final ItemType BRICK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brick")).get(); + public static final ItemType BROWN_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_dye")).get(); + public static final ItemType BUCKET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bucket")).get(); + public static final ItemType CARROT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("carrot")).get(); + public static final ItemType CARROT_ON_A_STICK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("carrot_on_a_stick")).get(); + public static final ItemType CAT_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cat_spawn_egg")).get(); + public static final ItemType CAVE_SPIDER_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cave_spider_spawn_egg")).get(); + public static final ItemType CHAINMAIL_BOOTS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chainmail_boots")).get(); + public static final ItemType CHAINMAIL_CHESTPLATE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chainmail_chestplate")).get(); + public static final ItemType CHAINMAIL_HELMET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chainmail_helmet")).get(); + public static final ItemType CHAINMAIL_LEGGINGS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chainmail_leggings")).get(); + public static final ItemType CHARCOAL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("charcoal")).get(); + public static final ItemType CHEST_MINECART = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chest_minecart")).get(); + public static final ItemType CHICKEN = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chicken")).get(); + public static final ItemType CHICKEN_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chicken_spawn_egg")).get(); + public static final ItemType CHORUS_FRUIT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chorus_fruit")).get(); + public static final ItemType CLAY_BALL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("clay_ball")).get(); + public static final ItemType CLOCK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("clock")).get(); + public static final ItemType COAL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("coal")).get(); + public static final ItemType COCOA_BEANS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cocoa_beans")).get(); + public static final ItemType COD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cod")).get(); + public static final ItemType COD_BUCKET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cod_bucket")).get(); + public static final ItemType COD_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cod_spawn_egg")).get(); + public static final ItemType COMMAND_BLOCK_MINECART = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("command_block_minecart")).get(); + public static final ItemType COMPASS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("compass")).get(); + public static final ItemType COOKED_BEEF = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cooked_beef")).get(); + public static final ItemType COOKED_CHICKEN = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cooked_chicken")).get(); + public static final ItemType COOKED_COD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cooked_cod")).get(); + public static final ItemType COOKED_MUTTON = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cooked_mutton")).get(); + public static final ItemType COOKED_PORKCHOP = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cooked_porkchop")).get(); + public static final ItemType COOKED_RABBIT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cooked_rabbit")).get(); + public static final ItemType COOKED_SALMON = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cooked_salmon")).get(); + public static final ItemType COOKIE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cookie")).get(); + public static final ItemType COW_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cow_spawn_egg")).get(); + public static final ItemType CREEPER_BANNER_PATTERN = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("creeper_banner_pattern")).get(); + public static final ItemType CREEPER_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("creeper_spawn_egg")).get(); + public static final ItemType CROSSBOW = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("crossbow")).get(); + public static final ItemType CYAN_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_dye")).get(); + public static final ItemType DARK_OAK_BOAT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_boat")).get(); + public static final ItemType DEBUG_STICK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("debug_stick")).get(); + public static final ItemType DIAMOND = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond")).get(); + public static final ItemType DIAMOND_AXE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_axe")).get(); + public static final ItemType DIAMOND_BOOTS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_boots")).get(); + public static final ItemType DIAMOND_CHESTPLATE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_chestplate")).get(); + public static final ItemType DIAMOND_HELMET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_helmet")).get(); + public static final ItemType DIAMOND_HOE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_hoe")).get(); + public static final ItemType DIAMOND_HORSE_ARMOR = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_horse_armor")).get(); + public static final ItemType DIAMOND_LEGGINGS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_leggings")).get(); + public static final ItemType DIAMOND_PICKAXE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_pickaxe")).get(); + public static final ItemType DIAMOND_SHOVEL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_shovel")).get(); + public static final ItemType DIAMOND_SWORD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_sword")).get(); + public static final ItemType DOLPHIN_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dolphin_spawn_egg")).get(); + public static final ItemType DONKEY_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("donkey_spawn_egg")).get(); + public static final ItemType DRAGON_BREATH = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dragon_breath")).get(); + public static final ItemType DRIED_KELP = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dried_kelp")).get(); + public static final ItemType DROWNED_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("drowned_spawn_egg")).get(); + public static final ItemType EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("egg")).get(); + public static final ItemType ELDER_GUARDIAN_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("elder_guardian_spawn_egg")).get(); + public static final ItemType ELYTRA = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("elytra")).get(); + public static final ItemType EMERALD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("emerald")).get(); + public static final ItemType ENCHANTED_BOOK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("enchanted_book")).get(); + public static final ItemType ENCHANTED_GOLDEN_APPLE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("enchanted_golden_apple")).get(); + public static final ItemType ENDERMAN_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("enderman_spawn_egg")).get(); + public static final ItemType ENDERMITE_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("endermite_spawn_egg")).get(); + public static final ItemType ENDER_EYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("ender_eye")).get(); + public static final ItemType ENDER_PEARL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("ender_pearl")).get(); + public static final ItemType END_CRYSTAL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("end_crystal")).get(); + public static final ItemType EVOKER_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("evoker_spawn_egg")).get(); + public static final ItemType EXPERIENCE_BOTTLE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("experience_bottle")).get(); + public static final ItemType FEATHER = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("feather")).get(); + public static final ItemType FERMENTED_SPIDER_EYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fermented_spider_eye")).get(); + public static final ItemType FILLED_MAP = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("filled_map")).get(); + public static final ItemType FIREWORK_ROCKET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("firework_rocket")).get(); + public static final ItemType FIREWORK_STAR = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("firework_star")).get(); + public static final ItemType FIRE_CHARGE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fire_charge")).get(); + public static final ItemType FISHING_ROD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fishing_rod")).get(); + public static final ItemType FLINT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("flint")).get(); + public static final ItemType FLINT_AND_STEEL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("flint_and_steel")).get(); + public static final ItemType FLOWER_BANNER_PATTERN = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("flower_banner_pattern")).get(); + public static final ItemType FOX_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fox_spawn_egg")).get(); + public static final ItemType FURNACE_MINECART = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("furnace_minecart")).get(); + public static final ItemType GHAST_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("ghast_spawn_egg")).get(); + public static final ItemType GHAST_TEAR = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("ghast_tear")).get(); + public static final ItemType GLASS_BOTTLE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("glass_bottle")).get(); + public static final ItemType GLISTERING_MELON_SLICE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("glistering_melon_slice")).get(); + public static final ItemType GLOBE_BANNER_PATTERN = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("globe_banner_pattern")).get(); + public static final ItemType GLOWSTONE_DUST = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("glowstone_dust")).get(); + public static final ItemType GOLDEN_APPLE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_apple")).get(); + public static final ItemType GOLDEN_AXE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_axe")).get(); + public static final ItemType GOLDEN_BOOTS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_boots")).get(); + public static final ItemType GOLDEN_CARROT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_carrot")).get(); + public static final ItemType GOLDEN_CHESTPLATE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_chestplate")).get(); + public static final ItemType GOLDEN_HELMET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_helmet")).get(); + public static final ItemType GOLDEN_HOE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_hoe")).get(); + public static final ItemType GOLDEN_HORSE_ARMOR = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_horse_armor")).get(); + public static final ItemType GOLDEN_LEGGINGS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_leggings")).get(); + public static final ItemType GOLDEN_PICKAXE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_pickaxe")).get(); + public static final ItemType GOLDEN_SHOVEL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_shovel")).get(); + public static final ItemType GOLDEN_SWORD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("golden_sword")).get(); + public static final ItemType GOLD_INGOT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gold_ingot")).get(); + public static final ItemType GOLD_NUGGET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gold_nugget")).get(); + public static final ItemType GRAY_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_dye")).get(); + public static final ItemType GREEN_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_dye")).get(); + public static final ItemType GUARDIAN_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("guardian_spawn_egg")).get(); + public static final ItemType GUNPOWDER = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gunpowder")).get(); + public static final ItemType HEART_OF_THE_SEA = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("heart_of_the_sea")).get(); + public static final ItemType HONEYCOMB = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("honeycomb")).get(); + public static final ItemType HONEY_BOTTLE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("honey_bottle")).get(); + public static final ItemType HOPPER_MINECART = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("hopper_minecart")).get(); + public static final ItemType HORSE_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("horse_spawn_egg")).get(); + public static final ItemType HUSK_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("husk_spawn_egg")).get(); + public static final ItemType INK_SAC = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("ink_sac")).get(); + public static final ItemType IRON_AXE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_axe")).get(); + public static final ItemType IRON_BOOTS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_boots")).get(); + public static final ItemType IRON_CHESTPLATE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_chestplate")).get(); + public static final ItemType IRON_HELMET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_helmet")).get(); + public static final ItemType IRON_HOE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_hoe")).get(); + public static final ItemType IRON_HORSE_ARMOR = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_horse_armor")).get(); + public static final ItemType IRON_INGOT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_ingot")).get(); + public static final ItemType IRON_LEGGINGS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_leggings")).get(); + public static final ItemType IRON_NUGGET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_nugget")).get(); + public static final ItemType IRON_PICKAXE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_pickaxe")).get(); + public static final ItemType IRON_SHOVEL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_shovel")).get(); + public static final ItemType IRON_SWORD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_sword")).get(); + public static final ItemType ITEM_FRAME = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("item_frame")).get(); + public static final ItemType JUNGLE_BOAT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_boat")).get(); + public static final ItemType KNOWLEDGE_BOOK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("knowledge_book")).get(); + public static final ItemType LAPIS_LAZULI = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lapis_lazuli")).get(); + public static final ItemType LAVA_BUCKET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lava_bucket")).get(); + public static final ItemType LEAD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lead")).get(); + public static final ItemType LEATHER = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("leather")).get(); + public static final ItemType LEATHER_BOOTS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("leather_boots")).get(); + public static final ItemType LEATHER_CHESTPLATE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("leather_chestplate")).get(); + public static final ItemType LEATHER_HELMET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("leather_helmet")).get(); + public static final ItemType LEATHER_HORSE_ARMOR = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("leather_horse_armor")).get(); + public static final ItemType LEATHER_LEGGINGS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("leather_leggings")).get(); + public static final ItemType LIGHT_BLUE_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_dye")).get(); + public static final ItemType LIGHT_GRAY_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_dye")).get(); + public static final ItemType LIME_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_dye")).get(); + public static final ItemType LINGERING_POTION = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lingering_potion")).get(); + public static final ItemType LLAMA_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("llama_spawn_egg")).get(); + public static final ItemType MAGENTA_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_dye")).get(); + public static final ItemType MAGMA_CREAM = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magma_cream")).get(); + public static final ItemType MAGMA_CUBE_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magma_cube_spawn_egg")).get(); + public static final ItemType MAP = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("map")).get(); + public static final ItemType MELON_SEEDS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("melon_seeds")).get(); + public static final ItemType MELON_SLICE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("melon_slice")).get(); + public static final ItemType MILK_BUCKET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("milk_bucket")).get(); + public static final ItemType MINECART = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("minecart")).get(); + public static final ItemType MOJANG_BANNER_PATTERN = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mojang_banner_pattern")).get(); + public static final ItemType MOOSHROOM_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mooshroom_spawn_egg")).get(); + public static final ItemType MULE_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mule_spawn_egg")).get(); + public static final ItemType MUSHROOM_STEW = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mushroom_stew")).get(); + public static final ItemType MUSIC_DISC_11 = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_11")).get(); + public static final ItemType MUSIC_DISC_13 = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_13")).get(); + public static final ItemType MUSIC_DISC_BLOCKS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_blocks")).get(); + public static final ItemType MUSIC_DISC_CAT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_cat")).get(); + public static final ItemType MUSIC_DISC_CHIRP = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_chirp")).get(); + public static final ItemType MUSIC_DISC_FAR = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_far")).get(); + public static final ItemType MUSIC_DISC_MALL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_mall")).get(); + public static final ItemType MUSIC_DISC_MELLOHI = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_mellohi")).get(); + public static final ItemType MUSIC_DISC_STAL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_stal")).get(); + public static final ItemType MUSIC_DISC_STRAD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_strad")).get(); + public static final ItemType MUSIC_DISC_WAIT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_wait")).get(); + public static final ItemType MUSIC_DISC_WARD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("music_disc_ward")).get(); + public static final ItemType MUTTON = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mutton")).get(); + public static final ItemType NAME_TAG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("name_tag")).get(); + public static final ItemType NAUTILUS_SHELL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nautilus_shell")).get(); + public static final ItemType NETHER_BRICK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_brick")).get(); + public static final ItemType NETHER_STAR = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_star")).get(); + public static final ItemType OAK_BOAT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_boat")).get(); + public static final ItemType OCELOT_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("ocelot_spawn_egg")).get(); + public static final ItemType ORANGE_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_dye")).get(); + public static final ItemType PAINTING = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("painting")).get(); + public static final ItemType PANDA_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("panda_spawn_egg")).get(); + public static final ItemType PAPER = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("paper")).get(); + public static final ItemType PARROT_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("parrot_spawn_egg")).get(); + public static final ItemType PHANTOM_MEMBRANE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("phantom_membrane")).get(); + public static final ItemType PHANTOM_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("phantom_spawn_egg")).get(); + public static final ItemType PIG_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pig_spawn_egg")).get(); + public static final ItemType PILLAGER_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pillager_spawn_egg")).get(); + public static final ItemType PINK_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_dye")).get(); + public static final ItemType POISONOUS_POTATO = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("poisonous_potato")).get(); + public static final ItemType POLAR_BEAR_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("polar_bear_spawn_egg")).get(); + public static final ItemType POPPED_CHORUS_FRUIT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("popped_chorus_fruit")).get(); + public static final ItemType PORKCHOP = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("porkchop")).get(); + public static final ItemType POTATO = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potato")).get(); + public static final ItemType POTION = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potion")).get(); + public static final ItemType PRISMARINE_CRYSTALS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("prismarine_crystals")).get(); + public static final ItemType PRISMARINE_SHARD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("prismarine_shard")).get(); + public static final ItemType PUFFERFISH = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pufferfish")).get(); + public static final ItemType PUFFERFISH_BUCKET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pufferfish_bucket")).get(); + public static final ItemType PUFFERFISH_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pufferfish_spawn_egg")).get(); + public static final ItemType PUMPKIN_PIE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pumpkin_pie")).get(); + public static final ItemType PUMPKIN_SEEDS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pumpkin_seeds")).get(); + public static final ItemType PURPLE_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_dye")).get(); + public static final ItemType QUARTZ = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("quartz")).get(); + public static final ItemType RABBIT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("rabbit")).get(); + public static final ItemType RABBIT_FOOT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("rabbit_foot")).get(); + public static final ItemType RABBIT_HIDE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("rabbit_hide")).get(); + public static final ItemType RABBIT_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("rabbit_spawn_egg")).get(); + public static final ItemType RABBIT_STEW = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("rabbit_stew")).get(); + public static final ItemType RAVAGER_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("ravager_spawn_egg")).get(); + public static final ItemType REDSTONE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("redstone")).get(); + public static final ItemType RED_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_dye")).get(); + public static final ItemType ROTTEN_FLESH = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("rotten_flesh")).get(); + public static final ItemType SADDLE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("saddle")).get(); + public static final ItemType SALMON = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("salmon")).get(); + public static final ItemType SALMON_BUCKET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("salmon_bucket")).get(); + public static final ItemType SALMON_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("salmon_spawn_egg")).get(); + public static final ItemType SCUTE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("scute")).get(); + public static final ItemType SHEARS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("shears")).get(); + public static final ItemType SHEEP_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sheep_spawn_egg")).get(); + public static final ItemType SHIELD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("shield")).get(); + public static final ItemType SHULKER_SHELL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("shulker_shell")).get(); + public static final ItemType SHULKER_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("shulker_spawn_egg")).get(); + public static final ItemType SILVERFISH_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("silverfish_spawn_egg")).get(); + public static final ItemType SKELETON_HORSE_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("skeleton_horse_spawn_egg")).get(); + public static final ItemType SKELETON_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("skeleton_spawn_egg")).get(); + public static final ItemType SKULL_BANNER_PATTERN = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("skull_banner_pattern")).get(); + public static final ItemType SLIME_BALL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("slime_ball")).get(); + public static final ItemType SLIME_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("slime_spawn_egg")).get(); + public static final ItemType SNOWBALL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("snowball")).get(); + public static final ItemType SPECTRAL_ARROW = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spectral_arrow")).get(); + public static final ItemType SPIDER_EYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spider_eye")).get(); + public static final ItemType SPIDER_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spider_spawn_egg")).get(); + public static final ItemType SPLASH_POTION = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("splash_potion")).get(); + public static final ItemType SPRUCE_BOAT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_boat")).get(); + public static final ItemType SQUID_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("squid_spawn_egg")).get(); + public static final ItemType STICK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stick")).get(); + public static final ItemType STONE_AXE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_axe")).get(); + public static final ItemType STONE_HOE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_hoe")).get(); + public static final ItemType STONE_PICKAXE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_pickaxe")).get(); + public static final ItemType STONE_SHOVEL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_shovel")).get(); + public static final ItemType STONE_SWORD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_sword")).get(); + public static final ItemType STRAY_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stray_spawn_egg")).get(); + public static final ItemType STRING = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("string")).get(); + public static final ItemType SUGAR = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sugar")).get(); + public static final ItemType SUSPICIOUS_STEW = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("suspicious_stew")).get(); + public static final ItemType SWEET_BERRIES = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sweet_berries")).get(); + public static final ItemType TIPPED_ARROW = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tipped_arrow")).get(); + public static final ItemType TNT_MINECART = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tnt_minecart")).get(); + public static final ItemType TOTEM_OF_UNDYING = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("totem_of_undying")).get(); + public static final ItemType TRADER_LLAMA_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("trader_llama_spawn_egg")).get(); + public static final ItemType TRIDENT = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("trident")).get(); + public static final ItemType TROPICAL_FISH = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tropical_fish")).get(); + public static final ItemType TROPICAL_FISH_BUCKET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tropical_fish_bucket")).get(); + public static final ItemType TROPICAL_FISH_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tropical_fish_spawn_egg")).get(); + public static final ItemType TURTLE_HELMET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("turtle_helmet")).get(); + public static final ItemType TURTLE_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("turtle_spawn_egg")).get(); + public static final ItemType VEX_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("vex_spawn_egg")).get(); + public static final ItemType VILLAGER_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("villager_spawn_egg")).get(); + public static final ItemType VINDICATOR_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("vindicator_spawn_egg")).get(); + public static final ItemType WANDERING_TRADER_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wandering_trader_spawn_egg")).get(); + public static final ItemType WATER_BUCKET = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("water_bucket")).get(); + public static final ItemType WHEAT_SEEDS = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wheat_seeds")).get(); + public static final ItemType WHITE_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_dye")).get(); + public static final ItemType WITCH_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("witch_spawn_egg")).get(); + public static final ItemType WITHER_SKELETON_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wither_skeleton_spawn_egg")).get(); + public static final ItemType WOLF_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wolf_spawn_egg")).get(); + public static final ItemType WOODEN_AXE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wooden_axe")).get(); + public static final ItemType WOODEN_HOE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wooden_hoe")).get(); + public static final ItemType WOODEN_PICKAXE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wooden_pickaxe")).get(); + public static final ItemType WOODEN_SHOVEL = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wooden_shovel")).get(); + public static final ItemType WOODEN_SWORD = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wooden_sword")).get(); + public static final ItemType WRITABLE_BOOK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("writable_book")).get(); + public static final ItemType WRITTEN_BOOK = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("written_book")).get(); + public static final ItemType YELLOW_DYE = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_dye")).get(); + public static final ItemType ZOMBIE_HORSE_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("zombie_horse_spawn_egg")).get(); + public static final ItemType ZOMBIE_PIGMAN_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("zombie_pigman_spawn_egg")).get(); + public static final ItemType ZOMBIE_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("zombie_spawn_egg")).get(); + public static final ItemType ZOMBIE_VILLAGER_SPAWN_EGG = ItemRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("zombie_villager_spawn_egg")).get(); + + /** + * Gets an {@link ItemType} from the given key + * + * @param key the {@link NamespacedKey} to get the item from + * @return an {@link ItemType} from the given key + */ + public static Optional getItemFromKey(NamespacedKey key) { + return Platform.getPlatform().getRegistry().getItemRegistry().fromKey(key); + } +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/component/ColorComponent.java b/modules/api/src/main/java/org/battleplugins/inventory/item/component/ColorComponent.java new file mode 100644 index 0000000..2b3189c --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/component/ColorComponent.java @@ -0,0 +1,10 @@ +package org.battleplugins.inventory.item.component; + +import java.awt.Color; + +/** + * Represents the component responsible for applying colors + * to applicable itemstacks. + */ +public interface ColorComponent extends ItemComponent { +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/component/CustomModelDataComponent.java b/modules/api/src/main/java/org/battleplugins/inventory/item/component/CustomModelDataComponent.java new file mode 100644 index 0000000..6fbbb9f --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/component/CustomModelDataComponent.java @@ -0,0 +1,8 @@ +package org.battleplugins.inventory.item.component; + +/** + * Represents the component responsible for applying custom + * model data to itemstacks. + */ +public interface CustomModelDataComponent extends ItemComponent { +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/component/DamageComponent.java b/modules/api/src/main/java/org/battleplugins/inventory/item/component/DamageComponent.java new file mode 100644 index 0000000..10ea072 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/component/DamageComponent.java @@ -0,0 +1,8 @@ +package org.battleplugins.inventory.item.component; + +/** + * Represents the component responsible for applying damage + * to itemstacks. + */ +public interface DamageComponent extends ItemComponent { +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/component/DisplayNameComponent.java b/modules/api/src/main/java/org/battleplugins/inventory/item/component/DisplayNameComponent.java new file mode 100644 index 0000000..d632ed5 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/component/DisplayNameComponent.java @@ -0,0 +1,8 @@ +package org.battleplugins.inventory.item.component; + +/** + * Represents the component responsible for applying display + * names to itemstacks. + */ +public interface DisplayNameComponent extends ItemComponent { +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/component/ItemComponent.java b/modules/api/src/main/java/org/battleplugins/inventory/item/component/ItemComponent.java new file mode 100644 index 0000000..4cebb26 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/component/ItemComponent.java @@ -0,0 +1,17 @@ +package org.battleplugins.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; + +import java.util.Optional; + +/** + * Represents a component that can be added to an item. + * + * @param the component able to be modified + */ +public interface ItemComponent { + + void applyComponent(ItemStack itemStack, T value); + + Optional getValue(ItemStack itemStack); +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/component/ItemFlagComponent.java b/modules/api/src/main/java/org/battleplugins/inventory/item/component/ItemFlagComponent.java new file mode 100644 index 0000000..a286089 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/component/ItemFlagComponent.java @@ -0,0 +1,12 @@ +package org.battleplugins.inventory.item.component; + +import org.battleplugins.inventory.item.component.flag.ItemFlag; + +import java.util.Set; + +/** + * Represents the component responsible for applying item flags + * to itemstacks. + */ +public interface ItemFlagComponent extends ItemComponent> { +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/component/LoreComponent.java b/modules/api/src/main/java/org/battleplugins/inventory/item/component/LoreComponent.java new file mode 100644 index 0000000..d8f8e50 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/component/LoreComponent.java @@ -0,0 +1,10 @@ +package org.battleplugins.inventory.item.component; + +import java.util.List; + +/** + * Represents the component responsible for applying lores + * to itemstacks. + */ +public interface LoreComponent extends ItemComponent> { +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/component/UnbreakableComponent.java b/modules/api/src/main/java/org/battleplugins/inventory/item/component/UnbreakableComponent.java new file mode 100644 index 0000000..f236307 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/component/UnbreakableComponent.java @@ -0,0 +1,8 @@ +package org.battleplugins.inventory.item.component; + +/** + * Represents the component responsible for making itemstacks + * unbreakable. + */ +public interface UnbreakableComponent extends ItemComponent { +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/component/flag/ItemFlag.java b/modules/api/src/main/java/org/battleplugins/inventory/item/component/flag/ItemFlag.java new file mode 100644 index 0000000..e0720e8 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/component/flag/ItemFlag.java @@ -0,0 +1,13 @@ +package org.battleplugins.inventory.item.component.flag; + +import lombok.Getter; + +@Getter +public class ItemFlag { + + private String name; + + ItemFlag(String name) { + this.name = name; + } +} diff --git a/modules/api/src/main/java/org/battleplugins/inventory/item/component/flag/ItemFlags.java b/modules/api/src/main/java/org/battleplugins/inventory/item/component/flag/ItemFlags.java new file mode 100644 index 0000000..1b8cb8b --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/inventory/item/component/flag/ItemFlags.java @@ -0,0 +1,47 @@ +package org.battleplugins.inventory.item.component.flag; + +/** + * Holds all the valid ItemFlags. + */ +public class ItemFlags { + + /** + * Hides the attributes on an item + */ + public static final ItemFlag HIDE_ATTRIBUTES = new ItemFlag("hide_attributes"); + + /** + * Hides what blocks an item can destroy + */ + public static final ItemFlag HIDE_DESTROYS = new ItemFlag("hide_destroys"); + + /** + * Hides the enchants on an item + */ + public static final ItemFlag HIDE_ENCHANTS = new ItemFlag("hide_enchants"); + + /** + * Hides what blocks the item (block) can be placed on + */ + public static final ItemFlag HIDE_PLACED_ON = new ItemFlag("hide_placed_on"); + + /** + * Hides the potion effects of an item + */ + public static final ItemFlag HIDE_POTION_EFFECTS = new ItemFlag("hide_potion_effects"); + + /** + * Hides if the item is unbreakable + */ + public static final ItemFlag HIDE_UNBREAKABLE = new ItemFlag("hide_unbreakable"); + + /** + * An array of all the {@link ItemFlag}s + * + * @return an array of all the item flags + */ + public static ItemFlag[] values() { + return new ItemFlag[] {HIDE_ATTRIBUTES, HIDE_DESTROYS, HIDE_ENCHANTS, + HIDE_PLACED_ON, HIDE_POTION_EFFECTS, HIDE_UNBREAKABLE}; + } +} diff --git a/modules/api/src/main/java/org/battleplugins/logger/Logger.java b/modules/api/src/main/java/org/battleplugins/logger/Logger.java index 49b8ffe..e80a173 100644 --- a/modules/api/src/main/java/org/battleplugins/logger/Logger.java +++ b/modules/api/src/main/java/org/battleplugins/logger/Logger.java @@ -1,12 +1,57 @@ package org.battleplugins.logger; +/** + * Logs messages to the console. + */ public interface Logger { + /** + * Logs a message prepended with a + * severe tag. Usually ran when something + * terribly wrong has happened + * + * @param message the message to log + */ void severe(String message); + + /** + * Logs a messaged prepended with an + * error tag. Usually ran when an + * error has occured + * + * @param message the message to log + */ void error(String message); + + /** + * Logs a messaged prepended with a + * warning tag. Usually ran when there + * is a warning + * + * @param message the message to log + */ void warning(String message); + + /** + * Logs an info message + * + * @param message the message to log + */ void info(String message); + /** + * Logs a message only visible if + * {@link #setDebug(boolean)} is true + * + * @param message the message to log + */ void debug(String message); + + /** + * Sets if debug messages should be + * logged + * + * @param debug if debug messages should be logged + */ void setDebug(boolean debug); } diff --git a/modules/api/src/main/java/org/battleplugins/message/ClickAction.java b/modules/api/src/main/java/org/battleplugins/message/ClickAction.java index d788e02..4c03746 100644 --- a/modules/api/src/main/java/org/battleplugins/message/ClickAction.java +++ b/modules/api/src/main/java/org/battleplugins/message/ClickAction.java @@ -1,10 +1,33 @@ package org.battleplugins.message; +/** + * Represents a click action in a message or + * a book. + */ public enum ClickAction { + /** + * Changes the page of a book + */ CHANGE_PAGE, + /** + * Opens a file + * + * @deprecated internal use only, + * may only be exposed on modded servers/clients + */ + @Deprecated OPEN_FILE, + /** + * Opens a URL + */ OPEN_URL, + /** + * Runs a command + */ RUN_COMMAND, + /** + * Suggests a command + */ SUGGEST_COMMAND, } diff --git a/modules/api/src/main/java/org/battleplugins/message/HoverAction.java b/modules/api/src/main/java/org/battleplugins/message/HoverAction.java index dea573a..8bce2fe 100644 --- a/modules/api/src/main/java/org/battleplugins/message/HoverAction.java +++ b/modules/api/src/main/java/org/battleplugins/message/HoverAction.java @@ -1,9 +1,28 @@ package org.battleplugins.message; +/** + * Represents a hover action in a message or + * a book. + */ public enum HoverAction { + /** + * Shows an achievement + * + * @deprecated removed in 1.12 + */ + @Deprecated SHOW_ACHIEVEMENT, + /** + * Shows an entity + */ SHOW_ENTITY, + /** + * Shows an item + */ SHOW_ITEM, + /** + * Shows text + */ SHOW_TEXT; } diff --git a/modules/api/src/main/java/org/battleplugins/message/Message.java b/modules/api/src/main/java/org/battleplugins/message/Message.java index c5d429b..98c8e39 100644 --- a/modules/api/src/main/java/org/battleplugins/message/Message.java +++ b/modules/api/src/main/java/org/battleplugins/message/Message.java @@ -9,27 +9,67 @@ import org.battleplugins.Platform; import org.battleplugins.entity.living.player.Player; +import java.util.Optional; + +/** + * Represents a customizable message able to be sent to players. + */ @Getter @Setter @NoArgsConstructor @RequiredArgsConstructor public abstract class Message { + /** + * The message to send + * + * @param message the message to send + * @return the message to send + */ @NonNull protected String message; + /** + * The {@link ClickAction} of the message + * + * @param clickAction the click action of the message + */ protected ClickAction clickAction; + + /** + * The {@link HoverAction} of the message + * + * @param hoverAction the hover action of the message + */ protected HoverAction hoverAction; + /** + * The hover message + * + * @param hoverMessage the hover message + */ protected String hoverMessage; + + /** + * The click value + * + * @param clickValue the click value + * @return the click value + */ protected String clickValue; + /** + * Sends the message to the {@link Player} + * + * @param player the player to send the message to + */ public abstract void sendMessage(Player player); - private static Message getDefaultPlatformMessage() { - return Platform.getPlatform().getDefaultPlatformMessage(); - } - + /** + * The message builder + * + * @return a new message builder + */ public static Builder builder() { return new Builder(); } @@ -39,7 +79,7 @@ public static class Builder { private Message message; Builder() { - this.message = Message.getDefaultPlatformMessage(); + this.message = Platform.getPlatform().getDefaultPlatformMessage(); } public Builder fromMessage(Message message) { @@ -76,4 +116,40 @@ public Message build() { return message; } } + + /** + * The {@link ClickAction} of the message + * + * @return the click action of the message + */ + public Optional getClickAction() { + return Optional.ofNullable(clickAction); + } + + /** + * The {@link HoverAction} of the message + * + * @return the hover action of the message + */ + public Optional getHoverAction() { + return Optional.ofNullable(hoverAction); + } + + /** + * The hover message + * + * @return the hover message + */ + public Optional getHoverMessage() { + return Optional.ofNullable(hoverMessage); + } + + /** + * The click value + * + * @return the click value + */ + public Optional getClickValue() { + return Optional.ofNullable(clickValue); + } } diff --git a/modules/api/src/main/java/org/battleplugins/plugin/Plugin.java b/modules/api/src/main/java/org/battleplugins/plugin/Plugin.java index f46af32..0c04fee 100644 --- a/modules/api/src/main/java/org/battleplugins/plugin/Plugin.java +++ b/modules/api/src/main/java/org/battleplugins/plugin/Plugin.java @@ -1,6 +1,6 @@ package org.battleplugins.plugin; -import org.battleplugins.APIType; +import org.battleplugins.PlatformType; import org.battleplugins.Platform; import org.battleplugins.command.Command; import org.battleplugins.command.CommandExecutor; @@ -12,37 +12,74 @@ import java.util.HashMap; import java.util.Map; +/** + * Represents a plugin that can be enabled/disabled. + */ public abstract class Plugin { protected PlatformPlugin platformPlugin; - protected Map platformCode; + protected Map platformCode; + /** + * Called when the plugin is enabled + */ public abstract void onEnable(); + + /** + * Called when the plugin is disabled + */ public abstract void onDisable(); public Plugin() { this.platformCode = new HashMap<>(); - for (APIType type : APIType.values()) { + for (PlatformType type : PlatformType.values()) { platformCode.put(type, new PlatformCodeHandler()); } } + /** + * If the plugin is enabled + * + * @return if the plugin is enabled + */ public boolean isEnabled() { return platformPlugin.isEnabled(); } + /** + * The data folder of the plugin + * + * @return the data folder of the plugin + */ public File getDataFolder() { return platformPlugin.getDataFolder(); } + /** + * The {@link Logger} + * + * @return the {@link Logger} + */ public Logger getLogger() { return platformPlugin.getMCLogger(); } + /** + * Registers a command with the given {@link Command} and + * {@link CommandExecutor} + * + * @param command the command to register + * @param executor the executor of the command + */ public void registerCommand(Command command, CommandExecutor executor) { platformPlugin.registerMCCommand(command, executor); } + /** + * The {@link PlatformPlugin} + * + * @return the {@link PlatformPlugin} + */ public PlatformPlugin getPlatformPlugin() { return platformPlugin; } @@ -51,14 +88,31 @@ protected void setPlatformPlugin(PlatformPlugin platformPlugin) { this.platformPlugin = platformPlugin; } + /** + * The {@link PluginDescription} containing information + * about the plugin + * + * @return the {@link PluginDescription} + */ public PluginDescription getDescription() { return new PluginDescription(getClass().getAnnotation(PluginProperties.class)); } + /** + * The {@link PlatformCodeHandler} for the given platform the + * plugin is currently running on + * + * @return the {@link PlatformCodeHandler} + */ public PlatformCodeHandler getPlatformCode() { - return platformCode.get(Platform.getAPI()); + return platformCode.get(Platform.getPlatformType()); } + /** + * The {@link Platform} + * + * @return the {@link Platform} + */ public Platform getPlatform() { return Platform.getPlatform(); } diff --git a/modules/api/src/main/java/org/battleplugins/plugin/PluginDescription.java b/modules/api/src/main/java/org/battleplugins/plugin/PluginDescription.java index 0e8c657..a50a8be 100644 --- a/modules/api/src/main/java/org/battleplugins/plugin/PluginDescription.java +++ b/modules/api/src/main/java/org/battleplugins/plugin/PluginDescription.java @@ -1,5 +1,13 @@ package org.battleplugins.plugin; +import mc.euro.version.Version; + +import java.util.Optional; + +/** + * Description and information about the plugin defined + * in {@link PluginProperties} + */ public class PluginDescription { private PluginProperties properties; @@ -8,27 +16,57 @@ protected PluginDescription(PluginProperties properties) { this.properties = properties; } + /** + * The id of the plugin + * + * @return the id of the plugin + */ public String getId() { return properties.id(); } + /** + * The name of the plugin + * + * @return the name of the plugin + */ public String getName() { return properties.name(); } - public String getVersion() { - return properties.version(); + /** + * The {@link Version} of the plugin + * + * @return the version of the plugin + */ + public Version getVersion() { + return new Version<>(properties.version()); } - public String getDescription() { - return properties.description(); + /** + * The description of the plugin + * + * @return the description of the plugin + */ + public Optional getDescription() { + return properties.description().isEmpty() ? Optional.empty() : Optional.of(properties.description()); } - public String getURL() { - return properties.url(); + /** + * The URL of the plugin + * + * @return the URL of the plugin + */ + public Optional getURL() { + return properties.url().isEmpty() ? Optional.empty() : Optional.of(properties.url()); } - public String[] getAuthors() { - return properties.authors(); + /** + * The authors of the plugin + * + * @return the authors of the plugin + */ + public Optional getAuthors() { + return properties.authors().length == 0 ? Optional.empty() : Optional.of(properties.authors()); } } diff --git a/modules/api/src/main/java/org/battleplugins/plugin/PluginManager.java b/modules/api/src/main/java/org/battleplugins/plugin/PluginManager.java index 5a7a06d..31048bb 100644 --- a/modules/api/src/main/java/org/battleplugins/plugin/PluginManager.java +++ b/modules/api/src/main/java/org/battleplugins/plugin/PluginManager.java @@ -10,11 +10,20 @@ import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; +/** + * The plugin manager for managing plugins built against + * this API (not to be confused with the platform plugin manager). + */ @Getter public class PluginManager { private Plugin plugin; + /** + * Initializes the given plugin + * + * @param platformPlugin the plugin to initialize + */ public void initializePlugin(PlatformPlugin platformPlugin) { InputStream propertyStream = getClass().getResourceAsStream("/plugin.properties"); BufferedReader reader = new BufferedReader(new InputStreamReader(propertyStream)); @@ -41,6 +50,9 @@ public void initializePlugin(PlatformPlugin platformPlugin) { } } + /** + * Enables the plugin + */ public void enablePlugin() { if (plugin != null) { try { @@ -56,6 +68,9 @@ public void enablePlugin() { } } + /** + * Disables the plugin + */ public void disablePlugin() { if (plugin != null) { try { diff --git a/modules/api/src/main/java/org/battleplugins/plugin/PluginProperties.java b/modules/api/src/main/java/org/battleplugins/plugin/PluginProperties.java index 5166aca..077fe41 100644 --- a/modules/api/src/main/java/org/battleplugins/plugin/PluginProperties.java +++ b/modules/api/src/main/java/org/battleplugins/plugin/PluginProperties.java @@ -5,6 +5,9 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Properties + */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface PluginProperties { diff --git a/modules/api/src/main/java/org/battleplugins/plugin/ServicePriority.java b/modules/api/src/main/java/org/battleplugins/plugin/ServicePriority.java deleted file mode 100644 index eb07afb..0000000 --- a/modules/api/src/main/java/org/battleplugins/plugin/ServicePriority.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.battleplugins.plugin; - -public enum ServicePriority { - - LOWEST, - LOW, - NORMAL, - HIGH, - HIGHEST; -} diff --git a/modules/api/src/main/java/org/battleplugins/plugin/platform/PlatformCodeHandler.java b/modules/api/src/main/java/org/battleplugins/plugin/platform/PlatformCodeHandler.java index ede5c2c..f31549c 100644 --- a/modules/api/src/main/java/org/battleplugins/plugin/platform/PlatformCodeHandler.java +++ b/modules/api/src/main/java/org/battleplugins/plugin/platform/PlatformCodeHandler.java @@ -1,5 +1,11 @@ package org.battleplugins.plugin.platform; +import org.battleplugins.plugin.Plugin; + +/** + * A code handler that controls platform-dependent code for when + * the plugin is enabled and disabled in {@link Plugin}. + */ public class PlatformCodeHandler { public void onEnable() { diff --git a/modules/api/src/main/java/org/battleplugins/plugin/platform/PlatformPlugin.java b/modules/api/src/main/java/org/battleplugins/plugin/platform/PlatformPlugin.java index bdc04fc..bf7700c 100644 --- a/modules/api/src/main/java/org/battleplugins/plugin/platform/PlatformPlugin.java +++ b/modules/api/src/main/java/org/battleplugins/plugin/platform/PlatformPlugin.java @@ -6,13 +6,38 @@ import java.io.File; +/** + * Represents a platform plugin. + */ public interface PlatformPlugin { + /** + * Registers a command with the given {@link Command} and + * {@link CommandExecutor} + * + * @param command the command to register + * @param executor the executor of the command + */ void registerMCCommand(Command command, CommandExecutor executor); + /** + * The data folder of the plugin + * + * @return the data folder of the plugin + */ File getDataFolder(); + /** + * The {@link Logger} + * + * @return the {@link Logger} + */ Logger getMCLogger(); + /** + * If the plugin is enabled + * + * @return if the plugin is enabled + */ boolean isEnabled(); } diff --git a/modules/api/src/main/java/org/battleplugins/plugin/service/ServicePriority.java b/modules/api/src/main/java/org/battleplugins/plugin/service/ServicePriority.java new file mode 100644 index 0000000..2e62448 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/plugin/service/ServicePriority.java @@ -0,0 +1,32 @@ +package org.battleplugins.plugin.service; + +/** + * The priority of a service. + */ +public enum ServicePriority { + + /** + * The lowest priority + */ + LOWEST, + + /** + * The second lowest priority + */ + LOW, + + /** + * Normal priority + */ + NORMAL, + + /** + * The second highest priority + */ + HIGH, + + /** + * The highest of importance! + */ + HIGHEST; +} diff --git a/modules/api/src/main/java/org/battleplugins/scheduler/Scheduler.java b/modules/api/src/main/java/org/battleplugins/scheduler/Scheduler.java index 91af398..d0b78ac 100644 --- a/modules/api/src/main/java/org/battleplugins/scheduler/Scheduler.java +++ b/modules/api/src/main/java/org/battleplugins/scheduler/Scheduler.java @@ -7,6 +7,9 @@ import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; +/** + * TODO: Redo scheduler API. + */ public class Scheduler { private static int count = 0; // count of current async timers diff --git a/modules/api/src/main/java/org/battleplugins/util/MCWrapper.java b/modules/api/src/main/java/org/battleplugins/util/MCWrapper.java index c40cd00..38544c8 100644 --- a/modules/api/src/main/java/org/battleplugins/util/MCWrapper.java +++ b/modules/api/src/main/java/org/battleplugins/util/MCWrapper.java @@ -5,10 +5,20 @@ import lombok.Data; import lombok.Setter; +/** + * Wraps an implementation class. + * + * @param the platform implementation + */ @AllArgsConstructor @Data public class MCWrapper { + /** + * The platform implementation handle + * + * @return the platform implementation handle + */ @Setter(AccessLevel.NONE) protected T handle; } diff --git a/modules/api/src/main/java/org/battleplugins/util/NamespacedKey.java b/modules/api/src/main/java/org/battleplugins/util/NamespacedKey.java new file mode 100644 index 0000000..b55a547 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/util/NamespacedKey.java @@ -0,0 +1,72 @@ +package org.battleplugins.util; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Setter; + +import org.battleplugins.plugin.Plugin; + +import java.util.regex.Pattern; + +/** + * Represents a String based key which consists of two components - + * a namespace and a key. + * + * Namespaces may only contain lowercase alphanumeric characters, + * periods underscores, and hyphens. Keys may only contain lowercase + * alphanumeric characters, periods, underscores, hyphens, and forward + * slashes. + */ +@Data +@Setter(AccessLevel.NONE) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +public class NamespacedKey { + + public static final String MINECRAFT = "minecraft"; + + private static final Pattern VALID_NAMESPACE = Pattern.compile("[a-z0-9._-]+"); + private static final Pattern VALID_KEY = Pattern.compile("[a-z0-9/._-]+"); + + private final String namespace; + private final String key; + + /** + * Gets a key in the Minecraft namespace + * + * @param key the key to use + * @return a new key in the Minecraft namespace + */ + public static NamespacedKey minecraft(String key) { + return of(MINECRAFT, key); + } + + /** + * Creates a namespace with the given plugin + * + * @param plugin the plugin to create the namespace with + * @param key the key + * @return a namespace with the given plugin + */ + public static NamespacedKey of(Plugin plugin, String key) { + return of(plugin.getDescription().getName(), key); + } + + private static NamespacedKey of(String namespace, String key) { + namespace = namespace.toLowerCase(); + key = key.toLowerCase(); + + if (!VALID_NAMESPACE.matcher(namespace).matches()) + throw new IllegalArgumentException("Invalid namespace. Must be [a-z0-9._-]: " + namespace); + + if (!VALID_KEY.matcher(key).matches()) + throw new IllegalArgumentException("Invalid key. Must be [a-z0-9/._-]: " + key); + + return new NamespacedKey(namespace, key); + } + + @Override + public String toString() { + return this.namespace + ":" + this.key; + } +} diff --git a/modules/api/src/main/java/org/battleplugins/world/Location.java b/modules/api/src/main/java/org/battleplugins/world/Location.java index 936eb62..3f30072 100644 --- a/modules/api/src/main/java/org/battleplugins/world/Location.java +++ b/modules/api/src/main/java/org/battleplugins/world/Location.java @@ -1,17 +1,77 @@ package org.battleplugins.world; +/** + * Represents a location in the world. + */ public interface Location { + /** + * The world the location is in. + * + * @return the world the location is in + * + */ World getWorld(); + /** + * The x coordinate of the location + * + * @return the x coordinate of the location + */ double getX(); + + /** + * The y coordinate of the location + * + * @return the y coordinate of the location + */ double getY(); + + /** + * The z coordinate of the location + * + * @return the z coordinate of the location + */ double getZ(); + /** + * The pitch of the location + * + * @return the pitch of the location + */ float getPitch(); + + /** + * The yaw of the location + * + * @return the yaw of the location + */ float getYaw(); - int getBlockX(); - int getBlockY(); - int getBlockZ(); + /** + * The block x coordinate of the location + * + * @return the block x coordinate of the location + */ + default int getBlockX() { + return (int) Math.floor(getX()); + } + + /** + * The block y coordinate of the location + * + * @return the block y coordinate of the location + */ + default int getBlockY() { + return (int) Math.floor(getY()); + } + + /** + * The block z coordinate of the location + * + * @return the block z coordinate of the location + */ + default int getBlockZ() { + return (int) Math.floor(getZ()); + } } diff --git a/modules/api/src/main/java/org/battleplugins/world/World.java b/modules/api/src/main/java/org/battleplugins/world/World.java index 25a67c4..5038f50 100644 --- a/modules/api/src/main/java/org/battleplugins/world/World.java +++ b/modules/api/src/main/java/org/battleplugins/world/World.java @@ -1,5 +1,6 @@ package org.battleplugins.world; +import org.battleplugins.entity.living.player.Player; import org.battleplugins.world.block.Block; import org.battleplugins.world.block.entity.BlockEntity; @@ -14,4 +15,7 @@ public interface World { boolean isType(BlockEntity blockEntity, Class clazz); T toType(BlockEntity blockEntity, Class clazz) throws ClassCastException; + + void sendBlockUpdate(Player player, Location location, Block block); + void sendBlockEntityUpdate(Player player, Location location, BlockEntity blockEntity); } diff --git a/modules/api/src/main/java/org/battleplugins/world/block/Block.java b/modules/api/src/main/java/org/battleplugins/world/block/Block.java index 9c2ca3a..e05444a 100644 --- a/modules/api/src/main/java/org/battleplugins/world/block/Block.java +++ b/modules/api/src/main/java/org/battleplugins/world/block/Block.java @@ -3,14 +3,31 @@ import org.battleplugins.world.Location; import org.battleplugins.world.World; +/** + * Represents a block in the world. + */ public interface Block { - World getWorld(); - Location getLocation(); + /** + * The {@link World} this block is located in + * + * @return the world this block is located in + */ + default World getWorld() { + return getLocation().getWorld(); + } - int getX(); - int getY(); - int getZ(); + /** + * The location of the block + * + * @return the location of the block + */ + Location getLocation(); - String getType(); + /** + * The {@link BlockType} of this block + * + * @return the block type of this block + */ + BlockType getType(); } diff --git a/modules/api/src/main/java/org/battleplugins/world/block/BlockRegistry.java b/modules/api/src/main/java/org/battleplugins/world/block/BlockRegistry.java new file mode 100644 index 0000000..6049a28 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/world/block/BlockRegistry.java @@ -0,0 +1,45 @@ +package org.battleplugins.world.block; + +import org.battleplugins.Platform; +import org.battleplugins.util.NamespacedKey; + +import java.util.Optional; + +/** + * A registry containing all the blocks based on various + * implementations depending on the platform. + * + * Certain platforms base their implementations of blocks + * on different values (e.g. Bukkit is Material/identifier + * based whilst Nukkit is ID based). This class allows for + * blocks to be mapped from their platform implementations as + * well as from {@link NamespacedKey}'s. + * + * @param the platform implementation + */ +public interface BlockRegistry { + + BlockRegistry REGISTRY = Platform.getPlatform().getRegistry().getBlockRegistry(); + + /** + * Gets the given block type from the platform + * block + * + * @param block the platform block + * @return the given block type + */ + BlockType fromPlatformBlock(T block); + + /** + * Gets the block type from the given + * {@link NamespacedKey}. Returns empty if the + * block could not be found. The only reason this should + * be used is if an block type needs to be obtained + * from a string, an block is not in the {@link BlockTypes} + * class, or if a modded block (Sponge) needs to be obtained. + * + * @param namespacedKey the given {@link NamespacedKey} + * @return the block type from the given namespaced key + */ + Optional fromKey(NamespacedKey namespacedKey); +} diff --git a/modules/api/src/main/java/org/battleplugins/world/block/BlockType.java b/modules/api/src/main/java/org/battleplugins/world/block/BlockType.java new file mode 100644 index 0000000..4e5d800 --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/world/block/BlockType.java @@ -0,0 +1,16 @@ +package org.battleplugins.world.block; + +import org.battleplugins.inventory.item.ItemType; + +/** + * Represents a block type. + */ +public interface BlockType extends ItemType { + + /** + * The hardness of the block + * + * @return the hardness of the block + */ + float getHardness(); +} diff --git a/modules/api/src/main/java/org/battleplugins/world/block/BlockTypes.java b/modules/api/src/main/java/org/battleplugins/world/block/BlockTypes.java new file mode 100644 index 0000000..01f025f --- /dev/null +++ b/modules/api/src/main/java/org/battleplugins/world/block/BlockTypes.java @@ -0,0 +1,703 @@ +package org.battleplugins.world.block; + +import org.battleplugins.Platform; +import org.battleplugins.util.NamespacedKey; + +import java.util.Optional; + +/** + * Holds all the valid BlockTypes. + */ +public class BlockTypes { + + public static final BlockType ACACIA_BUTTON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_button")).get(); + public static final BlockType ACACIA_DOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_door")).get(); + public static final BlockType ACACIA_FENCE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_fence")).get(); + public static final BlockType ACACIA_FENCE_GATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_fence_gate")).get(); + public static final BlockType ACACIA_LEAVES = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_leaves")).get(); + public static final BlockType ACACIA_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_log")).get(); + public static final BlockType ACACIA_PLANKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_planks")).get(); + public static final BlockType ACACIA_PRESSURE_PLATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_pressure_plate")).get(); + public static final BlockType ACACIA_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_sapling")).get(); + public static final BlockType ACACIA_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_sign")).get(); + public static final BlockType ACACIA_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_slab")).get(); + public static final BlockType ACACIA_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_stairs")).get(); + public static final BlockType ACACIA_TRAPDOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_trapdoor")).get(); + public static final BlockType ACACIA_WALL_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_wall_sign")).get(); + public static final BlockType ACACIA_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("acacia_wood")).get(); + public static final BlockType ACTIVATOR_RAIL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("activator_rail")).get(); + public static final BlockType AIR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("air")).get(); + public static final BlockType ALLIUM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("allium")).get(); + public static final BlockType ANDESITE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("andesite")).get(); + public static final BlockType ANDESITE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("andesite_slab")).get(); + public static final BlockType ANDESITE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("andesite_stairs")).get(); + public static final BlockType ANDESITE_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("andesite_wall")).get(); + public static final BlockType ANVIL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("anvil")).get(); + public static final BlockType ATTACHED_MELON_STEM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("attached_melon_stem")).get(); + public static final BlockType ATTACHED_PUMPKIN_STEM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("attached_pumpkin_stem")).get(); + public static final BlockType AZURE_BLUET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("azure_bluet")).get(); + public static final BlockType BAMBOO = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bamboo")).get(); + public static final BlockType BAMBOO_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bamboo_sapling")).get(); + public static final BlockType BARREL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("barrel")).get(); + public static final BlockType BARRIER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("barrier")).get(); + public static final BlockType BEACON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("beacon")).get(); + public static final BlockType BEDROCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bedrock")).get(); + public static final BlockType BEEHIVE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("beehive")).get(); + public static final BlockType BEETROOTS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("beetroots")).get(); + public static final BlockType BEE_NEST = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bee_nest")).get(); + public static final BlockType BELL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bell")).get(); + public static final BlockType BIRCH_BUTTON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_button")).get(); + public static final BlockType BIRCH_DOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_door")).get(); + public static final BlockType BIRCH_FENCE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_fence")).get(); + public static final BlockType BIRCH_FENCE_GATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_fence_gate")).get(); + public static final BlockType BIRCH_LEAVES = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_leaves")).get(); + public static final BlockType BIRCH_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_log")).get(); + public static final BlockType BIRCH_PLANKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_planks")).get(); + public static final BlockType BIRCH_PRESSURE_PLATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_pressure_plate")).get(); + public static final BlockType BIRCH_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_sapling")).get(); + public static final BlockType BIRCH_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_sign")).get(); + public static final BlockType BIRCH_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_slab")).get(); + public static final BlockType BIRCH_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_stairs")).get(); + public static final BlockType BIRCH_TRAPDOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_trapdoor")).get(); + public static final BlockType BIRCH_WALL_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_wall_sign")).get(); + public static final BlockType BIRCH_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("birch_wood")).get(); + public static final BlockType BLACK_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_banner")).get(); + public static final BlockType BLACK_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_bed")).get(); + public static final BlockType BLACK_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_carpet")).get(); + public static final BlockType BLACK_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_concrete")).get(); + public static final BlockType BLACK_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_concrete_powder")).get(); + public static final BlockType BLACK_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_glazed_terracotta")).get(); + public static final BlockType BLACK_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_shulker_box")).get(); + public static final BlockType BLACK_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_stained_glass")).get(); + public static final BlockType BLACK_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_stained_glass_pane")).get(); + public static final BlockType BLACK_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_terracotta")).get(); + public static final BlockType BLACK_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_wall_banner")).get(); + public static final BlockType BLACK_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("black_wool")).get(); + public static final BlockType BLAST_FURNACE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blast_furnace")).get(); + public static final BlockType BLUE_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_banner")).get(); + public static final BlockType BLUE_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_bed")).get(); + public static final BlockType BLUE_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_carpet")).get(); + public static final BlockType BLUE_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_concrete")).get(); + public static final BlockType BLUE_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_concrete_powder")).get(); + public static final BlockType BLUE_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_glazed_terracotta")).get(); + public static final BlockType BLUE_ICE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_ice")).get(); + public static final BlockType BLUE_ORCHID = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_orchid")).get(); + public static final BlockType BLUE_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_shulker_box")).get(); + public static final BlockType BLUE_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_stained_glass")).get(); + public static final BlockType BLUE_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_stained_glass_pane")).get(); + public static final BlockType BLUE_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_terracotta")).get(); + public static final BlockType BLUE_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_wall_banner")).get(); + public static final BlockType BLUE_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("blue_wool")).get(); + public static final BlockType BONE_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bone_block")).get(); + public static final BlockType BOOKSHELF = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bookshelf")).get(); + public static final BlockType BRAIN_CORAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brain_coral")).get(); + public static final BlockType BRAIN_CORAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brain_coral_block")).get(); + public static final BlockType BRAIN_CORAL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brain_coral_fan")).get(); + public static final BlockType BRAIN_CORAL_WALL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brain_coral_wall_fan")).get(); + public static final BlockType BREWING_STAND = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brewing_stand")).get(); + public static final BlockType BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bricks")).get(); + public static final BlockType BRICK_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brick_slab")).get(); + public static final BlockType BRICK_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brick_stairs")).get(); + public static final BlockType BRICK_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brick_wall")).get(); + public static final BlockType BROWN_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_banner")).get(); + public static final BlockType BROWN_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_bed")).get(); + public static final BlockType BROWN_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_carpet")).get(); + public static final BlockType BROWN_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_concrete")).get(); + public static final BlockType BROWN_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_concrete_powder")).get(); + public static final BlockType BROWN_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_glazed_terracotta")).get(); + public static final BlockType BROWN_MUSHROOM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_mushroom")).get(); + public static final BlockType BROWN_MUSHROOM_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_mushroom_block")).get(); + public static final BlockType BROWN_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_shulker_box")).get(); + public static final BlockType BROWN_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_stained_glass")).get(); + public static final BlockType BROWN_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_stained_glass_pane")).get(); + public static final BlockType BROWN_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_terracotta")).get(); + public static final BlockType BROWN_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_wall_banner")).get(); + public static final BlockType BROWN_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("brown_wool")).get(); + public static final BlockType BUBBLE_COLUMN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bubble_column")).get(); + public static final BlockType BUBBLE_CORAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bubble_coral")).get(); + public static final BlockType BUBBLE_CORAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bubble_coral_block")).get(); + public static final BlockType BUBBLE_CORAL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bubble_coral_fan")).get(); + public static final BlockType BUBBLE_CORAL_WALL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("bubble_coral_wall_fan")).get(); + public static final BlockType CACTUS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cactus")).get(); + public static final BlockType CAKE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cake")).get(); + public static final BlockType CAMPFIRE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("campfire")).get(); + public static final BlockType CARROTS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("carrots")).get(); + public static final BlockType CARTOGRAPHY_TABLE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cartography_table")).get(); + public static final BlockType CARVED_PUMPKIN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("carved_pumpkin")).get(); + public static final BlockType CAULDRON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cauldron")).get(); + public static final BlockType CAVE_AIR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cave_air")).get(); + public static final BlockType CHAIN_COMMAND_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chain_command_block")).get(); + public static final BlockType CHEST = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chest")).get(); + public static final BlockType CHIPPED_ANVIL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chipped_anvil")).get(); + public static final BlockType CHISELED_QUARTZ_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chiseled_quartz_block")).get(); + public static final BlockType CHISELED_RED_SANDSTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chiseled_red_sandstone")).get(); + public static final BlockType CHISELED_SANDSTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chiseled_sandstone")).get(); + public static final BlockType CHISELED_STONE_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chiseled_stone_bricks")).get(); + public static final BlockType CHORUS_FLOWER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chorus_flower")).get(); + public static final BlockType CHORUS_PLANT = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("chorus_plant")).get(); + public static final BlockType CLAY = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("clay")).get(); + public static final BlockType COAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("coal_block")).get(); + public static final BlockType COAL_ORE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("coal_ore")).get(); + public static final BlockType COARSE_DIRT = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("coarse_dirt")).get(); + public static final BlockType COBBLESTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cobblestone")).get(); + public static final BlockType COBBLESTONE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cobblestone_slab")).get(); + public static final BlockType COBBLESTONE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cobblestone_stairs")).get(); + public static final BlockType COBBLESTONE_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cobblestone_wall")).get(); + public static final BlockType COBWEB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cobweb")).get(); + public static final BlockType COCOA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cocoa")).get(); + public static final BlockType COMMAND_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("command_block")).get(); + public static final BlockType COMPARATOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("comparator")).get(); + public static final BlockType COMPOSTER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("composter")).get(); + public static final BlockType CONDUIT = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("conduit")).get(); + public static final BlockType CORNFLOWER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cornflower")).get(); + public static final BlockType CRACKED_STONE_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cracked_stone_bricks")).get(); + public static final BlockType CRAFTING_TABLE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("crafting_table")).get(); + public static final BlockType CREEPER_HEAD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("creeper_head")).get(); + public static final BlockType CREEPER_WALL_HEAD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("creeper_wall_head")).get(); + public static final BlockType CUT_RED_SANDSTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cut_red_sandstone")).get(); + public static final BlockType CUT_RED_SANDSTONE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cut_red_sandstone_slab")).get(); + public static final BlockType CUT_SANDSTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cut_sandstone")).get(); + public static final BlockType CUT_SANDSTONE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cut_sandstone_slab")).get(); + public static final BlockType CYAN_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_banner")).get(); + public static final BlockType CYAN_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_bed")).get(); + public static final BlockType CYAN_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_carpet")).get(); + public static final BlockType CYAN_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_concrete")).get(); + public static final BlockType CYAN_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_concrete_powder")).get(); + public static final BlockType CYAN_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_glazed_terracotta")).get(); + public static final BlockType CYAN_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_shulker_box")).get(); + public static final BlockType CYAN_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_stained_glass")).get(); + public static final BlockType CYAN_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_stained_glass_pane")).get(); + public static final BlockType CYAN_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_terracotta")).get(); + public static final BlockType CYAN_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_wall_banner")).get(); + public static final BlockType CYAN_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("cyan_wool")).get(); + public static final BlockType DAMAGED_ANVIL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("damaged_anvil")).get(); + public static final BlockType DANDELION = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dandelion")).get(); + public static final BlockType DARK_OAK_BUTTON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_button")).get(); + public static final BlockType DARK_OAK_DOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_door")).get(); + public static final BlockType DARK_OAK_FENCE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_fence")).get(); + public static final BlockType DARK_OAK_FENCE_GATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_fence_gate")).get(); + public static final BlockType DARK_OAK_LEAVES = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_leaves")).get(); + public static final BlockType DARK_OAK_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_log")).get(); + public static final BlockType DARK_OAK_PLANKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_planks")).get(); + public static final BlockType DARK_OAK_PRESSURE_PLATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_pressure_plate")).get(); + public static final BlockType DARK_OAK_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_sapling")).get(); + public static final BlockType DARK_OAK_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_sign")).get(); + public static final BlockType DARK_OAK_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_slab")).get(); + public static final BlockType DARK_OAK_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_stairs")).get(); + public static final BlockType DARK_OAK_TRAPDOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_trapdoor")).get(); + public static final BlockType DARK_OAK_WALL_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_wall_sign")).get(); + public static final BlockType DARK_OAK_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_oak_wood")).get(); + public static final BlockType DARK_PRISMARINE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_prismarine")).get(); + public static final BlockType DARK_PRISMARINE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_prismarine_slab")).get(); + public static final BlockType DARK_PRISMARINE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dark_prismarine_stairs")).get(); + public static final BlockType DAYLIGHT_DETECTOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("daylight_detector")).get(); + public static final BlockType DEAD_BRAIN_CORAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_brain_coral")).get(); + public static final BlockType DEAD_BRAIN_CORAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_brain_coral_block")).get(); + public static final BlockType DEAD_BRAIN_CORAL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_brain_coral_fan")).get(); + public static final BlockType DEAD_BRAIN_CORAL_WALL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_brain_coral_wall_fan")).get(); + public static final BlockType DEAD_BUBBLE_CORAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_bubble_coral")).get(); + public static final BlockType DEAD_BUBBLE_CORAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_bubble_coral_block")).get(); + public static final BlockType DEAD_BUBBLE_CORAL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_bubble_coral_fan")).get(); + public static final BlockType DEAD_BUBBLE_CORAL_WALL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_bubble_coral_wall_fan")).get(); + public static final BlockType DEAD_BUSH = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_bush")).get(); + public static final BlockType DEAD_FIRE_CORAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_fire_coral")).get(); + public static final BlockType DEAD_FIRE_CORAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_fire_coral_block")).get(); + public static final BlockType DEAD_FIRE_CORAL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_fire_coral_fan")).get(); + public static final BlockType DEAD_FIRE_CORAL_WALL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_fire_coral_wall_fan")).get(); + public static final BlockType DEAD_HORN_CORAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_horn_coral")).get(); + public static final BlockType DEAD_HORN_CORAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_horn_coral_block")).get(); + public static final BlockType DEAD_HORN_CORAL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_horn_coral_fan")).get(); + public static final BlockType DEAD_HORN_CORAL_WALL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_horn_coral_wall_fan")).get(); + public static final BlockType DEAD_TUBE_CORAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_tube_coral")).get(); + public static final BlockType DEAD_TUBE_CORAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_tube_coral_block")).get(); + public static final BlockType DEAD_TUBE_CORAL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_tube_coral_fan")).get(); + public static final BlockType DEAD_TUBE_CORAL_WALL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dead_tube_coral_wall_fan")).get(); + public static final BlockType DETECTOR_RAIL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("detector_rail")).get(); + public static final BlockType DIAMOND_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_block")).get(); + public static final BlockType DIAMOND_ORE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diamond_ore")).get(); + public static final BlockType DIORITE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diorite")).get(); + public static final BlockType DIORITE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diorite_slab")).get(); + public static final BlockType DIORITE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diorite_stairs")).get(); + public static final BlockType DIORITE_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("diorite_wall")).get(); + public static final BlockType DIRT = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dirt")).get(); + public static final BlockType DISPENSER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dispenser")).get(); + public static final BlockType DRAGON_EGG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dragon_egg")).get(); + public static final BlockType DRAGON_HEAD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dragon_head")).get(); + public static final BlockType DRAGON_WALL_HEAD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dragon_wall_head")).get(); + public static final BlockType DRIED_KELP_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dried_kelp_block")).get(); + public static final BlockType DROPPER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("dropper")).get(); + public static final BlockType EMERALD_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("emerald_block")).get(); + public static final BlockType EMERALD_ORE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("emerald_ore")).get(); + public static final BlockType ENCHANTING_TABLE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("enchanting_table")).get(); + public static final BlockType ENDER_CHEST = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("ender_chest")).get(); + public static final BlockType END_GATEWAY = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("end_gateway")).get(); + public static final BlockType END_PORTAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("end_portal")).get(); + public static final BlockType END_PORTAL_FRAME = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("end_portal_frame")).get(); + public static final BlockType END_ROD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("end_rod")).get(); + public static final BlockType END_STONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("end_stone")).get(); + public static final BlockType END_STONE_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("end_stone_bricks")).get(); + public static final BlockType END_STONE_BRICK_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("end_stone_brick_slab")).get(); + public static final BlockType END_STONE_BRICK_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("end_stone_brick_stairs")).get(); + public static final BlockType END_STONE_BRICK_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("end_stone_brick_wall")).get(); + public static final BlockType FARMLAND = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("farmland")).get(); + public static final BlockType FERN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fern")).get(); + public static final BlockType FIRE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fire")).get(); + public static final BlockType FIRE_CORAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fire_coral")).get(); + public static final BlockType FIRE_CORAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fire_coral_block")).get(); + public static final BlockType FIRE_CORAL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fire_coral_fan")).get(); + public static final BlockType FIRE_CORAL_WALL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fire_coral_wall_fan")).get(); + public static final BlockType FLETCHING_TABLE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("fletching_table")).get(); + public static final BlockType FLOWER_POT = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("flower_pot")).get(); + public static final BlockType FROSTED_ICE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("frosted_ice")).get(); + public static final BlockType FURNACE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("furnace")).get(); + public static final BlockType GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("glass")).get(); + public static final BlockType GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("glass_pane")).get(); + public static final BlockType GLOWSTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("glowstone")).get(); + public static final BlockType GOLD_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gold_block")).get(); + public static final BlockType GOLD_ORE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gold_ore")).get(); + public static final BlockType GRANITE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("granite")).get(); + public static final BlockType GRANITE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("granite_slab")).get(); + public static final BlockType GRANITE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("granite_stairs")).get(); + public static final BlockType GRANITE_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("granite_wall")).get(); + public static final BlockType GRASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("grass")).get(); + public static final BlockType GRASS_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("grass_block")).get(); + public static final BlockType GRASS_PATH = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("grass_path")).get(); + public static final BlockType GRAVEL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gravel")).get(); + public static final BlockType GRAY_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_banner")).get(); + public static final BlockType GRAY_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_bed")).get(); + public static final BlockType GRAY_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_carpet")).get(); + public static final BlockType GRAY_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_concrete")).get(); + public static final BlockType GRAY_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_concrete_powder")).get(); + public static final BlockType GRAY_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_glazed_terracotta")).get(); + public static final BlockType GRAY_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_shulker_box")).get(); + public static final BlockType GRAY_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_stained_glass")).get(); + public static final BlockType GRAY_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_stained_glass_pane")).get(); + public static final BlockType GRAY_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_terracotta")).get(); + public static final BlockType GRAY_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_wall_banner")).get(); + public static final BlockType GRAY_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("gray_wool")).get(); + public static final BlockType GREEN_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_banner")).get(); + public static final BlockType GREEN_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_bed")).get(); + public static final BlockType GREEN_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_carpet")).get(); + public static final BlockType GREEN_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_concrete")).get(); + public static final BlockType GREEN_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_concrete_powder")).get(); + public static final BlockType GREEN_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_glazed_terracotta")).get(); + public static final BlockType GREEN_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_shulker_box")).get(); + public static final BlockType GREEN_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_stained_glass")).get(); + public static final BlockType GREEN_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_stained_glass_pane")).get(); + public static final BlockType GREEN_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_terracotta")).get(); + public static final BlockType GREEN_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_wall_banner")).get(); + public static final BlockType GREEN_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("green_wool")).get(); + public static final BlockType GRINDSTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("grindstone")).get(); + public static final BlockType HAY_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("hay_block")).get(); + public static final BlockType HEAVY_WEIGHTED_PRESSURE_PLATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("heavy_weighted_pressure_plate")).get(); + public static final BlockType HONEYCOMB_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("honeycomb_block")).get(); + public static final BlockType HONEY_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("honey_block")).get(); + public static final BlockType HOPPER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("hopper")).get(); + public static final BlockType HORN_CORAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("horn_coral")).get(); + public static final BlockType HORN_CORAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("horn_coral_block")).get(); + public static final BlockType HORN_CORAL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("horn_coral_fan")).get(); + public static final BlockType HORN_CORAL_WALL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("horn_coral_wall_fan")).get(); + public static final BlockType ICE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("ice")).get(); + public static final BlockType INFESTED_CHISELED_STONE_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("infested_chiseled_stone_bricks")).get(); + public static final BlockType INFESTED_COBBLESTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("infested_cobblestone")).get(); + public static final BlockType INFESTED_CRACKED_STONE_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("infested_cracked_stone_bricks")).get(); + public static final BlockType INFESTED_MOSSY_STONE_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("infested_mossy_stone_bricks")).get(); + public static final BlockType INFESTED_STONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("infested_stone")).get(); + public static final BlockType INFESTED_STONE_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("infested_stone_bricks")).get(); + public static final BlockType IRON_BARS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_bars")).get(); + public static final BlockType IRON_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_block")).get(); + public static final BlockType IRON_DOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_door")).get(); + public static final BlockType IRON_ORE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_ore")).get(); + public static final BlockType IRON_TRAPDOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("iron_trapdoor")).get(); + public static final BlockType JACK_O_LANTERN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jack_o_lantern")).get(); + public static final BlockType JIGSAW = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jigsaw")).get(); + public static final BlockType JUKEBOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jukebox")).get(); + public static final BlockType JUNGLE_BUTTON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_button")).get(); + public static final BlockType JUNGLE_DOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_door")).get(); + public static final BlockType JUNGLE_FENCE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_fence")).get(); + public static final BlockType JUNGLE_FENCE_GATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_fence_gate")).get(); + public static final BlockType JUNGLE_LEAVES = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_leaves")).get(); + public static final BlockType JUNGLE_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_log")).get(); + public static final BlockType JUNGLE_PLANKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_planks")).get(); + public static final BlockType JUNGLE_PRESSURE_PLATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_pressure_plate")).get(); + public static final BlockType JUNGLE_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_sapling")).get(); + public static final BlockType JUNGLE_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_sign")).get(); + public static final BlockType JUNGLE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_slab")).get(); + public static final BlockType JUNGLE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_stairs")).get(); + public static final BlockType JUNGLE_TRAPDOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_trapdoor")).get(); + public static final BlockType JUNGLE_WALL_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_wall_sign")).get(); + public static final BlockType JUNGLE_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("jungle_wood")).get(); + public static final BlockType KELP = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("kelp")).get(); + public static final BlockType KELP_PLANT = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("kelp_plant")).get(); + public static final BlockType LADDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("ladder")).get(); + public static final BlockType LANTERN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lantern")).get(); + public static final BlockType LAPIS_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lapis_block")).get(); + public static final BlockType LAPIS_ORE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lapis_ore")).get(); + public static final BlockType LARGE_FERN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("large_fern")).get(); + public static final BlockType LAVA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lava")).get(); + public static final BlockType LECTERN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lectern")).get(); + public static final BlockType LEVER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lever")).get(); + public static final BlockType LIGHT_BLUE_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_banner")).get(); + public static final BlockType LIGHT_BLUE_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_bed")).get(); + public static final BlockType LIGHT_BLUE_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_carpet")).get(); + public static final BlockType LIGHT_BLUE_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_concrete")).get(); + public static final BlockType LIGHT_BLUE_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_concrete_powder")).get(); + public static final BlockType LIGHT_BLUE_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_glazed_terracotta")).get(); + public static final BlockType LIGHT_BLUE_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_shulker_box")).get(); + public static final BlockType LIGHT_BLUE_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_stained_glass")).get(); + public static final BlockType LIGHT_BLUE_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_stained_glass_pane")).get(); + public static final BlockType LIGHT_BLUE_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_terracotta")).get(); + public static final BlockType LIGHT_BLUE_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_wall_banner")).get(); + public static final BlockType LIGHT_BLUE_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_blue_wool")).get(); + public static final BlockType LIGHT_GRAY_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_banner")).get(); + public static final BlockType LIGHT_GRAY_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_bed")).get(); + public static final BlockType LIGHT_GRAY_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_carpet")).get(); + public static final BlockType LIGHT_GRAY_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_concrete")).get(); + public static final BlockType LIGHT_GRAY_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_concrete_powder")).get(); + public static final BlockType LIGHT_GRAY_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_glazed_terracotta")).get(); + public static final BlockType LIGHT_GRAY_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_shulker_box")).get(); + public static final BlockType LIGHT_GRAY_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_stained_glass")).get(); + public static final BlockType LIGHT_GRAY_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_stained_glass_pane")).get(); + public static final BlockType LIGHT_GRAY_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_terracotta")).get(); + public static final BlockType LIGHT_GRAY_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_wall_banner")).get(); + public static final BlockType LIGHT_GRAY_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_gray_wool")).get(); + public static final BlockType LIGHT_WEIGHTED_PRESSURE_PLATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("light_weighted_pressure_plate")).get(); + public static final BlockType LILAC = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lilac")).get(); + public static final BlockType LILY_OF_THE_VALLEY = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lily_of_the_valley")).get(); + public static final BlockType LILY_PAD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lily_pad")).get(); + public static final BlockType LIME_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_banner")).get(); + public static final BlockType LIME_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_bed")).get(); + public static final BlockType LIME_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_carpet")).get(); + public static final BlockType LIME_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_concrete")).get(); + public static final BlockType LIME_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_concrete_powder")).get(); + public static final BlockType LIME_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_glazed_terracotta")).get(); + public static final BlockType LIME_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_shulker_box")).get(); + public static final BlockType LIME_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_stained_glass")).get(); + public static final BlockType LIME_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_stained_glass_pane")).get(); + public static final BlockType LIME_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_terracotta")).get(); + public static final BlockType LIME_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_wall_banner")).get(); + public static final BlockType LIME_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("lime_wool")).get(); + public static final BlockType LOOM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("loom")).get(); + public static final BlockType MAGENTA_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_banner")).get(); + public static final BlockType MAGENTA_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_bed")).get(); + public static final BlockType MAGENTA_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_carpet")).get(); + public static final BlockType MAGENTA_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_concrete")).get(); + public static final BlockType MAGENTA_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_concrete_powder")).get(); + public static final BlockType MAGENTA_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_glazed_terracotta")).get(); + public static final BlockType MAGENTA_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_shulker_box")).get(); + public static final BlockType MAGENTA_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_stained_glass")).get(); + public static final BlockType MAGENTA_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_stained_glass_pane")).get(); + public static final BlockType MAGENTA_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_terracotta")).get(); + public static final BlockType MAGENTA_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_wall_banner")).get(); + public static final BlockType MAGENTA_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magenta_wool")).get(); + public static final BlockType MAGMA_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("magma_block")).get(); + public static final BlockType MELON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("melon")).get(); + public static final BlockType MELON_STEM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("melon_stem")).get(); + public static final BlockType MOSSY_COBBLESTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mossy_cobblestone")).get(); + public static final BlockType MOSSY_COBBLESTONE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mossy_cobblestone_slab")).get(); + public static final BlockType MOSSY_COBBLESTONE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mossy_cobblestone_stairs")).get(); + public static final BlockType MOSSY_COBBLESTONE_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mossy_cobblestone_wall")).get(); + public static final BlockType MOSSY_STONE_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mossy_stone_bricks")).get(); + public static final BlockType MOSSY_STONE_BRICK_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mossy_stone_brick_slab")).get(); + public static final BlockType MOSSY_STONE_BRICK_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mossy_stone_brick_stairs")).get(); + public static final BlockType MOSSY_STONE_BRICK_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mossy_stone_brick_wall")).get(); + public static final BlockType MOVING_PISTON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("moving_piston")).get(); + public static final BlockType MUSHROOM_STEM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mushroom_stem")).get(); + public static final BlockType MYCELIUM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("mycelium")).get(); + public static final BlockType NETHERRACK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("netherrack")).get(); + public static final BlockType NETHER_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_bricks")).get(); + public static final BlockType NETHER_BRICK_FENCE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_brick_fence")).get(); + public static final BlockType NETHER_BRICK_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_brick_slab")).get(); + public static final BlockType NETHER_BRICK_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_brick_stairs")).get(); + public static final BlockType NETHER_BRICK_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_brick_wall")).get(); + public static final BlockType NETHER_PORTAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_portal")).get(); + public static final BlockType NETHER_QUARTZ_ORE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_quartz_ore")).get(); + public static final BlockType NETHER_WART = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_wart")).get(); + public static final BlockType NETHER_WART_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("nether_wart_block")).get(); + public static final BlockType NOTE_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("note_block")).get(); + public static final BlockType OAK_BUTTON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_button")).get(); + public static final BlockType OAK_DOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_door")).get(); + public static final BlockType OAK_FENCE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_fence")).get(); + public static final BlockType OAK_FENCE_GATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_fence_gate")).get(); + public static final BlockType OAK_LEAVES = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_leaves")).get(); + public static final BlockType OAK_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_log")).get(); + public static final BlockType OAK_PLANKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_planks")).get(); + public static final BlockType OAK_PRESSURE_PLATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_pressure_plate")).get(); + public static final BlockType OAK_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_sapling")).get(); + public static final BlockType OAK_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_sign")).get(); + public static final BlockType OAK_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_slab")).get(); + public static final BlockType OAK_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_stairs")).get(); + public static final BlockType OAK_TRAPDOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_trapdoor")).get(); + public static final BlockType OAK_WALL_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_wall_sign")).get(); + public static final BlockType OAK_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oak_wood")).get(); + public static final BlockType OBSERVER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("observer")).get(); + public static final BlockType OBSIDIAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("obsidian")).get(); + public static final BlockType ORANGE_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_banner")).get(); + public static final BlockType ORANGE_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_bed")).get(); + public static final BlockType ORANGE_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_carpet")).get(); + public static final BlockType ORANGE_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_concrete")).get(); + public static final BlockType ORANGE_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_concrete_powder")).get(); + public static final BlockType ORANGE_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_glazed_terracotta")).get(); + public static final BlockType ORANGE_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_shulker_box")).get(); + public static final BlockType ORANGE_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_stained_glass")).get(); + public static final BlockType ORANGE_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_stained_glass_pane")).get(); + public static final BlockType ORANGE_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_terracotta")).get(); + public static final BlockType ORANGE_TULIP = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_tulip")).get(); + public static final BlockType ORANGE_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_wall_banner")).get(); + public static final BlockType ORANGE_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("orange_wool")).get(); + public static final BlockType OXEYE_DAISY = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("oxeye_daisy")).get(); + public static final BlockType PACKED_ICE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("packed_ice")).get(); + public static final BlockType PEONY = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("peony")).get(); + public static final BlockType PETRIFIED_OAK_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("petrified_oak_slab")).get(); + public static final BlockType PINK_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_banner")).get(); + public static final BlockType PINK_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_bed")).get(); + public static final BlockType PINK_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_carpet")).get(); + public static final BlockType PINK_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_concrete")).get(); + public static final BlockType PINK_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_concrete_powder")).get(); + public static final BlockType PINK_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_glazed_terracotta")).get(); + public static final BlockType PINK_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_shulker_box")).get(); + public static final BlockType PINK_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_stained_glass")).get(); + public static final BlockType PINK_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_stained_glass_pane")).get(); + public static final BlockType PINK_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_terracotta")).get(); + public static final BlockType PINK_TULIP = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_tulip")).get(); + public static final BlockType PINK_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_wall_banner")).get(); + public static final BlockType PINK_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pink_wool")).get(); + public static final BlockType PISTON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("piston")).get(); + public static final BlockType PISTON_HEAD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("piston_head")).get(); + public static final BlockType PLAYER_HEAD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("player_head")).get(); + public static final BlockType PLAYER_WALL_HEAD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("player_wall_head")).get(); + public static final BlockType PODZOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("podzol")).get(); + public static final BlockType POLISHED_ANDESITE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("polished_andesite")).get(); + public static final BlockType POLISHED_ANDESITE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("polished_andesite_slab")).get(); + public static final BlockType POLISHED_ANDESITE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("polished_andesite_stairs")).get(); + public static final BlockType POLISHED_DIORITE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("polished_diorite")).get(); + public static final BlockType POLISHED_DIORITE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("polished_diorite_slab")).get(); + public static final BlockType POLISHED_DIORITE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("polished_diorite_stairs")).get(); + public static final BlockType POLISHED_GRANITE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("polished_granite")).get(); + public static final BlockType POLISHED_GRANITE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("polished_granite_slab")).get(); + public static final BlockType POLISHED_GRANITE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("polished_granite_stairs")).get(); + public static final BlockType POPPY = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("poppy")).get(); + public static final BlockType POTATOES = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potatoes")).get(); + public static final BlockType POTTED_ACACIA_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_acacia_sapling")).get(); + public static final BlockType POTTED_ALLIUM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_allium")).get(); + public static final BlockType POTTED_AZURE_BLUET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_azure_bluet")).get(); + public static final BlockType POTTED_BAMBOO = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_bamboo")).get(); + public static final BlockType POTTED_BIRCH_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_birch_sapling")).get(); + public static final BlockType POTTED_BLUE_ORCHID = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_blue_orchid")).get(); + public static final BlockType POTTED_BROWN_MUSHROOM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_brown_mushroom")).get(); + public static final BlockType POTTED_CACTUS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_cactus")).get(); + public static final BlockType POTTED_CORNFLOWER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_cornflower")).get(); + public static final BlockType POTTED_DANDELION = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_dandelion")).get(); + public static final BlockType POTTED_DARK_OAK_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_dark_oak_sapling")).get(); + public static final BlockType POTTED_DEAD_BUSH = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_dead_bush")).get(); + public static final BlockType POTTED_FERN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_fern")).get(); + public static final BlockType POTTED_JUNGLE_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_jungle_sapling")).get(); + public static final BlockType POTTED_LILY_OF_THE_VALLEY = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_lily_of_the_valley")).get(); + public static final BlockType POTTED_OAK_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_oak_sapling")).get(); + public static final BlockType POTTED_ORANGE_TULIP = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_orange_tulip")).get(); + public static final BlockType POTTED_OXEYE_DAISY = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_oxeye_daisy")).get(); + public static final BlockType POTTED_PINK_TULIP = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_pink_tulip")).get(); + public static final BlockType POTTED_POPPY = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_poppy")).get(); + public static final BlockType POTTED_RED_MUSHROOM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_red_mushroom")).get(); + public static final BlockType POTTED_RED_TULIP = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_red_tulip")).get(); + public static final BlockType POTTED_SPRUCE_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_spruce_sapling")).get(); + public static final BlockType POTTED_WHITE_TULIP = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_white_tulip")).get(); + public static final BlockType POTTED_WITHER_ROSE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("potted_wither_rose")).get(); + public static final BlockType POWERED_RAIL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("powered_rail")).get(); + public static final BlockType PRISMARINE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("prismarine")).get(); + public static final BlockType PRISMARINE_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("prismarine_bricks")).get(); + public static final BlockType PRISMARINE_BRICK_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("prismarine_brick_slab")).get(); + public static final BlockType PRISMARINE_BRICK_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("prismarine_brick_stairs")).get(); + public static final BlockType PRISMARINE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("prismarine_slab")).get(); + public static final BlockType PRISMARINE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("prismarine_stairs")).get(); + public static final BlockType PRISMARINE_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("prismarine_wall")).get(); + public static final BlockType PUMPKIN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pumpkin")).get(); + public static final BlockType PUMPKIN_STEM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("pumpkin_stem")).get(); + public static final BlockType PURPLE_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_banner")).get(); + public static final BlockType PURPLE_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_bed")).get(); + public static final BlockType PURPLE_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_carpet")).get(); + public static final BlockType PURPLE_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_concrete")).get(); + public static final BlockType PURPLE_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_concrete_powder")).get(); + public static final BlockType PURPLE_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_glazed_terracotta")).get(); + public static final BlockType PURPLE_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_shulker_box")).get(); + public static final BlockType PURPLE_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_stained_glass")).get(); + public static final BlockType PURPLE_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_stained_glass_pane")).get(); + public static final BlockType PURPLE_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_terracotta")).get(); + public static final BlockType PURPLE_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_wall_banner")).get(); + public static final BlockType PURPLE_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purple_wool")).get(); + public static final BlockType PURPUR_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purpur_block")).get(); + public static final BlockType PURPUR_PILLAR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purpur_pillar")).get(); + public static final BlockType PURPUR_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purpur_slab")).get(); + public static final BlockType PURPUR_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("purpur_stairs")).get(); + public static final BlockType QUARTZ_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("quartz_block")).get(); + public static final BlockType QUARTZ_PILLAR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("quartz_pillar")).get(); + public static final BlockType QUARTZ_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("quartz_slab")).get(); + public static final BlockType QUARTZ_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("quartz_stairs")).get(); + public static final BlockType RAIL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("rail")).get(); + public static final BlockType REDSTONE_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("redstone_block")).get(); + public static final BlockType REDSTONE_LAMP = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("redstone_lamp")).get(); + public static final BlockType REDSTONE_ORE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("redstone_ore")).get(); + public static final BlockType REDSTONE_TORCH = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("redstone_torch")).get(); + public static final BlockType REDSTONE_WALL_TORCH = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("redstone_wall_torch")).get(); + public static final BlockType REDSTONE_WIRE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("redstone_wire")).get(); + public static final BlockType RED_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_banner")).get(); + public static final BlockType RED_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_bed")).get(); + public static final BlockType RED_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_carpet")).get(); + public static final BlockType RED_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_concrete")).get(); + public static final BlockType RED_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_concrete_powder")).get(); + public static final BlockType RED_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_glazed_terracotta")).get(); + public static final BlockType RED_MUSHROOM = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_mushroom")).get(); + public static final BlockType RED_MUSHROOM_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_mushroom_block")).get(); + public static final BlockType RED_NETHER_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_nether_bricks")).get(); + public static final BlockType RED_NETHER_BRICK_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_nether_brick_slab")).get(); + public static final BlockType RED_NETHER_BRICK_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_nether_brick_stairs")).get(); + public static final BlockType RED_NETHER_BRICK_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_nether_brick_wall")).get(); + public static final BlockType RED_SAND = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_sand")).get(); + public static final BlockType RED_SANDSTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_sandstone")).get(); + public static final BlockType RED_SANDSTONE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_sandstone_slab")).get(); + public static final BlockType RED_SANDSTONE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_sandstone_stairs")).get(); + public static final BlockType RED_SANDSTONE_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_sandstone_wall")).get(); + public static final BlockType RED_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_shulker_box")).get(); + public static final BlockType RED_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_stained_glass")).get(); + public static final BlockType RED_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_stained_glass_pane")).get(); + public static final BlockType RED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_terracotta")).get(); + public static final BlockType RED_TULIP = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_tulip")).get(); + public static final BlockType RED_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_wall_banner")).get(); + public static final BlockType RED_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("red_wool")).get(); + public static final BlockType REPEATER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("repeater")).get(); + public static final BlockType REPEATING_COMMAND_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("repeating_command_block")).get(); + public static final BlockType ROSE_BUSH = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("rose_bush")).get(); + public static final BlockType SAND = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sand")).get(); + public static final BlockType SANDSTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sandstone")).get(); + public static final BlockType SANDSTONE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sandstone_slab")).get(); + public static final BlockType SANDSTONE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sandstone_stairs")).get(); + public static final BlockType SANDSTONE_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sandstone_wall")).get(); + public static final BlockType SCAFFOLDING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("scaffolding")).get(); + public static final BlockType SEAGRASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("seagrass")).get(); + public static final BlockType SEA_LANTERN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sea_lantern")).get(); + public static final BlockType SEA_PICKLE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sea_pickle")).get(); + public static final BlockType SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("shulker_box")).get(); + public static final BlockType SKELETON_SKULL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("skeleton_skull")).get(); + public static final BlockType SKELETON_WALL_SKULL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("skeleton_wall_skull")).get(); + public static final BlockType SLIME_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("slime_block")).get(); + public static final BlockType SMITHING_TABLE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smithing_table")).get(); + public static final BlockType SMOKER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smoker")).get(); + public static final BlockType SMOOTH_QUARTZ = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_quartz")).get(); + public static final BlockType SMOOTH_QUARTZ_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_quartz_slab")).get(); + public static final BlockType SMOOTH_QUARTZ_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_quartz_stairs")).get(); + public static final BlockType SMOOTH_RED_SANDSTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_red_sandstone")).get(); + public static final BlockType SMOOTH_RED_SANDSTONE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_red_sandstone_slab")).get(); + public static final BlockType SMOOTH_RED_SANDSTONE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_red_sandstone_stairs")).get(); + public static final BlockType SMOOTH_SANDSTONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_sandstone")).get(); + public static final BlockType SMOOTH_SANDSTONE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_sandstone_slab")).get(); + public static final BlockType SMOOTH_SANDSTONE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_sandstone_stairs")).get(); + public static final BlockType SMOOTH_STONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_stone")).get(); + public static final BlockType SMOOTH_STONE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("smooth_stone_slab")).get(); + public static final BlockType SNOW = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("snow")).get(); + public static final BlockType SNOW_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("snow_block")).get(); + public static final BlockType SOUL_SAND = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("soul_sand")).get(); + public static final BlockType SPAWNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spawner")).get(); + public static final BlockType SPONGE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sponge")).get(); + public static final BlockType SPRUCE_BUTTON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_button")).get(); + public static final BlockType SPRUCE_DOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_door")).get(); + public static final BlockType SPRUCE_FENCE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_fence")).get(); + public static final BlockType SPRUCE_FENCE_GATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_fence_gate")).get(); + public static final BlockType SPRUCE_LEAVES = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_leaves")).get(); + public static final BlockType SPRUCE_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_log")).get(); + public static final BlockType SPRUCE_PLANKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_planks")).get(); + public static final BlockType SPRUCE_PRESSURE_PLATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_pressure_plate")).get(); + public static final BlockType SPRUCE_SAPLING = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_sapling")).get(); + public static final BlockType SPRUCE_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_sign")).get(); + public static final BlockType SPRUCE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_slab")).get(); + public static final BlockType SPRUCE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_stairs")).get(); + public static final BlockType SPRUCE_TRAPDOOR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_trapdoor")).get(); + public static final BlockType SPRUCE_WALL_SIGN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_wall_sign")).get(); + public static final BlockType SPRUCE_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("spruce_wood")).get(); + public static final BlockType STICKY_PISTON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sticky_piston")).get(); + public static final BlockType STONE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone")).get(); + public static final BlockType STONECUTTER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stonecutter")).get(); + public static final BlockType STONE_BRICKS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_bricks")).get(); + public static final BlockType STONE_BRICK_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_brick_slab")).get(); + public static final BlockType STONE_BRICK_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_brick_stairs")).get(); + public static final BlockType STONE_BRICK_WALL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_brick_wall")).get(); + public static final BlockType STONE_BUTTON = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_button")).get(); + public static final BlockType STONE_PRESSURE_PLATE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_pressure_plate")).get(); + public static final BlockType STONE_SLAB = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_slab")).get(); + public static final BlockType STONE_STAIRS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stone_stairs")).get(); + public static final BlockType STRIPPED_ACACIA_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_acacia_log")).get(); + public static final BlockType STRIPPED_ACACIA_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_acacia_wood")).get(); + public static final BlockType STRIPPED_BIRCH_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_birch_log")).get(); + public static final BlockType STRIPPED_BIRCH_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_birch_wood")).get(); + public static final BlockType STRIPPED_DARK_OAK_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_dark_oak_log")).get(); + public static final BlockType STRIPPED_DARK_OAK_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_dark_oak_wood")).get(); + public static final BlockType STRIPPED_JUNGLE_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_jungle_log")).get(); + public static final BlockType STRIPPED_JUNGLE_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_jungle_wood")).get(); + public static final BlockType STRIPPED_OAK_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_oak_log")).get(); + public static final BlockType STRIPPED_OAK_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_oak_wood")).get(); + public static final BlockType STRIPPED_SPRUCE_LOG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_spruce_log")).get(); + public static final BlockType STRIPPED_SPRUCE_WOOD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("stripped_spruce_wood")).get(); + public static final BlockType STRUCTURE_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("structure_block")).get(); + public static final BlockType STRUCTURE_VOID = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("structure_void")).get(); + public static final BlockType SUGAR_CANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sugar_cane")).get(); + public static final BlockType SUNFLOWER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sunflower")).get(); + public static final BlockType SWEET_BERRY_BUSH = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("sweet_berry_bush")).get(); + public static final BlockType TALL_GRASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tall_grass")).get(); + public static final BlockType TALL_SEAGRASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tall_seagrass")).get(); + public static final BlockType TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("terracotta")).get(); + public static final BlockType TNT = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tnt")).get(); + public static final BlockType TORCH = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("torch")).get(); + public static final BlockType TRAPPED_CHEST = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("trapped_chest")).get(); + public static final BlockType TRIPWIRE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tripwire")).get(); + public static final BlockType TRIPWIRE_HOOK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tripwire_hook")).get(); + public static final BlockType TUBE_CORAL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tube_coral")).get(); + public static final BlockType TUBE_CORAL_BLOCK = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tube_coral_block")).get(); + public static final BlockType TUBE_CORAL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tube_coral_fan")).get(); + public static final BlockType TUBE_CORAL_WALL_FAN = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("tube_coral_wall_fan")).get(); + public static final BlockType TURTLE_EGG = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("turtle_egg")).get(); + public static final BlockType VINE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("vine")).get(); + public static final BlockType VOID_AIR = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("void_air")).get(); + public static final BlockType WALL_TORCH = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wall_torch")).get(); + public static final BlockType WATER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("water")).get(); + public static final BlockType WET_SPONGE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wet_sponge")).get(); + public static final BlockType WHEAT = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wheat")).get(); + public static final BlockType WHITE_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_banner")).get(); + public static final BlockType WHITE_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_bed")).get(); + public static final BlockType WHITE_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_carpet")).get(); + public static final BlockType WHITE_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_concrete")).get(); + public static final BlockType WHITE_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_concrete_powder")).get(); + public static final BlockType WHITE_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_glazed_terracotta")).get(); + public static final BlockType WHITE_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_shulker_box")).get(); + public static final BlockType WHITE_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_stained_glass")).get(); + public static final BlockType WHITE_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_stained_glass_pane")).get(); + public static final BlockType WHITE_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_terracotta")).get(); + public static final BlockType WHITE_TULIP = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_tulip")).get(); + public static final BlockType WHITE_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_wall_banner")).get(); + public static final BlockType WHITE_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("white_wool")).get(); + public static final BlockType WITHER_ROSE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wither_rose")).get(); + public static final BlockType WITHER_SKELETON_SKULL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wither_skeleton_skull")).get(); + public static final BlockType WITHER_SKELETON_WALL_SKULL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("wither_skeleton_wall_skull")).get(); + public static final BlockType YELLOW_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_banner")).get(); + public static final BlockType YELLOW_BED = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_bed")).get(); + public static final BlockType YELLOW_CARPET = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_carpet")).get(); + public static final BlockType YELLOW_CONCRETE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_concrete")).get(); + public static final BlockType YELLOW_CONCRETE_POWDER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_concrete_powder")).get(); + public static final BlockType YELLOW_GLAZED_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_glazed_terracotta")).get(); + public static final BlockType YELLOW_SHULKER_BOX = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_shulker_box")).get(); + public static final BlockType YELLOW_STAINED_GLASS = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_stained_glass")).get(); + public static final BlockType YELLOW_STAINED_GLASS_PANE = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_stained_glass_pane")).get(); + public static final BlockType YELLOW_TERRACOTTA = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_terracotta")).get(); + public static final BlockType YELLOW_WALL_BANNER = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_wall_banner")).get(); + public static final BlockType YELLOW_WOOL = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("yellow_wool")).get(); + public static final BlockType ZOMBIE_HEAD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("zombie_head")).get(); + public static final BlockType ZOMBIE_WALL_HEAD = BlockRegistry.REGISTRY.fromKey(NamespacedKey.minecraft("zombie_wall_head")).get(); + + /** + * Gets an {@link BlockType} from the given key + * + * @param key the {@link NamespacedKey} to get the item from + * @return an {@link BlockType} from the given key + */ + public static Optional getBlockFromKey(NamespacedKey key) { + return Platform.getPlatform().getRegistry().getBlockRegistry().fromKey(key); + } +} diff --git a/modules/api/src/main/java/org/battleplugins/world/block/entity/BlockEntity.java b/modules/api/src/main/java/org/battleplugins/world/block/entity/BlockEntity.java index b169f66..76841fb 100644 --- a/modules/api/src/main/java/org/battleplugins/world/block/entity/BlockEntity.java +++ b/modules/api/src/main/java/org/battleplugins/world/block/entity/BlockEntity.java @@ -2,10 +2,28 @@ import org.battleplugins.world.block.Block; +/** + * Represents a block entity. + */ public interface BlockEntity { + /** + * The {@link Block} that corresponds to this block + * entity + * + * @return the {@link Block} + */ Block getBlock(); + /** + * Updates the block entity + */ void update(); - void update(boolean update); + + /** + * Updates the block entity + * + * @param force if the update should be forced + */ + void update(boolean force); } diff --git a/modules/api/src/main/java/org/battleplugins/world/block/entity/Chest.java b/modules/api/src/main/java/org/battleplugins/world/block/entity/Chest.java index d03c7a3..6a20d46 100644 --- a/modules/api/src/main/java/org/battleplugins/world/block/entity/Chest.java +++ b/modules/api/src/main/java/org/battleplugins/world/block/entity/Chest.java @@ -1,16 +1,39 @@ package org.battleplugins.world.block.entity; import org.battleplugins.inventory.Inventory; +import org.battleplugins.inventory.carrier.block.entity.BlockEntityCarrier; import org.battleplugins.inventory.item.ItemStack; import java.util.Optional; -public interface Chest extends BlockEntity { +/** + * Represents a chest. + */ +public interface Chest extends BlockEntity, BlockEntityCarrier { - boolean isDoubleChest(); + /** + * If the chest is a double chest + * + * @return if the chest is a double chest + */ + default boolean isDoubleChest() { + return getNeighborChest().isPresent(); + } + /** + * The neighbor chest next to this one. Will + * return empty if there is none + * + * @return the neighbor chest to this one + */ Optional getNeighborChest(); - ItemStack[] getItems(); - Inventory getInventory(); + /** + * The contents of the chest {@link Inventory} + * + * @return the contents of the chest inventory + */ + default ItemStack[] getContents() { + return getInventory().getContents(); + } } diff --git a/modules/api/src/main/java/org/battleplugins/world/block/entity/Sign.java b/modules/api/src/main/java/org/battleplugins/world/block/entity/Sign.java index e9d5aad..2e2f0a9 100644 --- a/modules/api/src/main/java/org/battleplugins/world/block/entity/Sign.java +++ b/modules/api/src/main/java/org/battleplugins/world/block/entity/Sign.java @@ -1,13 +1,32 @@ package org.battleplugins.world.block.entity; -import org.battleplugins.entity.living.player.Player; - +/** + * Represents a sign. + */ public interface Sign extends BlockEntity { - String getLine(int index); - String[] getLines(); + /** + * The line at the given index + * + * @param index the line number (0-3) + * @return the line at the given index + */ + default String getLine(int index) { + return getLines()[index]; + } - void setLine(int index, String msg); + /** + * A string array of all the lines + * + * @return a string array of all the lines + */ + String[] getLines(); - void sendSignChange(Player player, String[] lines); + /** + * Sets the text at the given line + * + * @param index the line number (0-3) + * @param text the text to set + */ + void setLine(int index, String text); } diff --git a/modules/bukkit/pom.xml b/modules/bukkit/pom.xml index d0b3531..2a202da 100644 --- a/modules/bukkit/pom.xml +++ b/modules/bukkit/pom.xml @@ -16,7 +16,7 @@ org.spigotmc spigot-api - 1.14-R0.1-SNAPSHOT + 1.15-R0.1-SNAPSHOT provided @@ -25,11 +25,5 @@ parent compile - - mc.euro - BukkitAdapter - 1.2.8 - compile - \ No newline at end of file diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/BukkitPlatform.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/BukkitPlatform.java index d9e38cb..33ef4a8 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/BukkitPlatform.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/BukkitPlatform.java @@ -1,18 +1,20 @@ package org.battleplugins.bukkit; -import org.battleplugins.APIType; +import mc.euro.version.Version; + +import org.battleplugins.PlatformType; import org.battleplugins.Platform; import org.battleplugins.bukkit.entity.living.player.BukkitOfflinePlayer; import org.battleplugins.bukkit.entity.living.player.BukkitPlayer; import org.battleplugins.bukkit.message.BukkitMessage; import org.battleplugins.bukkit.message.SpigotMessage; -import org.battleplugins.bukkit.inventory.BukkitInventory; import org.battleplugins.bukkit.inventory.item.BukkitItemStack; import org.battleplugins.bukkit.world.BukkitLocation; import org.battleplugins.bukkit.world.BukkitWorld; import org.battleplugins.plugin.Plugin; import org.battleplugins.message.Message; -import org.battleplugins.plugin.ServicePriority; +import org.battleplugins.plugin.service.ServicePriority; +import org.battleplugins.world.World; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -28,14 +30,20 @@ public class BukkitPlatform extends Platform { + private BukkitRegistry registry; + + public BukkitPlatform() { + registry = new BukkitRegistry(); + } + @Override - public APIType getAPIType() { - return APIType.BUKKIT; + public PlatformType getType() { + return PlatformType.BUKKIT; } @Override - public BukkitLocation getLocation(String world, double x, double y, double z, float pitch, float yaw) { - return new BukkitLocation(new Location(Bukkit.getWorld(world), x, y, z, pitch, yaw)); + public BukkitLocation getLocation(World world, double x, double y, double z, float pitch, float yaw) { + return new BukkitLocation(new Location(((BukkitWorld) world).getHandle(), x, y, z, pitch, yaw)); } @Override @@ -104,8 +112,8 @@ public boolean isOnlineMode() { } @Override - public String getVersion() { - return Bukkit.getVersion(); + public Version getVersion() { + return new Version<>(Bukkit.getVersion()); } @Override @@ -121,11 +129,6 @@ public BukkitItemStack getDefaultPlatformItemStack() { return new BukkitItemStack(new ItemStack(Material.AIR)); } - @Override - public BukkitInventory createInventory(Plugin plugin, int slots, String title) { - return new BukkitInventory<>(Bukkit.createInventory(null, slots, title)); - } - @Override public void registerService(Class clazz, T service, Plugin plugin, ServicePriority priority) { Bukkit.getServicesManager().register(clazz, service, (JavaPlugin) plugin.getPlatformPlugin(), org.bukkit.plugin.ServicePriority.values()[priority.ordinal()]); @@ -136,6 +139,11 @@ public Optional getService(Class clazz) { return Optional.ofNullable(Bukkit.getServicesManager().getRegistration(clazz)).map(RegisteredServiceProvider::getProvider); } + @Override + public BukkitRegistry getRegistry() { + return registry; + } + @Override public boolean cancelTask(long id) { Bukkit.getScheduler().cancelTask((int)id); diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/BukkitRegistry.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/BukkitRegistry.java new file mode 100644 index 0000000..ef01124 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/BukkitRegistry.java @@ -0,0 +1,38 @@ +package org.battleplugins.bukkit; + +import org.battleplugins.Registry; +import org.battleplugins.bukkit.inventory.BukkitInventoryBuilder; +import org.battleplugins.bukkit.inventory.item.BukkitItemRegistry; +import org.battleplugins.bukkit.inventory.item.component.*; +import org.battleplugins.bukkit.world.block.BukkitBlockRegistry; + +public class BukkitRegistry extends Registry { + + private BukkitItemRegistry itemRegistry; + private BukkitBlockRegistry blockRegistry; + + BukkitRegistry() { + itemRegistry = new BukkitItemRegistry(); + blockRegistry = new BukkitBlockRegistry(); + + itemComponents.add(BukkitColorComponent.class); + itemComponents.add(BukkitCustomModelDataComponent.class); + itemComponents.add(BukkitDamageComponent.class); + itemComponents.add(BukkitDisplayNameComponent.class); + itemComponents.add(BukkitItemFlagComponent.class); + itemComponents.add(BukkitLoreComponent.class); + itemComponents.add(BukkitUnbreakableComponent.class); + + builders.add(BukkitInventoryBuilder.class); + } + + @Override + public BukkitItemRegistry getItemRegistry() { + return itemRegistry; + } + + @Override + public BukkitBlockRegistry getBlockRegistry() { + return blockRegistry; + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/compat/BukkitCompatMaterial.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/compat/BukkitCompatMaterial.java new file mode 100644 index 0000000..5cfed75 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/compat/BukkitCompatMaterial.java @@ -0,0 +1,1091 @@ +package org.battleplugins.bukkit.compat; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +/** + * NOTE: This class is quite volatile and may break depending on the + * Bukkit update. It is recommended this is not used at all for + * plugins and if there is a reason why it should be accessed, + * it should be used sparingly. + */ +public enum BukkitCompatMaterial { + + ACACIA_BOAT(0, "BOAT_ACACIA"), + ACACIA_BUTTON(0, "WOOD_BUTTON"), + ACACIA_DOOR(0, "ACACIA_DOOR","ACACIA_DOOR_ITEM"), + ACACIA_FENCE(0, "ACACIA_FENCE"), + ACACIA_FENCE_GATE(0, "ACACIA_FENCE_GATE"), + ACACIA_LEAVES(0, "LEAVES_2"), + ACACIA_LOG(0, "LOG_2"), + ACACIA_PLANKS(4, "WOOD"), + ACACIA_PRESSURE_PLATE(0, "WOOD_PLATE"), + ACACIA_SAPLING(4, "SAPLING"), + ACACIA_SIGN(0, "SIGN"), + ACACIA_SLAB(4,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + ACACIA_STAIRS(4, "ACACIA_STAIRS"), + ACACIA_TRAPDOOR(0, "TRAP_DOOR"), + ACACIA_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + ACACIA_WOOD(0, "LOG_2"), + ACTIVATOR_RAIL(0, "ACTIVATOR_RAIL"), + AIR(0, "AIR"), + ALLIUM(2, "RED_ROSE"), + ANDESITE(5, "STONE"), + ANDESITE_SLAB(0, "ANDESITE_SLAB"), + ANDESITE_STAIRS(0, "ANDESITE_STAIRS"), + ANDESITE_WALL(0, "ANDESITE_WALL"), + ANVIL(0, "ANVIL"), + APPLE(0, "APPLE"), + ARMOR_STAND(0, "ARMOR_STAND"), + ARROW(0, "ARROW"), + ATTACHED_MELON_STEM(7, "MELON_STEM"), + ATTACHED_PUMPKIN_STEM(7, "PUMPKIN_STEM"), + AZURE_BLUET(3, "RED_ROSE"), + BAKED_POTATO(0, "BAKED_POTATO"), + BAMBOO(0, "BAMBOO"), + BAMBOO_SAPLING(0, "SAPLING"), + BARRIER(0, "BARRIER"), + BARREL(0, "BARREL"), + BAT_SPAWN_EGG(65, "MONSTER_EGG"), + BEACON(0, "BEACON"), + BEDROCK(0, "BEDROCK"), + BEEF(0, "RAW_BEEF"), + BEETROOT(0, "BEETROOT"), + BEETROOTS(0, "BEETROOT", "BEETROOT_BLOCK"), + BEETROOT_SEEDS(0, "BEETROOT_SEEDS"), + BEETROOT_SOUP(0, "BEETROOT_SOUP"), + BEEHIVE(0, "BEEHIVE"), + BEE_NEST(0, "BEE_NEST"), + BEE_SPAWN_EGG(0, "BEE_SPAWN_EGG"), + BELL(0, "BELL"), + BIRCH_BOAT(0, "BOAT_BIRCH"), + BIRCH_BUTTON(0, "WOOD_BUTTON"), + BIRCH_DOOR(0, "BIRCH_DOOR", "BIRCH_DOOR_ITEM"), + BIRCH_FENCE(0, "BIRCH_FENCE"), + BIRCH_FENCE_GATE(0, "BIRCH_FENCE_GATE"), + BIRCH_LEAVES(2, "LEAVES"), + BIRCH_LOG(2, "LOG"), + BIRCH_PLANKS(2, "WOOD"), + BIRCH_PRESSURE_PLATE(0, "WOOD_PLATE"), + BIRCH_SAPLING(2, "SAPLING"), + BIRCH_SIGN(0, "SIGN"), + BIRCH_SLAB(2,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + BIRCH_STAIRS(0, "BIRCH_WOOD_STAIRS"), + BIRCH_TRAPDOOR(0, "TRAP_DOOR"), + BIRCH_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + BIRCH_WOOD(2, "LOG"), + BLACK_BANNER(0, "BANNER", "STANDING_BANNER"), + BLACK_BED(15, "BED", "BED_BLOCK"), + BLACK_CARPET(15, "CARPET"), + BLACK_CONCRETE(15, "CONCRETE"), + BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"), + BLACK_DYE(0, "INK_SACK"), + BLACK_GLAZED_TERRACOTTA(0, "BLACK_GLAZED_TERRACOTTA"), + BLACK_SHULKER_BOX(0, "BLACK_SHULKER_BOX"), + BLACK_STAINED_GLASS(15, "STAINED_GLASS"), + BLACK_STAINED_GLASS_PANE(15, "STAINED_GLASS_PANE"), + BLACK_TERRACOTTA(15, "STAINED_CLAY"), + BLACK_WALL_BANNER(0, "WALL_BANNER"), + BLACK_WOOL(15, "WOOL"), + BLAST_FURNACE(0, "FURNACE"), + BLAZE_POWDER(0, "BLAZE_POWDER"), + BLAZE_ROD(0, "BLAZE_ROD"), + BLAZE_SPAWN_EGG(61, "MONSTER_EGG"), + BLUE_BANNER(11, "BANNER", "STANDING_BANNER"), + BLUE_BED(4, "BED", "BED_BLOCK"), + BLUE_CARPET(11, "CARPET"), + BLUE_CONCRETE(11, "CONCRETE"), + BLUE_CONCRETE_POWDER(11, "CONCRETE_POWDER"), + BLUE_DYE(0, "LAPIS_LAZULI"), + BLUE_GLAZED_TERRACOTTA(0, "BLUE_GLAZED_TERRACOTTA"), + BLUE_ICE(0, "PACKED_ICE"), + BLUE_ORCHID(1, "RED_ROSE"), + BLUE_SHULKER_BOX(0, "BLUE_SHULKER_BOX"), + BLUE_STAINED_GLASS(11, "STAINED_GLASS"), + BLUE_STAINED_GLASS_PANE(11, "STAINED_GLASS_PANE"), + BLUE_TERRACOTTA(11, "STAINED_CLAY"), + BLUE_WALL_BANNER(11, "WALL_BANNER"), + BLUE_WOOL(11, "WOOL"), + BONE(0, "BONE"), + BONE_BLOCK(0, "BONE_BLOCK"), + BONE_MEAL(15, "INK_SACK"), + BOOK(0, "BOOK"), + BOOKSHELF(0, "BOOKSHELF"), + BOW(0, "BOW"), + BOWL(0, "BOWL"), + BRAIN_CORAL(0, "STONE"), + BRAIN_CORAL_BLOCK(0, "STONE"), + BRAIN_CORAL_FAN(0, "STONE"), + BREAD(0, "BREAD"), + BREWING_STAND(0, "BREWING_STAND", "BREWING_STAND_ITEM"), + BRICK(0, "CLAY_BRICK"), + BRICKS(0, "BRICK"), + BRICK_SLAB(4, "STEP"), + BRICK_STAIRS(0, "BRICK_STAIRS"), + BROWN_BANNER(3, "BANNER", "STANDING_BANNER"), + BROWN_BED(12, "BED", "BED_BLOCK"), + BROWN_CARPET(12, "CARPET"), + BROWN_CONCRETE(12, "CONCRETE"), + BROWN_CONCRETE_POWDER(12, "CONCRETE_POWDER"), + BROWN_DYE(0, "COCOA_BEANS"), + BROWN_GLAZED_TERRACOTTA(0, "BROWN_GLAZED_TERRACOTTA"), + BROWN_MUSHROOM(0, "BROWN_MUSHROOM"), + BROWN_MUSHROOM_BLOCK(0, "BROWN_MUSHROOM", "HUGE_MUSHROOM_1"), + BROWN_SHULKER_BOX(0, "BROWN_SHULKER_BOX"), + BROWN_STAINED_GLASS(12, "STAINED_GLASS"), + BROWN_STAINED_GLASS_PANE(12, "STAINED_GLASS_PANE"), + BROWN_TERRACOTTA(12, "STAINED_CLAY"), + BROWN_WALL_BANNER(3, "WALL_BANNER"), + BROWN_WOOL(12, "WOOL"), + BUBBLE_COLUMN(0, "STONE"), + BUBBLE_CORAL(0, "STONE"), + BUBBLE_CORAL_BLOCK(0, "STONE"), + BUBBLE_CORAL_FAN(0, "STONE"), + BUCKET(0, "BUCKET"), + CACTUS(0, "CACTUS"), + CACTUS_GREEN(2, "INK_SACK"), + CAKE(0, "CAKE", "CAKE_BLOCK"), + CAMPFIRE(0, "CAMPFIRE"), + CARROT(0, "CARROT_ITEM"), + CARROTS(0, "CARROT"), + CARROT_ON_A_STICK(0, "CARROT_STICK"), + CARTOGRAPHY_TABLE(0, "CARTOGRAPHY_TABLE"), + CARVED_PUMPKIN(0, "PUMPKIN"), + CAT_SPAWN_EGG(0, "CAT_SPAWN_EGG"), + CAULDRON(0, "CAULDRON", "CAULDRON_ITEM"), + CAVE_AIR(0, "AIR"), + CAVE_SPIDER_SPAWN_EGG(59, "MONSTER_EGG"), + CHAINMAIL_BOOTS(0, "CHAINMAIL_BOOTS"), + CHAINMAIL_CHESTPLATE(0, "CHAINMAIL_CHESTPLATE"), + CHAINMAIL_HELMET(0, "CHAINMAIL_HELMET"), + CHAINMAIL_LEGGINGS(0, "CHAINMAIL_LEGGINGS"), + CHAIN_COMMAND_BLOCK(0, "COMMAND_CHAIN"), + CHARCOAL(1, "COAL"), + CHEST(0, "CHEST", "LOCKED_CHEST"), + CHEST_MINECART(0, "STORAGE_MINECART"), + CHICKEN(0, "RAW_CHICKEN"), + CHICKEN_SPAWN_EGG(93, "MONSTER_EGG"), + CHIPPED_ANVIL(1, "ANVIL"), + CHISELED_QUARTZ_BLOCK(1, "QUARTZ_BLOCK"), + CHISELED_RED_SANDSTONE(1, "RED_SANDSTONE"), + CHISELED_SANDSTONE(1, "SANDSTONE"), + CHISELED_STONE_BRICKS(3, "SMOOTH_BRICK"), + CHORUS_FLOWER(0, "CHORUS_FLOWER"), + CHORUS_FRUIT(0, "CHORUS_FRUIT"), + CHORUS_PLANT(0, "CHORUS_PLANT"), + CLAY(0, "CLAY"), + CLAY_BALL(0, "CLAY_BALL"), + CLOCK(0, "WATCH"), + COAL(0, "COAL"), + COAL_BLOCK(0, "COAL_BLOCK"), + COAL_ORE(0, "COAL_ORE"), + COARSE_DIRT(1, "DIRT"), + COBBLESTONE(0, "COBBLESTONE"), + COBBLESTONE_SLAB(3, "STEP"), + COBBLESTONE_STAIRS(0, "COBBLESTONE_STAIRS"), + COBBLESTONE_WALL(0, "COBBLE_WALL"), + COBWEB(0, "WEB"), + COCOA(0, "COCOA"), + COCOA_BEANS(3, "INK_SACK"), + COD(0, "RAW_FISH"), + COD_BUCKET(0, "BUCKET"), + COD_SPAWN_EGG(0, "MONSTER_EGG"), + COMMAND_BLOCK(0, "COMMAND"), + COMMAND_BLOCK_MINECART(0, "COMMAND_MINECART"), + COMPARATOR(0, "REDSTONE_COMPARATOR", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR_OFF"), + COMPASS(0, "COMPASS"), + COMPOSTER(0, "COMPOSTER"), + CONDUIT(0, "STONE"), + COOKED_BEEF(0, "COOKED_BEEF"), + COOKED_CHICKEN(0, "COOKED_CHICKEN"), + COOKED_COD(0, "COOKED_FISH"), + COOKED_MUTTON(0, "COOKED_MUTTON"), + COOKED_PORKCHOP(0, "GRILLED_PORK"), + COOKED_RABBIT(0, "COOKED_RABBIT"), + COOKED_SALMON(1, "COOKED_FISH"), + COOKIE(0, "COOKIE"), + CORNFLOWER(0, "CORNFLOWER"), + COW_SPAWN_EGG(92, "MONSTER_EGG"), + CRACKED_STONE_BRICKS(2, "SMOOTH_BRICK"), + CRAFTING_TABLE(0, "WORKBENCH"), + CREEPER_HEAD(4, "SKULL_ITEM","SKULL"), + CREEPER_SPAWN_EGG(50, "MONSTER_EGG"), + CREEPER_WALL_HEAD(4, "SKULL_ITEM","SKULL"), + CROSSBOW(0, "CROSSBOW"), + CUT_RED_SANDSTONE(0, "STONE"), + CUT_RED_SANDSTONE_SLAB(0, "CUT_RED_SANDSTONE_SLAB"), + CUT_SANDSTONE(0, "STONE"), + CUT_SANDSTONE_SLAB(0, "CUT_STANDSTONE_SLAB"), + CYAN_BANNER(6, "BANNER", "STANDING_BANNER"), + CYAN_BED(9, "BED", "BED_BLOCK"), + CYAN_CARPET(9, "CARPET"), + CYAN_CONCRETE(9, "CONCRETE"), + CYAN_CONCRETE_POWDER(9, "CONCRETE_POWDER"), + CYAN_DYE(6, "INK_SACK"), + CYAN_GLAZED_TERRACOTTA(0, "CYAN_GLAZED_TERRACOTTA"), + CYAN_SHULKER_BOX(0, "CYAN_SHULKER_BOX"), + CYAN_STAINED_GLASS(9, "STAINED_GLASS"), + CYAN_STAINED_GLASS_PANE(9, "STAINED_GLASS_PANE"), + CYAN_TERRACOTTA(9, "STAINED_CLAY"), + CYAN_WALL_BANNER(0, "WALL_BANNER"), + CYAN_WOOL(9, "WOOL"), + DAMAGED_ANVIL(2, "ANVIL"), + DANDELION(0, "YELLOW_FLOWER"), + DANDELION_YELLOW(11, "INK_SACK"), + DARK_OAK_BOAT(0, "BOAT_DARK_OAK"), + DARK_OAK_BUTTON(0, "WOOD_BUTTON"), + DARK_OAK_DOOR(0, "DARK_OAK_DOOR", "DARK_OAK_DOOR_ITEM"), + DARK_OAK_FENCE(0, "DARK_OAK_FENCE"), + DARK_OAK_FENCE_GATE(0, "DARK_OAK_FENCE_GATE"), + DARK_OAK_LEAVES(1, "LEAVES_2"), + DARK_OAK_LOG(1, "LOG_2"), + DARK_OAK_PLANKS(5, "WOOD"), + DARK_OAK_PRESSURE_PLATE(0, "WOOD_PLATE"), + DARK_OAK_SAPLING(5, "SAPLING"), + DARK_OAK_SIGN(0, "SIGN"), + DARK_OAK_SLAB(0,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + DARK_OAK_STAIRS(0, "DARK_OAK_STAIRS"), + DARK_OAK_TRAPDOOR(0, "TRAP_DOOR"), + DARK_OAK_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + DARK_OAK_WOOD(1, "LOG_2"), + DARK_PRISMARINE(2, "PRISMARINE"), + DARK_PRISMARINE_SLAB(0, "STONE"), + DARK_PRISMARINE_STAIRS(0, "STONE"), + DAYLIGHT_DETECTOR(0, "DAYLIGHT_DETECTOR", "DAYLIGHT_DETECTOR_INVERTED"), + DEAD_BRAIN_CORAL_BLOCK(0, "STONE"), + DEAD_BUBBLE_CORAL_BLOCK(0, "STONE"), + DEAD_BUSH(0, "DEAD_BUSH"), + DEAD_FIRE_CORAL_BLOCK(0, "STONE"), + DEAD_HORN_CORAL_BLOCK(0, "STONE"), + DEAD_TUBE_CORAL_BLOCK(0, "STONE"), + DEBUG_STICK(0, "STICK"), + DETECTOR_RAIL(0, "DETECTOR_RAIL"), + DIAMOND(0, "DIAMOND"), + DIAMOND_AXE(0, "DIAMOND_AXE"), + DIAMOND_BLOCK(0, "DIAMOND_BLOCK"), + DIAMOND_BOOTS(0, "DIAMOND_BOOTS"), + DIAMOND_CHESTPLATE(0, "DIAMOND_CHESTPLATE"), + DIAMOND_HELMET(0, "DIAMOND_HELMET"), + DIAMOND_HOE(0, "DIAMOND_HOE"), + DIAMOND_HORSE_ARMOR(0, "DIAMOND_BARDING"), + DIAMOND_LEGGINGS(0, "DIAMOND_LEGGINGS"), + DIAMOND_ORE(0, "DIAMOND_ORE"), + DIAMOND_PICKAXE(0, "DIAMOND_PICKAXE"), + DIAMOND_SHOVEL(0, "DIAMOND_SPADE"), + DIAMOND_SWORD(0, "DIAMOND_SWORD"), + DIORITE(3, "STONE"), + DIORITE_SLAB(0, "DIORITE_SLAB"), + DIORITE_STAIRS(0, "DIORITE_STAIRS"), + DIORITE_WALL(0, "DIORITE_WALL"), + DIRT(0, "DIRT"), + DISPENSER(0, "DISPENSER"), + DOLPHIN_SPAWN_EGG(0, "MONSTER_EGG"), + DONKEY_SPAWN_EGG(31, "MONSTER_EGG"), + DRAGON_BREATH(0, "DRAGONS_BREATH"), + DRAGON_EGG(0, "DRAGON_EGG"), + DRAGON_HEAD(5, "SKULL_ITEM","SKULL"), + DRAGON_WALL_HEAD(5, "SKULL_ITEM","SKULL"), + DRIED_KELP(0, "STONE"), + DRIED_KELP_BLOCK(0, "STONE"), + DROPPER(0, "DROPPER"), + DROWNED_SPAWN_EGG(0, "MONSTER_EGG"), + EGG(0, "EGG"), + ELDER_GUARDIAN_SPAWN_EGG(4, "MONSTER_EGG"), + ELYTRA(0, "ELYTRA"), + EMERALD(0, "EMERALD"), + EMERALD_BLOCK(0, "EMERALD_BLOCK"), + EMERALD_ORE(0, "EMERALD_ORE"), + ENCHANTED_BOOK(0, "ENCHANTED_BOOK"), + ENCHANTED_GOLDEN_APPLE(1, "GOLDEN_APPLE"), + ENCHANTING_TABLE(0, "ENCHANTMENT_TABLE"), + ENDERMAN_SPAWN_EGG(58, "MONSTER_EGG"), + ENDERMITE_SPAWN_EGG(67, "MONSTER_EGG"), + ENDER_CHEST(0, "ENDER_CHEST"), + ENDER_EYE(0, "EYE_OF_ENDER"), + ENDER_PEARL(0, "ENDER_PEARL"), + END_CRYSTAL(0, "END_CRYSTAL"), + END_GATEWAY(0, "END_GATEWAY"), + END_PORTAL(0, "ENDER_PORTAL"), + END_PORTAL_FRAME(0, "ENDER_PORTAL_FRAME"), + END_ROD(0, "END_ROD"), + END_STONE(0, "ENDER_STONE"), + END_STONE_BRICK_SLAB(0, "END_STONE_BRICK_SLAB"), + END_STONE_BRICK_STAIRS(0, "END_STONE_BRICK_STAIRS"), + END_STONE_BRICK_WALL(0, "END_STONE_BRICK_WALL"), + END_STONE_BRICKS(0, "END_BRICKS"), + EVOKER_SPAWN_EGG(34, "MONSTER_EGG"), + EXPERIENCE_BOTTLE(0, "EXP_BOTTLE"), + FARMLAND(0, "SOIL"), + FEATHER(0, "FEATHER"), + FERMENTED_SPIDER_EYE(0, "FERMENTED_SPIDER_EYE"), + FERN(2, "LONG_GRASS"), + FILLED_MAP(0, "MAP"), + FIRE(0, "FIRE"), + FIREWORK_ROCKET(0, "FIREWORK"), + FIREWORK_STAR(0, "FIREWORK_CHARGE"), + FIRE_CHARGE(0, "FIREBALL"), + FIRE_CORAL(0, "STONE"), + FIRE_CORAL_BLOCK(0, "STONE"), + FIRE_CORAL_FAN(0, "STONE"), + FISHING_ROD(0, "FISHING_ROD"), + FLETCHING_TABLE(0, "FLETCHING_TABLE"), + FLINT(0, "FLINT"), + FLINT_AND_STEEL(0, "FLINT_AND_STEEL"), + FLOWER_POT(0, "FLOWER_POT","FLOWER_POT_ITEM"), + FOX_SPAWN_EGG(0, "FOX_SPAWN_EGG"), + FROSTED_ICE(0, "FROSTED_ICE"), + FURNACE(0, "FURNACE", "BURNING_FURNACE"), + FURNACE_MINECART(0, "POWERED_MINECART"), + GHAST_SPAWN_EGG(56, "MONSTER_EGG"), + GHAST_TEAR(0, "GHAST_TEAR"), + GLASS(0, "GLASS"), + GLASS_BOTTLE(0, "GLASS_BOTTLE"), + GLASS_PANE(0, "THIN_GLASS"), + GLISTERING_MELON_SLICE(0, "SPECKLED_MELON"), + GLOWSTONE(0, "GLOWSTONE"), + GLOWSTONE_DUST(0, "GLOWSTONE_DUST"), + GOLDEN_APPLE(0, "GOLDEN_APPLE"), + GOLDEN_AXE(0, "GOLD_AXE"), + GOLDEN_BOOTS(0, "GOLD_BOOTS"), + GOLDEN_CARROT(0, "GOLDEN_CARROT"), + GOLDEN_CHESTPLATE(0, "GOLD_CHESTPLATE"), + GOLDEN_HELMET(0, "GOLD_HELMET"), + GOLDEN_HOE(0, "GOLD_HOE"), + GOLDEN_HORSE_ARMOR(0, "GOLD_BARDING"), + GOLDEN_LEGGINGS(0, "GOLD_LEGGINGS"), + GOLDEN_PICKAXE(0, "GOLD_PICKAXE"), + GOLDEN_SHOVEL(0, "GOLD_SPADE"), + GOLDEN_SWORD(0, "GOLD_SWORD"), + GOLD_BLOCK(0, "GOLD_BLOCK"), + GOLD_INGOT(0, "GOLD_INGOT"), + GOLD_NUGGET(0, "GOLD_NUGGET"), + GOLD_ORE(0, "GOLD_ORE"), + GRANITE(1, "STONE"), + GRANITE_SLAB(0, "GRANITE_SLAB"), + GRANITE_STAIRS(0, "GRANITE_STAIRS"), + GRANITE_WALL(0, "GRANITE_WALL"), + GRASS(0, "GRASS"), + GRASS_BLOCK(0, "GRASS"), + GRASS_PATH(0, "GRASS_PATH"), + GRAVEL(0, "GRAVEL"), + GRAY_BANNER(8, "BANNER", "STANDING_BANNER"), + GRAY_BED(7, "BED", "BED_BLOCK"), + GRAY_CARPET(7, "CARPET"), + GRAY_CONCRETE(7, "CONCRETE"), + GRAY_CONCRETE_POWDER(7, "CONCRETE_POWDER"), + GRAY_DYE(8, "INK_SACK"), + GRAY_GLAZED_TERRACOTTA(0, "GRAY_GLAZED_TERRACOTTA"), + GRAY_SHULKER_BOX(0, "GRAY_SHULKER_BOX"), + GRAY_STAINED_GLASS(7, "STAINED_GLASS"), + GRAY_STAINED_GLASS_PANE(7, "STAINED_GLASS_PANE"), + GRAY_TERRACOTTA(7, "STAINED_CLAY"), + GRAY_WALL_BANNER(0, "WALL_BANNER"), + GRAY_WOOL(7, "WOOL"), + GREEN_BANNER(2, "BANNER", "STANDING_BANNER"), + GREEN_BED(13, "BED", "BED_BLOCK"), + GREEN_CARPET(13, "CARPET"), + GREEN_CONCRETE(13, "CONCRETE"), + GREEN_CONCRETE_POWDER(13, "CONCRETE_POWDER"), + GREEN_GLAZED_TERRACOTTA(0, "GREEN_GLAZED_TERRACOTTA"), + GREEN_SHULKER_BOX(0, "GREEN_SHULKER_BOX"), + GREEN_STAINED_GLASS(13, "STAINED_GLASS"), + GREEN_STAINED_GLASS_PANE(13, "STAINED_GLASS_PANE"), + GREEN_TERRACOTTA(13, "STAINED_CLAY"), + GREEN_WALL_BANNER(0, "WALL_BANNER"), + GREEN_WOOL(13, "WOOL"), + GRINDSTONE(0, "GRINDSTONE"), + GUARDIAN_SPAWN_EGG(68, "MONSTER_EGG"), + GUNPOWDER(0, "SULPHUR"), + HAY_BLOCK(0, "HAY_BLOCK"), + HEART_OF_THE_SEA(0, "STONE"), + HEAVY_WEIGHTED_PRESSURE_PLATE(0, "IRON_PLATE"), + HONEY_BLOCK(0, "HONEY_BLOCK"), + HONEY_BOTTLE(0, "HONEY_BOTTLE"), + HONEYCOMB(0, "HONEYCOMB"), + HONEYCOMB_BLOCK(0, "HONEYCOMB_BLOCK"), + HOPPER(0, "HOPPER"), + HOPPER_MINECART(0, "HOPPER_MINECART"), + HORN_CORAL(0, "STONE"), + HORN_CORAL_BLOCK(0, "STONE"), + HORN_CORAL_FAN(0, "STONE"), + HORSE_SPAWN_EGG(100, "MONSTER_EGG"), + HUSK_SPAWN_EGG(23, "MONSTER_EGG"), + ICE(0, "ICE"), + INFESTED_CHISELED_STONE_BRICKS(5, "MONSTER_EGGS"), + INFESTED_COBBLESTONE(1, "MONSTER_EGGS"), + INFESTED_CRACKED_STONE_BRICKS(4, "MONSTER_EGGS"), + INFESTED_MOSSY_STONE_BRICKS(3, "MONSTER_EGGS"), + INFESTED_STONE(0, "MONSTER_EGGS"), + INFESTED_STONE_BRICKS(2, "MONSTER_EGGS"), + INK_SAC(0, "INK_SACK"), + IRON_AXE(0, "IRON_AXE"), + IRON_BARS(0, "IRON_FENCE"), + IRON_BLOCK(0, "IRON_BLOCK"), + IRON_BOOTS(0, "IRON_BOOTS"), + IRON_CHESTPLATE(0, "IRON_CHESTPLATE"), + IRON_DOOR(0, "IRON_DOOR", "IRON_DOOR_BLOCK"), + IRON_HELMET(0, "IRON_HELMET"), + IRON_HOE(0, "IRON_HOE"), + IRON_HORSE_ARMOR(0, "IRON_BARDING"), + IRON_INGOT(0, "IRON_INGOT"), + IRON_LEGGINGS(0, "IRON_LEGGINGS"), + IRON_NUGGET(0, "IRON_NUGGET"), + IRON_ORE(0, "IRON_ORE"), + IRON_PICKAXE(0, "IRON_PICKAXE"), + IRON_SHOVEL(0, "IRON_SPADE"), + IRON_SWORD(0, "IRON_SWORD"), + IRON_TRAPDOOR(0, "IRON_TRAPDOOR"), + ITEM_FRAME(0, "ITEM_FRAME"), + JACK_O_LANTERN(0, "JACK_O_LANTERN"), + JIGSAW(0, "JIGSAW"), + JUKEBOX(0, "JUKEBOX"), + JUNGLE_BOAT(0, "BOAT_JUNGLE"), + JUNGLE_BUTTON(0, "WOOD_BUTTON"), + JUNGLE_DOOR(0, "JUNGLE_DOOR", "JUNGLE_DOOR_ITEM"), + JUNGLE_FENCE(0, "JUNGLE_FENCE"), + JUNGLE_FENCE_GATE(0, "JUNGLE_FENCE_GATE"), + JUNGLE_LEAVES(3, "LEAVES"), + JUNGLE_LOG(3, "LOG"), + JUNGLE_PLANKS(3, "WOOD"), + JUNGLE_PRESSURE_PLATE(0, "WOOD_PLATE"), + JUNGLE_SAPLING(3, "SAPLING"), + JUNGLE_SIGN(0, "SIGN"), + JUNGLE_SLAB(3,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + JUNGLE_STAIRS(0, "JUNGLE_WOOD_STAIRS"), + JUNGLE_TRAPDOOR(0, "TRAP_DOOR"), + JUNGLE_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + JUNGLE_WOOD(3, "LOG"), + KELP(0, "STONE"), + KELP_PLANT(0, "STONE"), + KNOWLEDGE_BOOK(0, "KNOWLEDGE_BOOK"), + LADDER(0, "LADDER"), + LANTERN(0, "LANTERN"), + LAPIS_BLOCK(0, "LAPIS_BLOCK"), + LAPIS_LAZULI(4, "INK_SACK"), + LAPIS_ORE(0, "LAPIS_ORE"), + LARGE_FERN(3, "DOUBLE_PLANT"), + LAVA(0, "LAVA", "STATIONARY_LAVA"), + LAVA_BUCKET(0, "LAVA_BUCKET"), + LEAD(0, "LEASH"), + LEATHER(0, "LEATHER"), + LEATHER_BOOTS(0, "LEATHER_BOOTS"), + LEATHER_CHESTPLATE(0, "LEATHER_CHESTPLATE"), + LEATHER_HELMET(0, "LEATHER_HELMET"), + LEATHER_HORSE_ARMOR(0, "LEATHER_HORSE_ARMOR"), + LEATHER_LEGGINGS(0, "LEATHER_LEGGINGS"), + LECTERN(0, "LECTERN"), + LEVER(0, "LEVER"), + LIGHT_BLUE_BANNER(12, "BANNER", "STANDING_BANNER"), + LIGHT_BLUE_BED(3, "BED", "BED_BLOCK"), + LIGHT_BLUE_CARPET(3, "CARPET"), + LIGHT_BLUE_CONCRETE(3, "CONCRETE"), + LIGHT_BLUE_CONCRETE_POWDER(3, "CONCRETE_POWDER"), + LIGHT_BLUE_DYE(12, "INK_SACK"), + LIGHT_BLUE_GLAZED_TERRACOTTA(0, "LIGHT_BLUE_GLAZED_TERRACOTTA"), + LIGHT_BLUE_SHULKER_BOX(0, "LIGHT_BLUE_SHULKER_BOX"), + LIGHT_BLUE_STAINED_GLASS(3, "STAINED_GLASS"), + LIGHT_BLUE_STAINED_GLASS_PANE(3, "STAINED_GLASS_PANE"), + LIGHT_BLUE_TERRACOTTA(3, "STAINED_CLAY"), + LIGHT_BLUE_WALL_BANNER(0, "BANNER", "STANDING_BANNER"), + LIGHT_BLUE_WOOL(3, "WOOL"), + LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"), + LIGHT_GRAY_BED(8, "BED", "BED_BLOCK"), + LIGHT_GRAY_CARPET(8, "CARPET"), + LIGHT_GRAY_CONCRETE(8, "CONCRETE"), + LIGHT_GRAY_CONCRETE_POWDER(8, "CONCRETE_POWDER"), + LIGHT_GRAY_DYE(7, "INK_SACK"), + LIGHT_GRAY_GLAZED_TERRACOTTA(0, "SILVER_GLAZED_TERRACOTTA"), + LIGHT_GRAY_SHULKER_BOX(0, "SILVER_SHULKER_BOX"), + LIGHT_GRAY_STAINED_GLASS(8, "STAINED_GLASS"), + LIGHT_GRAY_STAINED_GLASS_PANE(8, "STAINED_GLASS_PANE"), + LIGHT_GRAY_TERRACOTTA(8, "STAINED_CLAY"), + LIGHT_GRAY_WALL_BANNER(0, "WALL_BANNER"), + LIGHT_GRAY_WOOL(8, "WOOL"), + LIGHT_WEIGHTED_PRESSURE_PLATE(0, "GOLD_PLATE"), + LILAC(1, "DOUBLE_PLANT"), + LILY_OF_THE_VALLEY(0, "LILY_OF_THE_VALLEY"), + LILY_PAD(0, "WATER_LILY"), + LIME_BANNER(10, "BANNER", "STANDING_BANNER"), + LIME_BED(5, "BED", "BED_BLOCK"), + LIME_CARPET(5, "CARPET"), + LIME_CONCRETE(5, "CONCRETE"), + LIME_CONCRETE_POWDER(5, "CONCRETE_POWDER"), + LIME_DYE(10, "INK_SACK"), + LIME_GLAZED_TERRACOTTA(0, "LIME_GLAZED_TERRACOTTA"), + LIME_SHULKER_BOX(0, "LIME_SHULKER_BOX"), + LIME_STAINED_GLASS(5, "STAINED_GLASS"), + LIME_STAINED_GLASS_PANE(5, "STAINED_GLASS_PANE"), + LIME_TERRACOTTA(5, "STAINED_CLAY"), + LIME_WALL_BANNER(0, "WALL_BANNER"), + LIME_WOOL(5, "WOOL"), + LINGERING_POTION(0, "LINGERING_POTION"), + LLAMA_SPAWN_EGG(103, "MONSTER_EGG"), + LOOM(0, "LOOM"), + MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"), + MAGENTA_BED(2, "BED", "BED_BLOCK"), + MAGENTA_CARPET(2, "CARPET"), + MAGENTA_CONCRETE(2, "CONCRETE"), + MAGENTA_CONCRETE_POWDER(2, "CONCRETE_POWDER"), + MAGENTA_DYE(13, "INK_SACK"), + MAGENTA_GLAZED_TERRACOTTA(0, "MAGENTA_GLAZED_TERRACOTTA"), + MAGENTA_SHULKER_BOX(0, "MAGENTA_SHULKER_BOX"), + MAGENTA_STAINED_GLASS(2, "STAINED_GLASS"), + MAGENTA_STAINED_GLASS_PANE(2, "STAINED_GLASS_PANE"), + MAGENTA_TERRACOTTA(2, "STAINED_CLAY"), + MAGENTA_WALL_BANNER(0, "WALL_BANNER"), + MAGENTA_WOOL(2, "WOOL"), + MAGMA_BLOCK(0, "MAGMA"), + MAGMA_CREAM(0, "MAGMA_CREAM"), + MAGMA_CUBE_SPAWN_EGG(62, "MONSTER_EGG"), + MAP(0, "MAP", "EMPTY_MAP"), + MELON(0, "MELON_BLOCK"), + MELON_SEEDS(0, "MELON_SEEDS"), + MELON_SLICE(0, "MELON"), + MELON_STEM(0, "MELON_STEM"), + MILK_BUCKET(0, "MILK_BUCKET"), + MINECART(0, "MINECART"), + MOOSHROOM_SPAWN_EGG(96, "MONSTER_EGG"), + MOSSY_COBBLESTONE(0, "MOSSY_COBBLESTONE"), + MOSSY_COBBLESTONE_SLAB(0, "MOSSY_COBBLESTONE_SLAB"), + MOSSY_COBBLESTONE_STAIRS(0, "MOSSY_COBBLESTONE_STAIRS"), + MOSSY_COBBLESTONE_WALL(1, "COBBLE_WALL"), + MOSSY_STONE_BRICKS(1, "SMOOTH_BRICK"), + MOSSY_STONE_BRICK_SLAB(0, "MOSSY_STONE_BRICK_SLAB"), + MOSSY_STONE_BRICK_STAIRS(0, "MOSSY_STONE_BRICK_STAIRS"), + MOSSY_STONE_BRICK_WALL(0, "MOSSY_STONE_BRICK_WALL"), + MOVING_PISTON(0, "PISTON_MOVING_PIECE"), + MULE_SPAWN_EGG(32, "MONSTER_EGG"), + MUSHROOM_STEM(0, "BROWN_MUSHROOM"), + MUSHROOM_STEW(0, "MUSHROOM_SOUP"), + MUSIC_DISC_11(0, "GOLD_RECORD"), + MUSIC_DISC_13(0, "GREEN_RECORD"), + MUSIC_DISC_BLOCKS(0, "RECORD_3"), + MUSIC_DISC_CAT(0, "RECORD_4"), + MUSIC_DISC_CHIRP(0, "RECORD_5"), + MUSIC_DISC_FAR(0, "RECORD_6"), + MUSIC_DISC_MALL(0, "RECORD_7"), + MUSIC_DISC_MELLOHI(0, "RECORD_8"), + MUSIC_DISC_STAL(0, "RECORD_9"), + MUSIC_DISC_STRAD(0, "RECORD_10"), + MUSIC_DISC_WAIT(0, "RECORD_11"), + MUSIC_DISC_WARD(0, "RECORD_12"), + MUTTON(0, "MUTTON"), + MYCELIUM(0, "MYCEL"), + NAME_TAG(0, "NAME_TAG"), + NAUTILUS_SHELL(0, "STONE"), + NETHERRACK(0, "NETHERRACK"), + NETHER_BRICK(0, "NETHER_BRICK"), + NETHER_BRICKS(0, "NETHER_BRICK"), + NETHER_BRICK_FENCE(0, "NETHER_FENCE"), + NETHER_BRICK_SLAB(6, "STEP"), + NETHER_BRICK_STAIRS(0, "NETHER_BRICK_STAIRS"), + NETHER_PORTAL(0, "PORTAL"), + NETHER_QUARTZ_ORE(0, "QUARTZ_ORE"), + NETHER_STAR(0, "NETHER_STAR"), + NETHER_WART(0, "NETHER_STALK"), + NETHER_WART_BLOCK(0, "NETHER_WART_BLOCK", "NETHER_WARTS"), + NOTE_BLOCK(0, "NOTE_BLOCK"), + OAK_BOAT(0, "BOAT"), + OAK_BUTTON(0, "WOOD_BUTTON"), + OAK_DOOR(0, "WOODEN_DOOR", "WOOD_DOOR"), + OAK_FENCE(0, "FENCE"), + OAK_FENCE_GATE(0, "FENCE_GATE"), + OAK_LEAVES(0, "LEAVES"), + OAK_LOG(0, "LOG"), + OAK_PLANKS(0, "WOOD"), + OAK_PRESSURE_PLATE(0, "WOOD_PLATE"), + OAK_SAPLING(0, "SAPLING"), + OAK_SIGN(0, "SIGN"), + OAK_SLAB(0,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + OAK_STAIRS(0, "WOOD_STAIRS"), + OAK_TRAPDOOR(0, "TRAP_DOOR"), + OAK_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + OAK_WOOD(0, "LOG"), + OBSERVER(0, "OBSERVER"), + OBSIDIAN(0, "OBSIDIAN"), + OCELOT_SPAWN_EGG(98, "RECORD_12"), + ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"), + ORANGE_BED(1, "BED", "BED_BLOCK"), + ORANGE_CARPET(1, "CARPET"), + ORANGE_CONCRETE(1, "CONCRETE"), + ORANGE_CONCRETE_POWDER(1, "CONCRETE_POWDER"), + ORANGE_DYE(14, "INK_SACK"), + ORANGE_GLAZED_TERRACOTTA(0, "ORANGE_GLAZED_TERRACOTTA"), + ORANGE_SHULKER_BOX(0, "ORANGE_SHULKER_BOX"), + ORANGE_STAINED_GLASS(1, "STAINED_GLASS"), + ORANGE_STAINED_GLASS_PANE(1, "STAINED_GLASS_PANE"), + ORANGE_TERRACOTTA(1, "STAINED_CLAY"), + ORANGE_TULIP(5, "RED_ROSE"), + ORANGE_WALL_BANNER(0, "WALL_BANNER"), + ORANGE_WOOL(1, "WOOL"), + OXEYE_DAISY(8, "RED_ROSE"), + PACKED_ICE(0, "PACKED_ICE"), + PAINTING(0, "PAINTING"), + PANDA_SPAWN_EGG(0, "PANDA_SPAWN_EGG"), + PAPER(0, "PAPER"), + PARROT_SPAWN_EGG(105, "MONSTER_EGG"), + PEONY(5, "DOUBLE_PLANT"), + PETRIFIED_OAK_SLAB(0, "STONE"), + PHANTOM_MEMBRANE(0, "STONE"), + PHANTOM_SPAWN_EGG(0, "MONSTER_EGG"), + PIG_SPAWN_EGG(90, "MONSTER_EGG"), + PILLAGER_SPAWN_EGG(0, "PILLAGER_SPAWN_EGG"), + PINK_BANNER(9, "BANNER", "STANDING_BANNER"), + PINK_BED(6, "BED", "BED_BLOCK"), + PINK_CARPET(6, "CARPET"), + PINK_CONCRETE(6, "CONCRETE"), + PINK_CONCRETE_POWDER(6, "CONCRETE_POWDER"), + PINK_DYE(9, "INK_SACK"), + PINK_GLAZED_TERRACOTTA(0, "PINK_GLAZED_TERRACOTTA"), + PINK_SHULKER_BOX(0, "PINK_SHULKER_BOX"), + PINK_STAINED_GLASS(6, "STAINED_GLASS"), + PINK_STAINED_GLASS_PANE(6, "STAINED_GLASS_PANE"), + PINK_TERRACOTTA(6, "STAINED_CLAY"), + PINK_TULIP(7, "RED_ROSE"), + PINK_WALL_BANNER(0, "WALL_BANNER"), + PINK_WOOL(6, "WOOL"), + PISTON(0, "PISTON_BASE"), + PISTON_HEAD(0, "PISTON_EXTENSION"), + PLAYER_HEAD(3, "SKULL_ITEM","SKULL"), + PLAYER_WALL_HEAD(3, "SKULL_ITEM","SKULL"), + PODZOL(2, "DIRT"), + POISONOUS_POTATO(0, "POISONOUS_POTATO"), + POLAR_BEAR_SPAWN_EGG(102, "MONSTER_EGG"), + POLISHED_ANDESITE(6, "STONE"), + POLISHED_ANDESITE_SLAB(0, "POLISHED_ANDESITE_SLAB"), + POLISHED_ANDESITE_STAIRS(0, "POLISED_ANDESITE_STAIRS"), + POLISHED_DIORITE(4, "STONE"), + POLISHED_DIORITE_SLAB(0, "POLISHED_DIORITE_SLAB"), + POLISHED_DIORITE_STAIRS(0, "POLISHED_DIORITE_STAIRS"), + POLISHED_GRANITE(2, "STONE"), + POLISHED_GRANITE_SLAB(0, "POLISHED_GRANITE_SLAB"), + POLISHED_GRANITE_STAIRS(0, "POLISHED_GRANITE_STAIRS"), + POPPED_CHORUS_FRUIT(0, "CHORUS_FRUIT_POPPED"), + POPPY(0, "RED_ROSE"), + PORKCHOP(0, "PORK"), + POTATO(0, "POTATO_ITEM"), + POTATOES(0, "POTATO"), + POTION(0, "POTION"), + POTTED_ACACIA_SAPLING(0, "FLOWER_POT"), + POTTED_ALLIUM(0, "FLOWER_POT"), + POTTED_AZURE_BLUET(0, "FLOWER_POT"), + POTTED_BIRCH_SAPLING(0, "FLOWER_POT"), + POTTED_BLUE_ORCHID(0, "FLOWER_POT"), + POTTED_BROWN_MUSHROOM(0, "FLOWER_POT"), + POTTED_CACTUS(0, "FLOWER_POT"), + POTTED_CORNFLOWER(0, "FLOWER_POT"), + POTTED_DANDELION(0, "FLOWER_POT"), + POTTED_DARK_OAK_SAPLING(0, "FLOWER_POT"), + POTTED_DEAD_BUSH(0, "FLOWER_POT"), + POTTED_FERN(0, "FLOWER_POT"), + POTTED_JUNGLE_SAPLING(0, "FLOWER_POT"), + POTTED_LILY_OF_THE_VALLEY(0, "FLOWER_POT"), + POTTED_OAK_SAPLING(0, "FLOWER_POT"), + POTTED_ORANGE_TULIP(0, "FLOWER_POT"), + POTTED_OXEYE_DAISY(0, "FLOWER_POT"), + POTTED_PINK_TULIP(0, "FLOWER_POT"), + POTTED_POPPY(0, "FLOWER_POT"), + POTTED_RED_MUSHROOM(0, "FLOWER_POT"), + POTTED_RED_TULIP(0, "FLOWER_POT"), + POTTED_SPRUCE_SAPLING(0, "FLOWER_POT"), + POTTED_WHITE_TULIP(0, "FLOWER_POT"), + POTTED_WITHER_ROSE(0, "FLOWER_POT"), + POWERED_RAIL(0, "POWERED_RAIL"), + PRISMARINE(0, "PRISMARINE"), + PRISMARINE_BRICKS(1, "PRISMARINE"), + PRISMARINE_BRICK_SLAB(0, "STONE"), + PRISMARINE_BRICK_STAIRS(0, "STONE"), + PRISMARINE_CRYSTALS(0, "PRISMARINE_CRYSTALS"), + PRISMARINE_SHARD(0, "PRISMARINE_SHARD"), + PRISMARINE_SLAB(0, "STONE"), + PRISMARINE_STAIRS(0, "STONE"), + PUFFERFISH(3, "RAW_FISH"), + PUFFERFISH_BUCKET(0, "STONE"), + PUFFERFISH_SPAWN_EGG(0, "MONSTER_EGG"), + PUMPKIN(0, "PUMPKIN"), + PUMPKIN_PIE(0, "PUMPKIN_PIE"), + PUMPKIN_SEEDS(0, "PUMPKIN_SEEDS"), + PUMPKIN_STEM(0, "PUMPKIN_STEM"), + PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"), + PURPLE_BED(10, "BED", "BED_BLOCK"), + PURPLE_CARPET(10, "CARPET"), + PURPLE_CONCRETE(10, "CONCRETE"), + PURPLE_CONCRETE_POWDER(10, "CONCRETE_POWDER"), + PURPLE_DYE(5, "INK_SACK"), + PURPLE_GLAZED_TERRACOTTA(0, "PURPLE_GLAZED_TERRACOTTA"), + PURPLE_SHULKER_BOX(0, "PURPLE_SHULKER_BOX"), + PURPLE_STAINED_GLASS(10, "STAINED_GLASS"), + PURPLE_STAINED_GLASS_PANE(10, "STAINED_GLASS_PANE"), + PURPLE_TERRACOTTA(10, "STAINED_CLAY"), + PURPLE_WALL_BANNER(0, "WALL_BANNER"), + PURPLE_WOOL(10, "WOOL"), + PURPUR_BLOCK(0, "PURPUR_BLOCK"), + PURPUR_PILLAR(0, "PURPUR_PILLAR"), + PURPUR_SLAB(0, "PURPUR_SLAB", "PURPUR_DOUBLE_SLAB"), + PURPUR_STAIRS(0, "PURPUR_STAIRS"), + QUARTZ(0, "QUARTZ"), + QUARTZ_BLOCK(0, "QUARTZ_BLOCK"), + QUARTZ_PILLAR(2, "QUARTZ_BLOCK"), + QUARTZ_SLAB(7, "STEP"), + QUARTZ_STAIRS(0, "QUARTZ_STAIRS"), + RABBIT(0, "RABBIT"), + RABBIT_FOOT(0, "RABBIT_FOOT"), + RABBIT_HIDE(0, "RABBIT_HIDE"), + RABBIT_SPAWN_EGG(101, "MONSTER_EGG"), + RABBIT_STEW(0, "RABBIT_STEW"), + RAIL(0, "RAILS"), + RAVAGER_SPAWN_EGG(0, "RAVAGER_SPAWN_EGG"), + REDSTONE(0, "REDSTONE"), + REDSTONE_BLOCK(0, "REDSTONE_BLOCK"), + REDSTONE_LAMP(0, "REDSTONE_LAMP_ON", "REDSTONE_LAMP_OFF"), + REDSTONE_ORE(0, "REDSTONE_ORE", "GLOWING_REDSTONE_ORE"), + REDSTONE_TORCH(0, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"), + REDSTONE_WALL_TORCH(1, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"), + REDSTONE_WIRE(0, "REDSTONE_WIRE"), + RED_BANNER(1, "BANNER", "STANDING_BANNER"), + RED_BED(14, "BED", "BED_BLOCK"), + RED_CARPET(14, "CARPET"), + RED_CONCRETE(14, "CONCRETE"), + RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"), + RED_GLAZED_TERRACOTTA(0, "RED_GLAZED_TERRACOTTA"), + RED_MUSHROOM(0, "RED_MUSHROOM"), + RED_MUSHROOM_BLOCK(0, "RED_MUSHROOM", "HUGE_MUSHROOM_2"), + RED_NETHER_BRICKS(0, "RED_NETHER_BRICK"), + RED_NEHTER_BRICK_SLAB(0, "RED_NEHTER_BRICK_SLAB"), + RED_NEHTER_BRICK_STAIRS(0, "RED_NEHTER_BRICK_STAIRS"), + RED_NEHTER_BRICK_WALL(0, "RED_NEHTER_BRICK_WALL"), + RED_SAND(1, "SAND"), + RED_SANDSTONE(0, "RED_SANDSTONE"), + RED_SANDSTONE_SLAB(0, "STONE_SLAB2", "DOUBLE_STONE_SLAB2"), + RED_SANDSTONE_STAIRS(0, "RED_SANDSTONE_STAIRS"), + RED_SHULKER_BOX(0, "RED_SHULKER_BOX"), + RED_STAINED_GLASS(14, "STAINED_GLASS"), + RED_STAINED_GLASS_PANE(14, "STAINED_GLASS_PANE"), + RED_TERRACOTTA(14, "STAINED_CLAY"), + RED_TULIP(4, "RED_ROSE"), + RED_WALL_BANNER(0, "WALL_BANNER"), + RED_WOOL(14, "WOOL"), + REPEATER(0, "DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"), + REPEATING_COMMAND_BLOCK(0, "COMMAND_REPEATING"), + ROSE_BUSH(4, "DOUBLE_PLANT"), + ROSE_RED(1, "INK_SACK"), + ROTTEN_FLESH(0, "ROTTEN_FLESH"), + SADDLE(0, "SADDLE"), + SALMON(1, "RAW_FISH"), + SALMON_BUCKET(0, "BUCKET"), + SALMON_SPAWN_EGG(0, "MONSTER_EGG"), + SAND(0, "SAND"), + SANDSTONE(0, "SANDSTONE"), + SANDSTONE_SLAB(1, "STONE_SLAB", "STEP", "DOUBLE_STEP"), + SANDSTONE_STAIRS(0, "SANDSTONE_STAIRS"), + SCAFFOLDING(0, "SCAFFOLDING"), + SCUTE(0, "STONE"), + SEAGRASS(0, "STONE"), + SEA_LANTERN(0, "SEA_LANTERN"), + SEA_PICKLE(0, "STONE"), + SHEARS(0, "SHEARS"), + SHEEP_SPAWN_EGG(91, "MONSTER_EGG"), + SHIELD(0, "SHIELD"), + SHULKER_BOX(0, "PURPLE_SHULKER_BOX"), + SHULKER_SHELL(0, "SHULKER_SHELL"), + SHULKER_SPAWN_EGG(69, "MONSTER_EGG"), + // SIGN(0, "SIGN"), + SILVERFISH_SPAWN_EGG(60, "MONSTER_EGG"), + SKELETON_HORSE_SPAWN_EGG(28, "MONSTER_EGG"), + SKELETON_SKULL(0, "SKULL_ITEM","SKULL"), + SKELETON_SPAWN_EGG(51, "MONSTER_EGG"), + SKELETON_WALL_SKULL(0, "SKULL_ITEM","SKULL"), + SLIME_BALL(0, "SLIME_BALL"), + SLIME_BLOCK(0, "SLIME_BLOCK"), + SLIME_SPAWN_EGG(55, "MONSTER_EGG"), + SMOOTH_QUARTZ(0, "STONE"), + SMOOTH_QUARTZ_SLAB(0, "SMOOTH_QUARTZ_SLAB"), + SMOOTH_QUARTZ_STAIRS(0, "SMOOTH_QUARTZ_STAIRS"), + SMOOTH_RED_SANDSTONE(2, "RED_SANDSTONE"), + SMOOTH_RED_SANDSTONE_SLAB(0, "SMOOTH_RED_SANDSTONE_SLAB"), + SMOOTH_RED_SANDSTONE_STAIRS(0, "SMOOTH_RED_SANDSTONE_STAIRS"), + SMOOTH_SANDSTONE(2, "SANDSTONE"), + SMOOTH_SANDSTONE_SLAB(0, "SMOOTH_SANDSTONE_SLAB"), + SMOOTH_SANDSTONE_STAIRS(0, "SMOOTH_SANDSTONE_STAIRS"), + SMOOTH_STONE(0, "STEP"), + SNOW(0, "SNOW"), + SNOWBALL(0, "SNOW_BALL"), + SNOW_BLOCK(0, "SNOW_BLOCK"), + SOUL_SAND(0, "SOUL_SAND"), + SPAWNER(0, "MOB_SPAWNER"), + SPECTRAL_ARROW(0, "SPECTRAL_ARROW"), + SPIDER_EYE(0, "SPIDER_EYE"), + SPIDER_SPAWN_EGG(52, "MONSTER_EGG"), + SPLASH_POTION(0, "SPLASH_POTION"), + SPONGE(0, "SPONGE"), + SPRUCE_BOAT(0, "BOAT_SPRUCE"), + SPRUCE_BUTTON(0, "WOOD_BUTTON"), + SPRUCE_DOOR(0, "SPRUCE_DOOR", "SPRUCE_DOOR_ITEM"), + SPRUCE_FENCE(0, "SPRUCE_FENCE"), + SPRUCE_FENCE_GATE(0, "SPRUCE_FENCE_GATE"), + SPRUCE_LEAVES(1, "LEAVES"), + SPRUCE_LOG(1, "LOG"), + SPRUCE_PLANKS(1, "WOOD"), + SPRUCE_PRESSURE_PLATE(0, "WOOD_PLATE"), + SPRUCE_SAPLING(1, "SAPLING"), + SPRUCE_SIGN(0, "SIGN"), + SPRUCE_SLAB(1,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + SPRUCE_STAIRS(0, "SPRUCE_WOOD_STAIRS"), + SPRUCE_TRAPDOOR(0, "TRAP_DOOR"), + SPRUCE_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + SPRUCE_WOOD(1, "LOG"), + SQUID_SPAWN_EGG(94, "MONSTER_EGG"), + STICK(0, "STICK"), + STICKY_PISTON(0, "PISTON_STICKY_BASE"), + STONE(0, "STONE"), + STONE_AXE(0, "STONE_AXE"), + STONE_BRICKS(0, "SMOOTH_BRICK"), + STONE_BRICK_SLAB(5, "STONE_SLAB", "STEP", "DOUBLE_STEP"), + STONE_BRICK_STAIRS(0, "SMOOTH_STAIRS"), + STONE_BUTTON(0, "STONE_BUTTON"), + STONE_HOE(0, "STONE_HOE"), + STONE_PICKAXE(0, "STONE_PICKAXE"), + STONE_PRESSURE_PLATE(0, "STONE_PLATE"), + STONE_SHOVEL(0, "STONE_SPADE"), + STONE_SLAB(0, "STONE_SLAB", "STEP", "DOUBLE_STEP"), + STONE_SWORD(0, "STONE_SWORD"), + STONECUTTER(0, "STONECUTTER"), + STRAY_SPAWN_EGG(6, "MONSTER_EGG"), + STRING(0, "STRING"), + STRIPPED_ACACIA_LOG(0, "STONE"), + STRIPPED_ACACIA_WOOD(0, "STONE"), + STRIPPED_BIRCH_LOG(0, "STONE"), + STRIPPED_BIRCH_WOOD(0, "STONE"), + STRIPPED_DARK_OAK_LOG(0, "STONE"), + STRIPPED_DARK_OAK_WOOD(0, "STONE"), + STRIPPED_JUNGLE_LOG(0, "STONE"), + STRIPPED_JUNGLE_WOOD(0, "STONE"), + STRIPPED_OAK_LOG(0, "STONE"), + STRIPPED_OAK_WOOD(0, "STONE"), + STRIPPED_SPRUCE_LOG(0, "STONE"), + STRIPPED_SPRUCE_WOOD(0, "STONE"), + STRUCTURE_BLOCK(0, "STRUCTURE_BLOCK"), + STRUCTURE_VOID(0, "STRUCTURE_VOID"), + SUGAR(0, "SUGAR"), + SUGAR_CANE(0, "SUGAR_CANE", "SUGAR_CANE_BLOCK"), + SUSPICIOUS_STEW(0, "SUSPICIOUS_STEW"), + SUNFLOWER(0, "DOUBLE_PLANT"), + SWEET_BERRIES(0, "SWEET_BERRIES"), + SWEET_BERRY_BUSH(0, "SWEET_BERRY_BUSH"), + TALL_GRASS(2, "DOUBLE_PLANT"), + TALL_SEAGRASS(0, "STONE"), + TERRACOTTA(0, "HARD_CLAY"), + TIPPED_ARROW(0, "TIPPED_ARROW"), + TNT(0, "TNT"), + TNT_MINECART(0, "EXPLOSIVE_MINECART"), + TORCH(0, "TORCH"), + TOTEM_OF_UNDYING(0, "TOTEM"), + TRADER_LLAMA_SPAWN_EGG(0, "TRADER_LLAMA_SPAWN_EGG"), + TRAPPED_CHEST(0, "TRAPPED_CHEST"), + TRIDENT(0, "STONE"), + TRIPWIRE(0, "TRIPWIRE"), + TRIPWIRE_HOOK(0, "TRIPWIRE_HOOK"), + TROPICAL_FISH(0, "RAW_FISH"), + TROPICAL_FISH_BUCKET(0, "BUCKET"), + TROPICAL_FISH_SPAWN_EGG(0, "MONSTER_EGG"), + TUBE_CORAL(0, "STONE"), + TUBE_CORAL_BLOCK(0, "STONE"), + TUBE_CORAL_FAN(0, "STONE"), + TURTLE_EGG(0, "MONSTER_EGG"), + TURTLE_HELMET(0, "STONE"), + TURTLE_SPAWN_EGG(0, "MONSTER_EGG"), + VEX_SPAWN_EGG(35, "MONSTER_EGG"), + VILLAGER_SPAWN_EGG(120, "MONSTER_EGG"), + VINDICATOR_SPAWN_EGG(36, "MONSTER_EGG"), + VINE(0, "VINE"), + VOID_AIR(0, "AIR"), + // WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + WALL_TORCH(1, "TORCH"), + WANDERING_TRADER_LLAMA_SPAWN_EGG(0, "WANDERING_TRADER_LLAMA_SPAWN_EGG"), + WANDERING_TRADER_SPAWN_EGG(0, "WANDERING_TRADER_SPAWN_EGG"), + WATER(0, "WATER", "STATIONARY_WATER"), + WATER_BUCKET(0, "WATER_BUCKET"), + WET_SPONGE(1, "SPONGE"), + WHEAT(0, "WHEAT", "CROPS"), + WHEAT_SEEDS(0, "WHEAT_SEEDS", "SEEDS"), + WHITE_BANNER(15, "BANNER", "STANDING_BANNER"), + WHITE_BED(0, "BED", "BED_BLOCK"), + WHITE_CARPET(0, "CARPET"), + WHITE_CONCRETE(0, "CONCRETE"), + WHITE_CONCRETE_POWDER(0, "CONCRETE_POWDER"), + WHITE_DYE(0, "BONE_MEAL"), + WHITE_GLAZED_TERRACOTTA(0, "WHITE_GLAZED_TERRACOTTA"), + WHITE_SHULKER_BOX(0, "WHITE_SHULKER_BOX"), + WHITE_STAINED_GLASS(0, "STAINED_GLASS"), + WHITE_STAINED_GLASS_PANE(0, "STAINED_GLASS_PANE"), + WHITE_TERRACOTTA(0, "TERRACOTTA"), + WHITE_TULIP(6, "RED_ROSE"), + WHITE_WALL_BANNER(0, "WALL_BANNER"), + WHITE_WOOL(0, "WOOL"), + WITHER_ROSE(0, "WITHER_ROSE"), + WITCH_SPAWN_EGG(66, "MONSTER_EGG"), + WITHER_SKELETON_SKULL(1, "SKULL_ITEM","SKULL"), + WITHER_SKELETON_SPAWN_EGG(5, "MONSTER_EGG"), + WITHER_SKELETON_WALL_SKULL(1, "SKULL_ITEM","SKULL"), + WOLF_SPAWN_EGG(95, "MONSTER_EGG"), + WOODEN_AXE(0, "WOOD_AXE"), + WOODEN_HOE(0, "WOOD_HOE"), + WOODEN_PICKAXE(0, "WOOD_PICKAXE"), + WOODEN_SHOVEL(0, "WOOD_SPADE"), + WOODEN_SWORD(0, "WOOD_SWORD"), + WRITABLE_BOOK(0, "BOOK_AND_QUILL"), + WRITTEN_BOOK(0, "WRITTEN_BOOK"), + YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"), + YELLOW_BED(4, "BED", "BED_BLOCK"), + YELLOW_CARPET(4, "CARPET"), + YELLOW_CONCRETE(4, "CONCRETE"), + YELLOW_CONCRETE_POWDER(4, "CONCRETE_POWDER"), + YELLOW_GLAZED_TERRACOTTA(0, "YELLOW_GLAZED_TERRACOTTA"), + YELLOW_SHULKER_BOX(0, "YELLOW_SHULKER_BOX"), + YELLOW_STAINED_GLASS(4, "STAINED_GLASS"), + YELLOW_STAINED_GLASS_PANE(4, "STAINED_GLASS_PANE"), + YELLOW_TERRACOTTA(4, "STAINED_CLAY"), + YELLOW_WALL_BANNER(0, "WALL_BANNER"), + YELLOW_WOOL(4, "WOOL"), + ZOMBIE_HEAD(2, "SKULL_ITEM","SKULL"), + ZOMBIE_HORSE_SPAWN_EGG(29, "MONSTER_EGG"), + ZOMBIE_PIGMAN_SPAWN_EGG(57, "MONSTER_EGG"), + ZOMBIE_SPAWN_EGG(2, "MONSTER_EGG"), + ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"), + ZOMBIE_WALL_HEAD(2, "SKULL_ITEM","SKULL"); + + private static Map cachedSearch = new HashMap<>(); + + private String[] materials; + private int data; + private Material cached = null; + + BukkitCompatMaterial(int data, String... materials) { + this.materials = materials; + this.data = data; + } + + public String[] getMaterials() { + return materials; + } + + public int getData() { + return data; + } + + public ItemStack parseItem() { + Material mat = parseMaterial(); + if (isNewVersion()) + return new ItemStack(mat); + + // noinspection deprecation + return new ItemStack(mat, 1, (byte) data); + } + + public boolean isDamageable(BukkitCompatMaterial type){ + if (type == null) + return false; + + String[] split = type.toString().split("_"); + int length = split.length; + switch (split[length - 1]) { + case "HELMET": + case "CHESTPLATE": + case "LEGGINGS": + case "BOOTS": + case "SWORD": + case "AXE": + case "PICKAXE": + case "SHOVEL": + case "HOE": + case "ELYTRA": + case "TURTLE_HELMET": + case "TRIDENT": + case "HORSE_ARMOR": + case "SHEARS": + return true; + } + + return false; + } + + public Material parseMaterial() { + if (cached != null) + return cached; + + Material mat = Material.matchMaterial(this.toString()); + if (mat != null) + return cached = mat; + + return cached = Material.matchMaterial(materials[0]); + } + + public boolean isSameMaterial(ItemStack comp){ + if (isNewVersion()) + return comp.getType() == this.parseMaterial(); + + if (comp.getType() == this.parseMaterial() && comp.getDurability() == (short) this.data) + return true; + + BukkitCompatMaterial mat = fromMaterial(comp.getType()); + return isDamageable(mat) && this.parseMaterial() == comp.getType(); + } + + public static BukkitCompatMaterial fromMaterial(Material mat) { + try { + return BukkitCompatMaterial.valueOf(mat.toString()); + } catch (IllegalArgumentException ex) { + for (BukkitCompatMaterial bukkitMat : BukkitCompatMaterial.values()) { + for (String test : bukkitMat.materials) { + if (test.equalsIgnoreCase(mat.toString())) + return bukkitMat; + } + } + } + + // in theory, we should never get here + throw new IllegalArgumentException("Could not find Bukkit Compat material from " + mat); + } + + public static Optional fromString(String key) { + String matKey = key.replace("minecraft:", "").toUpperCase(); + BukkitCompatMaterial mat; + + try { + mat = BukkitCompatMaterial.valueOf(matKey); + return Optional.of(mat); + } catch (IllegalArgumentException ex) { + String[] split = matKey.split(":"); + if (split.length == 1) + mat = requestBukkitMaterial(matKey, 0).orElse(null); + else + mat = requestBukkitMaterial(split[0], Integer.parseInt(split[1])).orElse(null); + + return Optional.ofNullable(mat); + } + } + + public static Optional requestBukkitMaterial(String name, int data) { + if (cachedSearch.containsKey(name.toUpperCase() + "," + data)) + return Optional.of(cachedSearch.get(name.toUpperCase() + "," + data)); + + for (BukkitCompatMaterial mat : BukkitCompatMaterial.values()) { + for (String test : mat.materials) { + if (name.toUpperCase().equals(test) && mat.data == data) { + cachedSearch.put(test + "," + data, mat); + return Optional.of(mat); + } + } + } + + return Optional.empty(); + } + + public static boolean isNewVersion() { + return Material.getMaterial("RED_WOOL") != null; + } +} \ No newline at end of file diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/BukkitEntity.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/BukkitEntity.java index 442a878..f1c072b 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/BukkitEntity.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/BukkitEntity.java @@ -3,6 +3,7 @@ import org.battleplugins.bukkit.world.BukkitLocation; import org.battleplugins.bukkit.world.BukkitWorld; import org.battleplugins.util.MCWrapper; +import org.battleplugins.util.NamespacedKey; import org.battleplugins.world.Location; import org.bukkit.entity.Entity; @@ -22,6 +23,11 @@ public String getName() { return handle.getName(); } + @Override + public NamespacedKey getKey() { + return NamespacedKey.minecraft(handle.getType().getName()); + } + @Override public UUID getUniqueId() { return handle.getUniqueId(); @@ -56,7 +62,7 @@ public boolean isValid() { public List getNearbyEntities(double x, double y, double z) { List entities = new ArrayList<>(); for (org.bukkit.entity.Entity entity : handle.getNearbyEntities(x, y, z)) { - entities.add(new BukkitEntity(entity)); + entities.add(new BukkitEntity<>(entity)); } return entities; } diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/BukkitHumanEntity.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/BukkitHumanEntity.java index 782f1f9..c977cb8 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/BukkitHumanEntity.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/BukkitHumanEntity.java @@ -11,7 +11,7 @@ public BukkitHumanEntity(T humanEntity) { @Override public BukkitPlayerInventory getInventory() { - return new BukkitPlayerInventory(handle.getInventory()); + return new BukkitPlayerInventory(this, handle.getInventory()); } @Override diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/player/BukkitOfflinePlayer.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/player/BukkitOfflinePlayer.java index edbd7f4..89e34a2 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/player/BukkitOfflinePlayer.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/player/BukkitOfflinePlayer.java @@ -5,6 +5,7 @@ import org.bukkit.OfflinePlayer; import java.util.Optional; +import java.util.OptionalLong; import java.util.UUID; public class BukkitOfflinePlayer extends MCWrapper implements org.battleplugins.entity.living.player.OfflinePlayer { @@ -34,13 +35,13 @@ public Optional getPlayer() { } @Override - public long getFirstPlayed() { - return handle.getFirstPlayed(); + public OptionalLong getFirstPlayed() { + return OptionalLong.of(handle.getFirstPlayed()); } @Override - public long getLastPlayed() { - return handle.getLastPlayed(); + public OptionalLong getLastPlayed() { + return OptionalLong.of(handle.getLastPlayed()); } @Override diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/player/BukkitPlayer.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/player/BukkitPlayer.java index dc65eda..c3d7035 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/player/BukkitPlayer.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/entity/living/player/BukkitPlayer.java @@ -4,11 +4,13 @@ import org.battleplugins.bukkit.entity.living.BukkitHumanEntity; import org.battleplugins.bukkit.inventory.BukkitInventory; -import org.battleplugins.entity.living.player.GameMode; +import org.battleplugins.entity.living.player.gamemode.GameMode; +import org.battleplugins.entity.living.player.gamemode.GameModes; import org.battleplugins.inventory.Inventory; import org.bukkit.entity.Player; import java.util.Optional; +import java.util.OptionalLong; public class BukkitPlayer extends BukkitHumanEntity implements org.battleplugins.entity.living.player.Player { @@ -25,13 +27,13 @@ public Optional getPlayer() { } @Override - public long getFirstPlayed() { - return handle.getFirstPlayed(); + public OptionalLong getFirstPlayed() { + return OptionalLong.of(handle.getFirstPlayed()); } @Override - public long getLastPlayed() { - return handle.getLastPlayed(); + public OptionalLong getLastPlayed() { + return OptionalLong.of(handle.getLastPlayed()); } @Override @@ -81,11 +83,11 @@ public boolean isOnline() { @Override public GameMode getGameMode() { - return GameMode.values()[handle.getGameMode().ordinal()]; + return GameModes.values()[handle.getGameMode().ordinal()]; } @Override public void setGameMode(GameMode gameMode) { - handle.setGameMode(org.bukkit.GameMode.values()[gameMode.ordinal()]); + handle.setGameMode(org.bukkit.GameMode.values()[gameMode.getId()]); } } diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/BukkitCarriedInventory.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/BukkitCarriedInventory.java new file mode 100644 index 0000000..edbc335 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/BukkitCarriedInventory.java @@ -0,0 +1,21 @@ +package org.battleplugins.bukkit.inventory; + +import org.battleplugins.inventory.CarriedInventory; +import org.battleplugins.inventory.carrier.Carrier; +import org.bukkit.inventory.Inventory; + +public class BukkitCarriedInventory extends BukkitInventory implements CarriedInventory { + + private C carrier; + + public BukkitCarriedInventory(T inventory, C carrier) { + super(inventory); + + this.carrier = carrier; + } + + @Override + public C getCarrier() { + return carrier; + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/BukkitInventory.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/BukkitInventory.java index 7dc5692..1fe7e8a 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/BukkitInventory.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/BukkitInventory.java @@ -16,22 +16,17 @@ public BukkitInventory(T inventory) { } @Override - public void addItem(ItemStack... itemStacks) { - for (ItemStack item : itemStacks) - addItem(item); - } - public void addItem(ItemStack itemStack) { - if (itemStack == null || itemStack.getType().equals(Material.AIR.name())) { + if (itemStack == null || itemStack.getType().getKey().getKey().equalsIgnoreCase(Material.AIR.name())) { return; } - BukkitInventoryUtil.addItemToInventory(handle, ((BukkitItemStack) itemStack).getHandle(), itemStack.getQuantity()); + handle.addItem(((BukkitItemStack) itemStack).getHandle()); } @Override public void removeItem(ItemStack itemStack) { - BukkitInventoryUtil.removeItem(handle, ((BukkitItemStack) itemStack).getHandle()) ; + handle.removeItem(((BukkitItemStack) itemStack).getHandle()); } @Override @@ -50,13 +45,6 @@ public int getItemAmount(ItemStack itemStack) { ((BukkitItemStack) itemStack).getHandle()); } - @Override - public boolean canFit(ItemStack itemStack) { - int space = BukkitInventoryUtil.amountFreeSpace(handle, - ((BukkitItemStack) itemStack).getHandle(), itemStack.getQuantity()); - return space >= 0; - } - @Override public int freeSpaceAfter(ItemStack itemStack) { return BukkitInventoryUtil.amountFreeSpace(handle, diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/BukkitInventoryBuilder.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/BukkitInventoryBuilder.java new file mode 100644 index 0000000..f576cf4 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/BukkitInventoryBuilder.java @@ -0,0 +1,63 @@ +package org.battleplugins.bukkit.inventory; + +import org.battleplugins.inventory.Inventory; +import org.battleplugins.inventory.item.ItemStack; +import org.bukkit.Bukkit; + +public class BukkitInventoryBuilder implements Inventory.Builder { + + private String name; + private int size; + private ItemStack[] contents = new ItemStack[54]; + + @Override + public BukkitInventoryBuilder fromInventory(Inventory inventory, String name) { + this.name = name; + this.size = ((BukkitInventory) inventory).getHandle().getSize(); + this.contents = inventory.getContents(); + return this; + } + + @Override + public BukkitInventoryBuilder name(String name) { + this.name = name; + return this; + } + + @Override + public BukkitInventoryBuilder size(int size) { + this.size = size; + if (this.contents.length > size) { + throw new IllegalArgumentException("Current inventory contents are larger than the set inventory size!"); + } + + ItemStack[] contents = this.contents.clone(); + System.arraycopy(contents, 0, this.contents, 0, contents.length); + return this; + } + + @Override + public BukkitInventoryBuilder item(int slot, ItemStack item) { + if (slot > size) { + throw new IllegalArgumentException("Slot is greater than the inventory size!"); + } + this.contents[slot] = item; + return this; + } + + @Override + public BukkitInventoryBuilder contents(ItemStack[] contents) { + if (contents.length > size) { + throw new IllegalArgumentException("Given contents are larger than the inventory size!"); + } + this.contents = contents; + return null; + } + + @Override + public BukkitInventory build() { + BukkitInventory inventory = new BukkitInventory<>(Bukkit.createInventory(null, size, name)); + inventory.setContents(this.contents); + return inventory; + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/entity/BukkitPlayerInventory.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/entity/BukkitPlayerInventory.java index cefc85f..745a8f5 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/entity/BukkitPlayerInventory.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/entity/BukkitPlayerInventory.java @@ -2,17 +2,20 @@ import org.battleplugins.bukkit.inventory.BukkitInventory; import org.battleplugins.bukkit.inventory.item.BukkitItemStack; +import org.battleplugins.entity.living.HumanEntity; import org.bukkit.inventory.PlayerInventory; import java.util.Optional; public class BukkitPlayerInventory extends BukkitInventory implements org.battleplugins.inventory.entity.PlayerInventory { + private HumanEntity carrier; private PlayerInventory inventory; - public BukkitPlayerInventory(PlayerInventory inventory) { + public BukkitPlayerInventory(HumanEntity carrier, PlayerInventory inventory) { super(inventory); + this.carrier = carrier; this.inventory = inventory; } @@ -51,4 +54,9 @@ public Optional getLeggings() { public Optional getBoots() { return Optional.ofNullable(inventory.getBoots()).map(BukkitItemStack::new); } + + @Override + public HumanEntity getCarrier() { + return carrier; + } } diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemMeta.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemMeta.java deleted file mode 100644 index 2621c15..0000000 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemMeta.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.battleplugins.bukkit.inventory.item; - -import org.battleplugins.util.MCWrapper; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.List; -import java.util.Optional; - -public class BukkitItemMeta extends MCWrapper implements org.battleplugins.inventory.item.ItemMeta { - - private ItemStack itemStack; - - public BukkitItemMeta(ItemStack itemStack, ItemMeta handle) { - super(handle); - - this.itemStack = itemStack; - } - - @Override - public Optional getDisplayName() { - return Optional.ofNullable(handle.getDisplayName()); - } - - @Override - public void setDisplayName(String displayName) { - handle.setDisplayName(displayName); - itemStack.setItemMeta(handle); - } - - @Override - public Optional> getLore() { - return Optional.ofNullable(handle.getLore()); - } - - @Override - public void setLore(List lore) { - handle.setLore(lore); - itemStack.setItemMeta(handle); - } - - @Override - public int getCustomModelData() { - return handle.getCustomModelData(); - } - - @Override - public void setCustomModelData(int modelData) { - handle.setCustomModelData(modelData); - itemStack.setItemMeta(handle); - } - - @Override - public boolean isUnbreakable() { - return handle.isUnbreakable(); - } - - @Override - public void setUnbreakable(boolean unbreakable) { - handle.setUnbreakable(unbreakable); - itemStack.setItemMeta(handle); - } -} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemRegistry.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemRegistry.java new file mode 100644 index 0000000..97a0a60 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemRegistry.java @@ -0,0 +1,22 @@ +package org.battleplugins.bukkit.inventory.item; + +import org.battleplugins.bukkit.util.BukkitMaterialAdapter; +import org.battleplugins.inventory.item.ItemRegistry; +import org.battleplugins.inventory.item.ItemType; +import org.battleplugins.util.NamespacedKey; +import org.bukkit.Material; + +import java.util.Optional; + +public class BukkitItemRegistry implements ItemRegistry { + + @Override + public ItemType fromPlatformItem(Material material) { + return new BukkitItemType(material); + } + + @Override + public Optional fromKey(NamespacedKey namespacedKey) { + return BukkitMaterialAdapter.getMaterial(namespacedKey.getKey()).map(this::fromPlatformItem); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemStack.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemStack.java index 427a48f..8971d8a 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemStack.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemStack.java @@ -3,10 +3,9 @@ import java.util.HashMap; import java.util.Map; -import mc.euro.bukkitadapter.enchant.BattleEnchant; -import mc.euro.bukkitadapter.material.BattleMaterial; - -import org.battleplugins.bukkit.util.BukkitInventoryUtil; +import org.battleplugins.bukkit.util.BukkitMaterialAdapter; +import org.battleplugins.inventory.item.ItemRegistry; +import org.battleplugins.inventory.item.ItemType; import org.battleplugins.util.MCWrapper; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -19,23 +18,13 @@ public BukkitItemStack(ItemStack itemStack) { } @Override - public void setType(String type) { - handle.setType(BattleMaterial.fromString(type).parseMaterial()); - } - - @Override - public String getType() { - return handle.getType().name(); + public void setType(ItemType type) { + handle.setType(BukkitMaterialAdapter.getMaterial(type.getIdentifier()).orElse(Material.AIR)); } @Override - public void setDataValue(short value) { - handle.setDurability(value); - } - - @Override - public short getDataValue() { - return handle.getDurability(); + public ItemType getType() { + return ((BukkitItemRegistry) ItemRegistry.REGISTRY).fromPlatformItem(handle.getType()); } @Override @@ -56,54 +45,13 @@ public Map getEnchantments() { } return encs; } - @Override - public String getCommonName() { - return handle.getType().name().toLowerCase(); - } - - @Override - public String getFormattedCommonName() { - return BukkitInventoryUtil.getFormattedCommonName(handle); + public void addEnchantment(String ench, int level) { + handle.addEnchantment(Enchantment.getByName(ench), level); } @Override public BukkitItemStack clone(){ return new BukkitItemStack(handle.clone()); } - - @Override - public String toString(){ - return handle != null ? "["+ handle.getType() +":"+handle.getDurability() + " q="+ - getQuantity()+"]" : "null"; - } - - @Override - public void addEnchantment(String ench, int level) { - handle.addEnchantment(BattleEnchant.fromString(ench).parseEnchant(), level); - } - - @Override - public int isSpecial() { - int special = 0; -// ItemMeta im = itemStack.getItemMeta(); -// Map map = itemStack.getEnchantments(); -// if (map != null){ -// for (Entry entry : map.entrySet()){ -//// entry.getKey().getId() -// } -// } - - return special; - } - - @Override - public boolean hasItemMeta() { - return handle.getItemMeta() != null; - } - - @Override - public BukkitItemMeta getItemMeta() { - return new BukkitItemMeta(handle, handle.getItemMeta()); - } } diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemType.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemType.java new file mode 100644 index 0000000..3c7bed7 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/BukkitItemType.java @@ -0,0 +1,25 @@ +package org.battleplugins.bukkit.inventory.item; + +import org.battleplugins.bukkit.compat.BukkitCompatMaterial; +import org.battleplugins.inventory.item.ItemType; +import org.battleplugins.util.MCWrapper; +import org.battleplugins.util.NamespacedKey; +import org.bukkit.Material; + +public class BukkitItemType extends MCWrapper implements ItemType { + + protected BukkitItemType(Material handle) { + super(handle); + } + + @Override + public NamespacedKey getKey() { + BukkitCompatMaterial bukkitMaterial = BukkitCompatMaterial.fromMaterial(handle); + return NamespacedKey.minecraft(bukkitMaterial.name().toLowerCase()); + } + + @Override + public int getMaximumStackSize() { + return handle.getMaxStackSize(); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitColorComponent.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitColorComponent.java new file mode 100644 index 0000000..14e5114 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitColorComponent.java @@ -0,0 +1,53 @@ +package org.battleplugins.bukkit.inventory.item.component; + +import org.battleplugins.bukkit.inventory.item.BukkitItemStack; +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.ColorComponent; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.inventory.meta.PotionMeta; + +import java.awt.Color; +import java.util.Optional; + +public class BukkitColorComponent implements ColorComponent { + + @Override + public void applyComponent(ItemStack itemStack, Color color) { + org.bukkit.inventory.ItemStack bukkitItemStack = ((BukkitItemStack) itemStack).getHandle(); + if (bukkitItemStack.getItemMeta() instanceof LeatherArmorMeta) { + LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) bukkitItemStack.getItemMeta(); + leatherArmorMeta.setColor(org.bukkit.Color.fromRGB(color.getRGB())); + bukkitItemStack.setItemMeta(leatherArmorMeta); + } + + try { + if (bukkitItemStack.getItemMeta() instanceof PotionMeta) { + PotionMeta potionMeta = (PotionMeta) bukkitItemStack.getItemMeta(); + potionMeta.setColor(org.bukkit.Color.fromRGB(color.getRGB())); + bukkitItemStack.setItemMeta(potionMeta); + } + } catch (Throwable ex) { + // May not be supported in this version + } + } + + @Override + public Optional getValue(ItemStack itemStack) { + org.bukkit.inventory.ItemStack bukkitItemStack = ((BukkitItemStack) itemStack).getHandle(); + if (bukkitItemStack.getItemMeta() instanceof LeatherArmorMeta) { + org.bukkit.Color color = ((LeatherArmorMeta) bukkitItemStack.getItemMeta()).getColor(); + return Optional.of(new Color(color.getRed(), color.getBlue(), color.getGreen())); + } + + try { + if (bukkitItemStack.getItemMeta() instanceof PotionMeta) { + org.bukkit.Color color = ((PotionMeta) bukkitItemStack.getItemMeta()).getColor(); + return Optional.of(new Color(color.getRed(), color.getBlue(), color.getGreen())); + } + } catch (Throwable ex) { + // May not be supported in this version + } + + return Optional.empty(); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitCustomModelDataComponent.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitCustomModelDataComponent.java new file mode 100644 index 0000000..0809ff6 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitCustomModelDataComponent.java @@ -0,0 +1,34 @@ +package org.battleplugins.bukkit.inventory.item.component; + +import org.battleplugins.bukkit.inventory.item.BukkitItemStack; +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.CustomModelDataComponent; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.Optional; + +public class BukkitCustomModelDataComponent implements CustomModelDataComponent { + + @Override + public void applyComponent(ItemStack itemStack, Integer modelData) { + org.bukkit.inventory.ItemStack bukkitItemStack = ((BukkitItemStack) itemStack).getHandle(); + ItemMeta itemMeta = bukkitItemStack.getItemMeta(); + try { + itemMeta.setCustomModelData(modelData); + } catch (Throwable ex) { + // May not be supported in this version + } + bukkitItemStack.setItemMeta(itemMeta); + } + + @Override + public Optional getValue(ItemStack itemStack) { + try { + return Optional.of(((BukkitItemStack) itemStack).getHandle().getItemMeta().getCustomModelData()); + } catch (Throwable ex) { + // May not be supported in this version + } + + return Optional.empty(); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitDamageComponent.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitDamageComponent.java new file mode 100644 index 0000000..c0ddecb --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitDamageComponent.java @@ -0,0 +1,20 @@ +package org.battleplugins.bukkit.inventory.item.component; + +import org.battleplugins.bukkit.inventory.item.BukkitItemStack; +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.DamageComponent; + +import java.util.Optional; + +public class BukkitDamageComponent implements DamageComponent { + + @Override + public void applyComponent(ItemStack itemStack, Short durability) { + ((BukkitItemStack) itemStack).getHandle().setDurability(durability); + } + + @Override + public Optional getValue(ItemStack itemStack) { + return Optional.of(((BukkitItemStack) itemStack).getHandle().getDurability()); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitDisplayNameComponent.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitDisplayNameComponent.java new file mode 100644 index 0000000..8e560ce --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitDisplayNameComponent.java @@ -0,0 +1,24 @@ +package org.battleplugins.bukkit.inventory.item.component; + +import org.battleplugins.bukkit.inventory.item.BukkitItemStack; +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.DisplayNameComponent; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.Optional; + +public class BukkitDisplayNameComponent implements DisplayNameComponent { + + @Override + public void applyComponent(ItemStack itemStack, String displayName) { + org.bukkit.inventory.ItemStack bukkitItemStack = ((BukkitItemStack) itemStack).getHandle(); + ItemMeta itemMeta = bukkitItemStack.getItemMeta(); + itemMeta.setDisplayName(displayName); + bukkitItemStack.setItemMeta(itemMeta); + } + + @Override + public Optional getValue(ItemStack itemStack) { + return Optional.ofNullable(((BukkitItemStack) itemStack).getHandle().getItemMeta().getDisplayName()); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitItemFlagComponent.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitItemFlagComponent.java new file mode 100644 index 0000000..dedc7f9 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitItemFlagComponent.java @@ -0,0 +1,40 @@ +package org.battleplugins.bukkit.inventory.item.component; + +import org.battleplugins.bukkit.inventory.item.BukkitItemStack; +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.ItemFlagComponent; +import org.battleplugins.inventory.item.component.flag.ItemFlag; +import org.battleplugins.inventory.item.component.flag.ItemFlags; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.HashSet; +import java.util.Optional; +import java.util.Set; + +public class BukkitItemFlagComponent implements ItemFlagComponent { + + @Override + public void applyComponent(ItemStack itemStack, Set itemFlags) { + org.bukkit.inventory.ItemStack bukkitItemStack = ((BukkitItemStack) itemStack).getHandle(); + ItemMeta itemMeta = bukkitItemStack.getItemMeta(); + for (ItemFlag itemFlag : itemFlags) { + itemMeta.addItemFlags(org.bukkit.inventory.ItemFlag.valueOf(itemFlag.getName().toUpperCase())); + } + bukkitItemStack.setItemMeta(itemMeta); + } + + @Override + public Optional> getValue(ItemStack itemStack) { + org.bukkit.inventory.ItemStack bukkitItemStack = ((BukkitItemStack) itemStack).getHandle(); + Set itemFlags = new HashSet<>(); + for (ItemFlag itemFlag : ItemFlags.values()) { + for (org.bukkit.inventory.ItemFlag bukkitItemFlag : bukkitItemStack.getItemMeta().getItemFlags()) { + if (bukkitItemFlag.name().equalsIgnoreCase(itemFlag.getName())) { + itemFlags.add(itemFlag); + } + } + } + + return itemFlags.isEmpty() ? Optional.empty() : Optional.of(itemFlags); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitLoreComponent.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitLoreComponent.java new file mode 100644 index 0000000..5b9a552 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitLoreComponent.java @@ -0,0 +1,25 @@ +package org.battleplugins.bukkit.inventory.item.component; + +import org.battleplugins.bukkit.inventory.item.BukkitItemStack; +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.LoreComponent; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Optional; + +public class BukkitLoreComponent implements LoreComponent { + + @Override + public void applyComponent(ItemStack itemStack, List lore) { + org.bukkit.inventory.ItemStack bukkitItemStack = ((BukkitItemStack) itemStack).getHandle(); + ItemMeta itemMeta = bukkitItemStack.getItemMeta(); + itemMeta.setLore(lore); + bukkitItemStack.setItemMeta(itemMeta); + } + + @Override + public Optional> getValue(ItemStack itemStack) { + return Optional.ofNullable(((BukkitItemStack) itemStack).getHandle().getItemMeta().getLore()); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitUnbreakableComponent.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitUnbreakableComponent.java new file mode 100644 index 0000000..a12c606 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/inventory/item/component/BukkitUnbreakableComponent.java @@ -0,0 +1,25 @@ +package org.battleplugins.bukkit.inventory.item.component; + +import org.battleplugins.bukkit.inventory.item.BukkitItemStack; +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.UnbreakableComponent; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.Optional; + +public class BukkitUnbreakableComponent implements UnbreakableComponent { + + @Override + public void applyComponent(ItemStack itemStack, Boolean unbreakable) { + org.bukkit.inventory.ItemStack bukkitItemStack = ((BukkitItemStack) itemStack).getHandle(); + ItemMeta itemMeta = bukkitItemStack.getItemMeta(); + itemMeta.setUnbreakable(unbreakable); + bukkitItemStack.setItemMeta(itemMeta); + } + + @Override + public Optional getValue(ItemStack itemStack) { + ItemMeta itemMeta = ((BukkitItemStack) itemStack).getHandle().getItemMeta(); + return Optional.of(itemMeta.isUnbreakable()); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/util/BukkitInventoryUtil.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/util/BukkitInventoryUtil.java index 2be87c8..accf7ac 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/util/BukkitInventoryUtil.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/util/BukkitInventoryUtil.java @@ -1,408 +1,52 @@ package org.battleplugins.bukkit.util; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import mc.euro.bukkitadapter.material.BattleMaterial; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.block.Chest; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; /** - * * @author alkarin - * */ public class BukkitInventoryUtil { - private static Map commonToStack = new HashMap(); - private static Map typeToCommon = new HashMap(); - - private static final Map itemNames = new HashMap(); - - static { - itemNames.put("light_gray_wool", BattleMaterial.LIGHT_GRAY_WOOL.parseItem()); - itemNames.put("stone_brick", BattleMaterial.STONE_BRICKS.parseItem()); - itemNames.put("mossy_stone", BattleMaterial.MOSSY_COBBLESTONE.parseItem()); - itemNames.put("mossy_smooth", BattleMaterial.MOSSY_STONE_BRICKS.parseItem()); - itemNames.put("cracked_stone", BattleMaterial.CRACKED_STONE_BRICKS.parseItem()); - itemNames.put("piston", BattleMaterial.PISTON.parseItem()); - itemNames.put("sticky_piston", BattleMaterial.STICKY_PISTON.parseItem()); - itemNames.put("long_grass", BattleMaterial.GRASS.parseItem()); - itemNames.put("fern", BattleMaterial.FERN.parseItem()); - itemNames.put("mycelium", BattleMaterial.MYCELIUM.parseItem()); - itemNames.put("nether_wart", BattleMaterial.NETHER_WART.parseItem()); - itemNames.put("redstone_lamp", BattleMaterial.REDSTONE_LAMP.parseItem()); - itemNames.put("redstone_torch", BattleMaterial.REDSTONE_TORCH.parseItem()); - itemNames.put("carrot", BattleMaterial.CARROT.parseItem()); - itemNames.put("carrots", BattleMaterial.CARROTS.parseItem()); - itemNames.put("carrot_seed", BattleMaterial.CARROT.parseItem()); - itemNames.put("potato", BattleMaterial.POTATO.parseItem()); - itemNames.put("potatoes", BattleMaterial.POTATOES.parseItem()); - itemNames.put("potato_seed", BattleMaterial.POTATO.parseItem()); - } - - static { - for (Material m : Material.values()){ - // System.out.println(" data = " + m.getData()); - for (int i =0;i< 64;i++){ - try { - String s = m.getNewData((byte)i).toString(); - s = s.replaceAll("null", ""); /// get rid of null - s = s.replaceAll("generic", ""); /// get rid of generic - s = s.replaceAll("\\(\\d+\\)$" , ""); - s = s.replaceAll("durability.*", ""); - s = s.replaceAll(" up ", ""); - s = s.replaceAll("^\\s+", "").replaceAll("\\s+$", ""); ///remove left and right whitespace - s = s.replaceAll(" ", "_"); - s = s.toLowerCase(); - if ( s.split("_").length > 3 || s.contains("(") || s.contains(")")){ /// Some strange block - break; - } - if (commonToStack.containsKey(s)){ /// already have gone through all of these - break; - } - ItemStack is = m.getNewData((byte)i).toItemStack(); -// System.out.println(" data = <" + s +"> " + printItemStack(is)); - is.setAmount(1); - commonToStack.put(s, is); - s = s.replaceAll("_", " "); - typeToCommon.put(is.getType() + ":" +is.getDurability(), s); - } catch (Exception e){ - /// well whoops.. no data for that byte - break; - } - } - } - } - - public static int getItemAmountFromInventory(Inventory inv, ItemStack is) { - return getItemAmount(inv.getContents(), is); - } - - public static boolean sameItem(final ItemStack is1, final ItemStack is2, boolean checkDura){ - if (is1 == null || is2 == null) - return false; - if (is1.getType() != is2.getType()) - return false; - if (checkDura && (is1.getDurability() != -1 && is1.getDurability() != is2.getDurability()) ) - return false; - final Map e1 = is1.getEnchantments(); - final Map e2 = is2.getEnchantments(); - return e1.size() == e2.size(); - } - - public static int getItemAmount(ItemStack[] items, ItemStack is){ - boolean checkDurability = true; - int count = 0; - for (ItemStack item : items) { - if (sameItem(item,is, checkDurability) && item.getAmount() > 0){ - count += item.getAmount();} - } - return count; - } - - /// Checks if there is enough free space in inventory - public static boolean checkFreeSpace(Chest chest,ItemStack is, int left){ - Inventory inv = chest.getInventory(); - return checkFreeSpace(inv, is, left); - } - - public static boolean checkFreeSpace(Inventory inv, ItemStack is, int left){ - return checkFreeSpace(inv.getContents(), is, left); - } - public static boolean checkFreeSpace(ItemStack[] contents, ItemStack is, int left){ - int maxStack = is.getType().getMaxStackSize(); - for(ItemStack curitem : contents){ - if(left <= 0){ - return true; - } - if(curitem == null || curitem.getType() == Material.AIR){ - left = left - maxStack; - continue; - } - if (!sameItem(curitem, is, true)) - continue; - - int amount = curitem.getAmount(); - if(amount < maxStack){ - left = left - (maxStack - amount); - } - } - return left <= 0; - } - - public static int amountFreeSpace(ItemStack[] contents, ItemStack is, int left){ - int maxStack = is.getType().getMaxStackSize(); - for(ItemStack curitem : contents){ - if(curitem == null){ - left = left - maxStack; - continue; - } - if (!sameItem(curitem, is, true)) - continue; - int amount = curitem.getAmount(); - if(amount < maxStack){ - left = left - (maxStack - amount); - } - } - return -left; - } - - public static int amountFreeSpace(Chest chest, ItemStack is, int left) { - Inventory inv = chest.getInventory(); - return amountFreeSpace(inv, is, left); - } - //Checks if there is enough free space in inventory - public static int amountFreeSpace(Inventory inv, ItemStack is, int left){ - return amountFreeSpace(inv.getContents(), is, left); - } - - - @SuppressWarnings("deprecation") - public static void addItemToInventory(Player player, ItemStack itemStack, int stockAmount) { - addItemToInventory(player.getInventory(), itemStack,stockAmount); - player.updateInventory(); - } - - public static void addItemToInventory(Chest chest, ItemStack is, int left){ - addItemToInventory(chest.getInventory(), is, left); - } - - ///Adds item to inventory - public static void addItemToInventory(Inventory inv, ItemStack is, int left){ - int maxStackSize = is.getType().getMaxStackSize(); - if(left <= maxStackSize){ - is.setAmount(left); - inv.addItem(is); - return; - } - - if(maxStackSize != 64){ - ArrayList items = new ArrayList(); - for (int i = 0; i < Math.ceil(left / maxStackSize); i++) { - if (left < maxStackSize) { - is.setAmount(left); - items.add(is); - return; - }else{ - is.setAmount(maxStackSize); - items.add(is); - } - } - Object[] iArray = items.toArray(); - for(Object o : iArray){ - inv.addItem((ItemStack) o); - } - }else{ - inv.addItem(is); - } - } - - - public static int first(Inventory inv, ItemStack is1) { - if (is1 == null) { - return -1; - } - ItemStack[] inventory = inv.getContents(); - for (int i = 0; i < inventory.length; i++) { - ItemStack is2 = inventory[i]; - if (is2 == null) continue; - if (sameItem(is1,is2,true)) - return i; - } - return -1; - } - - /** - * This is nearly a direct copy of the removeItem from CraftBukkit - * The difference is my ItemStack == ItemStack comparison (found in first()) - * there I change it to go by itemid and datavalue - * as opposed to itemid and quantity - * @param inv - * @param items - * @return - */ - public static HashMap removeItem(Inventory inv, ItemStack... items) { - HashMap leftover = new HashMap(); - - for (int i = 0; i < items.length; i++) { - ItemStack item = items[i]; - int toDelete = item.getAmount(); - - while (true) { - // System.out.println("inv= " + inv + " " + items.length + " item=" + item); - int first = first(inv, item); - // System.out.println("first= " + first); - - // Drat! we don't have this type in the inventory - if (first == -1) { - item.setAmount(toDelete); - leftover.put(i, item); - break; - } else { - ItemStack itemStack = inv.getItem(first); - int amount = itemStack.getAmount(); - - if (amount <= toDelete) { - toDelete -= amount; - // clear the slot, all used up - inv.setItem(first, null); - } else { - // split the stack and store - itemStack.setAmount(amount - toDelete); - inv.setItem(first, itemStack); - toDelete = 0; - } - } - - // Bail when done - if (toDelete <= 0) { - break; - } - } - } - return leftover; - } - - public static String printItemStack(ItemStack is){ - StringBuilder sb = new StringBuilder("[ItemStack] " +is.getType() + ":" + is.getAmount() + " dura="+is.getDurability()); - if (is.getData() != null){ - sb.append(" data=" + is.getData() + " d.itemType=" + is.getType() + - " d.data=" + is.getData().getData()); - } else { - sb.append(" data=null"); - } - return sb.toString(); - } - - /** - * Return a item stack from a given string - * @param name - * @return - */ - public static ItemStack getItemStack(String name) { - if (name == null || name.isEmpty()) - return null; - name = name.replace(" ", "_"); - name = name.replace(";", ":"); - name = decolorChat(name); - name = name.toLowerCase(); - - String split[] = name.split(":"); - short dataValue = 0; - if (split.length > 1 && isInt(split[1])){ - int i = Integer.valueOf(split[1]); - dataValue = (short) i; - name = split[0]; - } - - /// Check our prenamed items first - ItemStack is = itemNames.get(name); - if (is != null){ - return is;} - - BattleMaterial mat; - if (dataValue > 0) { - mat = BattleMaterial.fromString(name + ":" + 0); - } else { - mat = BattleMaterial.fromString(name); - } - if (mat != null && mat != BattleMaterial.AIR) { - return mat.parseItem(); - } - /// Try to get from our generic list - is = commonToStack.get(name); - if (is == null){ - /// look for first matching item - for (String itemName : commonToStack.keySet()){ - int index = itemName.indexOf(name,0); - if (index != -1 && index == 0){ - is = commonToStack.get(itemName); - return is; - } - } - } else { - is.setAmount(1); - } - return is; - } - - public static boolean isInt(String i) { - try {Integer.parseInt(i);return true;} catch (Exception e) {return false;} - } - public static String decolorChat(String string) { - /// Remove all the color codes, first the user defined &[0-9a-fA-F] - string = string.replaceAll("&[0-9a-fA-F]", ""); - /// Remove the implementation color codes - string = ChatColor.stripColor(string); - return string; - } - - - - -// public static String getCommonName(ItemStack is) { -// int id = is.getTypeId(); -// int datavalue = is.getDurability(); -// if (datavalue > 0){ -// return Material.getMaterial(id).toString() + ":" + datavalue; -// } -// return Material.getMaterial(id).toString(); -// } - - public static String getFormattedCommonName(ItemStack is) { - Material type = is.getType(); - short datavalue = is.getDurability(); - - String iname = ""; - try { - if (datavalue > 0){ - iname = type.toString() + ":" + datavalue; - } - String idkey = type + ":" + datavalue; - - String cname = typeToCommon.get(idkey); - if (cname != null) - return cname; - - int maxDurability = type.getMaxDurability(); - - iname = formatCommonName(type.toString().toLowerCase()) + " (" + (maxDurability - datavalue) + "/" + maxDurability + ")"; - } catch (Exception e){ - System.err.println("Error getting commonName type=" + type + " iname=" + iname + " datavalue=" + datavalue); - e.printStackTrace(); - } - return iname; - } - - public static String getCustomName(ItemStack item) { - ItemMeta im = item.getItemMeta(); - if (im == null){ - return item.getType().name().toLowerCase();} - String displayName = im.getDisplayName(); - return displayName == null || displayName.isEmpty() ? item.getType().name().toLowerCase() : displayName; - } - - public static ItemStack getItemStack(Material type, short datavalue) { - return BattleMaterial.fromString(type + ":" + datavalue).parseItem(); - } - - private static String formatCommonName(String name) { - name = name.toLowerCase().replace("_", " "); - - String[] words = name.split(" "); - for (int i = 0; i < words.length; i++) { - words[i] = words[i].substring(0, 1).toUpperCase() + words[i].substring(1).toLowerCase(); - } - - return String.join(" ", words); - } + public static int getItemAmountFromInventory(Inventory inv, ItemStack is) { + return getItemAmount(inv.getContents(), is); + } + + public static boolean sameItem(ItemStack is1, ItemStack is2, boolean checkDura) { + if (is1 == null || is2 == null) + return false; + if (is1.getType() != is2.getType()) + return false; + if (checkDura && (is1.getDurability() != -1 && is1.getDurability() != is2.getDurability()) ) + return false; + + return is1.getEnchantments().equals(is2.getEnchantments()); + } + + public static int getItemAmount(ItemStack[] items, ItemStack is) { + int count = 0; + for (ItemStack item : items) { + if (sameItem(item, is, true) && item.getAmount() > 0) { + count += item.getAmount(); + } + } + return count; + } + + public static int amountFreeSpace(Inventory inv, ItemStack is, int left){ + int maxStack = is.getType().getMaxStackSize(); + for (ItemStack curitem : inv.getContents()) { + if (curitem == null) { + left = left - maxStack; + continue; + } + if (!sameItem(curitem, is, true)) + continue; + int amount = curitem.getAmount(); + if (amount < maxStack) { + left = left - (maxStack - amount); + } + } + return -left; + } } diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/util/BukkitMaterialAdapter.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/util/BukkitMaterialAdapter.java new file mode 100644 index 0000000..935c1c6 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/util/BukkitMaterialAdapter.java @@ -0,0 +1,22 @@ +package org.battleplugins.bukkit.util; + +import org.battleplugins.bukkit.compat.BukkitCompatMaterial; +import org.bukkit.Material; + +import java.util.Optional; + +public class BukkitMaterialAdapter { + + public static Optional getMaterial(String mat) { + Optional material = Optional.empty(); + try { + material = BukkitCompatMaterial.fromString(mat).map(BukkitCompatMaterial::parseMaterial); + if (!material.isPresent()) { + material = Optional.ofNullable(Material.matchMaterial("LEGACY_" + mat.toUpperCase())); + } + } catch (NullPointerException ignored) { + } + + return material; + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/BukkitLocation.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/BukkitLocation.java index 73d5a9a..1e701db 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/BukkitLocation.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/BukkitLocation.java @@ -38,19 +38,4 @@ public float getPitch() { public float getYaw() { return handle.getYaw(); } - - @Override - public int getBlockX() { - return handle.getBlockX(); - } - - @Override - public int getBlockY() { - return handle.getBlockY(); - } - - @Override - public int getBlockZ() { - return handle.getBlockZ(); - } } diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/BukkitWorld.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/BukkitWorld.java index 2b26afa..3d83038 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/BukkitWorld.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/BukkitWorld.java @@ -1,10 +1,14 @@ package org.battleplugins.bukkit.world; +import org.battleplugins.bukkit.entity.living.player.BukkitPlayer; import org.battleplugins.bukkit.world.block.BukkitBlock; import org.battleplugins.bukkit.world.block.entity.BukkitBlockEntity; import org.battleplugins.bukkit.world.block.entity.BukkitChest; import org.battleplugins.bukkit.world.block.entity.BukkitSign; +import org.battleplugins.entity.living.player.Player; import org.battleplugins.util.MCWrapper; +import org.battleplugins.world.Location; +import org.battleplugins.world.block.Block; import org.battleplugins.world.block.entity.BlockEntity; import org.bukkit.World; import org.bukkit.block.BlockState; @@ -25,7 +29,7 @@ public String getName() { } @Override - public Optional getBlockEntityAt(org.battleplugins.world.Location loc) { + public Optional getBlockEntityAt(Location loc) { BlockState state = handle.getBlockAt(((BukkitLocation) loc).getHandle()).getState(); if (handle instanceof Chest) return Optional.of(new BukkitChest((Chest) state)); @@ -37,7 +41,7 @@ public Optional getBlockEntityAt(org.battleplugins.world.Loca } @Override - public BukkitBlock getBlockAt(org.battleplugins.world.Location loc) { + public BukkitBlock getBlockAt(Location loc) { return new BukkitBlock(handle.getBlockAt(((BukkitLocation) loc).getHandle())); } @@ -70,4 +74,19 @@ public T toType(BlockEntity blockEntity, Class clazz) } return null; } + + @Override + public void sendBlockUpdate(Player player, Location location, Block block) { + org.bukkit.entity.Player bukkitPlayer = ((BukkitPlayer) player).getHandle(); + org.bukkit.block.Block bukkitBlock = ((BukkitBlock) block).getHandle(); + bukkitPlayer.sendBlockChange(((BukkitLocation) location).getHandle(), bukkitBlock.getType(), bukkitBlock.getData()); + } + + @Override + public void sendBlockEntityUpdate(Player player, Location location, BlockEntity blockEntity) { + org.bukkit.entity.Player bukkitPlayer = ((BukkitPlayer) player).getHandle(); + if (blockEntity instanceof Sign) { + bukkitPlayer.sendSignChange(((BukkitLocation) location).getHandle(), ((Sign) blockEntity).getLines()); + } + } } diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/BukkitBlock.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/BukkitBlock.java index 4179a9b..55285a0 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/BukkitBlock.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/BukkitBlock.java @@ -3,6 +3,8 @@ import org.battleplugins.bukkit.world.BukkitLocation; import org.battleplugins.bukkit.world.BukkitWorld; import org.battleplugins.util.MCWrapper; +import org.battleplugins.world.block.BlockRegistry; +import org.battleplugins.world.block.BlockType; import org.bukkit.block.Block; public class BukkitBlock extends MCWrapper implements org.battleplugins.world.block.Block { @@ -22,23 +24,8 @@ public BukkitLocation getLocation() { } @Override - public int getX() { - return handle.getX(); - } - - @Override - public int getY() { - return handle.getY(); - } - - @Override - public int getZ() { - return handle.getZ(); - } - - @Override - public String getType() { - return handle.getType().name(); + public BlockType getType() { + return ((BukkitBlockRegistry) BlockRegistry.REGISTRY).fromPlatformBlock(handle.getType()); } @Override diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/BukkitBlockRegistry.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/BukkitBlockRegistry.java new file mode 100644 index 0000000..1591033 --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/BukkitBlockRegistry.java @@ -0,0 +1,22 @@ +package org.battleplugins.bukkit.world.block; + +import org.battleplugins.bukkit.util.BukkitMaterialAdapter; +import org.battleplugins.util.NamespacedKey; +import org.battleplugins.world.block.BlockRegistry; +import org.battleplugins.world.block.BlockType; +import org.bukkit.Material; + +import java.util.Optional; + +public class BukkitBlockRegistry implements BlockRegistry { + + @Override + public BlockType fromPlatformBlock(Material block) { + return new BukkitBlockType(block); + } + + @Override + public Optional fromKey(NamespacedKey namespacedKey) { + return BukkitMaterialAdapter.getMaterial(namespacedKey.getKey()).map(this::fromPlatformBlock); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/BukkitBlockType.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/BukkitBlockType.java new file mode 100644 index 0000000..31f785d --- /dev/null +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/BukkitBlockType.java @@ -0,0 +1,17 @@ +package org.battleplugins.bukkit.world.block; + +import org.battleplugins.bukkit.inventory.item.BukkitItemType; +import org.battleplugins.world.block.BlockType; +import org.bukkit.Material; + +public class BukkitBlockType extends BukkitItemType implements BlockType { + + protected BukkitBlockType(Material handle) { + super(handle); + } + + @Override + public float getHardness() { + return handle.getHardness(); + } +} diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/entity/BukkitChest.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/entity/BukkitChest.java index 5a1774c..56fe702 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/entity/BukkitChest.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/entity/BukkitChest.java @@ -1,12 +1,11 @@ package org.battleplugins.bukkit.world.block.entity; -import org.battleplugins.bukkit.inventory.BukkitInventory; -import org.battleplugins.bukkit.inventory.item.BukkitItemStack; +import org.battleplugins.bukkit.inventory.BukkitCarriedInventory; +import org.battleplugins.inventory.CarriedInventory; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Chest; -import org.bukkit.inventory.ItemStack; import java.util.Optional; @@ -16,25 +15,6 @@ public BukkitChest(Chest chest) { super(chest); } - @Override - public BukkitItemStack[] getItems() { - ItemStack[] items1 = handle.getInventory().getContents(); - BukkitItemStack[] items2 = new BukkitItemStack[items1.length]; - for (int i = 0; i < items1.length; i++){ - items2[i] = new BukkitItemStack(items1[i]); - } - return items2; - } - - @Override - public boolean isDoubleChest() { - final Block b = handle.getBlock(); - return (b.getRelative(BlockFace.NORTH).getType() == Material.CHEST || - b.getRelative(BlockFace.SOUTH).getType() == Material.CHEST || - b.getRelative(BlockFace.EAST).getType() == Material.CHEST || - b.getRelative(BlockFace.WEST).getType() == Material.CHEST); - } - @Override public Optional getNeighborChest() { if (handle.getBlock().getRelative(BlockFace.NORTH).getType() == Material.CHEST) @@ -53,7 +33,7 @@ else if (handle.getBlock().getRelative(BlockFace.WEST).getType() == Material.CHE } @Override - public BukkitInventory getInventory() { - return new BukkitInventory<>(handle.getInventory()); + public CarriedInventory getInventory() { + return new BukkitCarriedInventory<>(handle.getInventory(), this); } } diff --git a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/entity/BukkitSign.java b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/entity/BukkitSign.java index 6ddecc9..8f8a3c2 100644 --- a/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/entity/BukkitSign.java +++ b/modules/bukkit/src/main/java/org/battleplugins/bukkit/world/block/entity/BukkitSign.java @@ -1,7 +1,5 @@ package org.battleplugins.bukkit.world.block.entity; -import org.battleplugins.entity.living.player.Player; -import org.battleplugins.bukkit.entity.living.player.BukkitPlayer; import org.bukkit.block.Sign; public class BukkitSign extends BukkitBlockEntity implements org.battleplugins.world.block.entity.Sign { @@ -19,11 +17,6 @@ public void setLine(int index, String line) { sign.setLine(index, line); } - @Override - public void sendSignChange(Player player, String[] lines) { - ((BukkitPlayer) player).getHandle().sendSignChange(sign.getLocation(), lines); - } - @Override public String getLine(int index) { return sign.getLine(index); diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/NukkitPlatform.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/NukkitPlatform.java index e94ab52..db0278c 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/NukkitPlatform.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/NukkitPlatform.java @@ -5,20 +5,20 @@ import cn.nukkit.level.Location; import cn.nukkit.plugin.service.RegisteredServiceProvider; -import org.battleplugins.APIType; +import mc.euro.version.Version; + +import org.battleplugins.PlatformType; import org.battleplugins.Platform; import org.battleplugins.message.Message; import org.battleplugins.nukkit.entity.living.player.NukkitOfflinePlayer; import org.battleplugins.nukkit.entity.living.player.NukkitPlayer; import org.battleplugins.nukkit.message.NukkitMessage; -import org.battleplugins.nukkit.inventory.NukkitInventory; import org.battleplugins.nukkit.inventory.item.NukkitItemStack; -import org.battleplugins.nukkit.inventory.virtual.VirtualChestInventory; -import org.battleplugins.nukkit.inventory.virtual.VirtualDoubleChestInventory; import org.battleplugins.nukkit.world.NukkitLocation; import org.battleplugins.nukkit.world.NukkitWorld; import org.battleplugins.plugin.Plugin; -import org.battleplugins.plugin.ServicePriority; +import org.battleplugins.plugin.service.ServicePriority; +import org.battleplugins.world.World; import java.util.ArrayList; import java.util.Collection; @@ -28,14 +28,20 @@ public class NukkitPlatform extends Platform { + private NukkitRegistry registry; + + public NukkitPlatform() { + registry = new NukkitRegistry(); + } + @Override - public APIType getAPIType() { - return APIType.NUKKIT; + public PlatformType getType() { + return PlatformType.NUKKIT; } @Override - public NukkitLocation getLocation(String world, double x, double y, double z, float pitch, float yaw) { - return new NukkitLocation(new Location(x, y, z, pitch, yaw, Server.getInstance().getLevelByName(world))); + public NukkitLocation getLocation(World world, double x, double y, double z, float pitch, float yaw) { + return new NukkitLocation(new Location(x, y, z, pitch, yaw, ((NukkitWorld) world).getHandle())); } @Override @@ -101,8 +107,8 @@ public boolean isOnlineMode() { } @Override - public String getVersion() { - return Server.getInstance().getVersion(); + public Version getVersion() { + return new Version<>(Server.getInstance().getVersion()); } @Override @@ -121,25 +127,6 @@ public boolean cancelTask(long id) { return true; } - public NukkitInventory createInventory(Plugin plugin, int slots, String title) { - return createInventory(slots, title, true); - } - - public NukkitInventory createInventory(int slots, String title, boolean cancelled) { - // Nukkit on its own does not have support for virtual inventories - // So instead, we have to use some hacky methods and packets to create this - // However, they can only be 27 slots (3 rows) or 54 slots (6 rows) in size - VirtualChestInventory inventory = new VirtualChestInventory(null, title); - if (slots > 27) { - inventory = new VirtualDoubleChestInventory(null, title); - } - - // We just cancel this event for now :) - inventory.addListener(event -> event.setCancelled(cancelled)); - - return new NukkitInventory<>(inventory); - } - @Override public void registerService(Class clazz, T service, Plugin plugin, ServicePriority priority) { Server.getInstance().getServiceManager().register(clazz, service, (cn.nukkit.plugin.Plugin) plugin.getPlatformPlugin(), cn.nukkit.plugin.service.ServicePriority.values()[priority.ordinal()]); @@ -149,4 +136,9 @@ public void registerService(Class clazz, T service, Plugin plugin, Servic public Optional getService(Class clazz) { return Optional.ofNullable(Server.getInstance().getServiceManager().getProvider(clazz)).map(RegisteredServiceProvider::getProvider); } + + @Override + public NukkitRegistry getRegistry() { + return registry; + } } diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/NukkitRegistry.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/NukkitRegistry.java new file mode 100644 index 0000000..cef347b --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/NukkitRegistry.java @@ -0,0 +1,38 @@ +package org.battleplugins.nukkit; + +import org.battleplugins.Registry; +import org.battleplugins.nukkit.inventory.NukkitInventoryBuilder; +import org.battleplugins.nukkit.inventory.item.NukkitItemRegistry; +import org.battleplugins.nukkit.inventory.item.component.*; +import org.battleplugins.nukkit.world.block.NukkitBlockRegistry; + +public class NukkitRegistry extends Registry { + + private NukkitItemRegistry itemRegistry; + private NukkitBlockRegistry blockRegistry; + + NukkitRegistry() { + itemRegistry = new NukkitItemRegistry(); + blockRegistry = new NukkitBlockRegistry(); + + itemComponents.add(NukkitColorComponent.class); + itemComponents.add(NukkitCustomModelDataComponent.class); + itemComponents.add(NukkitDamageComponent.class); + itemComponents.add(NukkitDisplayNameComponent.class); + itemComponents.add(NukkitItemFlagComponent.class); + itemComponents.add(NukkitLoreComponent.class); + itemComponents.add(NukkitUnbreakableComponent.class); + + builders.add(NukkitInventoryBuilder.class); + } + + @Override + public NukkitItemRegistry getItemRegistry() { + return itemRegistry; + } + + @Override + public NukkitBlockRegistry getBlockRegistry() { + return blockRegistry; + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/NukkitEntity.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/NukkitEntity.java index d925fe4..6b1fc4a 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/NukkitEntity.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/NukkitEntity.java @@ -5,6 +5,7 @@ import org.battleplugins.nukkit.world.NukkitLocation; import org.battleplugins.nukkit.world.NukkitWorld; import org.battleplugins.util.MCWrapper; +import org.battleplugins.util.NamespacedKey; import org.battleplugins.world.Location; import java.util.ArrayList; @@ -23,6 +24,11 @@ public String getName() { return handle.getName(); } + @Override + public NamespacedKey getKey() { + return NamespacedKey.minecraft(handle.getSaveId().replace("Entity", "")); + } + @Override public UUID getUniqueId() { return UUID.randomUUID(); // no support diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/NukkitHumanEntity.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/NukkitHumanEntity.java index ec501a3..61ca818 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/NukkitHumanEntity.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/NukkitHumanEntity.java @@ -15,7 +15,7 @@ public NukkitHumanEntity(T humanEntity) { @Override public NukkitPlayerInventory getInventory() { - return new NukkitPlayerInventory(handle.getInventory()); + return new NukkitPlayerInventory(this, handle.getInventory()); } @Override diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/player/NukkitOfflinePlayer.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/player/NukkitOfflinePlayer.java index 6f2b9dd..183c8ac 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/player/NukkitOfflinePlayer.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/player/NukkitOfflinePlayer.java @@ -7,6 +7,7 @@ import org.battleplugins.util.MCWrapper; import java.util.Optional; +import java.util.OptionalLong; import java.util.UUID; public class NukkitOfflinePlayer extends MCWrapper implements OfflinePlayer { @@ -39,13 +40,13 @@ public Optional getPlayer() { } @Override - public long getFirstPlayed() { - return handle.getFirstPlayed(); + public OptionalLong getFirstPlayed() { + return OptionalLong.of(handle.getFirstPlayed()); } @Override - public long getLastPlayed() { - return handle.getLastPlayed(); + public OptionalLong getLastPlayed() { + return OptionalLong.of(handle.getLastPlayed()); } @Override diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/player/NukkitPlayer.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/player/NukkitPlayer.java index c4eb23d..4c5ee42 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/player/NukkitPlayer.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/entity/living/player/NukkitPlayer.java @@ -2,13 +2,15 @@ import cn.nukkit.Player; -import org.battleplugins.entity.living.player.GameMode; +import org.battleplugins.entity.living.player.gamemode.GameMode; +import org.battleplugins.entity.living.player.gamemode.GameModes; import org.battleplugins.inventory.Inventory; import org.battleplugins.nukkit.world.NukkitLocation; import org.battleplugins.nukkit.entity.living.NukkitHumanEntity; import org.battleplugins.nukkit.inventory.NukkitInventory; import java.util.Optional; +import java.util.OptionalLong; public class NukkitPlayer extends NukkitHumanEntity implements org.battleplugins.entity.living.player.Player { @@ -25,13 +27,13 @@ public Optional getPlayer() { } @Override - public long getFirstPlayed() { - return handle.getFirstPlayed(); + public OptionalLong getFirstPlayed() { + return OptionalLong.of(handle.getFirstPlayed()); } @Override - public long getLastPlayed() { - return handle.getLastPlayed(); + public OptionalLong getLastPlayed() { + return OptionalLong.of(handle.getLastPlayed()); } @Override @@ -82,7 +84,7 @@ public boolean isOnline() { @Override public GameMode getGameMode() { - return GameMode.values()[handle.getGamemode()]; + return GameModes.values()[handle.getGamemode()]; } @Override diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/NukkitCarriedInventory.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/NukkitCarriedInventory.java new file mode 100644 index 0000000..d8594de --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/NukkitCarriedInventory.java @@ -0,0 +1,22 @@ +package org.battleplugins.nukkit.inventory; + +import cn.nukkit.inventory.Inventory; + +import org.battleplugins.inventory.CarriedInventory; +import org.battleplugins.inventory.carrier.Carrier; + +public class NukkitCarriedInventory extends NukkitInventory implements CarriedInventory { + + private C carrier; + + public NukkitCarriedInventory(T inventory, C carrier) { + super(inventory); + + this.carrier = carrier; + } + + @Override + public C getCarrier() { + return carrier; + } +} \ No newline at end of file diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/NukkitInventory.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/NukkitInventory.java index ee7ba29..f424be1 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/NukkitInventory.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/NukkitInventory.java @@ -19,13 +19,8 @@ public NukkitInventory(T inventory) { } @Override - public void addItem(ItemStack... itemStacks) { - for (ItemStack item : itemStacks) - addItem(item); - } - public void addItem(ItemStack itemStack) { - if (itemStack == null || itemStack.getType().equals("0")) { + if (itemStack == null || itemStack.getType().getKey().getKey().equals("air")) { return; } @@ -38,7 +33,8 @@ public void removeItem(ItemStack itemStack) { } @Override - public void setItem(int slot, ItemStack item) { handle.setItem(slot, ((NukkitItemStack) item).getHandle()); + public void setItem(int slot, ItemStack item) { + handle.setItem(slot, ((NukkitItemStack) item).getHandle()); } @Override @@ -51,11 +47,6 @@ public int getItemAmount(ItemStack itemStack) { return NukkitInventoryUtil.getItemAmountFromInventory(handle, ((NukkitItemStack) itemStack).getHandle()); } - @Override - public boolean canFit(ItemStack itemStack) { - return freeSpaceAfter(itemStack) >= 0; - } - @Override public int freeSpaceAfter(ItemStack itemStack) { return NukkitInventoryUtil.amountFreeSpace(handle, diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/NukkitInventoryBuilder.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/NukkitInventoryBuilder.java new file mode 100644 index 0000000..73699c9 --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/NukkitInventoryBuilder.java @@ -0,0 +1,78 @@ +package org.battleplugins.nukkit.inventory; + +import org.battleplugins.inventory.Inventory; +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.nukkit.inventory.virtual.VirtualChestInventory; +import org.battleplugins.nukkit.inventory.virtual.VirtualDoubleChestInventory; + +public class NukkitInventoryBuilder implements Inventory.Builder { + + private String name; + private int size; + private ItemStack[] contents = new ItemStack[54]; + + @Override + public NukkitInventoryBuilder fromInventory(Inventory inventory, String name) { + this.name = name; + this.size = ((NukkitInventory) inventory).getHandle().getSize(); + this.contents = inventory.getContents(); + return this; + } + + @Override + public NukkitInventoryBuilder name(String name) { + this.name = name; + return this; + } + + @Override + public NukkitInventoryBuilder size(int size) { + this.size = size; + if (this.contents.length > size) { + throw new IllegalArgumentException("Current inventory contents are larger than the set inventory size!"); + } + + ItemStack[] contents = this.contents.clone(); + System.arraycopy(contents, 0, this.contents, 0, contents.length); + return this; + } + + @Override + public NukkitInventoryBuilder item(int slot, ItemStack item) { + if (slot > size) { + throw new IllegalArgumentException("Slot is greater than the inventory size!"); + } + this.contents[slot] = item; + return this; + } + + @Override + public NukkitInventoryBuilder contents(ItemStack[] contents) { + if (contents.length > size) { + throw new IllegalArgumentException("Given contents are larger than the inventory size!"); + } + this.contents = contents; + return null; + } + + @Override + public NukkitInventory build() { + return build(true); + } + + public NukkitInventory build(boolean cancelled) { + // Nukkit on its own does not have support for virtual inventories + // So instead, we have to use some hacky methods and packets to create this + // However, they can only be 27 slots (3 rows) or 54 slots (6 rows) in size + VirtualChestInventory inventory = new VirtualChestInventory(null, name); + if (size > 27) { + inventory = new VirtualDoubleChestInventory(null, name); + } + + inventory.addListener(event -> event.setCancelled(true)); + + NukkitInventory nukkitInventory = new NukkitInventory<>(inventory); + nukkitInventory.setContents(this.contents); + return nukkitInventory; + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/entity/NukkitPlayerInventory.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/entity/NukkitPlayerInventory.java index dfbfe6b..8997a54 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/entity/NukkitPlayerInventory.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/entity/NukkitPlayerInventory.java @@ -2,6 +2,7 @@ import cn.nukkit.inventory.PlayerInventory; +import org.battleplugins.entity.living.HumanEntity; import org.battleplugins.nukkit.inventory.NukkitInventory; import org.battleplugins.nukkit.inventory.item.NukkitItemStack; @@ -9,8 +10,12 @@ public class NukkitPlayerInventory extends NukkitInventory implements org.battleplugins.inventory.entity.PlayerInventory { - public NukkitPlayerInventory(PlayerInventory inventory) { + private HumanEntity carrier; + + public NukkitPlayerInventory(HumanEntity carrier, PlayerInventory inventory) { super(inventory); + + this.carrier = carrier; } @Override @@ -42,4 +47,9 @@ public Optional getLeggings() { public Optional getBoots() { return Optional.ofNullable(handle.getBoots()).map(NukkitItemStack::new); } + + @Override + public HumanEntity getCarrier() { + return carrier; + } } diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/ItemEntry.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/ItemEntry.java new file mode 100644 index 0000000..26a6465 --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/ItemEntry.java @@ -0,0 +1,18 @@ +package org.battleplugins.nukkit.inventory.item; + +import com.google.gson.annotations.SerializedName; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@AllArgsConstructor(access = AccessLevel.PACKAGE) +@Getter @Setter +public class ItemEntry { + + @SerializedName("bedrock_id") + private int bedrockId; + + @SerializedName("bedrock_data") + private int bedrockData; +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemMeta.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemMeta.java deleted file mode 100644 index 3950559..0000000 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemMeta.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.battleplugins.nukkit.inventory.item; - -import cn.nukkit.item.Item; - -import org.battleplugins.inventory.item.ItemMeta; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -/** - * Due to how Nukkit handles item metadata, we instead - * pass a Nukkit 'Item' in the constructor. - */ -public class NukkitItemMeta implements ItemMeta { - - private Item item; - - public NukkitItemMeta(Item item) { - this.item = item; - } - - @Override - public Optional getDisplayName() { - if (!item.hasCustomName()) - return Optional.empty(); - - return Optional.of(item.getCustomName()); - } - - @Override - public void setDisplayName(String displayName) { - item.setCustomName(displayName); - } - - @Override - public Optional> getLore() { - if (item.getLore().length == 0) - return Optional.empty(); - - return Optional.of(Arrays.asList(item.getLore())); - } - - @Override - public void setLore(List lore) { - item.setLore(lore.toArray(new String[0])); - } - - @Override - public int getCustomModelData() { - return 0; - } - - @Override - public void setCustomModelData(int modelData) { - // No support for this in Nukkit - } - - @Override - public boolean isUnbreakable() { - return item.isUnbreakable(); - } - - @Override - public void setUnbreakable(boolean unbreakable) { - // No support for this in Nukkit - } -} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemRegistry.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemRegistry.java new file mode 100644 index 0000000..5771403 --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemRegistry.java @@ -0,0 +1,53 @@ +package org.battleplugins.nukkit.inventory.item; + +import cn.nukkit.item.Item; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + +import org.battleplugins.inventory.item.ItemRegistry; +import org.battleplugins.inventory.item.ItemType; +import org.battleplugins.nukkit.NukkitPlatform; +import org.battleplugins.util.NamespacedKey; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +public class NukkitItemRegistry implements ItemRegistry { + + private static final Map ITEM_ENTRIES = new HashMap<>(); + private static final Map IDENTIFIER_TO_ENTRY = new HashMap<>(); + + public NukkitItemRegistry() { + InputStream inputStream = NukkitPlatform.class.getResourceAsStream("items.json"); + if (inputStream == null) + throw new AssertionError("Items Table not found"); + + Gson gson = new Gson(); + Type mapType = new TypeToken>() {}.getType(); + Map itemEntries = gson.fromJson(new InputStreamReader(inputStream), mapType); + for (Map.Entry itemEntry : itemEntries.entrySet()) { + ITEM_ENTRIES.put(itemEntry.getValue(), new NukkitItemType(NamespacedKey.minecraft(itemEntry.getKey()), + Item.get(itemEntry.getValue().getBedrockId(), itemEntry.getValue().getBedrockData()))); + IDENTIFIER_TO_ENTRY.put(itemEntry.getKey(), itemEntry.getValue()); + } + } + + @Override + public ItemType fromPlatformItem(Item item) { + return ITEM_ENTRIES.get(new ItemEntry(item.getId(), item.getDamage())); + } + + @Override + public Optional fromKey(NamespacedKey namespacedKey) { + ItemEntry itemEntry = IDENTIFIER_TO_ENTRY.get(namespacedKey.toString()); + if (itemEntry == null) + return Optional.empty(); + + return Optional.ofNullable(ITEM_ENTRIES.get(itemEntry)); + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemStack.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemStack.java index 939c901..7ac01e2 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemStack.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemStack.java @@ -3,8 +3,8 @@ import cn.nukkit.item.Item; import cn.nukkit.item.enchantment.Enchantment; -import org.battleplugins.inventory.item.ItemMeta; -import org.battleplugins.nukkit.util.NukkitInventoryUtil; +import org.battleplugins.inventory.item.ItemRegistry; +import org.battleplugins.inventory.item.ItemType; import org.battleplugins.util.MCWrapper; import java.util.HashMap; @@ -17,9 +17,9 @@ public NukkitItemStack(Item itemStack) { } @Override - public void setType(String type) { + public void setType(ItemType type) { // Nukkit doesn't have a setter for items.. so get from string instead - Item item = Item.fromString(type); + Item item = ((NukkitItemType) type).getHandle(); item.setCount(handle.getCount()); item.setCompoundTag(handle.getCompoundTag()); item.setCustomName(handle.getCustomName()); @@ -40,18 +40,8 @@ public void setType(String type) { } @Override - public String getType() { - return NukkitInventoryUtil.getTypeFromId(handle.getId()); - } - - @Override - public void setDataValue(short value) { - handle.setDamage((int) value); - } - - @Override - public short getDataValue() { - return (short) handle.getDamage(); + public ItemType getType() { + return ((NukkitItemRegistry) ItemRegistry.REGISTRY).fromPlatformItem(handle); } @Override @@ -66,23 +56,13 @@ public int getQuantity() { @Override public Map getEnchantments() { - Map encs = new HashMap(); + Map encs = new HashMap<>(); for (Enchantment enchant : handle.getEnchantments()) { encs.put(enchant.getName(), enchant.getId()); } return encs; } - @Override - public String getCommonName() { - return handle.getName(); - } - - @Override - public String getFormattedCommonName() { - return NukkitInventoryUtil.getFormattedCommonName(handle); - } - @Override public NukkitItemStack clone(){ return new NukkitItemStack(handle.clone()); @@ -98,28 +78,4 @@ public void addEnchantment(String ench, int level) { return; } } - - @Override - public int isSpecial() { - int special = 0; -// ItemMeta im = itemStack.getItemMeta(); -// Map map = itemStack.getEnchantments(); -// if (map != null){ -// for (Entry entry : map.entrySet()){ -//// entry.getKey().getId() -// } -// } - - return special; - } - - @Override - public boolean hasItemMeta() { - return true; - } - - @Override - public ItemMeta getItemMeta() { - return new NukkitItemMeta(handle); - } } diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemType.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemType.java new file mode 100644 index 0000000..912b948 --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/NukkitItemType.java @@ -0,0 +1,30 @@ +package org.battleplugins.nukkit.inventory.item; + +import cn.nukkit.item.Item; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; + +import org.battleplugins.inventory.item.ItemType; +import org.battleplugins.util.NamespacedKey; + +@AllArgsConstructor(access = AccessLevel.PROTECTED) +public class NukkitItemType implements ItemType { + + protected NamespacedKey key; + protected Item item; + + @Override + public NamespacedKey getKey() { + return key; + } + + @Override + public int getMaximumStackSize() { + return item.getMaxStackSize(); + } + + public Item getHandle() { + return item; + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitColorComponent.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitColorComponent.java new file mode 100644 index 0000000..1617238 --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitColorComponent.java @@ -0,0 +1,34 @@ +package org.battleplugins.nukkit.inventory.item.component; + +import cn.nukkit.item.Item; +import cn.nukkit.item.ItemColorArmor; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.ColorComponent; +import org.battleplugins.nukkit.inventory.item.NukkitItemStack; + +import java.awt.Color; +import java.util.Optional; + +public class NukkitColorComponent implements ColorComponent { + + @Override + public void applyComponent(ItemStack itemStack, Color color) { + Item item = ((NukkitItemStack) itemStack).getHandle(); + if (!(item instanceof ItemColorArmor)) + return; + + ItemColorArmor colorItem = (ItemColorArmor) item; + colorItem.setColor(color.getRed(), color.getBlue(), color.getGreen()); + } + + @Override + public Optional getValue(ItemStack itemStack) { + cn.nukkit.item.Item item = ((NukkitItemStack) itemStack).getHandle(); + if (!(item instanceof ItemColorArmor)) + return Optional.empty(); + + ItemColorArmor colorItem = (ItemColorArmor) item; + return Optional.of(new Color(colorItem.getColor().getRGB())); + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitCustomModelDataComponent.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitCustomModelDataComponent.java new file mode 100644 index 0000000..151a031 --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitCustomModelDataComponent.java @@ -0,0 +1,19 @@ +package org.battleplugins.nukkit.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.CustomModelDataComponent; + +import java.util.Optional; + +public class NukkitCustomModelDataComponent implements CustomModelDataComponent { + + @Override + public void applyComponent(ItemStack itemStack, Integer modelData) { + // unsupported + } + + @Override + public Optional getValue(ItemStack itemStack) { + return Optional.empty(); + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitDamageComponent.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitDamageComponent.java new file mode 100644 index 0000000..4a143ea --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitDamageComponent.java @@ -0,0 +1,20 @@ +package org.battleplugins.nukkit.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.DamageComponent; +import org.battleplugins.nukkit.inventory.item.NukkitItemStack; + +import java.util.Optional; + +public class NukkitDamageComponent implements DamageComponent { + + @Override + public void applyComponent(ItemStack itemStack, Short durability) { + ((NukkitItemStack) itemStack).getHandle().setDamage((int) durability); + } + + @Override + public Optional getValue(ItemStack itemStack) { + return Optional.of((short) ((NukkitItemStack) itemStack).getHandle().getDamage()); + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitDisplayNameComponent.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitDisplayNameComponent.java new file mode 100644 index 0000000..4b85fa7 --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitDisplayNameComponent.java @@ -0,0 +1,26 @@ +package org.battleplugins.nukkit.inventory.item.component; + +import cn.nukkit.item.Item; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.DisplayNameComponent; +import org.battleplugins.nukkit.inventory.item.NukkitItemStack; + +import java.util.Optional; + +public class NukkitDisplayNameComponent implements DisplayNameComponent { + + @Override + public void applyComponent(ItemStack itemStack, String displayName) { + ((NukkitItemStack) itemStack).getHandle().setCustomName(displayName); + } + + @Override + public Optional getValue(ItemStack itemStack) { + Item item = ((NukkitItemStack) itemStack).getHandle(); + if (!item.hasCustomName()) + return Optional.empty(); + + return Optional.ofNullable(((NukkitItemStack) itemStack).getHandle().getCustomName()); + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitItemFlagComponent.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitItemFlagComponent.java new file mode 100644 index 0000000..730490f --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitItemFlagComponent.java @@ -0,0 +1,21 @@ +package org.battleplugins.nukkit.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.ItemFlagComponent; +import org.battleplugins.inventory.item.component.flag.ItemFlag; + +import java.util.Optional; +import java.util.Set; + +public class NukkitItemFlagComponent implements ItemFlagComponent { + + @Override + public void applyComponent(ItemStack itemStack, Set itemFlags) { + // unsupported + } + + @Override + public Optional> getValue(ItemStack itemStack) { + return Optional.empty(); + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitLoreComponent.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitLoreComponent.java new file mode 100644 index 0000000..3385811 --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitLoreComponent.java @@ -0,0 +1,25 @@ +package org.battleplugins.nukkit.inventory.item.component; + +import cn.nukkit.item.Item; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.LoreComponent; +import org.battleplugins.nukkit.inventory.item.NukkitItemStack; + +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +public class NukkitLoreComponent implements LoreComponent { + + @Override + public void applyComponent(ItemStack itemStack, List lore) { + Item item = ((NukkitItemStack) itemStack).getHandle(); + item.setLore(lore.toArray(new String[0])); + } + + @Override + public Optional> getValue(ItemStack itemStack) { + return Optional.of(Arrays.asList(((NukkitItemStack) itemStack).getHandle().getLore())); + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitUnbreakableComponent.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitUnbreakableComponent.java new file mode 100644 index 0000000..e564c56 --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/inventory/item/component/NukkitUnbreakableComponent.java @@ -0,0 +1,19 @@ +package org.battleplugins.nukkit.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.UnbreakableComponent; + +import java.util.Optional; + +public class NukkitUnbreakableComponent implements UnbreakableComponent { + + @Override + public void applyComponent(ItemStack itemStack, Boolean unbreakable) { + // unsupported + } + + @Override + public Optional getValue(ItemStack itemStack) { + return Optional.empty(); + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/util/NukkitInventoryUtil.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/util/NukkitInventoryUtil.java index a72a00f..eba3d57 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/util/NukkitInventoryUtil.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/util/NukkitInventoryUtil.java @@ -1,11 +1,9 @@ package org.battleplugins.nukkit.util; -import cn.nukkit.Player; import cn.nukkit.inventory.Inventory; import cn.nukkit.item.Item; import cn.nukkit.item.enchantment.Enchantment; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -47,48 +45,6 @@ public static int getItemAmount(Collection items, Item is) { return count; } - public static String getFormattedCommonName(Item is) { - int datavalue = is.getDamage(); - - String iname = ""; - try { - int maxDurability = is.getMaxDurability(); - - iname = formatCommonName(is.getName().toLowerCase()) + " (" + (maxDurability - datavalue) + "/" + maxDurability + ")"; - } catch (Exception e){ - System.err.println("Error getting commonName type=" + is + " iname=" + iname + " datavalue=" + datavalue); - e.printStackTrace(); - } - return iname; - } - - /// Checks if there is enough free space in inventory - public static boolean checkFreeSpace(Inventory inv, Item is, int left) { - return checkFreeSpace(inv.getContents().values(), is, left); - } - - public static boolean checkFreeSpace(Collection contents, Item is, int left) { - int maxStack = is.getMaxStackSize(); - for (Item curitem : contents) { - if (left <= 0) { - return true; - } - if (curitem == null || curitem.getId() == 0) { - left = left - maxStack; - continue; - } - - if (!sameItem(curitem, is, true)) - continue; - - int amount = curitem.getCount(); - if (amount < maxStack) { - left = left - (maxStack - amount); - } - } - return left <= 0; - } - public static int amountFreeSpace(Collection contents, Item is, int left) { int maxStack = is.getMaxStackSize(); for (Item curitem : contents) { @@ -111,10 +67,6 @@ public static int amountFreeSpace(Inventory inv, Item is, int left) { return amountFreeSpace(inv.getContents().values(), is, left); } - public static void addItemToInventory(Player player, Item itemStack, int stockAmount) { - addItemToInventory(player.getInventory(), itemStack, stockAmount); - } - ///Adds item to inventory public static void addItemToInventory(Inventory inv, Item is, int left) { int maxStackSize = is.getMaxStackSize(); @@ -144,34 +96,4 @@ public static void addItemToInventory(Inventory inv, Item is, int left) { inv.addItem(is); } } - - public static String getTypeFromId(int id) { - // This is a hacky method, but Nukkit materials are terribly coded.. - // so what else can you do? - try { - for (Field field : Item.class.getFields()) { - Item item = Item.fromString(field.getName()); - if (item == null) - continue; - - if (id == item.getId()) - return field.getName(); - } - } catch (Exception ex) { - /* do nothing */ - } - - return String.valueOf(id); - } - - private static String formatCommonName(String name) { - name = name.toLowerCase().replace("_", " "); - - String[] words = name.split(" "); - for (int i = 0; i < words.length; i++) { - words[i] = words[i].substring(0, 1).toUpperCase() + words[i].substring(1).toLowerCase(); - } - - return String.join(" ", words); - } } diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/NukkitLocation.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/NukkitLocation.java index a771a9f..c875a8f 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/NukkitLocation.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/NukkitLocation.java @@ -39,19 +39,4 @@ public float getPitch() { public float getYaw() { return (float) handle.getYaw(); } - - @Override - public int getBlockX() { - return handle.getFloorX(); - } - - @Override - public int getBlockY() { - return handle.getFloorY(); - } - - @Override - public int getBlockZ() { - return handle.getFloorZ(); - } } diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/NukkitWorld.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/NukkitWorld.java index 64b79cc..68cec97 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/NukkitWorld.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/NukkitWorld.java @@ -3,14 +3,20 @@ import cn.nukkit.blockentity.BlockEntityChest; import cn.nukkit.blockentity.BlockEntitySign; import cn.nukkit.level.Level; -import cn.nukkit.level.Location; +import cn.nukkit.nbt.tag.CompoundTag; +import cn.nukkit.network.protocol.UpdateBlockPacket; +import org.battleplugins.entity.living.player.Player; +import org.battleplugins.nukkit.entity.living.player.NukkitPlayer; import org.battleplugins.nukkit.world.block.NukkitBlock; import org.battleplugins.nukkit.world.block.entity.NukkitBlockEntity; import org.battleplugins.nukkit.world.block.entity.NukkitChest; import org.battleplugins.nukkit.world.block.entity.NukkitSign; import org.battleplugins.util.MCWrapper; +import org.battleplugins.world.Location; +import org.battleplugins.world.block.Block; import org.battleplugins.world.block.entity.BlockEntity; +import org.battleplugins.world.block.entity.Sign; import java.util.Optional; @@ -71,4 +77,32 @@ public T toType(BlockEntity blockEntity, Class clazz) } return null; } + + @Override + public void sendBlockUpdate(Player player, Location location, Block block) { + cn.nukkit.block.Block nukkitBlock = ((NukkitBlock) block).getHandle(); + nukkitBlock.getLevel().sendBlocks(new cn.nukkit.Player[]{((NukkitPlayer) player).getHandle()}, + new cn.nukkit.block.Block[] {((NukkitBlock) block).getHandle()}, + UpdateBlockPacket.FLAG_ALL_PRIORITY); + } + + @Override + public void sendBlockEntityUpdate(Player player, Location location, BlockEntity blockEntity) { + if (blockEntity instanceof Sign) { + Sign sign = (Sign) blockEntity; + CompoundTag nbt = new CompoundTag() + .putString("id", cn.nukkit.blockentity.BlockEntity.SIGN) + .putInt("x", location.getBlockX()) + .putInt("y", location.getBlockY()) + .putInt("z", location.getBlockZ()) + .putString("Text1", "") + .putString("Text2", "") + .putString("Text3", "") + .putString("Text4", ""); + + BlockEntitySign nukkitSign = new BlockEntitySign(((NukkitLocation) location).getHandle().getChunk(), nbt); + nukkitSign.setText(sign.getLines()); + nukkitSign.spawnTo(((NukkitPlayer) player).getHandle()); + } + } } diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/BlockEntry.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/BlockEntry.java new file mode 100644 index 0000000..adbbc94 --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/BlockEntry.java @@ -0,0 +1,19 @@ +package org.battleplugins.nukkit.world.block; + +import com.google.gson.annotations.SerializedName; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@AllArgsConstructor(access = AccessLevel.PACKAGE) +@Getter +@Setter +public class BlockEntry { + + @SerializedName("bedrock_identifier") + private String bedrockIdentifier; + + @SerializedName("bedrock_data") + private int bedrockData; +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/NukkitBlock.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/NukkitBlock.java index 56d3448..6ea5ef4 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/NukkitBlock.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/NukkitBlock.java @@ -5,6 +5,8 @@ import org.battleplugins.nukkit.world.NukkitLocation; import org.battleplugins.nukkit.world.NukkitWorld; import org.battleplugins.util.MCWrapper; +import org.battleplugins.world.block.BlockRegistry; +import org.battleplugins.world.block.BlockType; public class NukkitBlock extends MCWrapper implements org.battleplugins.world.block.Block { @@ -23,23 +25,8 @@ public NukkitLocation getLocation() { } @Override - public int getX() { - return (int) handle.x; - } - - @Override - public int getY() { - return (int) handle.y; - } - - @Override - public int getZ() { - return (int) handle.z; - } - - @Override - public String getType() { - return String.valueOf(handle.getId()); + public BlockType getType() { + return ((NukkitBlockRegistry) BlockRegistry.REGISTRY).fromPlatformBlock(handle); } @Override diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/NukkitBlockRegistry.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/NukkitBlockRegistry.java new file mode 100644 index 0000000..1cd426e --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/NukkitBlockRegistry.java @@ -0,0 +1,58 @@ +package org.battleplugins.nukkit.world.block; + +import cn.nukkit.block.Block; +import cn.nukkit.item.Item; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + +import org.battleplugins.nukkit.NukkitPlatform; +import org.battleplugins.util.NamespacedKey; +import org.battleplugins.world.block.BlockRegistry; +import org.battleplugins.world.block.BlockType; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Field; +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +public class NukkitBlockRegistry implements BlockRegistry { + + private static final Map BLOCK_ENTRIES = new HashMap<>(); + private static final Map IDENTIFIER_TO_BLOCK = new HashMap<>(); + + public NukkitBlockRegistry() { + InputStream inputStream = NukkitPlatform.class.getResourceAsStream("blocks.json"); + if (inputStream == null) + throw new AssertionError("Blocks Table not found"); + + Gson gson = new Gson(); + Type mapType = new TypeToken>() {}.getType(); + Map blockEntries = gson.fromJson(new InputStreamReader(inputStream), mapType); + for (Map.Entry blockEntry : blockEntries.entrySet()) { + Item item = Item.fromString(blockEntry.getValue().getBedrockIdentifier() + ":" + + blockEntry.getValue().getBedrockData()); + + Block block = Block.get(item.getId(), item.getDamage()); + BLOCK_ENTRIES.put(block, new NukkitBlockType(NamespacedKey.minecraft(blockEntry.getKey()), block)); + IDENTIFIER_TO_BLOCK.put(blockEntry.getKey(), block); + } + } + + @Override + public BlockType fromPlatformBlock(Block block) { + return BLOCK_ENTRIES.get(block); + } + + @Override + public Optional fromKey(NamespacedKey namespacedKey) { + Block block = IDENTIFIER_TO_BLOCK.get(namespacedKey.toString()); + if (block == null) + return Optional.empty(); + + return Optional.ofNullable(BLOCK_ENTRIES.get(block)); + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/NukkitBlockType.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/NukkitBlockType.java new file mode 100644 index 0000000..331d41f --- /dev/null +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/NukkitBlockType.java @@ -0,0 +1,23 @@ +package org.battleplugins.nukkit.world.block; + +import cn.nukkit.block.Block; + +import org.battleplugins.nukkit.inventory.item.NukkitItemType; +import org.battleplugins.util.NamespacedKey; +import org.battleplugins.world.block.BlockType; + +public class NukkitBlockType extends NukkitItemType implements BlockType { + + private Block block; + + protected NukkitBlockType(NamespacedKey key, Block block) { + super(key, block.toItem()); + + this.block = block; + } + + @Override + public float getHardness() { + return (float) block.getHardness(); + } +} diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/entity/NukkitChest.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/entity/NukkitChest.java index 8caa4ad..2e5e6c1 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/entity/NukkitChest.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/entity/NukkitChest.java @@ -1,13 +1,11 @@ package org.battleplugins.nukkit.world.block.entity; import cn.nukkit.blockentity.BlockEntityChest; -import cn.nukkit.item.Item; -import org.battleplugins.nukkit.inventory.NukkitInventory; -import org.battleplugins.nukkit.inventory.item.NukkitItemStack; +import org.battleplugins.inventory.CarriedInventory; +import org.battleplugins.inventory.carrier.Carrier; +import org.battleplugins.nukkit.inventory.NukkitCarriedInventory; -import java.util.ArrayList; -import java.util.List; import java.util.Optional; public class NukkitChest extends NukkitBlockEntity implements org.battleplugins.world.block.entity.Chest { @@ -16,29 +14,13 @@ public NukkitChest(BlockEntityChest chest) { super(chest); } - @Override - public NukkitItemStack[] getItems() { - List items = new ArrayList<>(handle.getInventory().getContents().values()); - NukkitItemStack[] mcItems = new NukkitItemStack[items.size()]; - for (int i = 0; i < items.size(); i++){ - mcItems[i] = new NukkitItemStack(items.get(i)); - } - - return mcItems; - } - - @Override - public boolean isDoubleChest() { - return handle.isPaired(); - } - @Override public Optional getNeighborChest() { return Optional.ofNullable(handle.getPair()).map(NukkitChest::new); } @Override - public NukkitInventory getInventory() { - return new NukkitInventory<>(handle.getInventory()); + public CarriedInventory getInventory() { + return new NukkitCarriedInventory<>(handle.getInventory(), this); } } diff --git a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/entity/NukkitSign.java b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/entity/NukkitSign.java index 116aa8e..0f78832 100644 --- a/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/entity/NukkitSign.java +++ b/modules/nukkit/src/main/java/org/battleplugins/nukkit/world/block/entity/NukkitSign.java @@ -22,23 +22,6 @@ public void setLine(int index, String line) { handle.scheduleUpdate(); } - @Override - public void sendSignChange(Player player, String[] lines) { - CompoundTag nbt = new CompoundTag() - .putString("id", BlockEntity.SIGN) - .putInt("x", (int) handle.getLocation().x) - .putInt("y", (int) handle.getLocation().y) - .putInt("z", (int) handle.getLocation().z) - .putString("Text1", "") - .putString("Text2", "") - .putString("Text3", "") - .putString("Text4", ""); - - BlockEntitySign sign = new BlockEntitySign(handle.getChunk(), nbt); - sign.setText(lines); - sign.spawnTo(((NukkitPlayer) player).getHandle()); - } - @Override public String getLine(int index) { return handle.getText()[index]; diff --git a/modules/nukkit/src/main/resources/mappings b/modules/nukkit/src/main/resources/mappings new file mode 160000 index 0000000..3d4147f --- /dev/null +++ b/modules/nukkit/src/main/resources/mappings @@ -0,0 +1 @@ +Subproject commit 3d4147f001266d01eae6b8479428ca77bb5bf0c3 diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/SpongePlatform.java b/modules/sponge/src/main/java/org/battleplugins/sponge/SpongePlatform.java index 10143db..53f13b0 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/SpongePlatform.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/SpongePlatform.java @@ -1,26 +1,23 @@ package org.battleplugins.sponge; -import org.battleplugins.APIType; +import mc.euro.version.Version; +import org.battleplugins.PlatformType; import org.battleplugins.Platform; import org.battleplugins.message.Message; import org.battleplugins.plugin.Plugin; -import org.battleplugins.plugin.ServicePriority; +import org.battleplugins.plugin.service.ServicePriority; import org.battleplugins.sponge.entity.living.player.SpongeOfflinePlayer; import org.battleplugins.sponge.entity.living.player.SpongePlayer; import org.battleplugins.sponge.message.SpongeMessage; -import org.battleplugins.sponge.inventory.SpongeInventory; import org.battleplugins.sponge.inventory.item.SpongeItemStack; import org.battleplugins.sponge.world.SpongeLocation; import org.battleplugins.sponge.world.SpongeWorld; +import org.battleplugins.world.World; import org.spongepowered.api.Sponge; import org.spongepowered.api.item.ItemTypes; -import org.spongepowered.api.item.inventory.Inventory; import org.spongepowered.api.item.inventory.ItemStack; -import org.spongepowered.api.item.inventory.property.InventoryDimension; -import org.spongepowered.api.item.inventory.property.InventoryTitle; import org.spongepowered.api.service.ProviderRegistration; import org.spongepowered.api.service.user.UserStorageService; -import org.spongepowered.api.text.Text; import org.spongepowered.api.world.Location; import java.util.ArrayList; @@ -32,14 +29,20 @@ public class SpongePlatform extends Platform { + private SpongeRegistry registry; + + public SpongePlatform() { + this.registry = new SpongeRegistry(); + } + @Override - public APIType getAPIType() { - return APIType.SPONGE; + public PlatformType getType() { + return PlatformType.SPONGE; } @Override - public SpongeLocation getLocation(String world, double x, double y, double z, float pitch, float yaw) { - return new SpongeLocation(new Location<>(Sponge.getServer().getWorld(world).get(), x, y, z)); + public SpongeLocation getLocation(World world, double x, double y, double z, float pitch, float yaw) { + return new SpongeLocation(new Location<>(((SpongeWorld) world).getHandle(), x, y, z)); } @Override @@ -120,8 +123,8 @@ public boolean isOnlineMode() { } @Override - public String getVersion() { - return Sponge.getGame().getPlatform().getMinecraftVersion().getName(); + public Version getVersion() { + return new Version<>(Sponge.getGame().getPlatform().getMinecraftVersion().getName()); } @Override @@ -134,14 +137,6 @@ public SpongeItemStack getDefaultPlatformItemStack() { return new SpongeItemStack(ItemStack.of(ItemTypes.AIR)); } - @Override - public SpongeInventory createInventory(Plugin plugin, int slots, String title) { - Inventory inventory = Inventory.builder().property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(Text.of(title))) - .property(InventoryDimension.PROPERTY_NAME, new InventoryDimension( 9, slots / 9)).build(plugin.getPlatformPlugin()); - - return new SpongeInventory<>(inventory); - } - @Override public void registerService(Class clazz, T service, Plugin plugin, ServicePriority priority) { Sponge.getServiceManager().setProvider(plugin.getPlatformPlugin(), clazz, service); @@ -151,4 +146,9 @@ public void registerService(Class clazz, T service, Plugin plugin, Servic public Optional getService(Class clazz) { return Sponge.getServiceManager().getRegistration(clazz).map(ProviderRegistration::getProvider); } + + @Override + public SpongeRegistry getRegistry() { + return registry; + } } diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/SpongeRegistry.java b/modules/sponge/src/main/java/org/battleplugins/sponge/SpongeRegistry.java new file mode 100644 index 0000000..653dddc --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/SpongeRegistry.java @@ -0,0 +1,38 @@ +package org.battleplugins.sponge; + +import org.battleplugins.Registry; +import org.battleplugins.sponge.inventory.SpongeInventoryBuilder; +import org.battleplugins.sponge.inventory.item.SpongeItemRegistry; +import org.battleplugins.sponge.inventory.item.component.*; +import org.battleplugins.sponge.world.block.SpongeBlockRegistry; + +public class SpongeRegistry extends Registry { + + private SpongeItemRegistry itemRegistry; + private SpongeBlockRegistry blockRegistry; + + SpongeRegistry() { + itemRegistry = new SpongeItemRegistry(); + blockRegistry = new SpongeBlockRegistry(); + + itemComponents.add(SpongeColorComponent.class); + itemComponents.add(SpongeCustomModelDataComponent.class); + itemComponents.add(SpongeDamageComponent.class); + itemComponents.add(SpongeDisplayNameComponent.class); + itemComponents.add(SpongeItemFlagComponent.class); + itemComponents.add(SpongeLoreComponent.class); + itemComponents.add(SpongeUnbreakableComponent.class); + + builders.add(SpongeInventoryBuilder.class); + } + + @Override + public SpongeItemRegistry getItemRegistry() { + return itemRegistry; + } + + @Override + public SpongeBlockRegistry getBlockRegistry() { + return blockRegistry; + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/compat/SpongeCompatItemType.java b/modules/sponge/src/main/java/org/battleplugins/sponge/compat/SpongeCompatItemType.java new file mode 100644 index 0000000..8a72954 --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/compat/SpongeCompatItemType.java @@ -0,0 +1,1094 @@ +package org.battleplugins.sponge.compat; + +import org.spongepowered.api.Sponge; +import org.spongepowered.api.data.DataQuery; +import org.spongepowered.api.data.key.Keys; +import org.spongepowered.api.item.ItemType; +import org.spongepowered.api.item.ItemTypes; +import org.spongepowered.api.item.inventory.ItemStack; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +/** + * NOTE: This class is quite volatile and may break depending on the + * Bukkit update. It is recommended this is not used at all for + * plugins and if there is a reason why it should be accessed, + * it should be used sparingly. + */ +public enum SpongeCompatItemType { + + ACACIA_BOAT(0, "BOAT_ACACIA"), + ACACIA_BUTTON(0, "WOOD_BUTTON"), + ACACIA_DOOR(0, "ACACIA_DOOR","ACACIA_DOOR_ITEM"), + ACACIA_FENCE(0, "ACACIA_FENCE"), + ACACIA_FENCE_GATE(0, "ACACIA_FENCE_GATE"), + ACACIA_LEAVES(0, "LEAVES_2"), + ACACIA_LOG(0, "LOG_2"), + ACACIA_PLANKS(4, "WOOD"), + ACACIA_PRESSURE_PLATE(0, "WOOD_PLATE"), + ACACIA_SAPLING(4, "SAPLING"), + ACACIA_SIGN(0, "SIGN"), + ACACIA_SLAB(4,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + ACACIA_STAIRS(4, "ACACIA_STAIRS"), + ACACIA_TRAPDOOR(0, "TRAP_DOOR"), + ACACIA_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + ACACIA_WOOD(0, "LOG_2"), + ACTIVATOR_RAIL(0, "ACTIVATOR_RAIL"), + AIR(0, "AIR"), + ALLIUM(2, "RED_ROSE"), + ANDESITE(5, "STONE"), + ANDESITE_SLAB(0, "ANDESITE_SLAB"), + ANDESITE_STAIRS(0, "ANDESITE_STAIRS"), + ANDESITE_WALL(0, "ANDESITE_WALL"), + ANVIL(0, "ANVIL"), + APPLE(0, "APPLE"), + ARMOR_STAND(0, "ARMOR_STAND"), + ARROW(0, "ARROW"), + ATTACHED_MELON_STEM(7, "MELON_STEM"), + ATTACHED_PUMPKIN_STEM(7, "PUMPKIN_STEM"), + AZURE_BLUET(3, "RED_ROSE"), + BAKED_POTATO(0, "BAKED_POTATO"), + BAMBOO(0, "BAMBOO"), + BAMBOO_SAPLING(0, "SAPLING"), + BARRIER(0, "BARRIER"), + BARREL(0, "BARREL"), + BAT_SPAWN_EGG(65, "MONSTER_EGG"), + BEACON(0, "BEACON"), + BEDROCK(0, "BEDROCK"), + BEEF(0, "RAW_BEEF"), + BEETROOT(0, "BEETROOT"), + BEETROOTS(0, "BEETROOT", "BEETROOT_BLOCK"), + BEETROOT_SEEDS(0, "BEETROOT_SEEDS"), + BEETROOT_SOUP(0, "BEETROOT_SOUP"), + BEEHIVE(0, "BEEHIVE"), + BEE_NEST(0, "BEE_NEST"), + BEE_SPAWN_EGG(0, "BEE_SPAWN_EGG"), + BELL(0, "BELL"), + BIRCH_BOAT(0, "BOAT_BIRCH"), + BIRCH_BUTTON(0, "WOOD_BUTTON"), + BIRCH_DOOR(0, "BIRCH_DOOR", "BIRCH_DOOR_ITEM"), + BIRCH_FENCE(0, "BIRCH_FENCE"), + BIRCH_FENCE_GATE(0, "BIRCH_FENCE_GATE"), + BIRCH_LEAVES(2, "LEAVES"), + BIRCH_LOG(2, "LOG"), + BIRCH_PLANKS(2, "WOOD"), + BIRCH_PRESSURE_PLATE(0, "WOOD_PLATE"), + BIRCH_SAPLING(2, "SAPLING"), + BIRCH_SIGN(0, "SIGN"), + BIRCH_SLAB(2,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + BIRCH_STAIRS(0, "BIRCH_WOOD_STAIRS"), + BIRCH_TRAPDOOR(0, "TRAP_DOOR"), + BIRCH_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + BIRCH_WOOD(2, "LOG"), + BLACK_BANNER(0, "BANNER", "STANDING_BANNER"), + BLACK_BED(15, "BED", "BED_BLOCK"), + BLACK_CARPET(15, "CARPET"), + BLACK_CONCRETE(15, "CONCRETE"), + BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"), + BLACK_DYE(0, "INK_SACK"), + BLACK_GLAZED_TERRACOTTA(0, "BLACK_GLAZED_TERRACOTTA"), + BLACK_SHULKER_BOX(0, "BLACK_SHULKER_BOX"), + BLACK_STAINED_GLASS(15, "STAINED_GLASS"), + BLACK_STAINED_GLASS_PANE(15, "STAINED_GLASS_PANE"), + BLACK_TERRACOTTA(15, "STAINED_CLAY"), + BLACK_WALL_BANNER(0, "WALL_BANNER"), + BLACK_WOOL(15, "WOOL"), + BLAST_FURNACE(0, "FURNACE"), + BLAZE_POWDER(0, "BLAZE_POWDER"), + BLAZE_ROD(0, "BLAZE_ROD"), + BLAZE_SPAWN_EGG(61, "MONSTER_EGG"), + BLUE_BANNER(11, "BANNER", "STANDING_BANNER"), + BLUE_BED(4, "BED", "BED_BLOCK"), + BLUE_CARPET(11, "CARPET"), + BLUE_CONCRETE(11, "CONCRETE"), + BLUE_CONCRETE_POWDER(11, "CONCRETE_POWDER"), + BLUE_DYE(0, "LAPIS_LAZULI"), + BLUE_GLAZED_TERRACOTTA(0, "BLUE_GLAZED_TERRACOTTA"), + BLUE_ICE(0, "PACKED_ICE"), + BLUE_ORCHID(1, "RED_ROSE"), + BLUE_SHULKER_BOX(0, "BLUE_SHULKER_BOX"), + BLUE_STAINED_GLASS(11, "STAINED_GLASS"), + BLUE_STAINED_GLASS_PANE(11, "STAINED_GLASS_PANE"), + BLUE_TERRACOTTA(11, "STAINED_CLAY"), + BLUE_WALL_BANNER(11, "WALL_BANNER"), + BLUE_WOOL(11, "WOOL"), + BONE(0, "BONE"), + BONE_BLOCK(0, "BONE_BLOCK"), + BONE_MEAL(15, "INK_SACK"), + BOOK(0, "BOOK"), + BOOKSHELF(0, "BOOKSHELF"), + BOW(0, "BOW"), + BOWL(0, "BOWL"), + BRAIN_CORAL(0, "STONE"), + BRAIN_CORAL_BLOCK(0, "STONE"), + BRAIN_CORAL_FAN(0, "STONE"), + BREAD(0, "BREAD"), + BREWING_STAND(0, "BREWING_STAND", "BREWING_STAND_ITEM"), + BRICK(0, "CLAY_BRICK"), + BRICKS(0, "BRICK"), + BRICK_SLAB(4, "STEP"), + BRICK_STAIRS(0, "BRICK_STAIRS"), + BROWN_BANNER(3, "BANNER", "STANDING_BANNER"), + BROWN_BED(12, "BED", "BED_BLOCK"), + BROWN_CARPET(12, "CARPET"), + BROWN_CONCRETE(12, "CONCRETE"), + BROWN_CONCRETE_POWDER(12, "CONCRETE_POWDER"), + BROWN_DYE(0, "COCOA_BEANS"), + BROWN_GLAZED_TERRACOTTA(0, "BROWN_GLAZED_TERRACOTTA"), + BROWN_MUSHROOM(0, "BROWN_MUSHROOM"), + BROWN_MUSHROOM_BLOCK(0, "BROWN_MUSHROOM", "HUGE_MUSHROOM_1"), + BROWN_SHULKER_BOX(0, "BROWN_SHULKER_BOX"), + BROWN_STAINED_GLASS(12, "STAINED_GLASS"), + BROWN_STAINED_GLASS_PANE(12, "STAINED_GLASS_PANE"), + BROWN_TERRACOTTA(12, "STAINED_CLAY"), + BROWN_WALL_BANNER(3, "WALL_BANNER"), + BROWN_WOOL(12, "WOOL"), + BUBBLE_COLUMN(0, "STONE"), + BUBBLE_CORAL(0, "STONE"), + BUBBLE_CORAL_BLOCK(0, "STONE"), + BUBBLE_CORAL_FAN(0, "STONE"), + BUCKET(0, "BUCKET"), + CACTUS(0, "CACTUS"), + CACTUS_GREEN(2, "INK_SACK"), + CAKE(0, "CAKE", "CAKE_BLOCK"), + CAMPFIRE(0, "CAMPFIRE"), + CARROT(0, "CARROT_ITEM"), + CARROTS(0, "CARROT"), + CARROT_ON_A_STICK(0, "CARROT_STICK"), + CARTOGRAPHY_TABLE(0, "CARTOGRAPHY_TABLE"), + CARVED_PUMPKIN(0, "PUMPKIN"), + CAT_SPAWN_EGG(0, "CAT_SPAWN_EGG"), + CAULDRON(0, "CAULDRON", "CAULDRON_ITEM"), + CAVE_AIR(0, "AIR"), + CAVE_SPIDER_SPAWN_EGG(59, "MONSTER_EGG"), + CHAINMAIL_BOOTS(0, "CHAINMAIL_BOOTS"), + CHAINMAIL_CHESTPLATE(0, "CHAINMAIL_CHESTPLATE"), + CHAINMAIL_HELMET(0, "CHAINMAIL_HELMET"), + CHAINMAIL_LEGGINGS(0, "CHAINMAIL_LEGGINGS"), + CHAIN_COMMAND_BLOCK(0, "COMMAND_CHAIN"), + CHARCOAL(1, "COAL"), + CHEST(0, "CHEST", "LOCKED_CHEST"), + CHEST_MINECART(0, "STORAGE_MINECART"), + CHICKEN(0, "RAW_CHICKEN"), + CHICKEN_SPAWN_EGG(93, "MONSTER_EGG"), + CHIPPED_ANVIL(1, "ANVIL"), + CHISELED_QUARTZ_BLOCK(1, "QUARTZ_BLOCK"), + CHISELED_RED_SANDSTONE(1, "RED_SANDSTONE"), + CHISELED_SANDSTONE(1, "SANDSTONE"), + CHISELED_STONE_BRICKS(3, "SMOOTH_BRICK"), + CHORUS_FLOWER(0, "CHORUS_FLOWER"), + CHORUS_FRUIT(0, "CHORUS_FRUIT"), + CHORUS_PLANT(0, "CHORUS_PLANT"), + CLAY(0, "CLAY"), + CLAY_BALL(0, "CLAY_BALL"), + CLOCK(0, "WATCH"), + COAL(0, "COAL"), + COAL_BLOCK(0, "COAL_BLOCK"), + COAL_ORE(0, "COAL_ORE"), + COARSE_DIRT(1, "DIRT"), + COBBLESTONE(0, "COBBLESTONE"), + COBBLESTONE_SLAB(3, "STEP"), + COBBLESTONE_STAIRS(0, "COBBLESTONE_STAIRS"), + COBBLESTONE_WALL(0, "COBBLE_WALL"), + COBWEB(0, "WEB"), + COCOA(0, "COCOA"), + COCOA_BEANS(3, "INK_SACK"), + COD(0, "RAW_FISH"), + COD_BUCKET(0, "BUCKET"), + COD_SPAWN_EGG(0, "MONSTER_EGG"), + COMMAND_BLOCK(0, "COMMAND"), + COMMAND_BLOCK_MINECART(0, "COMMAND_MINECART"), + COMPARATOR(0, "REDSTONE_COMPARATOR", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR_OFF"), + COMPASS(0, "COMPASS"), + COMPOSTER(0, "COMPOSTER"), + CONDUIT(0, "STONE"), + COOKED_BEEF(0, "COOKED_BEEF"), + COOKED_CHICKEN(0, "COOKED_CHICKEN"), + COOKED_COD(0, "COOKED_FISH"), + COOKED_MUTTON(0, "COOKED_MUTTON"), + COOKED_PORKCHOP(0, "GRILLED_PORK"), + COOKED_RABBIT(0, "COOKED_RABBIT"), + COOKED_SALMON(1, "COOKED_FISH"), + COOKIE(0, "COOKIE"), + CORNFLOWER(0, "CORNFLOWER"), + COW_SPAWN_EGG(92, "MONSTER_EGG"), + CRACKED_STONE_BRICKS(2, "SMOOTH_BRICK"), + CRAFTING_TABLE(0, "WORKBENCH"), + CREEPER_HEAD(4, "SKULL_ITEM","SKULL"), + CREEPER_SPAWN_EGG(50, "MONSTER_EGG"), + CREEPER_WALL_HEAD(4, "SKULL_ITEM","SKULL"), + CROSSBOW(0, "CROSSBOW"), + CUT_RED_SANDSTONE(0, "STONE"), + CUT_RED_SANDSTONE_SLAB(0, "CUT_RED_SANDSTONE_SLAB"), + CUT_SANDSTONE(0, "STONE"), + CUT_SANDSTONE_SLAB(0, "CUT_STANDSTONE_SLAB"), + CYAN_BANNER(6, "BANNER", "STANDING_BANNER"), + CYAN_BED(9, "BED", "BED_BLOCK"), + CYAN_CARPET(9, "CARPET"), + CYAN_CONCRETE(9, "CONCRETE"), + CYAN_CONCRETE_POWDER(9, "CONCRETE_POWDER"), + CYAN_DYE(6, "INK_SACK"), + CYAN_GLAZED_TERRACOTTA(0, "CYAN_GLAZED_TERRACOTTA"), + CYAN_SHULKER_BOX(0, "CYAN_SHULKER_BOX"), + CYAN_STAINED_GLASS(9, "STAINED_GLASS"), + CYAN_STAINED_GLASS_PANE(9, "STAINED_GLASS_PANE"), + CYAN_TERRACOTTA(9, "STAINED_CLAY"), + CYAN_WALL_BANNER(0, "WALL_BANNER"), + CYAN_WOOL(9, "WOOL"), + DAMAGED_ANVIL(2, "ANVIL"), + DANDELION(0, "YELLOW_FLOWER"), + DANDELION_YELLOW(11, "INK_SACK"), + DARK_OAK_BOAT(0, "BOAT_DARK_OAK"), + DARK_OAK_BUTTON(0, "WOOD_BUTTON"), + DARK_OAK_DOOR(0, "DARK_OAK_DOOR", "DARK_OAK_DOOR_ITEM"), + DARK_OAK_FENCE(0, "DARK_OAK_FENCE"), + DARK_OAK_FENCE_GATE(0, "DARK_OAK_FENCE_GATE"), + DARK_OAK_LEAVES(1, "LEAVES_2"), + DARK_OAK_LOG(1, "LOG_2"), + DARK_OAK_PLANKS(5, "WOOD"), + DARK_OAK_PRESSURE_PLATE(0, "WOOD_PLATE"), + DARK_OAK_SAPLING(5, "SAPLING"), + DARK_OAK_SIGN(0, "SIGN"), + DARK_OAK_SLAB(0,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + DARK_OAK_STAIRS(0, "DARK_OAK_STAIRS"), + DARK_OAK_TRAPDOOR(0, "TRAP_DOOR"), + DARK_OAK_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + DARK_OAK_WOOD(1, "LOG_2"), + DARK_PRISMARINE(2, "PRISMARINE"), + DARK_PRISMARINE_SLAB(0, "STONE"), + DARK_PRISMARINE_STAIRS(0, "STONE"), + DAYLIGHT_DETECTOR(0, "DAYLIGHT_DETECTOR", "DAYLIGHT_DETECTOR_INVERTED"), + DEAD_BRAIN_CORAL_BLOCK(0, "STONE"), + DEAD_BUBBLE_CORAL_BLOCK(0, "STONE"), + DEAD_BUSH(0, "DEAD_BUSH"), + DEAD_FIRE_CORAL_BLOCK(0, "STONE"), + DEAD_HORN_CORAL_BLOCK(0, "STONE"), + DEAD_TUBE_CORAL_BLOCK(0, "STONE"), + DEBUG_STICK(0, "STICK"), + DETECTOR_RAIL(0, "DETECTOR_RAIL"), + DIAMOND(0, "DIAMOND"), + DIAMOND_AXE(0, "DIAMOND_AXE"), + DIAMOND_BLOCK(0, "DIAMOND_BLOCK"), + DIAMOND_BOOTS(0, "DIAMOND_BOOTS"), + DIAMOND_CHESTPLATE(0, "DIAMOND_CHESTPLATE"), + DIAMOND_HELMET(0, "DIAMOND_HELMET"), + DIAMOND_HOE(0, "DIAMOND_HOE"), + DIAMOND_HORSE_ARMOR(0, "DIAMOND_BARDING"), + DIAMOND_LEGGINGS(0, "DIAMOND_LEGGINGS"), + DIAMOND_ORE(0, "DIAMOND_ORE"), + DIAMOND_PICKAXE(0, "DIAMOND_PICKAXE"), + DIAMOND_SHOVEL(0, "DIAMOND_SPADE"), + DIAMOND_SWORD(0, "DIAMOND_SWORD"), + DIORITE(3, "STONE"), + DIORITE_SLAB(0, "DIORITE_SLAB"), + DIORITE_STAIRS(0, "DIORITE_STAIRS"), + DIORITE_WALL(0, "DIORITE_WALL"), + DIRT(0, "DIRT"), + DISPENSER(0, "DISPENSER"), + DOLPHIN_SPAWN_EGG(0, "MONSTER_EGG"), + DONKEY_SPAWN_EGG(31, "MONSTER_EGG"), + DRAGON_BREATH(0, "DRAGONS_BREATH"), + DRAGON_EGG(0, "DRAGON_EGG"), + DRAGON_HEAD(5, "SKULL_ITEM","SKULL"), + DRAGON_WALL_HEAD(5, "SKULL_ITEM","SKULL"), + DRIED_KELP(0, "STONE"), + DRIED_KELP_BLOCK(0, "STONE"), + DROPPER(0, "DROPPER"), + DROWNED_SPAWN_EGG(0, "MONSTER_EGG"), + EGG(0, "EGG"), + ELDER_GUARDIAN_SPAWN_EGG(4, "MONSTER_EGG"), + ELYTRA(0, "ELYTRA"), + EMERALD(0, "EMERALD"), + EMERALD_BLOCK(0, "EMERALD_BLOCK"), + EMERALD_ORE(0, "EMERALD_ORE"), + ENCHANTED_BOOK(0, "ENCHANTED_BOOK"), + ENCHANTED_GOLDEN_APPLE(1, "GOLDEN_APPLE"), + ENCHANTING_TABLE(0, "ENCHANTMENT_TABLE"), + ENDERMAN_SPAWN_EGG(58, "MONSTER_EGG"), + ENDERMITE_SPAWN_EGG(67, "MONSTER_EGG"), + ENDER_CHEST(0, "ENDER_CHEST"), + ENDER_EYE(0, "EYE_OF_ENDER"), + ENDER_PEARL(0, "ENDER_PEARL"), + END_CRYSTAL(0, "END_CRYSTAL"), + END_GATEWAY(0, "END_GATEWAY"), + END_PORTAL(0, "ENDER_PORTAL"), + END_PORTAL_FRAME(0, "ENDER_PORTAL_FRAME"), + END_ROD(0, "END_ROD"), + END_STONE(0, "ENDER_STONE"), + END_STONE_BRICK_SLAB(0, "END_STONE_BRICK_SLAB"), + END_STONE_BRICK_STAIRS(0, "END_STONE_BRICK_STAIRS"), + END_STONE_BRICK_WALL(0, "END_STONE_BRICK_WALL"), + END_STONE_BRICKS(0, "END_BRICKS"), + EVOKER_SPAWN_EGG(34, "MONSTER_EGG"), + EXPERIENCE_BOTTLE(0, "EXP_BOTTLE"), + FARMLAND(0, "SOIL"), + FEATHER(0, "FEATHER"), + FERMENTED_SPIDER_EYE(0, "FERMENTED_SPIDER_EYE"), + FERN(2, "LONG_GRASS"), + FILLED_MAP(0, "MAP"), + FIRE(0, "FIRE"), + FIREWORK_ROCKET(0, "FIREWORK"), + FIREWORK_STAR(0, "FIREWORK_CHARGE"), + FIRE_CHARGE(0, "FIREBALL"), + FIRE_CORAL(0, "STONE"), + FIRE_CORAL_BLOCK(0, "STONE"), + FIRE_CORAL_FAN(0, "STONE"), + FISHING_ROD(0, "FISHING_ROD"), + FLETCHING_TABLE(0, "FLETCHING_TABLE"), + FLINT(0, "FLINT"), + FLINT_AND_STEEL(0, "FLINT_AND_STEEL"), + FLOWER_POT(0, "FLOWER_POT","FLOWER_POT_ITEM"), + FOX_SPAWN_EGG(0, "FOX_SPAWN_EGG"), + FROSTED_ICE(0, "FROSTED_ICE"), + FURNACE(0, "FURNACE", "BURNING_FURNACE"), + FURNACE_MINECART(0, "POWERED_MINECART"), + GHAST_SPAWN_EGG(56, "MONSTER_EGG"), + GHAST_TEAR(0, "GHAST_TEAR"), + GLASS(0, "GLASS"), + GLASS_BOTTLE(0, "GLASS_BOTTLE"), + GLASS_PANE(0, "THIN_GLASS"), + GLISTERING_MELON_SLICE(0, "SPECKLED_MELON"), + GLOWSTONE(0, "GLOWSTONE"), + GLOWSTONE_DUST(0, "GLOWSTONE_DUST"), + GOLDEN_APPLE(0, "GOLDEN_APPLE"), + GOLDEN_AXE(0, "GOLD_AXE"), + GOLDEN_BOOTS(0, "GOLD_BOOTS"), + GOLDEN_CARROT(0, "GOLDEN_CARROT"), + GOLDEN_CHESTPLATE(0, "GOLD_CHESTPLATE"), + GOLDEN_HELMET(0, "GOLD_HELMET"), + GOLDEN_HOE(0, "GOLD_HOE"), + GOLDEN_HORSE_ARMOR(0, "GOLD_BARDING"), + GOLDEN_LEGGINGS(0, "GOLD_LEGGINGS"), + GOLDEN_PICKAXE(0, "GOLD_PICKAXE"), + GOLDEN_SHOVEL(0, "GOLD_SPADE"), + GOLDEN_SWORD(0, "GOLD_SWORD"), + GOLD_BLOCK(0, "GOLD_BLOCK"), + GOLD_INGOT(0, "GOLD_INGOT"), + GOLD_NUGGET(0, "GOLD_NUGGET"), + GOLD_ORE(0, "GOLD_ORE"), + GRANITE(1, "STONE"), + GRANITE_SLAB(0, "GRANITE_SLAB"), + GRANITE_STAIRS(0, "GRANITE_STAIRS"), + GRANITE_WALL(0, "GRANITE_WALL"), + GRASS(0, "GRASS"), + GRASS_BLOCK(0, "GRASS"), + GRASS_PATH(0, "GRASS_PATH"), + GRAVEL(0, "GRAVEL"), + GRAY_BANNER(8, "BANNER", "STANDING_BANNER"), + GRAY_BED(7, "BED", "BED_BLOCK"), + GRAY_CARPET(7, "CARPET"), + GRAY_CONCRETE(7, "CONCRETE"), + GRAY_CONCRETE_POWDER(7, "CONCRETE_POWDER"), + GRAY_DYE(8, "INK_SACK"), + GRAY_GLAZED_TERRACOTTA(0, "GRAY_GLAZED_TERRACOTTA"), + GRAY_SHULKER_BOX(0, "GRAY_SHULKER_BOX"), + GRAY_STAINED_GLASS(7, "STAINED_GLASS"), + GRAY_STAINED_GLASS_PANE(7, "STAINED_GLASS_PANE"), + GRAY_TERRACOTTA(7, "STAINED_CLAY"), + GRAY_WALL_BANNER(0, "WALL_BANNER"), + GRAY_WOOL(7, "WOOL"), + GREEN_BANNER(2, "BANNER", "STANDING_BANNER"), + GREEN_BED(13, "BED", "BED_BLOCK"), + GREEN_CARPET(13, "CARPET"), + GREEN_CONCRETE(13, "CONCRETE"), + GREEN_CONCRETE_POWDER(13, "CONCRETE_POWDER"), + GREEN_GLAZED_TERRACOTTA(0, "GREEN_GLAZED_TERRACOTTA"), + GREEN_SHULKER_BOX(0, "GREEN_SHULKER_BOX"), + GREEN_STAINED_GLASS(13, "STAINED_GLASS"), + GREEN_STAINED_GLASS_PANE(13, "STAINED_GLASS_PANE"), + GREEN_TERRACOTTA(13, "STAINED_CLAY"), + GREEN_WALL_BANNER(0, "WALL_BANNER"), + GREEN_WOOL(13, "WOOL"), + GRINDSTONE(0, "GRINDSTONE"), + GUARDIAN_SPAWN_EGG(68, "MONSTER_EGG"), + GUNPOWDER(0, "SULPHUR"), + HAY_BLOCK(0, "HAY_BLOCK"), + HEART_OF_THE_SEA(0, "STONE"), + HEAVY_WEIGHTED_PRESSURE_PLATE(0, "IRON_PLATE"), + HONEY_BLOCK(0, "HONEY_BLOCK"), + HONEY_BOTTLE(0, "HONEY_BOTTLE"), + HONEYCOMB(0, "HONEYCOMB"), + HONEYCOMB_BLOCK(0, "HONEYCOMB_BLOCK"), + HOPPER(0, "HOPPER"), + HOPPER_MINECART(0, "HOPPER_MINECART"), + HORN_CORAL(0, "STONE"), + HORN_CORAL_BLOCK(0, "STONE"), + HORN_CORAL_FAN(0, "STONE"), + HORSE_SPAWN_EGG(100, "MONSTER_EGG"), + HUSK_SPAWN_EGG(23, "MONSTER_EGG"), + ICE(0, "ICE"), + INFESTED_CHISELED_STONE_BRICKS(5, "MONSTER_EGGS"), + INFESTED_COBBLESTONE(1, "MONSTER_EGGS"), + INFESTED_CRACKED_STONE_BRICKS(4, "MONSTER_EGGS"), + INFESTED_MOSSY_STONE_BRICKS(3, "MONSTER_EGGS"), + INFESTED_STONE(0, "MONSTER_EGGS"), + INFESTED_STONE_BRICKS(2, "MONSTER_EGGS"), + INK_SAC(0, "INK_SACK"), + IRON_AXE(0, "IRON_AXE"), + IRON_BARS(0, "IRON_FENCE"), + IRON_BLOCK(0, "IRON_BLOCK"), + IRON_BOOTS(0, "IRON_BOOTS"), + IRON_CHESTPLATE(0, "IRON_CHESTPLATE"), + IRON_DOOR(0, "IRON_DOOR", "IRON_DOOR_BLOCK"), + IRON_HELMET(0, "IRON_HELMET"), + IRON_HOE(0, "IRON_HOE"), + IRON_HORSE_ARMOR(0, "IRON_BARDING"), + IRON_INGOT(0, "IRON_INGOT"), + IRON_LEGGINGS(0, "IRON_LEGGINGS"), + IRON_NUGGET(0, "IRON_NUGGET"), + IRON_ORE(0, "IRON_ORE"), + IRON_PICKAXE(0, "IRON_PICKAXE"), + IRON_SHOVEL(0, "IRON_SPADE"), + IRON_SWORD(0, "IRON_SWORD"), + IRON_TRAPDOOR(0, "IRON_TRAPDOOR"), + ITEM_FRAME(0, "ITEM_FRAME"), + JACK_O_LANTERN(0, "JACK_O_LANTERN"), + JIGSAW(0, "JIGSAW"), + JUKEBOX(0, "JUKEBOX"), + JUNGLE_BOAT(0, "BOAT_JUNGLE"), + JUNGLE_BUTTON(0, "WOOD_BUTTON"), + JUNGLE_DOOR(0, "JUNGLE_DOOR", "JUNGLE_DOOR_ITEM"), + JUNGLE_FENCE(0, "JUNGLE_FENCE"), + JUNGLE_FENCE_GATE(0, "JUNGLE_FENCE_GATE"), + JUNGLE_LEAVES(3, "LEAVES"), + JUNGLE_LOG(3, "LOG"), + JUNGLE_PLANKS(3, "WOOD"), + JUNGLE_PRESSURE_PLATE(0, "WOOD_PLATE"), + JUNGLE_SAPLING(3, "SAPLING"), + JUNGLE_SIGN(0, "SIGN"), + JUNGLE_SLAB(3,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + JUNGLE_STAIRS(0, "JUNGLE_WOOD_STAIRS"), + JUNGLE_TRAPDOOR(0, "TRAP_DOOR"), + JUNGLE_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + JUNGLE_WOOD(3, "LOG"), + KELP(0, "STONE"), + KELP_PLANT(0, "STONE"), + KNOWLEDGE_BOOK(0, "KNOWLEDGE_BOOK"), + LADDER(0, "LADDER"), + LANTERN(0, "LANTERN"), + LAPIS_BLOCK(0, "LAPIS_BLOCK"), + LAPIS_LAZULI(4, "INK_SACK"), + LAPIS_ORE(0, "LAPIS_ORE"), + LARGE_FERN(3, "DOUBLE_PLANT"), + LAVA(0, "LAVA", "STATIONARY_LAVA"), + LAVA_BUCKET(0, "LAVA_BUCKET"), + LEAD(0, "LEASH"), + LEATHER(0, "LEATHER"), + LEATHER_BOOTS(0, "LEATHER_BOOTS"), + LEATHER_CHESTPLATE(0, "LEATHER_CHESTPLATE"), + LEATHER_HELMET(0, "LEATHER_HELMET"), + LEATHER_HORSE_ARMOR(0, "LEATHER_HORSE_ARMOR"), + LEATHER_LEGGINGS(0, "LEATHER_LEGGINGS"), + LECTERN(0, "LECTERN"), + LEVER(0, "LEVER"), + LIGHT_BLUE_BANNER(12, "BANNER", "STANDING_BANNER"), + LIGHT_BLUE_BED(3, "BED", "BED_BLOCK"), + LIGHT_BLUE_CARPET(3, "CARPET"), + LIGHT_BLUE_CONCRETE(3, "CONCRETE"), + LIGHT_BLUE_CONCRETE_POWDER(3, "CONCRETE_POWDER"), + LIGHT_BLUE_DYE(12, "INK_SACK"), + LIGHT_BLUE_GLAZED_TERRACOTTA(0, "LIGHT_BLUE_GLAZED_TERRACOTTA"), + LIGHT_BLUE_SHULKER_BOX(0, "LIGHT_BLUE_SHULKER_BOX"), + LIGHT_BLUE_STAINED_GLASS(3, "STAINED_GLASS"), + LIGHT_BLUE_STAINED_GLASS_PANE(3, "STAINED_GLASS_PANE"), + LIGHT_BLUE_TERRACOTTA(3, "STAINED_CLAY"), + LIGHT_BLUE_WALL_BANNER(0, "BANNER", "STANDING_BANNER"), + LIGHT_BLUE_WOOL(3, "WOOL"), + LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"), + LIGHT_GRAY_BED(8, "BED", "BED_BLOCK"), + LIGHT_GRAY_CARPET(8, "CARPET"), + LIGHT_GRAY_CONCRETE(8, "CONCRETE"), + LIGHT_GRAY_CONCRETE_POWDER(8, "CONCRETE_POWDER"), + LIGHT_GRAY_DYE(7, "INK_SACK"), + LIGHT_GRAY_GLAZED_TERRACOTTA(0, "SILVER_GLAZED_TERRACOTTA"), + LIGHT_GRAY_SHULKER_BOX(0, "SILVER_SHULKER_BOX"), + LIGHT_GRAY_STAINED_GLASS(8, "STAINED_GLASS"), + LIGHT_GRAY_STAINED_GLASS_PANE(8, "STAINED_GLASS_PANE"), + LIGHT_GRAY_TERRACOTTA(8, "STAINED_CLAY"), + LIGHT_GRAY_WALL_BANNER(0, "WALL_BANNER"), + LIGHT_GRAY_WOOL(8, "WOOL"), + LIGHT_WEIGHTED_PRESSURE_PLATE(0, "GOLD_PLATE"), + LILAC(1, "DOUBLE_PLANT"), + LILY_OF_THE_VALLEY(0, "LILY_OF_THE_VALLEY"), + LILY_PAD(0, "WATER_LILY"), + LIME_BANNER(10, "BANNER", "STANDING_BANNER"), + LIME_BED(5, "BED", "BED_BLOCK"), + LIME_CARPET(5, "CARPET"), + LIME_CONCRETE(5, "CONCRETE"), + LIME_CONCRETE_POWDER(5, "CONCRETE_POWDER"), + LIME_DYE(10, "INK_SACK"), + LIME_GLAZED_TERRACOTTA(0, "LIME_GLAZED_TERRACOTTA"), + LIME_SHULKER_BOX(0, "LIME_SHULKER_BOX"), + LIME_STAINED_GLASS(5, "STAINED_GLASS"), + LIME_STAINED_GLASS_PANE(5, "STAINED_GLASS_PANE"), + LIME_TERRACOTTA(5, "STAINED_CLAY"), + LIME_WALL_BANNER(0, "WALL_BANNER"), + LIME_WOOL(5, "WOOL"), + LINGERING_POTION(0, "LINGERING_POTION"), + LLAMA_SPAWN_EGG(103, "MONSTER_EGG"), + LOOM(0, "LOOM"), + MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"), + MAGENTA_BED(2, "BED", "BED_BLOCK"), + MAGENTA_CARPET(2, "CARPET"), + MAGENTA_CONCRETE(2, "CONCRETE"), + MAGENTA_CONCRETE_POWDER(2, "CONCRETE_POWDER"), + MAGENTA_DYE(13, "INK_SACK"), + MAGENTA_GLAZED_TERRACOTTA(0, "MAGENTA_GLAZED_TERRACOTTA"), + MAGENTA_SHULKER_BOX(0, "MAGENTA_SHULKER_BOX"), + MAGENTA_STAINED_GLASS(2, "STAINED_GLASS"), + MAGENTA_STAINED_GLASS_PANE(2, "STAINED_GLASS_PANE"), + MAGENTA_TERRACOTTA(2, "STAINED_CLAY"), + MAGENTA_WALL_BANNER(0, "WALL_BANNER"), + MAGENTA_WOOL(2, "WOOL"), + MAGMA_BLOCK(0, "MAGMA"), + MAGMA_CREAM(0, "MAGMA_CREAM"), + MAGMA_CUBE_SPAWN_EGG(62, "MONSTER_EGG"), + MAP(0, "MAP", "EMPTY_MAP"), + MELON(0, "MELON_BLOCK"), + MELON_SEEDS(0, "MELON_SEEDS"), + MELON_SLICE(0, "MELON"), + MELON_STEM(0, "MELON_STEM"), + MILK_BUCKET(0, "MILK_BUCKET"), + MINECART(0, "MINECART"), + MOOSHROOM_SPAWN_EGG(96, "MONSTER_EGG"), + MOSSY_COBBLESTONE(0, "MOSSY_COBBLESTONE"), + MOSSY_COBBLESTONE_SLAB(0, "MOSSY_COBBLESTONE_SLAB"), + MOSSY_COBBLESTONE_STAIRS(0, "MOSSY_COBBLESTONE_STAIRS"), + MOSSY_COBBLESTONE_WALL(1, "COBBLE_WALL"), + MOSSY_STONE_BRICKS(1, "SMOOTH_BRICK"), + MOSSY_STONE_BRICK_SLAB(0, "MOSSY_STONE_BRICK_SLAB"), + MOSSY_STONE_BRICK_STAIRS(0, "MOSSY_STONE_BRICK_STAIRS"), + MOSSY_STONE_BRICK_WALL(0, "MOSSY_STONE_BRICK_WALL"), + MOVING_PISTON(0, "PISTON_MOVING_PIECE"), + MULE_SPAWN_EGG(32, "MONSTER_EGG"), + MUSHROOM_STEM(0, "BROWN_MUSHROOM"), + MUSHROOM_STEW(0, "MUSHROOM_SOUP"), + MUSIC_DISC_11(0, "GOLD_RECORD"), + MUSIC_DISC_13(0, "GREEN_RECORD"), + MUSIC_DISC_BLOCKS(0, "RECORD_3"), + MUSIC_DISC_CAT(0, "RECORD_4"), + MUSIC_DISC_CHIRP(0, "RECORD_5"), + MUSIC_DISC_FAR(0, "RECORD_6"), + MUSIC_DISC_MALL(0, "RECORD_7"), + MUSIC_DISC_MELLOHI(0, "RECORD_8"), + MUSIC_DISC_STAL(0, "RECORD_9"), + MUSIC_DISC_STRAD(0, "RECORD_10"), + MUSIC_DISC_WAIT(0, "RECORD_11"), + MUSIC_DISC_WARD(0, "RECORD_12"), + MUTTON(0, "MUTTON"), + MYCELIUM(0, "MYCEL"), + NAME_TAG(0, "NAME_TAG"), + NAUTILUS_SHELL(0, "STONE"), + NETHERRACK(0, "NETHERRACK"), + NETHER_BRICK(0, "NETHER_BRICK"), + NETHER_BRICKS(0, "NETHER_BRICK"), + NETHER_BRICK_FENCE(0, "NETHER_FENCE"), + NETHER_BRICK_SLAB(6, "STEP"), + NETHER_BRICK_STAIRS(0, "NETHER_BRICK_STAIRS"), + NETHER_PORTAL(0, "PORTAL"), + NETHER_QUARTZ_ORE(0, "QUARTZ_ORE"), + NETHER_STAR(0, "NETHER_STAR"), + NETHER_WART(0, "NETHER_STALK"), + NETHER_WART_BLOCK(0, "NETHER_WART_BLOCK", "NETHER_WARTS"), + NOTE_BLOCK(0, "NOTE_BLOCK"), + OAK_BOAT(0, "BOAT"), + OAK_BUTTON(0, "WOOD_BUTTON"), + OAK_DOOR(0, "WOODEN_DOOR", "WOOD_DOOR"), + OAK_FENCE(0, "FENCE"), + OAK_FENCE_GATE(0, "FENCE_GATE"), + OAK_LEAVES(0, "LEAVES"), + OAK_LOG(0, "LOG"), + OAK_PLANKS(0, "WOOD"), + OAK_PRESSURE_PLATE(0, "WOOD_PLATE"), + OAK_SAPLING(0, "SAPLING"), + OAK_SIGN(0, "SIGN"), + OAK_SLAB(0,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + OAK_STAIRS(0, "WOOD_STAIRS"), + OAK_TRAPDOOR(0, "TRAP_DOOR"), + OAK_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + OAK_WOOD(0, "LOG"), + OBSERVER(0, "OBSERVER"), + OBSIDIAN(0, "OBSIDIAN"), + OCELOT_SPAWN_EGG(98, "RECORD_12"), + ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"), + ORANGE_BED(1, "BED", "BED_BLOCK"), + ORANGE_CARPET(1, "CARPET"), + ORANGE_CONCRETE(1, "CONCRETE"), + ORANGE_CONCRETE_POWDER(1, "CONCRETE_POWDER"), + ORANGE_DYE(14, "INK_SACK"), + ORANGE_GLAZED_TERRACOTTA(0, "ORANGE_GLAZED_TERRACOTTA"), + ORANGE_SHULKER_BOX(0, "ORANGE_SHULKER_BOX"), + ORANGE_STAINED_GLASS(1, "STAINED_GLASS"), + ORANGE_STAINED_GLASS_PANE(1, "STAINED_GLASS_PANE"), + ORANGE_TERRACOTTA(1, "STAINED_CLAY"), + ORANGE_TULIP(5, "RED_ROSE"), + ORANGE_WALL_BANNER(0, "WALL_BANNER"), + ORANGE_WOOL(1, "WOOL"), + OXEYE_DAISY(8, "RED_ROSE"), + PACKED_ICE(0, "PACKED_ICE"), + PAINTING(0, "PAINTING"), + PANDA_SPAWN_EGG(0, "PANDA_SPAWN_EGG"), + PAPER(0, "PAPER"), + PARROT_SPAWN_EGG(105, "MONSTER_EGG"), + PEONY(5, "DOUBLE_PLANT"), + PETRIFIED_OAK_SLAB(0, "STONE"), + PHANTOM_MEMBRANE(0, "STONE"), + PHANTOM_SPAWN_EGG(0, "MONSTER_EGG"), + PIG_SPAWN_EGG(90, "MONSTER_EGG"), + PILLAGER_SPAWN_EGG(0, "PILLAGER_SPAWN_EGG"), + PINK_BANNER(9, "BANNER", "STANDING_BANNER"), + PINK_BED(6, "BED", "BED_BLOCK"), + PINK_CARPET(6, "CARPET"), + PINK_CONCRETE(6, "CONCRETE"), + PINK_CONCRETE_POWDER(6, "CONCRETE_POWDER"), + PINK_DYE(9, "INK_SACK"), + PINK_GLAZED_TERRACOTTA(0, "PINK_GLAZED_TERRACOTTA"), + PINK_SHULKER_BOX(0, "PINK_SHULKER_BOX"), + PINK_STAINED_GLASS(6, "STAINED_GLASS"), + PINK_STAINED_GLASS_PANE(6, "STAINED_GLASS_PANE"), + PINK_TERRACOTTA(6, "STAINED_CLAY"), + PINK_TULIP(7, "RED_ROSE"), + PINK_WALL_BANNER(0, "WALL_BANNER"), + PINK_WOOL(6, "WOOL"), + PISTON(0, "PISTON_BASE"), + PISTON_HEAD(0, "PISTON_EXTENSION"), + PLAYER_HEAD(3, "SKULL_ITEM","SKULL"), + PLAYER_WALL_HEAD(3, "SKULL_ITEM","SKULL"), + PODZOL(2, "DIRT"), + POISONOUS_POTATO(0, "POISONOUS_POTATO"), + POLAR_BEAR_SPAWN_EGG(102, "MONSTER_EGG"), + POLISHED_ANDESITE(6, "STONE"), + POLISHED_ANDESITE_SLAB(0, "POLISHED_ANDESITE_SLAB"), + POLISHED_ANDESITE_STAIRS(0, "POLISED_ANDESITE_STAIRS"), + POLISHED_DIORITE(4, "STONE"), + POLISHED_DIORITE_SLAB(0, "POLISHED_DIORITE_SLAB"), + POLISHED_DIORITE_STAIRS(0, "POLISHED_DIORITE_STAIRS"), + POLISHED_GRANITE(2, "STONE"), + POLISHED_GRANITE_SLAB(0, "POLISHED_GRANITE_SLAB"), + POLISHED_GRANITE_STAIRS(0, "POLISHED_GRANITE_STAIRS"), + POPPED_CHORUS_FRUIT(0, "CHORUS_FRUIT_POPPED"), + POPPY(0, "RED_ROSE"), + PORKCHOP(0, "PORK"), + POTATO(0, "POTATO_ITEM"), + POTATOES(0, "POTATO"), + POTION(0, "POTION"), + POTTED_ACACIA_SAPLING(0, "FLOWER_POT"), + POTTED_ALLIUM(0, "FLOWER_POT"), + POTTED_AZURE_BLUET(0, "FLOWER_POT"), + POTTED_BIRCH_SAPLING(0, "FLOWER_POT"), + POTTED_BLUE_ORCHID(0, "FLOWER_POT"), + POTTED_BROWN_MUSHROOM(0, "FLOWER_POT"), + POTTED_CACTUS(0, "FLOWER_POT"), + POTTED_CORNFLOWER(0, "FLOWER_POT"), + POTTED_DANDELION(0, "FLOWER_POT"), + POTTED_DARK_OAK_SAPLING(0, "FLOWER_POT"), + POTTED_DEAD_BUSH(0, "FLOWER_POT"), + POTTED_FERN(0, "FLOWER_POT"), + POTTED_JUNGLE_SAPLING(0, "FLOWER_POT"), + POTTED_LILY_OF_THE_VALLEY(0, "FLOWER_POT"), + POTTED_OAK_SAPLING(0, "FLOWER_POT"), + POTTED_ORANGE_TULIP(0, "FLOWER_POT"), + POTTED_OXEYE_DAISY(0, "FLOWER_POT"), + POTTED_PINK_TULIP(0, "FLOWER_POT"), + POTTED_POPPY(0, "FLOWER_POT"), + POTTED_RED_MUSHROOM(0, "FLOWER_POT"), + POTTED_RED_TULIP(0, "FLOWER_POT"), + POTTED_SPRUCE_SAPLING(0, "FLOWER_POT"), + POTTED_WHITE_TULIP(0, "FLOWER_POT"), + POTTED_WITHER_ROSE(0, "FLOWER_POT"), + POWERED_RAIL(0, "POWERED_RAIL"), + PRISMARINE(0, "PRISMARINE"), + PRISMARINE_BRICKS(1, "PRISMARINE"), + PRISMARINE_BRICK_SLAB(0, "STONE"), + PRISMARINE_BRICK_STAIRS(0, "STONE"), + PRISMARINE_CRYSTALS(0, "PRISMARINE_CRYSTALS"), + PRISMARINE_SHARD(0, "PRISMARINE_SHARD"), + PRISMARINE_SLAB(0, "STONE"), + PRISMARINE_STAIRS(0, "STONE"), + PUFFERFISH(3, "RAW_FISH"), + PUFFERFISH_BUCKET(0, "STONE"), + PUFFERFISH_SPAWN_EGG(0, "MONSTER_EGG"), + PUMPKIN(0, "PUMPKIN"), + PUMPKIN_PIE(0, "PUMPKIN_PIE"), + PUMPKIN_SEEDS(0, "PUMPKIN_SEEDS"), + PUMPKIN_STEM(0, "PUMPKIN_STEM"), + PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"), + PURPLE_BED(10, "BED", "BED_BLOCK"), + PURPLE_CARPET(10, "CARPET"), + PURPLE_CONCRETE(10, "CONCRETE"), + PURPLE_CONCRETE_POWDER(10, "CONCRETE_POWDER"), + PURPLE_DYE(5, "INK_SACK"), + PURPLE_GLAZED_TERRACOTTA(0, "PURPLE_GLAZED_TERRACOTTA"), + PURPLE_SHULKER_BOX(0, "PURPLE_SHULKER_BOX"), + PURPLE_STAINED_GLASS(10, "STAINED_GLASS"), + PURPLE_STAINED_GLASS_PANE(10, "STAINED_GLASS_PANE"), + PURPLE_TERRACOTTA(10, "STAINED_CLAY"), + PURPLE_WALL_BANNER(0, "WALL_BANNER"), + PURPLE_WOOL(10, "WOOL"), + PURPUR_BLOCK(0, "PURPUR_BLOCK"), + PURPUR_PILLAR(0, "PURPUR_PILLAR"), + PURPUR_SLAB(0, "PURPUR_SLAB", "PURPUR_DOUBLE_SLAB"), + PURPUR_STAIRS(0, "PURPUR_STAIRS"), + QUARTZ(0, "QUARTZ"), + QUARTZ_BLOCK(0, "QUARTZ_BLOCK"), + QUARTZ_PILLAR(2, "QUARTZ_BLOCK"), + QUARTZ_SLAB(7, "STEP"), + QUARTZ_STAIRS(0, "QUARTZ_STAIRS"), + RABBIT(0, "RABBIT"), + RABBIT_FOOT(0, "RABBIT_FOOT"), + RABBIT_HIDE(0, "RABBIT_HIDE"), + RABBIT_SPAWN_EGG(101, "MONSTER_EGG"), + RABBIT_STEW(0, "RABBIT_STEW"), + RAIL(0, "RAILS"), + RAVAGER_SPAWN_EGG(0, "RAVAGER_SPAWN_EGG"), + REDSTONE(0, "REDSTONE"), + REDSTONE_BLOCK(0, "REDSTONE_BLOCK"), + REDSTONE_LAMP(0, "REDSTONE_LAMP_ON", "REDSTONE_LAMP_OFF"), + REDSTONE_ORE(0, "REDSTONE_ORE", "GLOWING_REDSTONE_ORE"), + REDSTONE_TORCH(0, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"), + REDSTONE_WALL_TORCH(1, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"), + REDSTONE_WIRE(0, "REDSTONE_WIRE"), + RED_BANNER(1, "BANNER", "STANDING_BANNER"), + RED_BED(14, "BED", "BED_BLOCK"), + RED_CARPET(14, "CARPET"), + RED_CONCRETE(14, "CONCRETE"), + RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"), + RED_GLAZED_TERRACOTTA(0, "RED_GLAZED_TERRACOTTA"), + RED_MUSHROOM(0, "RED_MUSHROOM"), + RED_MUSHROOM_BLOCK(0, "RED_MUSHROOM", "HUGE_MUSHROOM_2"), + RED_NETHER_BRICKS(0, "RED_NETHER_BRICK"), + RED_NEHTER_BRICK_SLAB(0, "RED_NEHTER_BRICK_SLAB"), + RED_NEHTER_BRICK_STAIRS(0, "RED_NEHTER_BRICK_STAIRS"), + RED_NEHTER_BRICK_WALL(0, "RED_NEHTER_BRICK_WALL"), + RED_SAND(1, "SAND"), + RED_SANDSTONE(0, "RED_SANDSTONE"), + RED_SANDSTONE_SLAB(0, "STONE_SLAB2", "DOUBLE_STONE_SLAB2"), + RED_SANDSTONE_STAIRS(0, "RED_SANDSTONE_STAIRS"), + RED_SHULKER_BOX(0, "RED_SHULKER_BOX"), + RED_STAINED_GLASS(14, "STAINED_GLASS"), + RED_STAINED_GLASS_PANE(14, "STAINED_GLASS_PANE"), + RED_TERRACOTTA(14, "STAINED_CLAY"), + RED_TULIP(4, "RED_ROSE"), + RED_WALL_BANNER(0, "WALL_BANNER"), + RED_WOOL(14, "WOOL"), + REPEATER(0, "DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"), + REPEATING_COMMAND_BLOCK(0, "COMMAND_REPEATING"), + ROSE_BUSH(4, "DOUBLE_PLANT"), + ROSE_RED(1, "INK_SACK"), + ROTTEN_FLESH(0, "ROTTEN_FLESH"), + SADDLE(0, "SADDLE"), + SALMON(1, "RAW_FISH"), + SALMON_BUCKET(0, "BUCKET"), + SALMON_SPAWN_EGG(0, "MONSTER_EGG"), + SAND(0, "SAND"), + SANDSTONE(0, "SANDSTONE"), + SANDSTONE_SLAB(1, "STONE_SLAB", "STEP", "DOUBLE_STEP"), + SANDSTONE_STAIRS(0, "SANDSTONE_STAIRS"), + SCAFFOLDING(0, "SCAFFOLDING"), + SCUTE(0, "STONE"), + SEAGRASS(0, "STONE"), + SEA_LANTERN(0, "SEA_LANTERN"), + SEA_PICKLE(0, "STONE"), + SHEARS(0, "SHEARS"), + SHEEP_SPAWN_EGG(91, "MONSTER_EGG"), + SHIELD(0, "SHIELD"), + SHULKER_BOX(0, "PURPLE_SHULKER_BOX"), + SHULKER_SHELL(0, "SHULKER_SHELL"), + SHULKER_SPAWN_EGG(69, "MONSTER_EGG"), + // SIGN(0, "SIGN"), + SILVERFISH_SPAWN_EGG(60, "MONSTER_EGG"), + SKELETON_HORSE_SPAWN_EGG(28, "MONSTER_EGG"), + SKELETON_SKULL(0, "SKULL_ITEM","SKULL"), + SKELETON_SPAWN_EGG(51, "MONSTER_EGG"), + SKELETON_WALL_SKULL(0, "SKULL_ITEM","SKULL"), + SLIME_BALL(0, "SLIME_BALL"), + SLIME_BLOCK(0, "SLIME_BLOCK"), + SLIME_SPAWN_EGG(55, "MONSTER_EGG"), + SMOOTH_QUARTZ(0, "STONE"), + SMOOTH_QUARTZ_SLAB(0, "SMOOTH_QUARTZ_SLAB"), + SMOOTH_QUARTZ_STAIRS(0, "SMOOTH_QUARTZ_STAIRS"), + SMOOTH_RED_SANDSTONE(2, "RED_SANDSTONE"), + SMOOTH_RED_SANDSTONE_SLAB(0, "SMOOTH_RED_SANDSTONE_SLAB"), + SMOOTH_RED_SANDSTONE_STAIRS(0, "SMOOTH_RED_SANDSTONE_STAIRS"), + SMOOTH_SANDSTONE(2, "SANDSTONE"), + SMOOTH_SANDSTONE_SLAB(0, "SMOOTH_SANDSTONE_SLAB"), + SMOOTH_SANDSTONE_STAIRS(0, "SMOOTH_SANDSTONE_STAIRS"), + SMOOTH_STONE(0, "STEP"), + SNOW(0, "SNOW"), + SNOWBALL(0, "SNOW_BALL"), + SNOW_BLOCK(0, "SNOW_BLOCK"), + SOUL_SAND(0, "SOUL_SAND"), + SPAWNER(0, "MOB_SPAWNER"), + SPECTRAL_ARROW(0, "SPECTRAL_ARROW"), + SPIDER_EYE(0, "SPIDER_EYE"), + SPIDER_SPAWN_EGG(52, "MONSTER_EGG"), + SPLASH_POTION(0, "SPLASH_POTION"), + SPONGE(0, "SPONGE"), + SPRUCE_BOAT(0, "BOAT_SPRUCE"), + SPRUCE_BUTTON(0, "WOOD_BUTTON"), + SPRUCE_DOOR(0, "SPRUCE_DOOR", "SPRUCE_DOOR_ITEM"), + SPRUCE_FENCE(0, "SPRUCE_FENCE"), + SPRUCE_FENCE_GATE(0, "SPRUCE_FENCE_GATE"), + SPRUCE_LEAVES(1, "LEAVES"), + SPRUCE_LOG(1, "LOG"), + SPRUCE_PLANKS(1, "WOOD"), + SPRUCE_PRESSURE_PLATE(0, "WOOD_PLATE"), + SPRUCE_SAPLING(1, "SAPLING"), + SPRUCE_SIGN(0, "SIGN"), + SPRUCE_SLAB(1,"WOODEN_SLAB", "WOOD_STEP", "WOOD_DOUBLE_STEP"), + SPRUCE_STAIRS(0, "SPRUCE_WOOD_STAIRS"), + SPRUCE_TRAPDOOR(0, "TRAP_DOOR"), + SPRUCE_WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + SPRUCE_WOOD(1, "LOG"), + SQUID_SPAWN_EGG(94, "MONSTER_EGG"), + STICK(0, "STICK"), + STICKY_PISTON(0, "PISTON_STICKY_BASE"), + STONE(0, "STONE"), + STONE_AXE(0, "STONE_AXE"), + STONE_BRICKS(0, "SMOOTH_BRICK"), + STONE_BRICK_SLAB(5, "STONE_SLAB", "STEP", "DOUBLE_STEP"), + STONE_BRICK_STAIRS(0, "SMOOTH_STAIRS"), + STONE_BUTTON(0, "STONE_BUTTON"), + STONE_HOE(0, "STONE_HOE"), + STONE_PICKAXE(0, "STONE_PICKAXE"), + STONE_PRESSURE_PLATE(0, "STONE_PLATE"), + STONE_SHOVEL(0, "STONE_SPADE"), + STONE_SLAB(0, "STONE_SLAB", "STEP", "DOUBLE_STEP"), + STONE_SWORD(0, "STONE_SWORD"), + STONECUTTER(0, "STONECUTTER"), + STRAY_SPAWN_EGG(6, "MONSTER_EGG"), + STRING(0, "STRING"), + STRIPPED_ACACIA_LOG(0, "STONE"), + STRIPPED_ACACIA_WOOD(0, "STONE"), + STRIPPED_BIRCH_LOG(0, "STONE"), + STRIPPED_BIRCH_WOOD(0, "STONE"), + STRIPPED_DARK_OAK_LOG(0, "STONE"), + STRIPPED_DARK_OAK_WOOD(0, "STONE"), + STRIPPED_JUNGLE_LOG(0, "STONE"), + STRIPPED_JUNGLE_WOOD(0, "STONE"), + STRIPPED_OAK_LOG(0, "STONE"), + STRIPPED_OAK_WOOD(0, "STONE"), + STRIPPED_SPRUCE_LOG(0, "STONE"), + STRIPPED_SPRUCE_WOOD(0, "STONE"), + STRUCTURE_BLOCK(0, "STRUCTURE_BLOCK"), + STRUCTURE_VOID(0, "STRUCTURE_VOID"), + SUGAR(0, "SUGAR"), + SUGAR_CANE(0, "SUGAR_CANE", "SUGAR_CANE_BLOCK"), + SUSPICIOUS_STEW(0, "SUSPICIOUS_STEW"), + SUNFLOWER(0, "DOUBLE_PLANT"), + SWEET_BERRIES(0, "SWEET_BERRIES"), + SWEET_BERRY_BUSH(0, "SWEET_BERRY_BUSH"), + TALL_GRASS(2, "DOUBLE_PLANT"), + TALL_SEAGRASS(0, "STONE"), + TERRACOTTA(0, "HARD_CLAY"), + TIPPED_ARROW(0, "TIPPED_ARROW"), + TNT(0, "TNT"), + TNT_MINECART(0, "EXPLOSIVE_MINECART"), + TORCH(0, "TORCH"), + TOTEM_OF_UNDYING(0, "TOTEM"), + TRADER_LLAMA_SPAWN_EGG(0, "TRADER_LLAMA_SPAWN_EGG"), + TRAPPED_CHEST(0, "TRAPPED_CHEST"), + TRIDENT(0, "STONE"), + TRIPWIRE(0, "TRIPWIRE"), + TRIPWIRE_HOOK(0, "TRIPWIRE_HOOK"), + TROPICAL_FISH(0, "RAW_FISH"), + TROPICAL_FISH_BUCKET(0, "BUCKET"), + TROPICAL_FISH_SPAWN_EGG(0, "MONSTER_EGG"), + TUBE_CORAL(0, "STONE"), + TUBE_CORAL_BLOCK(0, "STONE"), + TUBE_CORAL_FAN(0, "STONE"), + TURTLE_EGG(0, "MONSTER_EGG"), + TURTLE_HELMET(0, "STONE"), + TURTLE_SPAWN_EGG(0, "MONSTER_EGG"), + VEX_SPAWN_EGG(35, "MONSTER_EGG"), + VILLAGER_SPAWN_EGG(120, "MONSTER_EGG"), + VINDICATOR_SPAWN_EGG(36, "MONSTER_EGG"), + VINE(0, "VINE"), + VOID_AIR(0, "AIR"), + // WALL_SIGN(0, "WALL_SIGN", "SIGN_POST"), + WALL_TORCH(1, "TORCH"), + WANDERING_TRADER_LLAMA_SPAWN_EGG(0, "WANDERING_TRADER_LLAMA_SPAWN_EGG"), + WANDERING_TRADER_SPAWN_EGG(0, "WANDERING_TRADER_SPAWN_EGG"), + WATER(0, "WATER", "STATIONARY_WATER"), + WATER_BUCKET(0, "WATER_BUCKET"), + WET_SPONGE(1, "SPONGE"), + WHEAT(0, "WHEAT", "CROPS"), + WHEAT_SEEDS(0, "WHEAT_SEEDS", "SEEDS"), + WHITE_BANNER(15, "BANNER", "STANDING_BANNER"), + WHITE_BED(0, "BED", "BED_BLOCK"), + WHITE_CARPET(0, "CARPET"), + WHITE_CONCRETE(0, "CONCRETE"), + WHITE_CONCRETE_POWDER(0, "CONCRETE_POWDER"), + WHITE_DYE(0, "BONE_MEAL"), + WHITE_GLAZED_TERRACOTTA(0, "WHITE_GLAZED_TERRACOTTA"), + WHITE_SHULKER_BOX(0, "WHITE_SHULKER_BOX"), + WHITE_STAINED_GLASS(0, "STAINED_GLASS"), + WHITE_STAINED_GLASS_PANE(0, "STAINED_GLASS_PANE"), + WHITE_TERRACOTTA(0, "TERRACOTTA"), + WHITE_TULIP(6, "RED_ROSE"), + WHITE_WALL_BANNER(0, "WALL_BANNER"), + WHITE_WOOL(0, "WOOL"), + WITHER_ROSE(0, "WITHER_ROSE"), + WITCH_SPAWN_EGG(66, "MONSTER_EGG"), + WITHER_SKELETON_SKULL(1, "SKULL_ITEM","SKULL"), + WITHER_SKELETON_SPAWN_EGG(5, "MONSTER_EGG"), + WITHER_SKELETON_WALL_SKULL(1, "SKULL_ITEM","SKULL"), + WOLF_SPAWN_EGG(95, "MONSTER_EGG"), + WOODEN_AXE(0, "WOOD_AXE"), + WOODEN_HOE(0, "WOOD_HOE"), + WOODEN_PICKAXE(0, "WOOD_PICKAXE"), + WOODEN_SHOVEL(0, "WOOD_SPADE"), + WOODEN_SWORD(0, "WOOD_SWORD"), + WRITABLE_BOOK(0, "BOOK_AND_QUILL"), + WRITTEN_BOOK(0, "WRITTEN_BOOK"), + YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"), + YELLOW_BED(4, "BED", "BED_BLOCK"), + YELLOW_CARPET(4, "CARPET"), + YELLOW_CONCRETE(4, "CONCRETE"), + YELLOW_CONCRETE_POWDER(4, "CONCRETE_POWDER"), + YELLOW_GLAZED_TERRACOTTA(0, "YELLOW_GLAZED_TERRACOTTA"), + YELLOW_SHULKER_BOX(0, "YELLOW_SHULKER_BOX"), + YELLOW_STAINED_GLASS(4, "STAINED_GLASS"), + YELLOW_STAINED_GLASS_PANE(4, "STAINED_GLASS_PANE"), + YELLOW_TERRACOTTA(4, "STAINED_CLAY"), + YELLOW_WALL_BANNER(0, "WALL_BANNER"), + YELLOW_WOOL(4, "WOOL"), + ZOMBIE_HEAD(2, "SKULL_ITEM","SKULL"), + ZOMBIE_HORSE_SPAWN_EGG(29, "MONSTER_EGG"), + ZOMBIE_PIGMAN_SPAWN_EGG(57, "MONSTER_EGG"), + ZOMBIE_SPAWN_EGG(2, "MONSTER_EGG"), + ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"), + ZOMBIE_WALL_HEAD(2, "SKULL_ITEM","SKULL"); + + private static Map cachedSearch = new HashMap<>(); + + private String[] materials; + private int data; + private ItemType cached = null; + + SpongeCompatItemType(int data, String... materials) { + this.materials = materials; + this.data = data; + } + + public String[] getMaterials() { + return materials; + } + + public int getData() { + return data; + } + + public ItemStack parseItem() { + ItemType mat = parseMaterial(); + if (isNewVersion()) + return ItemStack.builder().itemType(mat).build(); + + ItemStack stack = ItemStack.builder().itemType(mat).quantity(1).build(); + return ItemStack.builder() + .fromContainer(stack.toContainer().set(DataQuery.of("UnsafeDamage"), data)) + .build(); + } + + public boolean isDamageable(SpongeCompatItemType type){ + if (type == null) + return false; + + String[] split = type.toString().split("_"); + int length = split.length; + switch (split[length - 1]) { + case "HELMET": + case "CHESTPLATE": + case "LEGGINGS": + case "BOOTS": + case "SWORD": + case "AXE": + case "PICKAXE": + case "SHOVEL": + case "HOE": + case "ELYTRA": + case "TURTLE_HELMET": + case "TRIDENT": + case "HORSE_ARMOR": + case "SHEARS": + return true; + } + + return false; + } + + public ItemType parseMaterial() { + if (cached != null) + return cached; + + Optional mat = Sponge.getRegistry().getType(ItemType.class, this.toString()); + return mat.map(itemType -> cached = itemType).orElseGet(() -> cached = Sponge.getRegistry().getType(ItemType.class, materials[0]).orElse(ItemTypes.AIR)); + } + + public boolean isSameMaterial(ItemStack comp){ + if (isNewVersion()) + return comp.getType() == this.parseMaterial(); + + if (comp.getType() == this.parseMaterial() && comp.get(Keys.ITEM_DURABILITY).orElse(0) == (short) this.data) + return true; + + SpongeCompatItemType mat = fromMaterial(comp.getType()); + return isDamageable(mat) && this.parseMaterial() == comp.getType(); + } + + public static SpongeCompatItemType fromMaterial(ItemType mat) { + try { + return SpongeCompatItemType.valueOf(mat.toString()); + } catch (IllegalArgumentException ex) { + for (SpongeCompatItemType spongeItem : SpongeCompatItemType.values()) { + for (String test : spongeItem.materials) { + if (test.equalsIgnoreCase(mat.toString())) + return spongeItem; + } + } + } + + // in theory, we should never get here + throw new IllegalArgumentException("Could not find Sponge Compat material from " + mat); + } + + public static Optional fromString(String key) { + String matKey = key.replace("minecraft:", "").toUpperCase(); + SpongeCompatItemType mat; + + try { + mat = SpongeCompatItemType.valueOf(matKey); + return Optional.of(mat); + } catch (IllegalArgumentException ex) { + String[] split = matKey.split(":"); + if (split.length == 1) + mat = requestSpongeItem(matKey, 0).orElse(null); + else + mat = requestSpongeItem(split[0], Integer.parseInt(split[1])).orElse(null); + + return Optional.ofNullable(mat); + } + } + + public static Optional requestSpongeItem(String name, int data) { + if (cachedSearch.containsKey(name.toUpperCase() + "," + data)) + return Optional.of(cachedSearch.get(name.toUpperCase() + "," + data)); + + for (SpongeCompatItemType mat : SpongeCompatItemType.values()) { + for (String test : mat.materials) { + if (name.toUpperCase().equals(test) && mat.data == data) { + cachedSearch.put(test + "," + data, mat); + return Optional.of(mat); + } + } + } + + return Optional.empty(); + } + + public static boolean isNewVersion() { + return Sponge.getRegistry().getType(ItemType.class, "RED_WOOL").isPresent(); + } +} \ No newline at end of file diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/entity/SpongeEntity.java b/modules/sponge/src/main/java/org/battleplugins/sponge/entity/SpongeEntity.java index 312ae2f..5d536b8 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/entity/SpongeEntity.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/entity/SpongeEntity.java @@ -4,9 +4,13 @@ import org.battleplugins.sponge.world.SpongeWorld; import org.battleplugins.sponge.util.SpongeUtil; import org.battleplugins.util.MCWrapper; +import org.battleplugins.util.NamespacedKey; import org.battleplugins.world.Location; import org.spongepowered.api.data.key.Keys; import org.spongepowered.api.entity.Entity; +import org.spongepowered.api.entity.EntityType; +import org.spongepowered.api.entity.EntityTypes; +import org.spongepowered.api.entity.living.animal.Pig; import org.spongepowered.api.text.Text; import java.util.ArrayList; @@ -25,6 +29,11 @@ public String getName() { return handle.getType().getName(); } + @Override + public NamespacedKey getKey() { + return NamespacedKey.minecraft(handle.getType().getId()); + } + @Override public UUID getUniqueId() { return handle.getUniqueId(); @@ -59,7 +68,7 @@ public boolean isValid() { public List getNearbyEntities(double x, double y, double z) { List entities = new ArrayList<>(); for (Entity entity : SpongeUtil.getNearbyEntities(handle, x, y, z)) { - entities.add(new SpongeEntity(entity)); + entities.add(new SpongeEntity<>(entity)); } return entities; } diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/entity/living/player/SpongeOfflinePlayer.java b/modules/sponge/src/main/java/org/battleplugins/sponge/entity/living/player/SpongeOfflinePlayer.java index 7497b31..9688e22 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/entity/living/player/SpongeOfflinePlayer.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/entity/living/player/SpongeOfflinePlayer.java @@ -7,9 +7,9 @@ import org.spongepowered.api.entity.living.player.User; import org.spongepowered.api.util.RespawnLocation; -import java.time.Instant; import java.util.HashMap; import java.util.Optional; +import java.util.OptionalLong; import java.util.UUID; public class SpongeOfflinePlayer extends MCWrapper implements OfflinePlayer { @@ -39,13 +39,15 @@ public Optional getPlayer() { } @Override - public long getFirstPlayed() { - return handle.get(Keys.FIRST_DATE_PLAYED).orElse(Instant.now()).toEpochMilli(); + public OptionalLong getFirstPlayed() { + return handle.get(Keys.FIRST_DATE_PLAYED).map(value -> OptionalLong.of(value.toEpochMilli())) + .orElse(OptionalLong.empty()); } @Override - public long getLastPlayed() { - return handle.get(Keys.LAST_DATE_PLAYED).orElse(Instant.now()).toEpochMilli(); + public OptionalLong getLastPlayed() { + return handle.get(Keys.LAST_DATE_PLAYED).map(value -> OptionalLong.of(value.toEpochMilli())) + .orElse(OptionalLong.empty()); } @Override diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/entity/living/player/SpongePlayer.java b/modules/sponge/src/main/java/org/battleplugins/sponge/entity/living/player/SpongePlayer.java index 2ceba13..7980ed5 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/entity/living/player/SpongePlayer.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/entity/living/player/SpongePlayer.java @@ -1,6 +1,7 @@ package org.battleplugins.sponge.entity.living.player; -import org.battleplugins.entity.living.player.GameMode; +import org.battleplugins.entity.living.player.gamemode.GameMode; +import org.battleplugins.entity.living.player.gamemode.GameModes; import org.battleplugins.inventory.Inventory; import org.battleplugins.sponge.world.SpongeLocation; import org.battleplugins.sponge.entity.living.SpongeHumanEntity; @@ -8,13 +9,13 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.data.key.Keys; import org.spongepowered.api.entity.living.player.Player; -import org.spongepowered.api.entity.living.player.gamemode.GameModes; import org.spongepowered.api.text.Text; import org.spongepowered.api.util.RespawnLocation; -import java.time.Instant; +import java.util.Arrays; import java.util.HashMap; import java.util.Optional; +import java.util.OptionalLong; public class SpongePlayer extends SpongeHumanEntity implements org.battleplugins.entity.living.player.Player { @@ -36,13 +37,15 @@ public Optional getPlayer() { } @Override - public long getFirstPlayed() { - return handle.get(Keys.FIRST_DATE_PLAYED).orElse(Instant.now()).toEpochMilli(); + public OptionalLong getFirstPlayed() { + return handle.get(Keys.FIRST_DATE_PLAYED).map(value -> OptionalLong.of(value.toEpochMilli())) + .orElse(OptionalLong.empty()); } @Override - public long getLastPlayed() { - return handle.get(Keys.LAST_DATE_PLAYED).orElse(Instant.now()).toEpochMilli(); + public OptionalLong getLastPlayed() { + return handle.get(Keys.LAST_DATE_PLAYED).map(value -> OptionalLong.of(value.toEpochMilli())) + .orElse(OptionalLong.empty()); } @Override @@ -96,11 +99,15 @@ public boolean isOnline() { @Override public GameMode getGameMode() { - return GameMode.valueOf(handle.getGameModeData().type().get().getId().toUpperCase()); + org.spongepowered.api.entity.living.player.gamemode.GameMode spongeGamemode = handle.gameMode().get(); + return Arrays.stream(GameModes.values()) + .filter(mode -> mode.getKey().getKey().equals(spongeGamemode.getId())) + .findFirst().orElse(GameModes.SURVIVAL); } @Override public void setGameMode(GameMode gameMode) { - handle.getGameModeData().type().set(Sponge.getRegistry().getType(org.spongepowered.api.entity.living.player.gamemode.GameMode.class, gameMode.name().toUpperCase()).orElse(GameModes.SURVIVAL)); + handle.offer(Keys.GAME_MODE, Sponge.getRegistry().getType(org.spongepowered.api.entity.living.player.gamemode.GameMode.class, + gameMode.getKey().getKey().toUpperCase()).orElse(org.spongepowered.api.entity.living.player.gamemode.GameModes.SURVIVAL)); } } diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/SpongeCarriedInventory.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/SpongeCarriedInventory.java new file mode 100644 index 0000000..7129f86 --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/SpongeCarriedInventory.java @@ -0,0 +1,20 @@ +package org.battleplugins.sponge.inventory; + +import org.battleplugins.inventory.CarriedInventory; +import org.battleplugins.inventory.carrier.Carrier; + +public class SpongeCarriedInventory extends SpongeInventory implements CarriedInventory { + + private C carrier; + + public SpongeCarriedInventory(T inventory, C carrier) { + super(inventory); + + this.carrier = carrier; + } + + @Override + public C getCarrier() { + return carrier; + } +} \ No newline at end of file diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/SpongeInventory.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/SpongeInventory.java index 1346a90..e3e5a20 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/SpongeInventory.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/SpongeInventory.java @@ -18,10 +18,8 @@ public SpongeInventory(T inventory) { } @Override - public void addItem(ItemStack... itemStacks) { - for (ItemStack itemStack : itemStacks) { - handle.set(((SpongeItemStack) itemStack).getHandle()); - } + public void addItem(ItemStack itemStack) { + handle.set(((SpongeItemStack) itemStack).getHandle()); } @Override diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/SpongeInventoryBuilder.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/SpongeInventoryBuilder.java new file mode 100644 index 0000000..9e19692 --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/SpongeInventoryBuilder.java @@ -0,0 +1,70 @@ +package org.battleplugins.sponge.inventory; + +import org.battleplugins.Platform; +import org.battleplugins.inventory.Inventory; +import org.battleplugins.inventory.item.ItemStack; +import org.spongepowered.api.item.inventory.property.InventoryDimension; +import org.spongepowered.api.item.inventory.property.InventoryTitle; +import org.spongepowered.api.text.Text; + +public class SpongeInventoryBuilder implements Inventory.Builder { + + private String name; + private int size; + private ItemStack[] contents = new ItemStack[54]; + + @Override + public SpongeInventoryBuilder fromInventory(Inventory inventory, String name) { + this.name = name; + this.size = ((SpongeInventory) inventory).getHandle().size(); + this.contents = inventory.getContents(); + return this; + } + + @Override + public SpongeInventoryBuilder name(String name) { + this.name = name; + return this; + } + + @Override + public SpongeInventoryBuilder size(int size) { + this.size = size; + if (this.contents.length > size) { + throw new IllegalArgumentException("Current inventory contents are larger than the set inventory size!"); + } + + ItemStack[] contents = this.contents.clone(); + System.arraycopy(contents, 0, this.contents, 0, contents.length); + return this; + } + + @Override + public SpongeInventoryBuilder item(int slot, ItemStack item) { + if (slot > size) { + throw new IllegalArgumentException("Slot is greater than the inventory size!"); + } + this.contents[slot] = item; + return this; + } + + @Override + public SpongeInventoryBuilder contents(ItemStack[] contents) { + if (contents.length > size) { + throw new IllegalArgumentException("Given contents are larger than the inventory size!"); + } + this.contents = contents; + return null; + } + + @Override + public SpongeInventory build() { + SpongeInventory inventory = new SpongeInventory<>(org.spongepowered.api.item.inventory.Inventory + .builder() + .property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(Text.of(name))) + .property(InventoryDimension.PROPERTY_NAME, new InventoryDimension( 9, size / 9)) + .build(Platform.getPluginManager().getPlugin())); + inventory.setContents(this.contents); + return inventory; + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/entity/SpongePlayerInventory.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/entity/SpongePlayerInventory.java index b673d47..39802a9 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/entity/SpongePlayerInventory.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/entity/SpongePlayerInventory.java @@ -1,5 +1,7 @@ package org.battleplugins.sponge.inventory.entity; +import org.battleplugins.entity.living.HumanEntity; +import org.battleplugins.sponge.entity.living.SpongeHumanEntity; import org.battleplugins.sponge.inventory.SpongeInventory; import org.battleplugins.sponge.inventory.item.SpongeItemStack; import org.spongepowered.api.data.type.HandTypes; @@ -51,4 +53,9 @@ public Optional getLeggings() { public Optional getBoots() { return inventory.getCarrier().get().getBoots().map(SpongeItemStack::new); } + + @Override + public HumanEntity getCarrier() { + return new SpongeHumanEntity<>(inventory.getCarrier().get()); + } } diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemMeta.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemMeta.java deleted file mode 100644 index 67c5a97..0000000 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemMeta.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.battleplugins.sponge.inventory.item; - -import org.battleplugins.inventory.item.ItemMeta; -import org.spongepowered.api.data.key.Keys; -import org.spongepowered.api.data.manipulator.mutable.DisplayNameData; -import org.spongepowered.api.data.manipulator.mutable.item.DurabilityData; -import org.spongepowered.api.data.manipulator.mutable.item.LoreData; -import org.spongepowered.api.item.inventory.ItemStack; -import org.spongepowered.api.text.Text; - -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * Due to how Sponge handles item metadata, we instead - * pass a Sponge 'ItemStack' in the constructor. - */ -public class SpongeItemMeta implements ItemMeta { - - private ItemStack itemStack; - - public SpongeItemMeta(ItemStack itemStack) { - this.itemStack = itemStack; - } - - @Override - public Optional getDisplayName() { - return itemStack.getOrCreate(DisplayNameData.class).map(data -> data.displayName().get().toPlain()); - } - - @Override - public void setDisplayName(String displayName) { - itemStack.offer(Keys.DISPLAY_NAME, Text.of(displayName)); - } - - @Override - public Optional> getLore() { - return itemStack.getOrCreate(LoreData.class).map(data -> data.lore().get().stream().map(Text::toPlain).collect(Collectors.toList())); - } - - @Override - public void setLore(List lore) { - itemStack.offer(Keys.ITEM_LORE, lore.stream().map(Text::of).collect(Collectors.toList())); - } - - @Override - public int getCustomModelData() { - return 0; - } - - @Override - public void setCustomModelData(int modelData) { - // No support for this in Sponge... yet :) - } - - @Override - public boolean isUnbreakable() { - return itemStack.getOrCreate(DurabilityData.class).map(DurabilityData::unbreakable).get().get(); - } - - @Override - public void setUnbreakable(boolean unbreakable) { - itemStack.offer(Keys.UNBREAKABLE, unbreakable); - } -} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemRegistry.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemRegistry.java new file mode 100644 index 0000000..bdc789c --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemRegistry.java @@ -0,0 +1,23 @@ +package org.battleplugins.sponge.inventory.item; + +import org.battleplugins.inventory.item.ItemRegistry; +import org.battleplugins.inventory.item.ItemType; +import org.battleplugins.sponge.compat.SpongeCompatItemType; +import org.battleplugins.util.NamespacedKey; + +import java.util.Optional; + +public class SpongeItemRegistry implements ItemRegistry { + + @Override + public ItemType fromPlatformItem(org.spongepowered.api.item.ItemType item) { + return null; + } + + @Override + public Optional fromKey(NamespacedKey namespacedKey) { + // return BukkitMaterialAdapter.getMaterial(namespacedKey.getKey()).map(this::fromPlatformItem); + return SpongeCompatItemType.fromString(namespacedKey.getKey()) + .map(itemType -> fromPlatformItem(itemType.parseItem().getType())); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemStack.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemStack.java index 907544a..06a9979 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemStack.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemStack.java @@ -1,10 +1,7 @@ package org.battleplugins.sponge.inventory.item; -import org.battleplugins.inventory.item.ItemMeta; -import org.battleplugins.sponge.util.SpongeInventoryUtil; import org.battleplugins.util.MCWrapper; import org.spongepowered.api.Sponge; -import org.spongepowered.api.data.key.Keys; import org.spongepowered.api.data.manipulator.mutable.item.EnchantmentData; import org.spongepowered.api.item.ItemType; import org.spongepowered.api.item.ItemTypes; @@ -23,7 +20,7 @@ public SpongeItemStack(ItemStack itemStack) { } @Override - public void setType(String type) { + public void setType(org.battleplugins.inventory.item.ItemType type) { Optional opItem = Sponge.getGame().getRegistry().getType(ItemType.class, "minecraft:" + type); if (!opItem.isPresent()) return; @@ -32,18 +29,8 @@ public void setType(String type) { } @Override - public String getType() { - return handle.getType().getName(); - } - - @Override - public void setDataValue(short value) { - handle.offer(Keys.ITEM_DURABILITY, (int) value); - } - - @Override - public short getDataValue() { - return handle.get(Keys.ITEM_DURABILITY).orElse(0).shortValue(); + public org.battleplugins.inventory.item.ItemType getType() { + return new SpongeItemType(handle.getType()); } @Override @@ -58,7 +45,7 @@ public int getQuantity() { @Override public Map getEnchantments() { - Map enchants = new HashMap(); + Map enchants = new HashMap<>(); EnchantmentData data = handle.getOrCreate(EnchantmentData.class).get(); for (Enchantment ench : data.enchantments()) { enchants.put(ench.getType().getName(), ench.getLevel()); @@ -78,33 +65,8 @@ public void addEnchantment(String ench, int level) { handle.offer(data); } - @Override - public String getCommonName() { - return handle.getType().getName(); - } - - @Override - public String getFormattedCommonName() { - return SpongeInventoryUtil.getFormattedCommonName(handle); - } - @Override public SpongeItemStack clone() { return new SpongeItemStack(handle.copy()); } - - @Override - public int isSpecial() { - return 0; - } - - @Override - public boolean hasItemMeta() { - return true; - } - - @Override - public ItemMeta getItemMeta() { - return new SpongeItemMeta(handle); - } } diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemType.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemType.java new file mode 100644 index 0000000..b219666 --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/SpongeItemType.java @@ -0,0 +1,24 @@ +package org.battleplugins.sponge.inventory.item; + +import org.battleplugins.inventory.item.ItemType; +import org.battleplugins.sponge.compat.SpongeCompatItemType; +import org.battleplugins.util.MCWrapper; +import org.battleplugins.util.NamespacedKey; + +public class SpongeItemType extends MCWrapper implements ItemType { + + protected SpongeItemType(org.spongepowered.api.item.ItemType handle) { + super(handle); + } + + @Override + public NamespacedKey getKey() { + SpongeCompatItemType spongeItemType = SpongeCompatItemType.fromMaterial(handle); + return NamespacedKey.minecraft(spongeItemType.name().toLowerCase()); + } + + @Override + public int getMaximumStackSize() { + return handle.getMaxStackQuantity(); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeColorComponent.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeColorComponent.java new file mode 100644 index 0000000..8536f23 --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeColorComponent.java @@ -0,0 +1,23 @@ +package org.battleplugins.sponge.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.ColorComponent; +import org.battleplugins.sponge.inventory.item.SpongeItemStack; +import org.spongepowered.api.data.key.Keys; + +import java.awt.Color; +import java.util.Optional; + +public class SpongeColorComponent implements ColorComponent { + + @Override + public void applyComponent(ItemStack itemStack, Color color) { + ((SpongeItemStack) itemStack).getHandle().offer(Keys.COLOR, org.spongepowered.api.util.Color.of(color)); + } + + @Override + public Optional getValue(ItemStack itemStack) { + return ((SpongeItemStack) itemStack).getHandle().get(Keys.COLOR) + .map(org.spongepowered.api.util.Color::asJavaColor); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeCustomModelDataComponent.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeCustomModelDataComponent.java new file mode 100644 index 0000000..e93d9be --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeCustomModelDataComponent.java @@ -0,0 +1,20 @@ +package org.battleplugins.sponge.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.CustomModelDataComponent; + +import java.util.Optional; + +public class SpongeCustomModelDataComponent implements CustomModelDataComponent { + + @Override + public void applyComponent(ItemStack itemStack, Integer modelData) { + // not implemented (sponge is still 1.12) + // ((SpongeItemStack) itemStack).getHandle().offer(Keys.MODEL_DATA, modelData); + } + + @Override + public Optional getValue(ItemStack itemStack) { + return Optional.empty(); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeDamageComponent.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeDamageComponent.java new file mode 100644 index 0000000..9a490f1 --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeDamageComponent.java @@ -0,0 +1,21 @@ +package org.battleplugins.sponge.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.DamageComponent; +import org.battleplugins.sponge.inventory.item.SpongeItemStack; +import org.spongepowered.api.data.key.Keys; + +import java.util.Optional; + +public class SpongeDamageComponent implements DamageComponent { + + @Override + public void applyComponent(ItemStack itemStack, Short durability) { + ((SpongeItemStack) itemStack).getHandle().offer(Keys.ITEM_DURABILITY, (int) durability); + } + + @Override + public Optional getValue(ItemStack itemStack) { + return ((SpongeItemStack) itemStack).getHandle().get(Keys.ITEM_DURABILITY).map(Integer::shortValue); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeDisplayNameComponent.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeDisplayNameComponent.java new file mode 100644 index 0000000..998e55c --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeDisplayNameComponent.java @@ -0,0 +1,22 @@ +package org.battleplugins.sponge.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.DisplayNameComponent; +import org.battleplugins.sponge.inventory.item.SpongeItemStack; +import org.spongepowered.api.data.key.Keys; +import org.spongepowered.api.text.Text; + +import java.util.Optional; + +public class SpongeDisplayNameComponent implements DisplayNameComponent { + + @Override + public void applyComponent(ItemStack itemStack, String displayName) { + ((SpongeItemStack) itemStack).getHandle().offer(Keys.DISPLAY_NAME, Text.of(displayName)); + } + + @Override + public Optional getValue(ItemStack itemStack) { + return ((SpongeItemStack) itemStack).getHandle().get(Keys.DISPLAY_NAME).map(Text::toPlain); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeItemFlagComponent.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeItemFlagComponent.java new file mode 100644 index 0000000..33b23ca --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeItemFlagComponent.java @@ -0,0 +1,70 @@ +package org.battleplugins.sponge.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.ItemFlagComponent; +import org.battleplugins.inventory.item.component.flag.ItemFlag; +import org.battleplugins.inventory.item.component.flag.ItemFlags; +import org.battleplugins.sponge.inventory.item.SpongeItemStack; +import org.spongepowered.api.data.key.Keys; + +import java.util.HashSet; +import java.util.Optional; +import java.util.Set; + +public class SpongeItemFlagComponent implements ItemFlagComponent { + + @Override + public void applyComponent(ItemStack itemStack, Set itemFlags) { + org.spongepowered.api.item.inventory.ItemStack spongeItemStack = ((SpongeItemStack) itemStack).getHandle(); + for (ItemFlag flag : itemFlags) { + if (flag.equals(ItemFlags.HIDE_ATTRIBUTES)) { + spongeItemStack.offer(Keys.HIDE_ATTRIBUTES, true); + } + + if (flag.equals(ItemFlags.HIDE_DESTROYS)) { + spongeItemStack.offer(Keys.HIDE_CAN_DESTROY, true); + } + + if (flag.equals(ItemFlags.HIDE_ENCHANTS)) { + spongeItemStack.offer(Keys.HIDE_ENCHANTMENTS, true); + } + + if (flag.equals(ItemFlags.HIDE_PLACED_ON)) { + spongeItemStack.offer(Keys.HIDE_CAN_PLACE, true); + } + + if (flag.equals(ItemFlags.HIDE_POTION_EFFECTS)) { + spongeItemStack.offer(Keys.HIDE_MISCELLANEOUS, true); + } + + if (flag.equals(ItemFlags.HIDE_UNBREAKABLE)) { + spongeItemStack.offer(Keys.HIDE_UNBREAKABLE, true); + } + } + } + + @Override + public Optional> getValue(ItemStack itemStack) { + org.spongepowered.api.item.inventory.ItemStack spongeItemStack = ((SpongeItemStack) itemStack).getHandle(); + Set itemFlags = new HashSet<>(); + if (spongeItemStack.get(Keys.HIDE_ATTRIBUTES).isPresent()) + itemFlags.add(ItemFlags.HIDE_ATTRIBUTES); + + if (spongeItemStack.get(Keys.HIDE_CAN_DESTROY).isPresent()) + itemFlags.add(ItemFlags.HIDE_DESTROYS); + + if (spongeItemStack.get(Keys.HIDE_ENCHANTMENTS).isPresent()) + itemFlags.add(ItemFlags.HIDE_ENCHANTS); + + if (spongeItemStack.get(Keys.HIDE_CAN_PLACE).isPresent()) + itemFlags.add(ItemFlags.HIDE_PLACED_ON); + + if (spongeItemStack.get(Keys.HIDE_MISCELLANEOUS).isPresent()) + itemFlags.add(ItemFlags.HIDE_POTION_EFFECTS); + + if (spongeItemStack.get(Keys.HIDE_UNBREAKABLE).isPresent()) + itemFlags.add(ItemFlags.HIDE_UNBREAKABLE); + + return itemFlags.isEmpty() ? Optional.empty() : Optional.of(itemFlags); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeLoreComponent.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeLoreComponent.java new file mode 100644 index 0000000..cb136bd --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeLoreComponent.java @@ -0,0 +1,26 @@ +package org.battleplugins.sponge.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.LoreComponent; +import org.battleplugins.sponge.inventory.item.SpongeItemStack; +import org.spongepowered.api.data.key.Keys; +import org.spongepowered.api.text.Text; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +public class SpongeLoreComponent implements LoreComponent { + + @Override + public void applyComponent(ItemStack itemStack, List lore) { + ((SpongeItemStack) itemStack).getHandle().offer(Keys.ITEM_LORE, + lore.stream().map(Text::of).collect(Collectors.toList())); + } + + @Override + public Optional> getValue(ItemStack itemStack) { + return ((SpongeItemStack) itemStack).getHandle().get(Keys.ITEM_LORE) + .map(val -> val.stream().map(Text::toPlain).collect(Collectors.toList())); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeUnbreakableComponent.java b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeUnbreakableComponent.java new file mode 100644 index 0000000..481084d --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/inventory/item/component/SpongeUnbreakableComponent.java @@ -0,0 +1,21 @@ +package org.battleplugins.sponge.inventory.item.component; + +import org.battleplugins.inventory.item.ItemStack; +import org.battleplugins.inventory.item.component.UnbreakableComponent; +import org.battleplugins.sponge.inventory.item.SpongeItemStack; +import org.spongepowered.api.data.key.Keys; + +import java.util.Optional; + +public class SpongeUnbreakableComponent implements UnbreakableComponent { + + @Override + public void applyComponent(ItemStack itemStack, Boolean unbreakable) { + ((SpongeItemStack) itemStack).getHandle().offer(Keys.UNBREAKABLE, unbreakable); + } + + @Override + public Optional getValue(ItemStack itemStack) { + return ((SpongeItemStack) itemStack).getHandle().get(Keys.UNBREAKABLE); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/world/SpongeWorld.java b/modules/sponge/src/main/java/org/battleplugins/sponge/world/SpongeWorld.java index 58497d7..5f58007 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/world/SpongeWorld.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/world/SpongeWorld.java @@ -1,10 +1,14 @@ package org.battleplugins.sponge.world; +import org.battleplugins.entity.living.player.Player; +import org.battleplugins.sponge.entity.living.player.SpongePlayer; import org.battleplugins.sponge.world.block.SpongeBlock; import org.battleplugins.sponge.world.block.entity.SpongeBlockEntity; import org.battleplugins.sponge.world.block.entity.SpongeChest; import org.battleplugins.sponge.world.block.entity.SpongeSign; import org.battleplugins.util.MCWrapper; +import org.battleplugins.world.Location; +import org.battleplugins.world.block.Block; import org.battleplugins.world.block.entity.BlockEntity; import org.spongepowered.api.block.tileentity.Sign; import org.spongepowered.api.block.tileentity.TileEntity; @@ -71,4 +75,15 @@ public T toType(BlockEntity blockEntity, Class clazz) } return null; } + + @Override + public void sendBlockUpdate(Player player, Location location, Block block) { + ((SpongePlayer) player).getHandle().sendBlockChange(((SpongeLocation) location).getHandle().getBlockPosition(), + ((SpongeBlock) block).getHandle().getState()); + } + + @Override + public void sendBlockEntityUpdate(Player player, Location location, BlockEntity blockEntity) { + // oof + } } diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/SpongeBlock.java b/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/SpongeBlock.java index 0eb0ca5..4935565 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/SpongeBlock.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/SpongeBlock.java @@ -3,6 +3,7 @@ import org.battleplugins.sponge.world.SpongeLocation; import org.battleplugins.sponge.world.SpongeWorld; import org.battleplugins.util.MCWrapper; +import org.battleplugins.world.block.BlockType; import org.spongepowered.api.block.BlockSnapshot; public class SpongeBlock extends MCWrapper implements org.battleplugins.world.block.Block { @@ -22,23 +23,8 @@ public SpongeLocation getLocation() { } @Override - public int getX() { - return handle.getLocation().get().getBlockX(); - } - - @Override - public int getY() { - return handle.getLocation().get().getBlockY(); - } - - @Override - public int getZ() { - return handle.getLocation().get().getBlockZ(); - } - - @Override - public String getType() { - return handle.getState().getType().getName(); + public BlockType getType() { + return new SpongeBlockType(handle.getState().getType()); } @Override diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/SpongeBlockRegistry.java b/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/SpongeBlockRegistry.java new file mode 100644 index 0000000..43ebb9c --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/SpongeBlockRegistry.java @@ -0,0 +1,26 @@ +package org.battleplugins.sponge.world.block; + +import org.battleplugins.sponge.compat.SpongeCompatItemType; +import org.battleplugins.util.NamespacedKey; +import org.battleplugins.world.block.BlockRegistry; +import org.battleplugins.world.block.BlockType; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.block.BlockTypes; + +import java.util.Optional; + +public class SpongeBlockRegistry implements BlockRegistry { + + @Override + public BlockType fromPlatformBlock(org.spongepowered.api.block.BlockType block) { + return new SpongeBlockType(block); + } + + @Override + public Optional fromKey(NamespacedKey namespacedKey) { + return SpongeCompatItemType.fromString(namespacedKey.getKey()) + .map(itemType -> fromPlatformBlock(Sponge.getRegistry() + .getType(org.spongepowered.api.block.BlockType.class, + itemType.name()).orElse(BlockTypes.AIR))); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/SpongeBlockType.java b/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/SpongeBlockType.java new file mode 100644 index 0000000..3d85903 --- /dev/null +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/SpongeBlockType.java @@ -0,0 +1,23 @@ +package org.battleplugins.sponge.world.block; + +import org.battleplugins.sponge.inventory.item.SpongeItemType; +import org.battleplugins.world.block.BlockType; +import org.spongepowered.api.data.property.block.HardnessProperty; +import org.spongepowered.api.item.ItemTypes; + +public class SpongeBlockType extends SpongeItemType implements BlockType { + + org.spongepowered.api.block.BlockType blockType; + protected SpongeBlockType(org.spongepowered.api.block.BlockType blockType) { + super(blockType.getItem().orElse(ItemTypes.AIR)); + + this.blockType = blockType; + } + + @Override + public float getHardness() { + return blockType.getProperty(HardnessProperty.class) + .map(property -> property.getValue().floatValue()) + .orElse(0f); + } +} diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/entity/SpongeChest.java b/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/entity/SpongeChest.java index 7a86eb3..a8f889f 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/entity/SpongeChest.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/entity/SpongeChest.java @@ -1,5 +1,8 @@ package org.battleplugins.sponge.world.block.entity; +import org.battleplugins.inventory.CarriedInventory; +import org.battleplugins.inventory.carrier.Carrier; +import org.battleplugins.sponge.inventory.SpongeCarriedInventory; import org.battleplugins.sponge.inventory.SpongeInventory; import org.battleplugins.sponge.inventory.item.SpongeItemStack; import org.spongepowered.api.block.BlockTypes; @@ -18,28 +21,6 @@ public SpongeChest(Chest chest) { super(chest); } - @Override - public boolean isDoubleChest() { - return handle.getConnectedChests().size() > 0; - } - - @Override - public SpongeItemStack[] getItems() { - SpongeItemStack[] items = new SpongeItemStack[handle.getInventory(Direction.NONE).totalItems()]; - - int i = 0; - for (Inventory slot : handle.getInventory(Direction.NONE)) { - Optional opStack = slot.peek(); - if (!opStack.isPresent()) - continue; - - ItemStack stack = opStack.get(); - items[i] = new SpongeItemStack(stack); - i++; - } - - return items; - } @Override public Optional getNeighborChest() { Location loc = handle.getLocation(); @@ -59,7 +40,7 @@ else if (loc.getRelative(Direction.WEST).getBlock().getType() == BlockTypes.CHES } @Override - public SpongeInventory getInventory() { - return new SpongeInventory<>(handle.getInventory()); + public CarriedInventory getInventory() { + return new SpongeCarriedInventory<>(handle.getInventory(), this); } } diff --git a/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/entity/SpongeSign.java b/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/entity/SpongeSign.java index 078d4d5..4aaeff5 100644 --- a/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/entity/SpongeSign.java +++ b/modules/sponge/src/main/java/org/battleplugins/sponge/world/block/entity/SpongeSign.java @@ -1,6 +1,5 @@ package org.battleplugins.sponge.world.block.entity; -import org.battleplugins.entity.living.player.Player; import org.spongepowered.api.block.tileentity.Sign; import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; import org.spongepowered.api.text.Text; @@ -27,18 +26,9 @@ public String[] getLines() { } @Override - public void setLine(int index, String msg) { + public void setLine(int index, String line) { SignData signData = handle.getOrCreate(SignData.class).get(); - signData.set(signData.lines().set(index, Text.of(msg))); + signData.set(signData.lines().set(index, Text.of(line))); handle.offer(signData); } - - @Override - public void sendSignChange(Player player, String[] lines) { - // This isn't possible at the moment, so instead we send the - // player a message of what is to be displayed. - for (String line : lines) { - player.sendMessage(line); - } - } } diff --git a/pom.xml b/pom.xml index 2b8a211..31cc1ea 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,12 @@ 1.18.4 provided + + mc.euro + Version + 4.1.1 + compile + install