Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by Mad Alchemist
Fixed a typo in code piece

  • 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...

 

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.