WIP PlayerHeadMeta & SpawnEggMeta

This commit is contained in:
Felix Cravic 2020-08-01 20:50:39 +02:00
parent 6501a43820
commit 395b205484
3 changed files with 89 additions and 0 deletions

View File

@ -596,6 +596,9 @@ public class ItemStack implements DataContainer {
if (material == Material.FIREWORK_ROCKET)
return new FireworkMeta();
if (material == Material.PLAYER_HEAD)
return new PlayerHeadMeta();
if (material == Material.LEATHER_HELMET ||
material == Material.LEATHER_CHESTPLATE ||
material == Material.LEATHER_LEGGINGS ||

View File

@ -0,0 +1,38 @@
package net.minestom.server.item.metadata;
import net.minestom.server.entity.PlayerSkin;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
public class PlayerHeadMeta implements ItemMeta {
private String playerName;
private PlayerSkin playerSkin;
@Override
public boolean hasNbt() {
return playerSkin != null;
}
@Override
public boolean isSimilar(ItemMeta itemMeta) {
if (!(itemMeta instanceof PlayerHeadMeta))
return false;
final PlayerHeadMeta playerHeadMeta = (PlayerHeadMeta) itemMeta;
return playerHeadMeta.playerSkin == playerSkin;
}
@Override
public void read(NBTCompound compound) {
}
@Override
public void write(NBTCompound compound) {
}
@Override
public ItemMeta clone() {
return null;
}
}

View File

@ -0,0 +1,48 @@
package net.minestom.server.item.metadata;
import net.minestom.server.entity.EntityType;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
// TODO for which item
public class SpawnEggMeta implements ItemMeta {
private EntityType entityType;
@Override
public boolean hasNbt() {
return entityType != null;
}
@Override
public boolean isSimilar(ItemMeta itemMeta) {
if (!(itemMeta instanceof SpawnEggMeta))
return false;
final SpawnEggMeta spawnEggMeta = (SpawnEggMeta) itemMeta;
return spawnEggMeta.entityType == entityType;
}
@Override
public void read(NBTCompound compound) {
if (compound.containsKey("EntityTag")) {
}
}
@Override
public void write(NBTCompound compound) {
if (!hasNbt())
return;
NBTCompound entityCompound = new NBTCompound();
if (entityType != null) {
entityCompound.setString("id", entityType.getNamespaceID());
}
}
@Override
public ItemMeta clone() {
SpawnEggMeta spawnEggMeta = new SpawnEggMeta();
spawnEggMeta.entityType = entityType;
return spawnEggMeta;
}
}