Jump to content

Recommended Posts

Posted (edited)

If we take a look at a class like AbstractSkeletonEntity, this snippet determines if they should burn:

public void livingTick() {
   boolean flag = this.isInDaylight();
   if (flag) {
      ItemStack itemstack = this.getItemStackFromSlot(EquipmentSlotType.HEAD);
      if (!itemstack.isEmpty()) {
         if (itemstack.isDamageable()) {
            itemstack.setDamage(itemstack.getDamage() + this.rand.nextInt(2));
            if (itemstack.getDamage() >= itemstack.getMaxDamage()) {
               this.sendBreakAnimation(EquipmentSlotType.HEAD);
               this.setItemStackToSlot(EquipmentSlotType.HEAD, ItemStack.EMPTY);
            }
         }
         flag = false;
      }
      if (flag) {
         this.setFire(8);
      }
   }
   super.livingTick();
}

However this also requires we look at isInDaylight() in MobEntity:

protected boolean isInDaylight() {
   if (this.world.isDaytime() && !this.world.isRemote) {
      float f = this.getBrightness();
      BlockPos blockpos = this.getRidingEntity() instanceof BoatEntity ? (new BlockPos(this.getPosX(), (double)Math.round(this.getPosY()), this.getPosZ())).up() : new BlockPos(this.getPosX(), (double)Math.round(this.getPosY()), this.getPosZ());
      if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.canSeeSky(blockpos)) {
         return true;
      }
   }

   return false;
}

And finally, isDaytime() in World:

public boolean isDaytime() {
   return !this.func_230315_m_().func_241514_p_() && this.skylightSubtracted < 4;
}

And there's the light level. So altogether you'll need to add code like these three for your entity.

 

Edited by urbanxx001
Posted

I have some code, but it doesn't seem to work:

public void livingTick() {
    if (this.isAlive()) {
        boolean flag = (this.shouldBurnInDay() && this.isInDaylight()) || this.isInLightLevel();
        if (flag) {
            this.setFire(4);
        }
    }
    super.livingTick();
}

protected boolean isInLightLevel() {
    return world.getLightValue(this.getPosition()) >= 8;
}

Any help?

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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