Skip to content

Commit

Permalink
Fix crash when attack speed doesnt exist
Browse files Browse the repository at this point in the history
Fixes #179
  • Loading branch information
Shnupbups committed Jul 24, 2020
1 parent aec98de commit f12f065
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import java.util.Optional;
import java.util.UUID;

@Mixin(MiningToolItem.class)
Expand All @@ -42,6 +43,7 @@ public abstract class MiningToolItemMixin implements MiningToolItemAccess {

@Override
public double astromine_getAttackSpeed() {
return getAttributeModifiers(EquipmentSlot.MAINHAND).get(EntityAttributes.GENERIC_ATTACK_SPEED).stream().filter((EntityAttributeModifier modifier) -> modifier.getId().equals(UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"))).findFirst().get().getValue();
Optional<EntityAttributeModifier> opt = getAttributeModifiers(EquipmentSlot.MAINHAND).get(EntityAttributes.GENERIC_ATTACK_SPEED).stream().filter((EntityAttributeModifier modifier) -> modifier.getId().equals(UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"))).findFirst();
return opt.map(EntityAttributeModifier::getValue).orElse(0d);
}
}

0 comments on commit f12f065

Please sign in to comment.