Posted October 18, 20196 yr Hello, I have a little API mod (Or a library, core or how you want to call it) that has methods used to spawn items/mobs/etc but I have problems setting attributes/NBT to an entity. This is how I spawn an entity without armor public static void SpawnEntityNoArmor(World worldIn, int x, int y, int z, Class<? extends Entity> entity, int amount, Boolean hasCustomName, @Nullable String name, Boolean hasMessage, @Nullable EntityPlayer player, @Nullable String message, Boolean hasCustomHealth, @Nullable Integer health) { for (int b = 0; b < amount; b++) { Entity en = EntityList.newEntity(entity, worldIn); en.setPositionAndUpdate(x, y, z); if (hasCustomName) { en.setCustomNameTag(Messages.color(name)); } if (hasCustomHealth) { } worldIn.spawnEntity(en); } if (hasMessage) { Messages.sendMessage(player, message); } } I use Entity en = EntityList.newEntity(entity, worldIn); because is the only method I've found on the internet that let me spawn an entity using EntityName.class I don't know how to add to this entity an attribute/NBT because en.getEntityAttribute doesn't exists Calling the method with: EntityHelper.SpawnEntityNoArmor(worldIn, x + new Random().nextInt(12) - 6, y, z + new Random().nextInt(12) - 6, EntitySheep.class, new Random().nextInt(8) + 1, true, "jeb_", true, player, "I'm a sheep"); If you want to know what "EntityHelper" class contain is just this method above (the first one) plus some other useless methods for this question How can I set an entity Attribute using my entity spawn method or using a different method that let me dynamically choose an entity?
October 18, 20196 yr Author getEntityAttribute has nothing to do with NBT. I need both, and both are my problem, that's why I said Attribute/NBT I'll try it now Do not create new Random instances all the time. What can I do then? Edited October 18, 20196 yr by NoobMaster4000
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.