[Forge - 1.19.2]: Random chance for zombies to not drop loot or experience
SiverDX opened this issue · 3 comments
It's due to this return here
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
just saw that there is already an issue about this #30
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);
}
}
}
}