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

Hi! In my mod, "Zombination", being attacked by zombie gives a slight chance to contract a zombie virus. It happens in LivingAttackEvent handler, and, problem is, zombies may infect players even if attack was blocked by shield. Of course, I can check if attacked entity is a player, has a shield, and is crouching, but, maybe, there is a better way to make shield protect from infection?

This is how it works currently (no check for shield blocking):

 

/* Is damage source a zombie ? */
        if (event.getSource().getEntity() instanceof ZombieEntity ||
            event.getSource().getEntity() instanceof ZombieBear ||
            event.getSource().getEntity() instanceof ZolphinEntity) {

            /* Is target an enderman? */
            if(event.getEntityLiving() instanceof EndermanEntity) {
                // Heal enderman, so that zombies almost never win this fight
                event.getEntityLiving().heal(10f);
            }

            /* Is target infectable */
            if (isInfectable(event.getEntity())) {
                double d = Math.random();
                if (d <= ConfigHandler.INFECTION.infectionChance.get() || (event.getEntity().hasCustomName() && event.getEntity().getCustomName().getString().equals("Heisenberg"))) {
                    /* Is entity already infected? */
                    if(!event.getEntityLiving().hasEffect(PotionsRegistry.POTION_ZOMBIE_VIRUS.getEffect())) {
                        event.getEntityLiving().addEffect(new EffectInstance(PotionsRegistry.POTION_ZOMBIE_VIRUS, ConfigHandler.INFECTION.infectionDuration.get() * 20, (int) 0, true, (false)));
                    }
                }
            }

 

Edited by Mad Alchemist
Added some code to make problem easier to understand

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.