Disable creeper explosions
This commit is contained in:
parent
d7c1f5297a
commit
ff5774f3cb
29
src/main/java/party/_2a03/mc/mixin/MixinCreeperEntity.java
Normal file
29
src/main/java/party/_2a03/mc/mixin/MixinCreeperEntity.java
Normal file
@ -0,0 +1,29 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -35,9 +35,10 @@ public class Config {
|
||||
json = new JSONObject();
|
||||
}
|
||||
|
||||
setDefault("persistentFlight", true);
|
||||
setDefault("persistentFlight", false);
|
||||
setDefault("disableFlyCommand", true);
|
||||
setDefault("disableTntExplosions", false);
|
||||
setDefault("disableCreeperExplosions", false);
|
||||
setDefault("disableRespawnAnchorExplosions", false);
|
||||
setDefault("iphubApiKey", "");
|
||||
setDefault("spawn", (new PlayerPosition()).getJSON());
|
||||
|
@ -3,6 +3,7 @@
|
||||
"package": "party._2a03.mc.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"server": [
|
||||
"MixinCreeperEntity",
|
||||
"MixinGameModeCommand",
|
||||
"MixinPlayerManager",
|
||||
"MixinRespawnAnchorBlock",
|
||||
|
Loading…
Reference in New Issue
Block a user