Posted April 23, 20223 yr I have added an option to replace all skeletons in overworld with zombies, but it may (exactly, MAY and not WILL) crash server during world load. Here is a problemmatic piece of code: /* This code is inside EntityJoinWorldEvent event handler */ /* Replace skeletons with zombies? */ if (ConfigHandler.GENERAL.noSkeletons.get()) { //Zombienation.LOGGER.debug("Attempting to replace skeleton with zombie..."); if (event.getEntity() instanceof SkeletonEntity || event.getEntity() instanceof StrayEntity) { if (event.getEntity().level.dimension().location().toString().equals("minecraft:overworld")) { /* Random zombie randomly turns into any other zombie from vanilla or my mod on spawn */ /* Zombie itself isn't a problem - I have tried vanilla zombies or even pigs */ RandomZombie zombie = new RandomZombie(ZombiesRegistry.RANDOM_ZOMBIE.get(), event.getEntity().level); zombie.setPos(event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ()); event.getEntity().level.addFreshEntity(zombie); //Server freezes at this line /* Line below is never reached if server freezes, so it can't be an issue? */ event.setCanceled(true); //Zombienation.LOGGER.debug("Done!"); } } } Edited April 23, 20223 yr by Mad Alchemist Fixed a typo in code piece
April 25, 20223 yr Author 23 hours ago, diesieben07 said: This should really check the entity type instead, not the class. Leaving it "as is", it will also replace everything that extends SkeletonEntity or StrayEntity classes? Not sure if I want it... It may be desired behavior if some mod adds skeletons by extending vanilla ones... And thanks for help, I probably would never find out it myself...
April 25, 20223 yr Author Quote Look at ForgeInternalHandler#onEntityJoinWorld for how to do it properly. Where is this "ForgeInternalHandler" located? And, can't I just do it in entity tick and check if chunk entity is in is fully loaded?
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.