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

30 lines
1.3 KiB
Java

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/World$ExplosionSourceType;)Lnet/minecraft/world/explosion/Explosion;"))
private Explosion OnCreeperExplode(World self, Entity entity,
double x, double y, double z, float r,
World.ExplosionSourceType explosionSourceType) {
if (Config.getBool("disableCreeperExplosions"))
explosionSourceType = World.ExplosionSourceType.NONE;
return self.createExplosion(entity, x, y, z, r, explosionSourceType);
}
}