From 3d48b69d4fec57b67e0f6dfa2b1f158143da509b Mon Sep 17 00:00:00 2001 From: LexManos Date: Fri, 22 Jun 2012 17:44:04 -0700 Subject: [PATCH] Added configuration option to disable the darkroom mechanic. For servers who wish to not risk destruction at one broken pipe. --- .../src/net/minecraft/src/mod_MinecraftForge.java | 3 +++ .../net/minecraft/src/forge/ForgeHooks.java | 7 ++++++- .../src/net/minecraft/src/mod_MinecraftForge.java | 3 +++ .../minecraft/net/minecraft/src/ItemDye.java.patch | 10 ++++++++-- .../net/minecraft/src/ItemDye.java.patch | 8 +++++++- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/forge/forge_client/src/net/minecraft/src/mod_MinecraftForge.java b/forge/forge_client/src/net/minecraft/src/mod_MinecraftForge.java index ad373559e..4a6c55e33 100644 --- a/forge/forge_client/src/net/minecraft/src/mod_MinecraftForge.java +++ b/forge/forge_client/src/net/minecraft/src/mod_MinecraftForge.java @@ -10,6 +10,9 @@ import net.minecraft.src.forge.NetworkMod; */ public class mod_MinecraftForge extends NetworkMod { + @MLProp(info = "Set to true to disable darkrooms, it adds a extra check when planting the grass and plants to check that they won't instantly die.") + public static boolean DISABLE_DARK_ROOMS = false; + @MLProp(info = "Set to false to reproduce a vinella bug that prevents mobs from spawning on inverted half-slabs and inverted stairs.") public static boolean SPAWNER_ALLOW_ON_INVERTED = true; diff --git a/forge/forge_common/net/minecraft/src/forge/ForgeHooks.java b/forge/forge_common/net/minecraft/src/forge/ForgeHooks.java index 06b76645d..9261739f8 100644 --- a/forge/forge_common/net/minecraft/src/forge/ForgeHooks.java +++ b/forge/forge_common/net/minecraft/src/forge/ForgeHooks.java @@ -27,6 +27,7 @@ import net.minecraft.src.Packet131MapData; import net.minecraft.src.Packet1Login; import net.minecraft.src.Packet250CustomPayload; import net.minecraft.src.World; +import net.minecraft.src.mod_MinecraftForge; import net.minecraft.src.forge.packets.PacketEntitySpawn; import net.minecraft.src.forge.packets.PacketHandlerBase; @@ -510,7 +511,11 @@ public class ForgeHooks { int index = world.rand.nextInt(plantGrassWeight); ProbableItem item = getRandomItem(plantGrassList, index); - if (item == null) + if (item == null || Block.blocksList[item.ItemID] == null) + { + return; + } + if (mod_MinecraftForge.DISABLE_DARK_ROOMS && !Block.blocksList[item.ItemID].canBlockStay(world, x, y, z)) { return; } diff --git a/forge/forge_server/src/net/minecraft/src/mod_MinecraftForge.java b/forge/forge_server/src/net/minecraft/src/mod_MinecraftForge.java index 7e56bba12..0caa2fd45 100644 --- a/forge/forge_server/src/net/minecraft/src/mod_MinecraftForge.java +++ b/forge/forge_server/src/net/minecraft/src/mod_MinecraftForge.java @@ -11,6 +11,9 @@ import net.minecraft.src.forge.NetworkMod; */ public class mod_MinecraftForge extends NetworkMod { + @MLProp(info = "Set to true to disable darkrooms, it adds a extra check when planting the grass and plants to check that they won't instantly die.") + public static boolean DISABLE_DARK_ROOMS = false; + @MLProp(info = "Set to false to reproduce a vinella bug that prevents mobs from spawning on inverted half-slabs and inverted stairs.") public static boolean SPAWNER_ALLOW_ON_INVERTED = true; diff --git a/forge/patches/minecraft/net/minecraft/src/ItemDye.java.patch b/forge/patches/minecraft/net/minecraft/src/ItemDye.java.patch index d1712dc52..498521a5f 100644 --- a/forge/patches/minecraft/net/minecraft/src/ItemDye.java.patch +++ b/forge/patches/minecraft/net/minecraft/src/ItemDye.java.patch @@ -26,8 +26,14 @@ if (var8 == Block.sapling.blockID) { -@@ -118,13 +131,9 @@ +@@ -116,15 +129,15 @@ + { + if (itemRand.nextInt(10) != 0) { ++ if (mod_MinecraftForge.DISABLE_DARK_ROOMS && !Block.tallGrass.canBlockStay(par3World, var10, var11, var12)) ++ { ++ continue; ++ } par3World.setBlockAndMetadataWithNotify(var10, var11, var12, Block.tallGrass.blockID, 1); } - else if (itemRand.nextInt(3) != 0) @@ -41,7 +47,7 @@ } } } -@@ -155,4 +164,20 @@ +@@ -155,4 +168,20 @@ } } } diff --git a/forge/patches/minecraft_server/net/minecraft/src/ItemDye.java.patch b/forge/patches/minecraft_server/net/minecraft/src/ItemDye.java.patch index b97550415..93969d736 100644 --- a/forge/patches/minecraft_server/net/minecraft/src/ItemDye.java.patch +++ b/forge/patches/minecraft_server/net/minecraft/src/ItemDye.java.patch @@ -33,8 +33,14 @@ if (var8 == Block.sapling.blockID) { if (!par3World.isRemote) -@@ -109,13 +118,9 @@ +@@ -107,15 +116,15 @@ + { + if (itemRand.nextInt(10) != 0) { ++ if (mod_MinecraftForge.DISABLE_DARK_ROOMS && !Block.tallGrass.canBlockStay(par3World, var10, var11, var12)) ++ { ++ continue; ++ } par3World.setBlockAndMetadataWithNotify(var10, var11, var12, Block.tallGrass.blockID, 1); } - else if (itemRand.nextInt(3) != 0)