Jump to content

Petchy

Members
  • Posts

    9
  • Joined

  • Last visited

Posts posted by Petchy

  1. I'm attempting to make the bee entity setHasStung() method public, however I can't seem to get the access transformer to work, what should I put in the accesstransformer.cfg file to accomplish this?
    Thanks so much

    Edit: nvm figured it out

  2. Hi, i'm trying to make it so that wolves will not attack other mobs when untamed, i'm aware im probably doing it totally wrong, but I can't figure out how to make this work:
     

    @SubscribeEvent
            public static void wolfNoChase(EntityJoinWorldEvent e) {
                if (e.getEntity() instanceof Wolf) {
                    ((Wolf) e.getEntity()).targetSelector.removeGoal(NonTameRandomTargetGoal);
                }
            }

    Please could I be given some pointers or shown an example of how to do this properly? Thank you so much

    I also tried this (doesnt work either):

    @SubscribeEvent
            public static void wolfNoChase(EntityJoinWorldEvent e) {
                if (e.getEntity() instanceof Wolf) {
                    for(Goal goal: ((Wolf) e.getEntity()).targetSelector.getAvailableGoals()) {
                        if (goal instanceof NonTameRandomTargetGoal) {
                            ((Wolf) e.getEntity()).targetSelector.removeGoal(goal);
                        }
                    }
                }
            }

     

  3. public void setHasStung(boolean p_27926_) {
          this.setFlag(4, p_27926_);
       }

    I have set setHasStung to public, however it still seems to not let me call the method. I'm trying to make it so that bees can sting you, but will not lose their stinger and die:
     

    @SubscribeEvent
            public static void unSting(LivingHurtEvent e) {
                if (e.getSource().getEntity() instanceof Bee) {
                    ((Bee)e.getSource().getEntity()).setHasStung(false);
                }
            }

    setHasStung is just underlined red, can anyone explain this? Thank you

     

  4. @EventHandler
        public void attack(LivingDamageEvent event) {
            if (event.getEntity() instanceof EntityCow) {
                event.setCanceled(true);
            }
        }

    I'm new to minecraft mods, why does this not trigger when I hit a cow and cancel the damage? Thank you

  5. 5 hours ago, diesieben07 said:

    It depends on what aspects you want to modify. For invincibility there are two options:

    • Subscribe to EntityJoinWorldEvent (once PR 8264 is merged use that event instead). In there call Entity#setInvulnerable(true) for all entities that you want to be invulnerable.
    • Alternatively you can use LivingAttackEvent. Cancel it to prevent damage to a living entity. This allows more fine grained control.

    For other aspects that you want to modify, you'll have to provide details.

    Can I just ask, I wrote this quick code, should this not work? It doesn't seem to:

    @EventHandler
        public void attack(LivingDamageEvent event) {
            if (event.getEntity() instanceof EntityCow) {
                event.setCanceled(true);
            }
        }

     

×
×
  • Create New...

Important Information

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