Rotten Creatures

Rotten Creatures

1M Downloads

[Forge - 1.19.2]: Random chance for zombies to not drop loot or experience

SiverDX opened this issue · 3 comments

commented

It's due to this return here

if (this.level.getDifficulty() != Difficulty.HARD && this.level.random.nextBoolean()) return;

why are you even doing this
it's skipping the entire logic in livingentity, including the forge livingdeathevent

(since the entity stays at 0 health it will just be removed in the next tick)

also dont use the level random, use the entity random if you can to avoid concurrency problems

commented

just saw that there is already an issue about this #30

commented

reference what im doing now

@Mixin(LivingEntity.class)
public abstract class MixinLivingEntity {
    @Inject(method = "die", at = @At("HEAD"))
    private void convert(final DamageSource damageSource, final CallbackInfo callback) {
        if ((LivingEntity) (Object) this instanceof Zombie zombie) {
            int difficultyLevel = zombie.level.getDifficulty().getId();

            // Only convert base zombies | Don't convert below NORMAL difficulty | Convert chance of 50% for NORMAL difficulty
            if (zombie.getType() != EntityType.ZOMBIE || difficultyLevel < Difficulty.NORMAL.getId() || (difficultyLevel == Difficulty.NORMAL.getId() && zombie.getRandom().nextBoolean())) {
                return;
            }

            if (zombie.isInLava()) {
                zombie.convertTo(RCEntityTypes.BURNED.get(), true);
            } else if (zombie.isInPowderSnow || zombie.wasInPowderSnow) {
                zombie.convertTo(RCEntityTypes.FROSTBITTEN.get(), true);
            }

            if (!zombie.isSilent()) {
                zombie.level.levelEvent(LevelEvent.SOUND_ZOMBIE_INFECTED, zombie.blockPosition(), 0);
            }
        }
    }
}
commented

oh yeah, that has been fixed in the new version that's in dev, it was a silly mistake 🤔