Skip to content

Commit

Permalink
feat: make Cleansing Serum able to remove forced age from applicable …
Browse files Browse the repository at this point in the history
…mobs
  • Loading branch information
Elenterius committed Apr 25, 2023
1 parent 8fff2a5 commit 908c7ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/com/github/elenterius/biomancy/entity/MobUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ public static void convertToAdult(Mob mob) {

mob.setBaby(false);
if (mob instanceof AgeableMob ageableMob) {
AgeableMobAccessor accessor = (AgeableMobAccessor) ageableMob;
if (accessor.biomancy_getForcedAge() != 0) {
accessor.biomancy_setForcedAge(0); //unset forced age
}
removeForcedAge(ageableMob);
}
}

public static void removeForcedAge(AgeableMob mob) {
AgeableMobAccessor accessor = (AgeableMobAccessor) mob;
if (accessor.biomancy_getForcedAge() != 0) {
accessor.biomancy_setForcedAge(0); //unset forced age
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.AgeableMob;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.WitherSkeleton;
Expand Down Expand Up @@ -34,6 +35,10 @@ public void affectEntity(ServerLevel level, CompoundTag tag, @Nullable LivingEnt
else if (target instanceof WitherSkeleton skeleton) {
MobUtil.convertMobTo((ServerLevel) target.level, skeleton, EntityType.SKELETON);
}

if (target instanceof AgeableMob ageableMob) {
MobUtil.removeForcedAge(ageableMob);
}
}

private void resetPehkuiSize(LivingEntity target) {
Expand Down

0 comments on commit 908c7ef

Please sign in to comment.