WIP FireworkMeta & ChatHoverEvent cleanup

This commit is contained in:
Felix Cravic 2020-08-01 03:57:55 +02:00
parent bf55bf23e7
commit 6cc315fe78
3 changed files with 79 additions and 8 deletions

View File

@ -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

View File

@ -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 ||

View File

@ -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
}
}