Skip to content

Commit

Permalink
remove healing exhaustion attribute and use blood exhaustion attribut…
Browse files Browse the repository at this point in the history
…e every time
  • Loading branch information
Cheaterpaul committed Dec 14, 2023
1 parent 1876f0e commit a14ecc6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
5 changes: 0 additions & 5 deletions src/main/java/de/teamlapen/vampirism/core/ModAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public class ModAttributes {
* Registered for EntityPlayer
*/
public static final RegistryObject<RangedAttribute> DBNO_DURATION = ATTRIBUTES.register("dbno_duration", () -> (RangedAttribute) new RangedAttribute("vampirism.dbno_duration", 1.0, 0.0, Integer.MAX_VALUE).setSyncable(true));
/**
* Allows modifying the blood exhaustion except it also applies to exhaustion increased from healing as well. Like the other attribute, multiplies the value.
* Registered for EntityPlayer
*/
public static final RegistryObject<RangedAttribute> BLOOD_EXHAUSTION_INCLUDE_HEALING = ATTRIBUTES.register("blood_exhaustion_healing", () -> (RangedAttribute) new RangedAttribute("vampirism.blood_exhaustion_healing", 1.0, 0.0, 1000).setSyncable(true));

static void register(IEventBus bus) {
ATTRIBUTES.register(bus);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/de/teamlapen/vampirism/core/ModEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ static void onModifyEntityTypeAttributes(@NotNull EntityAttributeModificationEve
event.add(EntityType.PLAYER, ModAttributes.BLOOD_EXHAUSTION.get());
event.add(EntityType.PLAYER, ModAttributes.NEONATAL_DURATION.get());
event.add(EntityType.PLAYER, ModAttributes.DBNO_DURATION.get());
event.add(EntityType.PLAYER, ModAttributes.BLOOD_EXHAUSTION_INCLUDE_HEALING.get());
}

private static <T extends Entity> RegistryObject<EntityType<T>> prepareEntityType(String id, @NotNull Supplier<EntityType.Builder<T>> builder, boolean spawnable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ public boolean onUpdate() {
if (this.bloodTimer >= 10) {
float f = Math.min(this.bloodSaturationLevel, 6F);
player.heal(f / 6F);
this.addExhaustion(f, true);
this.addExhaustion(f);
this.bloodTimer = 0;
}
} else if (regen && this.bloodLevel >= (18) && player.isHurt()) {
++this.bloodTimer;

if (this.bloodTimer >= 80) {
player.heal(1.0F);
this.addExhaustion(6F, true);
this.addExhaustion(6F);
this.bloodTimer = 0;
}
} else if (this.bloodLevel <= 0) {
Expand Down Expand Up @@ -174,12 +174,10 @@ void addExhaustion(float amount) {
*
* @param ignoreModifier If the entity exhaustion attribute {@link de.teamlapen.vampirism.core.ModAttributes#BLOOD_EXHAUSTION} should be ignored
*/
void addExhaustion(float amount, boolean ignoreModifier) {
void addExhaustion(float amount, @SuppressWarnings("SameParameterValue") boolean ignoreModifier) {
if (!ignoreModifier) {
AttributeInstance attribute = player.getAttribute(ModAttributes.BLOOD_EXHAUSTION.get());
amount *= attribute.getValue();
amount *= (float) player.getAttributeValue(ModAttributes.BLOOD_EXHAUSTION.get());
}
amount *= player.getAttribute(ModAttributes.BLOOD_EXHAUSTION_INCLUDE_HEALING.get()).getValue();
this.bloodExhaustionLevel = Math.min(bloodExhaustionLevel + amount, 40F);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public void increaseRemainingBarkTicks(int additionalTicks) {
}

public int getDbnoDuration() {
return (int) player.getAttribute(ModAttributes.DBNO_DURATION.get()).getValue();
return (int) player.getAttributeValue(ModAttributes.DBNO_DURATION.get());
}

public int getDbnoTimer() {
Expand Down Expand Up @@ -1048,7 +1048,7 @@ public void tryResurrect() {
this.player.setForcedPose(null);
this.player.refreshDimensions();
this.sync(true);
int duration = (int) player.getAttribute(ModAttributes.NEONATAL_DURATION.get()).getValue();
int duration = (int) player.getAttributeValue(ModAttributes.NEONATAL_DURATION.get());
this.player.addEffect(new MobEffectInstance(ModEffects.NEONATAL.get(), duration));
this.player.awardStat(ModStats.resurrected);
if (this.player instanceof ServerPlayer serverPlayer) {
Expand Down Expand Up @@ -1220,15 +1220,13 @@ private void applyEntityAttributes() {
player.getAttribute(ModAttributes.BLOOD_EXHAUSTION.get()).setBaseValue(VampirismConfig.BALANCE.vpBloodExhaustionFactor.get());
player.getAttribute(ModAttributes.NEONATAL_DURATION.get()).setBaseValue(VampirismConfig.BALANCE.vpNeonatalDuration.get() * 20);
player.getAttribute(ModAttributes.DBNO_DURATION.get()).setBaseValue(VampirismConfig.BALANCE.vpDbnoDuration.get() * 20);
player.getAttribute(ModAttributes.BLOOD_EXHAUSTION_INCLUDE_HEALING.get()).setBaseValue(1);
}

private void removeEntityAttributes() {
player.getAttribute(ModAttributes.SUNDAMAGE.get()).setBaseValue(0);
player.getAttribute(ModAttributes.BLOOD_EXHAUSTION.get()).setBaseValue(0);
player.getAttribute(ModAttributes.NEONATAL_DURATION.get()).setBaseValue(0);
player.getAttribute(ModAttributes.DBNO_DURATION.get()).setBaseValue(0);
player.getAttribute(ModAttributes.BLOOD_EXHAUSTION_INCLUDE_HEALING.get()).setBaseValue(0);
}

/**
Expand Down

0 comments on commit a14ecc6

Please sign in to comment.