|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: MidnightTale < [email protected]> |
| 3 | +Date: Fri, 25 Jul 2025 11:33:18 +0700 |
| 4 | +Subject: [PATCH] Grief prevention |
| 5 | + |
| 6 | + |
| 7 | +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java |
| 8 | +index 87377bba2ebdc0eba5b7b212d971994c35ca0b62..d356938e3f71cb394e0b5a5b49fb3cca00dab512 100644 |
| 9 | +--- a/net/minecraft/server/level/ServerLevel.java |
| 10 | ++++ b/net/minecraft/server/level/ServerLevel.java |
| 11 | +@@ -2031,6 +2031,27 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe |
| 12 | + @Nullable java.util.function.Consumer<ServerExplosion> configurator |
| 13 | + ) { |
| 14 | + // CraftBukkit end |
| 15 | ++ // atDeprecated start - Grief Prevention |
| 16 | ++ if (source instanceof net.minecraft.world.entity.item.PrimedTnt && fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventTntGrief) { |
| 17 | ++ explosionInteraction = Level.ExplosionInteraction.NONE; |
| 18 | ++ } else if (source instanceof net.minecraft.world.entity.monster.Creeper && fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventCreeperGrief) { |
| 19 | ++ explosionInteraction = Level.ExplosionInteraction.NONE; |
| 20 | ++ } else if (source instanceof net.minecraft.world.entity.vehicle.MinecartTNT && fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventTntMinecartGrief) { |
| 21 | ++ explosionInteraction = Level.ExplosionInteraction.NONE; |
| 22 | ++ } else if (source instanceof net.minecraft.world.entity.boss.enderdragon.EndCrystal && fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventEndCrystalGrief) { |
| 23 | ++ explosionInteraction = Level.ExplosionInteraction.NONE; |
| 24 | ++ } else if (source instanceof net.minecraft.world.entity.projectile.WitherSkull && fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventWitherSkullExplode) { |
| 25 | ++ explosionInteraction = Level.ExplosionInteraction.NONE; |
| 26 | ++ } else if (source instanceof net.minecraft.world.entity.projectile.AbstractHurtingProjectile && fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventFireballGrief) { |
| 27 | ++ explosionInteraction = Level.ExplosionInteraction.NONE; |
| 28 | ++ } else if (source instanceof net.minecraft.world.entity.boss.wither.WitherBoss && fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventWitherBossExplode) { |
| 29 | ++ explosionInteraction = Level.ExplosionInteraction.NONE; |
| 30 | ++ } else if (damageSource != null && damageSource.is(net.minecraft.world.damagesource.DamageTypes.BAD_RESPAWN_POINT)) { |
| 31 | ++ if (fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventBedGrief || fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventRespawnAnchorGrief) { |
| 32 | ++ explosionInteraction = Level.ExplosionInteraction.NONE; |
| 33 | ++ } |
| 34 | ++ } |
| 35 | ++ // atDeprecated end - Grief Prevention |
| 36 | + Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { |
| 37 | + case NONE -> Explosion.BlockInteraction.KEEP; |
| 38 | + case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); |
| 39 | +diff --git a/net/minecraft/world/entity/boss/wither/WitherBoss.java b/net/minecraft/world/entity/boss/wither/WitherBoss.java |
| 40 | +index 787b74c5aa02afc4ba95fa1cdaf6cc21b6554b56..dffb05123e648f70683df2308d3e9493f8a08c02 100644 |
| 41 | +--- a/net/minecraft/world/entity/boss/wither/WitherBoss.java |
| 42 | ++++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java |
| 43 | +@@ -348,7 +348,7 @@ public class WitherBoss extends Monster implements RangedAttackMob { |
| 44 | + |
| 45 | + if (this.destroyBlocksTick > 0) { |
| 46 | + this.destroyBlocksTick--; |
| 47 | +- if (this.destroyBlocksTick == 0 && level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { |
| 48 | ++ if (this.destroyBlocksTick == 0 && level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventWitherBossDestroyBlock) { |
| 49 | + boolean flag = false; |
| 50 | + int alternativeTarget = Mth.floor(this.getBbWidth() / 2.0F + 1.0F); |
| 51 | + int floor = Mth.floor(this.getBbHeight()); |
| 52 | +diff --git a/net/minecraft/world/entity/monster/EnderMan.java b/net/minecraft/world/entity/monster/EnderMan.java |
| 53 | +index c0e38131da55d8a85444ef4248224d37a7271089..e0155727e50060d4ee8f88913fe20fb265e9b66d 100644 |
| 54 | +--- a/net/minecraft/world/entity/monster/EnderMan.java |
| 55 | ++++ b/net/minecraft/world/entity/monster/EnderMan.java |
| 56 | +@@ -631,6 +631,9 @@ public class EnderMan extends Monster implements NeutralMob { |
| 57 | + |
| 58 | + @Override |
| 59 | + public boolean canUse() { |
| 60 | ++ if (fun.mntale.atdeprecated.config.AtCoreConfig.GRIEF_PREVENTION_CONFIG.preventEndermanGrief) { |
| 61 | ++ return false; |
| 62 | ++ } |
| 63 | + return this.enderman.getCarriedBlock() == null |
| 64 | + && getServerLevel(this.enderman).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) |
| 65 | + && this.enderman.getRandom().nextInt(reducedTickDelay(20)) == 0; |
0 commit comments