From 6cc315fe78a089edf8d4f9ef74139d68897c9281 Mon Sep 17 00:00:00 2001 From: Felix Cravic Date: Sat, 1 Aug 2020 03:57:55 +0200 Subject: [PATCH] WIP FireworkMeta & ChatHoverEvent cleanup --- .../minestom/server/chat/ChatHoverEvent.java | 39 ++++++++++++---- .../net/minestom/server/item/ItemStack.java | 3 ++ .../server/item/metadata/FireworkMeta.java | 45 +++++++++++++++++++ 3 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 src/main/java/net/minestom/server/item/metadata/FireworkMeta.java diff --git a/src/main/java/net/minestom/server/chat/ChatHoverEvent.java b/src/main/java/net/minestom/server/chat/ChatHoverEvent.java index 0a437f3ac..3651a4bb5 100644 --- a/src/main/java/net/minestom/server/chat/ChatHoverEvent.java +++ b/src/main/java/net/minestom/server/chat/ChatHoverEvent.java @@ -127,7 +127,15 @@ public class ChatHoverEvent { JsonObject displayJson = null; if (itemStack.hasDisplayName() || itemStack.hasLore()) { displayJson = new JsonObject(); - // TODO: Color (Leather armour) + + // Leather armor + { + if (hasMeta && itemMeta instanceof LeatherArmorMeta) { + final LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemMeta; + // TODO: Color + } + } + if (itemStack.hasDisplayName()) { // This is done as this contains a json text component describing the item's name. // We replace it in the last step, as adding it now would replace it with lenient JSON which MC doesn't want. @@ -147,20 +155,35 @@ public class ChatHoverEvent { } // WrittenBooks - // TODO: Resolved - // TODO: Generation - // TODO: Author - // TODO: Title - // TODO: Pages + { + if (hasMeta && itemMeta instanceof WrittenBookMeta) { + final WrittenBookMeta writtenBookMeta = (WrittenBookMeta) itemMeta; + // TODO: Resolved + // TODO: Generation + // TODO: Author + // TODO: Title + // TODO: Pages + } + } // Book and Quills - // TODO: Pages + { + if (hasMeta && itemMeta instanceof WritableBookMeta) { + final WritableBookMeta writableBookMeta = (WritableBookMeta) itemMeta; + // TODO: Pages + } + } // Player Heads // TODO: Alot check https://minecraft.gamepedia.com/Player.dat_format#Item_structure#Player_Heads // Fireworks - // TODO: Alot check https://minecraft.gamepedia.com/Player.dat_format#Item_structure#Fireworks + { + if (hasMeta && itemMeta instanceof FireworkMeta) { + final FireworkMeta fireworkMeta = (FireworkMeta) itemMeta; + // TODO: Alot check https://minecraft.gamepedia.com/Player.dat_format#Item_structure#Fireworks + } + } // Armorstands and Spawn Eggs // TODO: EntityTag diff --git a/src/main/java/net/minestom/server/item/ItemStack.java b/src/main/java/net/minestom/server/item/ItemStack.java index aebd6d8c5..9f65cfcad 100644 --- a/src/main/java/net/minestom/server/item/ItemStack.java +++ b/src/main/java/net/minestom/server/item/ItemStack.java @@ -593,6 +593,9 @@ public class ItemStack implements DataContainer { if (material == Material.WRITTEN_BOOK) return new WrittenBookMeta(); + if (material == Material.FIREWORK_ROCKET) + return new FireworkMeta(); + if (material == Material.LEATHER_HELMET || material == Material.LEATHER_CHESTPLATE || material == Material.LEATHER_LEGGINGS || diff --git a/src/main/java/net/minestom/server/item/metadata/FireworkMeta.java b/src/main/java/net/minestom/server/item/metadata/FireworkMeta.java new file mode 100644 index 000000000..738ef03fc --- /dev/null +++ b/src/main/java/net/minestom/server/item/metadata/FireworkMeta.java @@ -0,0 +1,45 @@ +package net.minestom.server.item.metadata; + +import org.jglrxavpok.hephaistos.nbt.NBTCompound; + +public class FireworkMeta implements ItemMeta { + + private boolean flicker; + private boolean trail; + private FireworkType type; + private int[] colors; + private int[] fadeColors; + + private byte flightDuration; + // TODO Explosions list + + @Override + public boolean hasNbt() { + return false; + } + + @Override + public boolean isSimilar(ItemMeta itemMeta) { + return false; + } + + @Override + public void read(NBTCompound compound) { + + } + + @Override + public void write(NBTCompound compound) { + + } + + @Override + public ItemMeta clone() { + return null; + } + + public enum FireworkType { + SMALL_BALL, LARGE_BALL, STAR_SHAPED, CREEPER_SHAPED, BURST + } + +}