Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/main/java/de/dafuqs/spectrum/mixin/LivingEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,19 @@ private float getToughness() {
return (float) this.getAttributeValue(EntityAttributes.GENERIC_ARMOR_TOUGHNESS);
}

@Inject(method = "handleFallDamage", at = @At("HEAD"), cancellable = true)
private void spectrum$puffCircletDamageNegation(float fallDistance, float damageMultiplier, DamageSource damageSource, CallbackInfoReturnable<Boolean> cir) {
@ModifyReturnValue(method = "handleFallDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;computeFallDamage(FF)I"))
private int spectrum$puffCircletDamageNegation(int original) {
LivingEntity thisEntity = (LivingEntity) (Object) this;
float cost = Math.min(original, PuffCircletItem.FALL_DAMAGE_NEGATING_COST);
// check if damage reduction is applicable to this entity
if (thisEntity.isInvulnerableTo(thisEntity.getDamageSources().fall()) || AzureDikeProvider.getAzureDikeCharges(thisEntity) <= 0) return;
if (original <= 0 || thisEntity.isInvulnerableTo(thisEntity.getDamageSources().fall()) || AzureDikeProvider.getAzureDikeCharges(thisEntity) <= cost) return original;

// check if this entity is protected by puff circlet
Optional<TrinketComponent> component = TrinketsApi.getTrinketComponent(thisEntity);
if (component.isEmpty() || component.get().getEquipped(SpectrumItems.PUFF_CIRCLET).isEmpty()) return;
if (component.isEmpty() || component.get().getEquipped(SpectrumItems.PUFF_CIRCLET).isEmpty()) return original;

// do damage reduction
AzureDikeProvider.absorbDamage(thisEntity, PuffCircletItem.FALL_DAMAGE_NEGATING_COST);
AzureDikeProvider.absorbDamage(thisEntity, cost);

// yoink
Vec3d velocity = thisEntity.getVelocity();
Expand All @@ -411,8 +412,7 @@ private float getToughness() {
}
thisEntity.getWorld().playSound(null, thisEntity.getBlockPos(), SpectrumSoundEvents.PUFF_CIRCLET_PFFT, SoundCategory.PLAYERS, 1.0F, 1.0F);

// at last, cancel the function
cir.setReturnValue(false);
return 0;
}

@ModifyVariable(at = @At("HEAD"), method = "damage(Lnet/minecraft/entity/damage/DamageSource;F)Z", argsOnly = true)
Expand Down
Loading