Started by
Mr_Alpha
on
Topic category: Help with Minecraft modding (Java Edition)
I set an item to summon entity with ID 58 (Enderman) one block above the block you right click on. It spawns, but gravity doesn't affect it, it doesn't move and won't attack you. It stays in an infinite loop of its standing animation and you can't hit it. I tried execute command on rightclick on block and put "summon Enderman ~ ~1 ~" (because it says command without the /) and it says you do not have permissions. I turned on cheats via hosting the world on LAN and it still didn't work. Then, I typed /summon Enderman in the chat and an Enderman appeared and worked completely. If you help me in a reply and it works, you'll get a dedication on the mod page! Thanks!
It is the "ghost mob" bug. The real enderman spawned but probably instantly tped away. The ghost enderman would disappear after relogging.
To fix this bug, add if(!world.isRemote){ before the spawning code and close with the bracket }
so it should look like:
Entity sentity = EntityList.createEntityByName("name", world);if (sentity != null){sentity.setLocationAndAngles(i, j, k, world.rand.nextFloat() * 360F, 0.0F);if(!world.isRemote){world.spawnEntityInWorld(sentity);}((EntityLiving)sentity).playLivingSound();}
}
@#1 Thanks! Do you know what line of code that will be on? Or at least a general area?
@#1.1 see my example
Entity sentity = EntityList.createEntityByName("name", world);if (sentity != null){sentity.setLocationAndAngles(i, j, k, world.rand.nextFloat() * 360F, 0.0F);if(!world.isRemote){world.spawnEntityInWorld(sentity);}((EntityLiving)sentity).playLivingSound();}
}
@#1.1.1 Ok, I found the spot. Thanks a lot. :) Let's hope this works...
UPDATE: OK, I got the semicolon placing wrong. Rewriting and retrying...
UPDATE 2: It still doesn't work. The enderman spawns in like before and jsut stands there. This time I shot it with a bow and it disappeared, but there was no enderman in sight within 100 blocks radius. The code did literally nothing, sorry. Any other suggestions?
@#1.1.1.1 Can you show the code?
@#1.1.1.1.1 I think I'm just going to have it give you an enderman spawn egg. But... You can only spawn a generic spawn egg. Do you know how to select a spawn egg of a specific mob?
Maybe: new ItemStack(Item.getItemById(383),1,58);
@#2 Thanks, I'll try it.
@#2 Okay, so it worked and it didn't work. It gave me the egg, but then I tried to use it and all of the multiple eggs in my inventory disappeared and it didn't spawn an enderman on rightclick. Do you have any ideas on how to just summon it in without the "Ghost Mob Bug?"