Disable TNT using callback injectors
This commit is contained in:
parent
73f76ecc6f
commit
c833b625f2
@ -9,12 +9,15 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import party._2a03.mc.server.Config;
|
||||||
|
|
||||||
@Mixin(TntBlock.class)
|
@Mixin(TntBlock.class)
|
||||||
public class MixinTntBlock extends Block {
|
public abstract class MixinTntBlock extends Block {
|
||||||
@Shadow
|
@Shadow
|
||||||
public static final BooleanProperty UNSTABLE = Properties.UNSTABLE;
|
public static final BooleanProperty UNSTABLE = Properties.UNSTABLE;
|
||||||
|
|
||||||
@ -23,11 +26,9 @@ public class MixinTntBlock extends Block {
|
|||||||
this.setDefaultState(this.getDefaultState().with(UNSTABLE, false));
|
this.setDefaultState(this.getDefaultState().with(UNSTABLE, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Inject(method = "primeTnt", at = @At("HEAD"), cancellable = true)
|
||||||
* @reason Disable TNT block explosions.
|
private static void OnPrimeTnt(CallbackInfo ci) {
|
||||||
* @author flewkey
|
if (Config.getBool("disableTntExplosions") == true)
|
||||||
*/
|
ci.cancel();
|
||||||
@Overwrite
|
|
||||||
private static void primeTnt(World world, BlockPos pos, @Nullable LivingEntity igniter) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,12 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.TntEntity;
|
import net.minecraft.entity.TntEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import party._2a03.mc.server.Config;
|
||||||
|
|
||||||
@Mixin(TntEntity.class)
|
@Mixin(TntEntity.class)
|
||||||
public abstract class MixinTntEntity extends Entity {
|
public abstract class MixinTntEntity extends Entity {
|
||||||
@ -19,11 +22,9 @@ public abstract class MixinTntEntity extends Entity {
|
|||||||
this.inanimate = true;
|
this.inanimate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Inject(method = "explode", at = @At("HEAD"), cancellable = true)
|
||||||
* @reason Disable TNT entity explosions.
|
private void OnTntExplode(CallbackInfo ci) {
|
||||||
* @author flewkey
|
if (Config.getBool("disableTntExplosions") == true)
|
||||||
*/
|
ci.cancel();
|
||||||
@Overwrite
|
|
||||||
private void explode() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,10 @@ public class Config {
|
|||||||
return json.getJSONArray(key);
|
return json.getJSONArray(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getBool(String key) {
|
||||||
|
return json.getBoolean(key);
|
||||||
|
}
|
||||||
|
|
||||||
public static void setData(String key, JSONArray data) {
|
public static void setData(String key, JSONArray data) {
|
||||||
json.put(key, data);
|
json.put(key, data);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user