Bassebombecraft

Bassebombecraft

18.5k Downloads

SpawnAngryParrots operator sets attributes which aren't defined on parrot entity

athrane opened this issue ยท 2 comments

commented

This is a sister investigation to #1207 in order to resolve any potential bugs.

The SpawnAngryParrots operator sets these vanilla attributes:

setAttribute(entity, FLYING_SPEED, movementSpeed);
setAttribute(entity, MOVEMENT_SPEED, movementSpeed);
setAttribute(entity, ATTACK_DAMAGE, damage);

But only the FLYING_SPEED and MOVEMENT_SPEED are defined in the ParrotEntity:

   public static AttributeModifierMap.MutableAttribute func_234213_eS_() {
      return MobEntity.func_233666_p_().createMutableAttribute(Attributes.MAX_HEALTH, 6.0D).createMutableAttribute(Attributes.FLYING_SPEED, (double)0.4F).createMutableAttribute(Attributes.MOVEMENT_SPEED, (double)0.2F);
   }

.. ATTACK_DAMAGE isn't defined in the MobEntity "super class":

   public static AttributeModifierMap.MutableAttribute func_233666_p_() {
      return LivingEntity.registerAttributes().createMutableAttribute(Attributes.FOLLOW_RANGE, 16.0D).createMutableAttribute(Attributes.ATTACK_KNOCKBACK);
   }

.. ATTACK_DAMAGE isn't defined in the LivingEntity "super class":

   public static AttributeModifierMap.MutableAttribute registerAttributes() {
      return AttributeModifierMap.createMutableAttribute().createMutableAttribute(Attributes.MAX_HEALTH).createMutableAttribute(Attributes.KNOCKBACK_RESISTANCE).createMutableAttribute(Attributes.MOVEMENT_SPEED).createMutableAttribute(Attributes.ARMOR).createMutableAttribute(Attributes.ARMOR_TOUGHNESS).createMutableAttribute(net.minecraftforge.common.ForgeMod.SWIM_SPEED.get()).createMutableAttribute(net.minecraftforge.common.ForgeMod.NAMETAG_DISTANCE.get()).createMutableAttribute(net.minecraftforge.common.ForgeMod.ENTITY_GRAVITY.get());
   }

So ATTACK_DAMAGE should defined as mutable attribute for ParrotEntity in order to set it and avoid the type of errors from #1207.

commented

Observed runtime error when testing:

[29Aug2021 16:56:58.447] [Server thread/ERROR] [net.minecraft.server.MinecraftServer/]: Encountered an unexpected exception
net.minecraft.crash.ReportedException: Ticking player
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:154) ~[forge:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:899) ~[forge:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:821) ~[forge:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:84) ~[forge:?]
	at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:664) ~[forge:?]
	at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:233) ~[forge:?]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_211]
Caused by: java.lang.NullPointerException
	at bassebombecraft.entity.EntityUtils.setAttribute(EntityUtils.java:456) ~[?:?]
	at bassebombecraft.item.action.inventory.SpawnAngryParrots.applyEffect(SpawnAngryParrots.java:86) ~[?:?]
	at bassebombecraft.item.inventory.GenericInventoryItem.applyEffect(GenericInventoryItem.java:191) ~[?:?]
	at bassebombecraft.item.inventory.GenericInventoryItem.inventoryTick(GenericInventoryItem.java:152) ~[?:?]
	at net.minecraft.item.ItemStack.inventoryTick(ItemStack.java:499) ~[forge:?]
	at net.minecraft.entity.player.PlayerInventory.tick(PlayerInventory.java:265) ~[forge:?]
	at net.minecraft.entity.player.PlayerEntity.livingTick(PlayerEntity.java:514) ~[forge:?]
	at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2305) ~[forge:?]
	at net.minecraft.entity.player.PlayerEntity.tick(PlayerEntity.java:227) ~[forge:?]
	at net.minecraft.entity.player.ServerPlayerEntity.playerTick(ServerPlayerEntity.java:422) ~[forge:?]
	at net.minecraft.network.play.ServerPlayNetHandler.tick(ServerPlayNetHandler.java:212) ~[forge:?]
	at net.minecraft.network.NetworkManager.tick(NetworkManager.java:248) ~[forge:?]
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:151) ~[forge:?]

commented

Resolved with commit: 3bf5ddd