Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Add should_damage_condition field to freeze power type.
Browse files Browse the repository at this point in the history
  • Loading branch information
MerchantPug committed Nov 12, 2023
1 parent 6ba64a2 commit 0b37572
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Added `function` field to `modify_durability_change` power type. Can be `floor`, `round`, or `ceiling`. Defaults to `floor`.
- Added `self_target_bientity_action`, `self_nearby_bientity_action`, and `target_nearby_bientity_action` to `damage_nearby_on_hit` power type. (All optional).
- Added `attacker_target_bientity_action`, `attacker_nearby_bientity_action`, and `self_nearby_bientity_action` to `damage_nearby_when_hit` power type. (All optional).
- Added `should_damage_condition` to `freeze` power type.

### Bi-entity Condition Types
- Added `compare_dimensions` bi-entity condition type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public LivingEntityMixin(EntityType<? extends LivingEntity> entityType, Level wo

@ModifyExpressionValue(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;canFreeze()Z", ordinal = 1))
private boolean apugli$stopFreezeDamage(boolean original) {
if (Services.POWER.hasPower((LivingEntity)(Object)this, ApugliPowers.FREEZE.get()) && Services.POWER.getPowers((LivingEntity)(Object)this, ApugliPowers.FREEZE.get()).stream().anyMatch(p -> !ApugliPowers.FREEZE.get().shouldDamage(p))) {
if (Services.POWER.hasPower((LivingEntity)(Object)this, ApugliPowers.FREEZE.get()) && Services.POWER.getPowers((LivingEntity)(Object)this, ApugliPowers.FREEZE.get()).stream().anyMatch(p -> !ApugliPowers.FREEZE.get().shouldDamage(p, (LivingEntity)(Object)this))) {
return false;
}
return original;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@

import io.github.apace100.calio.data.SerializableData;
import io.github.apace100.calio.data.SerializableDataTypes;
import net.merchantpug.apugli.platform.Services;
import net.minecraft.world.entity.Entity;

public interface FreezePowerFactory<P> extends ValueModifyingPowerFactory<P> {

static SerializableData getSerializableData() {
return ValueModifyingPowerFactory.getSerializableData()
.add("should_damage_condition", Services.CONDITION.entityDataType(), null)
.add("should_damage", SerializableDataTypes.BOOLEAN, true);
}

default boolean shouldDamage(P power) {
return getDataFromPower(power).getBoolean("should_damage");
default boolean shouldDamage(P power, Entity entity) {
SerializableData.Instance data = getDataFromPower(power);

if (!Services.CONDITION.checkEntity(data, "should_damage_condition", entity)) {
return false;
}

return data.getBoolean("should_damage");
}

}

0 comments on commit 0b37572

Please sign in to comment.