1
0
minecraft-tweaks-2a03/src/main/java/party/_2a03/mc/mixin/MixinCreeperEntity.java

30 lines
1.3 KiB
Java
Raw Normal View History

2022-02-08 13:43:58 -05:00
package party._2a03.mc.mixin;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.mob.CreeperEntity;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.Mixin;
import party._2a03.mc.util.Config;
@Mixin(CreeperEntity.class)
public abstract class MixinCreeperEntity extends HostileEntity {
public MixinCreeperEntity(EntityType<? extends CreeperEntity> entityType, World world) {
super((EntityType<? extends HostileEntity>)entityType, world);
}
@Redirect(method = "explode()V", at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/World;createExplosion(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/world/explosion/Explosion$DestructionType;)Lnet/minecraft/world/explosion/Explosion;"))
private Explosion OnCreeperExplode(World self, Entity entity,
double x, double y, double z, float r,
Explosion.DestructionType destructionType) {
if (Config.getBool("disableCreeperExplosions"))
destructionType = Explosion.DestructionType.NONE;
return self.createExplosion(entity, x, y, z, r, destructionType);
}
}