Skip to content

Commit

Permalink
Fixed Anubi's Wraith tiers not increasing damage
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Oct 22, 2020
1 parent bedcd15 commit 9015ebb
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@

@Mod.EventBusSubscriber(modid = Atum.MOD_ID)
public class AnubisWrathItem extends SwordItem {
private static final Object2FloatMap<PlayerEntity> cooldown = new Object2FloatOpenHashMap<>();
private final float attackDamage;
private static final Object2FloatMap<PlayerEntity> COOLDOWN = new Object2FloatOpenHashMap<>();
private float attackDamage = 5.0F;

public AnubisWrathItem() {
super(ItemTier.DIAMOND, 0, 0.0F, new Item.Properties().rarity(Rarity.RARE).group(Atum.GROUP));
int tier = getTier(new ItemStack(this));
this.attackDamage = tier == 3 ? 9.0F : tier + 5.0F;
}

@Override
Expand Down Expand Up @@ -89,16 +88,16 @@ public static void onAttack(AttackEntityEvent event) {
if (player.world.isRemote) return;
if (player.getHeldItemMainhand().getItem() == AtumItems.ANUBIS_WRATH && getTier(player.getHeldItemMainhand()) == 3) {
if (event.getTarget() instanceof LivingEntity && ((LivingEntity) event.getTarget()).getCreatureAttribute() != CreatureAttribute.UNDEAD && !(event.getTarget() instanceof StoneBaseEntity)) {
cooldown.put(player, player.getCooledAttackStrength(0.5F));
COOLDOWN.put(player, player.getCooledAttackStrength(0.5F));
}
}
}

@SubscribeEvent
public static void onHurt(LivingHurtEvent event) {
Entity trueSource = event.getSource().getTrueSource();
if (trueSource instanceof PlayerEntity && cooldown.containsKey(trueSource)) {
if (cooldown.getFloat(trueSource) == 1.0F) {
if (trueSource instanceof PlayerEntity && COOLDOWN.containsKey(trueSource)) {
if (COOLDOWN.getFloat(trueSource) == 1.0F) {
event.setAmount(event.getAmount() * 2);
LivingEntity entity = event.getEntityLiving();
double y = MathHelper.nextDouble(random, 0.02D, 0.1D);
Expand All @@ -107,7 +106,7 @@ public static void onHurt(LivingHurtEvent event) {
serverWorld.spawnParticle(AtumParticles.ANUBIS, entity.getPosX() + (random.nextDouble() - 0.5D) * (double) entity.getWidth(), entity.getPosY() + entity.getEyeHeight(), entity.getPosZ() + (random.nextDouble() - 0.5D) * (double) entity.getWidth(), 5, 0.0D, y, 0.0D, 0.04D);
}
}
cooldown.removeFloat(trueSource);
COOLDOWN.removeFloat(trueSource);
}
}

Expand Down Expand Up @@ -159,7 +158,8 @@ public Multimap<Attribute, AttributeModifier> getAttributeModifiers(@Nonnull Equ
ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
if (slot == EquipmentSlotType.MAINHAND) {
int tier = getTier(stack);
builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", this.attackDamage, AttributeModifier.Operation.ADDITION));
this.attackDamage = tier == 3 ? 9.0F : tier + 5.0F;
builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", this.getAttackDamage(), AttributeModifier.Operation.ADDITION));
double speed = tier == 0 ? 0.6D : tier == 1 ? 0.7D : tier == 2 ? 0.8D : tier == 3 ? 1.0D : 0;
builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", speed - 3.0D, AttributeModifier.Operation.ADDITION));
}
Expand Down

0 comments on commit 9015ebb

Please sign in to comment.