package zone.oat.disableharmfulmobgriefs.mixin; import net.minecraft.entity.mob.CreeperEntity; import net.minecraft.world.GameRules; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(CreeperEntity.class) public class DisableCreeperExplosion { // the explode function references `.getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)` // we simply redirect it to a "false", making it always believe the gamerule is off - meaning it *doesn't* to mob griefing @Redirect(method = "explode()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/GameRules;getBoolean(Lnet/minecraft/world/GameRules$Key;)Z")) private boolean injected(GameRules instance, GameRules.Key rule) { return false; } }