disable fireballs from ghasts aswell

This commit is contained in:
Jill 2021-12-09 19:20:14 +03:00
parent b5f0ce1981
commit 821f1ac044
2 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,17 @@
package zone.oat.disableharmfulmobgriefs.mixin;
import net.minecraft.entity.projectile.FireballEntity;
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(FireballEntity.class)
public class DisableFireball {
// 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 = "onCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/GameRules;getBoolean(Lnet/minecraft/world/GameRules$Key;)Z"))
private boolean injected(GameRules instance, GameRules.Key<GameRules.BooleanRule> rule) {
return false;
}
}

View File

@ -4,7 +4,8 @@
"package": "zone.oat.disableharmfulmobgriefs.mixin",
"compatibilityLevel": "JAVA_16",
"mixins": [
"DisableCreeperExplosion"
"DisableCreeperExplosion",
"DisableFireball"
],
"injectors": {
"defaultRequire": 1