Good day skript community. Few days back i started with NMS part of Minecraft i want to add totally customizable entities. Now i only need to check from config when spawning them what behaviour set them. So i store the ID/Name of entity in it's metadata.
Before this i create a new instance of customZombie class - That's works nice. But problem is when i try to acces the MetaData value from the customZombie class.
Can you please help me ?
Thanks for any help, HamAndRock.
Java:
@Override
public void spawnEntity(Object entity, Location loc, String ID) {
net.minecraft.server.v1_11_R1.Entity ent = (net.minecraft.server.v1_11_R1.Entity) entity;
ent.getBukkitEntity().setMetadata("ID", new FixedMetadataValue(AnerCraftRPG.getInstance(),ID));
ent.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
((CraftWorld)loc.getWorld()).getHandle().addEntity(ent);
System.out.println(ent.getBukkitEntity().getMetadata("ID").get(0).asString()); //Return ID
}
Before this i create a new instance of customZombie class - That's works nice. But problem is when i try to acces the MetaData value from the customZombie class.
Java:
public class customZombie extends EntityZombie {
public customZombie(World world) {
super(world);
}
@Override
protected void r() {
if (!AnerCraftRPG.mobs.getYml().getBoolean("Customer.Pushable")) {
return;
} else {
super.r();
}
}
@Override
protected void i() { //This trigger when the entity is initialized
System.out.println(this.getBukkitEntity().getMetadata("ID")); //Return empty array
super.i();
}
}
Can you please help me ?
Thanks for any help, HamAndRock.