mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +01:00
WIP PlayerHeadMeta & SpawnEggMeta
This commit is contained in:
parent
6501a43820
commit
395b205484
@ -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 ||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user