forked from BRNSystems/tweaks
feat: make creeper fuse time a gamerule
This commit is contained in:
@@ -18,6 +18,9 @@ public class Tweaks implements ModInitializer {
|
||||
public static final GameRules.Key<GameRules.IntRule> CRITICAL_MULTIPLIER =
|
||||
GameRuleRegistry.register("criticalHitMultiplier", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(150, 0, Integer.MAX_VALUE));
|
||||
|
||||
public static final GameRules.Key<GameRules.IntRule> CREEPER_FUSE_TIME =
|
||||
GameRuleRegistry.register("creeperDefaultFuseTime", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(30, 0, Integer.MAX_VALUE));
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package systems.brn.tweaks.mixin;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.mob.CreeperEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import systems.brn.tweaks.Tweaks;
|
||||
import systems.brn.tweaks.mixin.accessors.CreeperEntityAccessor;
|
||||
|
||||
@Mixin(CreeperEntity.class)
|
||||
public abstract class CreeperEntityMixin {
|
||||
@Inject(
|
||||
method = "<init>",
|
||||
at = @At("TAIL")
|
||||
)
|
||||
private void onConstructor(EntityType<? extends CreeperEntity> entityType, World world, CallbackInfo ci) {
|
||||
CreeperEntity creeper = (CreeperEntity)(Object)this;
|
||||
if (!world.isClient) {
|
||||
ServerWorld serverWorld = (ServerWorld) world;
|
||||
GameRules.IntRule rule = serverWorld.getGameRules().get(Tweaks.CREEPER_FUSE_TIME);
|
||||
((CreeperEntityAccessor) creeper).setFuseTime(rule.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package systems.brn.tweaks.mixin.accessors;
|
||||
|
||||
import net.minecraft.entity.mob.CreeperEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(CreeperEntity.class)
|
||||
public interface CreeperEntityAccessor {
|
||||
@Accessor("fuseTime")
|
||||
void setFuseTime(int fuseTime);
|
||||
|
||||
@Accessor("fuseTime")
|
||||
int getFuseTime();
|
||||
}
|
||||
@@ -4,9 +4,11 @@
|
||||
"package": "systems.brn.tweaks.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"CreeperEntityMixin",
|
||||
"DontHurtMePearlMixin",
|
||||
"JustTeleportAlreadyMixin",
|
||||
"PlayerEntityMixin"
|
||||
"PlayerEntityMixin",
|
||||
"accessors.CreeperEntityAccessor"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
Reference in New Issue
Block a user