Brewin' And Chewin'

Brewin' And Chewin'

9M Downloads

[1.20.1 Forge] RagingCapability only partially checks whether the ATTACK_SPEED attribute is present.

Fealtous opened this issue ยท 0 comments

commented

https://gnomebot.dev/paste/mclogs/qfhhaKl#L8423
Per the above log, it is possible that some LivingEntity may not have the ATTACK_SPEED attribute, which you seem to check for.

if (living.getAttributes().hasModifier(Attributes.ATTACK_SPEED, RAGING_ATTRIBUTE_UUID))
living.getAttribute(Attributes.ATTACK_SPEED).removeModifier(RAGING_ATTRIBUTE_UUID);
living.getAttribute(Attributes.ATTACK_SPEED).addTransientModifier(new AttributeModifier(RAGING_ATTRIBUTE_UUID, "Raging attack speed increase", Math.min(0.8, 0.05 * cap.getStacks() + 0.025 * living.getEffect(BnCEffects.RAGING.get()).getAmplifier() * cap.getStacks()), AttributeModifier.Operation.MULTIPLY_TOTAL));
BnCNetworkHandler.INSTANCE.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> living), new SyncRagingStacksClientboundPacket(living.getId(), cap.getStacks()));

Except it's only validating for L82. L83 just assumes that the attribute is present and can cause the associated crash.
What seems to have been meant was this:

if (living.getAttributes().hasModifier(Attributes.ATTACK_SPEED, RAGING_ATTRIBUTE_UUID)) {
    var attribute = living.getAttribute(Attributes.ATTACK_SPEED);
    attribute.removeModifier(RAGING_ATTRIBUTE_UUID); 
    attribute.addTransientModifier(new AttributeModifier(RAGING_ATTRIBUTE_UUID, "Raging attack speed increase", Math.min(0.8, 0.05 * cap.getStacks() + 0.025 * living.getEffect(BnCEffects.RAGING.get()).getAmplifier() * cap.getStacks()), AttributeModifier.Operation.MULTIPLY_TOTAL)); 
    BnCNetworkHandler.INSTANCE.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> living), new SyncRagingStacksClientboundPacket(living.getId(), cap.getStacks()));
} 

This report was made on behalf of a user who came into the MinecraftForge support channels.