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

Hello,

I am trying to make a drowned transform into a custom mod I made (called Hot Drowned) when it goes through a magma bubble column. I already have the mob fully working in game, but the code for the transformation is giving me trouble. Since I can't edit the drowned code, I tried to make it check on Living Tick Event for a drowned that is doing the ticking and check its position from there in relation to a magma block but its not working. My code is below, thank you in advance.

    @SubscribeEvent(priority = EventPriority.HIGHEST)
    public void entityJoinWorld(LivingEvent.LivingTickEvent event, ServerLevel pServerLevel) {
        System.out.println("Entity Ticked");
        Entity entity = event.getEntity();
        if (entity.isAlive() && entity instanceof Drowned) {
            Drowned drowned = (Drowned) entity;
            BlockPos bPos = BlockPos.of(drowned.blockPosition().get(Direction.Axis.Y));
            BlockState bPosBlock = pServerLevel.getBlockState(bPos);
            int dHieght = bPos.getY();
            if (bPosBlock == Blocks.WATER.defaultBlockState() || bPosBlock == Blocks.MAGMA_BLOCK.defaultBlockState()){
                if (bPosBlock == Blocks.MAGMA_BLOCK.defaultBlockState()){
                    ModEntities.HOT_DROWN.get().spawn(pServerLevel, BlockPos.of(drowned.blockPosition().get(Direction.Axis.Y)), NATURAL);
                }else {
                    for (int x = dHieght + 64; x > 0; x--) {
                        bPos = BlockPos.of(bPos.below().get(Direction.Axis.Y));
                        bPosBlock = pServerLevel.getBlockState(bPos);
                        System.out.println(bPosBlock);
                        if (bPosBlock == Blocks.MAGMA_BLOCK.defaultBlockState()) {
                            ModEntities.HOT_DROWN.get().spawn(pServerLevel, BlockPos.of(drowned.blockPosition().get(Direction.Axis.Y)), NATURAL);
                        } else {
                            return;
                        }
                    }
                }
            }
            }
        }
    }

 

Is the code inside the event event gets called? I believe that event listeners needs to be public static and the Level parameter should be retrieved from the event itself (not sure if you can provide it as a listener parameter, I don't think so tbh)

Don't blame me if i always ask for your help. I just want to learn to be better :)

  • Author

I changed it to public static void but I can't find anyway to get level from the event even if it isn't a listener parameter. @JimiIT92

On 12/5/2023 at 1:08 PM, Chydog376 said:

I changed it to public static void but I can't find anyway to get level from the event even if it isn't a listener parameter. @JimiIT92

You can use 

event.getEntity().level()

 

Don't blame me if i always ask for your help. I just want to learn to be better :)

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.