NMS: Stop Zombies From Burning?

Discussion in 'Spigot Plugin Development' started by Bladian, May 7, 2015.

Thread Status:
Not open for further replies.
  1. Title says it all...

    I could always use an MobCombustEvent but I would rather keep it all in an NMS mob class.
     
  2. Do you want to keep them from burning or spawning because your title and thread content say 2 different things
     
    • Agree Agree x 1
  3. This is what happens when you have lack of sleep.

    Sorry, meant it to say burning.
     
  4. Honestly you would be best off using the EntityCombustEvent
    But for NMS, I dont have the docs in front of me but I believe you should be overriding m()
    If someone else could check that and correct me if im wrong. If no one can then i'll check it when I get home (if i remember to)
     
    • Creative Creative x 1
  5. Do you know where exactly the docs are?

    I would love to see them, since for now I've only been decompiling the spigot jar.
     
  6. Override K() (Could have a different name if you're not using the same version as I do) and add
    Code (Text):
    entity.setFireTicks(0);
    Be sure to call the super method aswell though.
     
  7. Thanks.

    Where do you get this from?

    Are they in the spigot docs anywhere?
     
  8. Nope they aren't, you just have to learn NMS.
     
  9. Looking around the jar and I believe it should be like this correct?

    Code (Text):
    @Override
        public void m() {
            this.setOnFire(0);
            super.m();
        }
     
     
  10. Depends, what Spigot version are you using?
     
  11. I believe K() would just be used for ticks for just Entity not EntityZombie in the latest version

    Don't completely override m() because I believe that also handles baby zombies riding chickens
     
  12. Here is the m() just incase (if it's not allowed I will remove it immediately):

    Code (Text):
    public void m() {
        if ((this.world.w()) && (!this.world.isClientSide) && (!isBaby())) {
          float f = c(1.0F);
          BlockPosition blockposition = new BlockPosition(this.locX, Math.round(this.locY), this.locZ);

          if ((f > 0.5F) && (this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) && (this.world.i(blockposition))) {
            boolean flag = true;
            ItemStack itemstack = getEquipment(4);

            if (itemstack != null) {
              if (itemstack.e()) {
                itemstack.setData(itemstack.h() + this.random.nextInt(2));
                if (itemstack.h() >= itemstack.j()) {
                  b(itemstack);
                  setEquipment(4, null);
                }
              }

              flag = false;
            }

            if (flag)
            {
              EntityCombustEvent event = new EntityCombustEvent(getBukkitEntity(), 8);
              this.world.getServer().getPluginManager().callEvent(event);

              if (!event.isCancelled()) {
                setOnFire(event.getDuration());
              }
            }
          }

        }

        if ((au()) && (getGoalTarget() != null) && ((this.vehicle instanceof EntityChicken))) {
          ((EntityInsentient)this.vehicle).getNavigation().a(getNavigation().j(), 1.5D);
        }

        super.m();
      }
     
     
  13. EnityZombie is a subclass of Entity.
     
  14. Just override m() and remove its content (don't even call the super method).
     
  15. But is the "this.setOnFire(0)" method correct?
     
  16. That's not needed anymore since you're not overriding the ticking method.
     
    • Informative Informative x 1
  17. I know but if you override K() for Entity then no mobs will burn or be able to use portals right?

    Just so you know, I'm not trying to argue im just trying to make sure im following nms correctly
     
    • Agree Agree x 1
  18. If you override K() in EntityZombie and spawn this custom Zombie it will only be overridden by this custom Zombie.
     
    • Agree Agree x 1
  19. It annoys me, that if a guy posts a post giving his opinion, there's a huge chance he'll get judged.

    Props to you my good sir!
     
  20. Are you saying that I was judging him or are you just saying this in general? Because I wasn't.
     
    • Optimistic Optimistic x 1
Thread Status:
Not open for further replies.