From f40bdeca97ea6c92babb58d7b0ce996597975b1f Mon Sep 17 00:00:00 2001 From: Ben Blank Date: Sat, 28 Sep 2013 17:56:19 -0700 Subject: [PATCH] allow blocks to choose how they handle indirect power --- .../net/minecraft/block/Block.java.patch | 27 +++++++++-- .../net/minecraft/world/World.java.patch | 48 ++++++++++++++----- 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index dbbc6adbd..c388bd009 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -145,7 +145,28 @@ } /** -@@ -1086,6 +1110,7 @@ +@@ -1036,6 +1060,20 @@ + public int getRenderColor(int par1) + { + return 16777215; ++ } ++ ++ /** ++ * Called to determine whether to allow the a block to handle its own indirect power rather than using the default rules. ++ * @param world The world ++ * @param x The x position of this block instance ++ * @param y The y position of this block instance ++ * @param z The z position of this block instance ++ * @param side The INPUT side of the block to be powered - ie the opposite of this block's output side ++ * @return Whether Block#isProvidingWeakPower should be called when determining indirect power ++ */ ++ public boolean shouldCheckWeakPower(World world, int x, int y, int z, int side) ++ { ++ return !this.isNormalCube(world.getBlockId(x, y, z)); + } + + /** +@@ -1086,6 +1124,7 @@ */ public void setBlockBoundsForItemRender() {} @@ -153,7 +174,7 @@ /** * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the * block and l is the block's subtype/damage. -@@ -1095,28 +1120,37 @@ +@@ -1095,28 +1134,37 @@ par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); par2EntityPlayer.addExhaustion(0.025F); @@ -198,7 +219,7 @@ } /** -@@ -1457,4 +1491,979 @@ +@@ -1457,4 +1505,979 @@ canBlockGrass[0] = true; StatList.initBreakableStats(); } diff --git a/patches/minecraft/net/minecraft/world/World.java.patch b/patches/minecraft/net/minecraft/world/World.java.patch index 26732593b..33ed9901f 100644 --- a/patches/minecraft/net/minecraft/world/World.java.patch +++ b/patches/minecraft/net/minecraft/world/World.java.patch @@ -748,7 +748,31 @@ { block = null; } -@@ -3914,7 +4083,7 @@ +@@ -3744,14 +3913,20 @@ + */ + public int getIndirectPowerLevelTo(int par1, int par2, int par3, int par4) + { +- if (this.isBlockNormalCube(par1, par2, par3)) ++ Block block = Block.blocksList[this.getBlockId(par1, par2, par3)]; ++ ++ if (block == null) ++ { ++ return 0; ++ } ++ ++ if (!block.shouldCheckWeakPower(this, par1, par2, par3, par4)) + { + return this.getBlockPowerInput(par1, par2, par3); + } + else + { +- int i1 = this.getBlockId(par1, par2, par3); +- return i1 == 0 ? 0 : Block.blocksList[i1].isProvidingWeakPower(this, par1, par2, par3, par4); ++ return block.isProvidingWeakPower(this, par1, par2, par3, par4); + } + } + +@@ -3914,7 +4089,7 @@ */ public long getSeed() { @@ -757,7 +781,7 @@ } public long getTotalWorldTime() -@@ -3924,7 +4093,7 @@ +@@ -3924,7 +4099,7 @@ public long getWorldTime() { @@ -766,7 +790,7 @@ } /** -@@ -3932,7 +4101,7 @@ +@@ -3932,7 +4107,7 @@ */ public void setWorldTime(long par1) { @@ -775,7 +799,7 @@ } /** -@@ -3940,13 +4109,13 @@ +@@ -3940,13 +4115,13 @@ */ public ChunkCoordinates getSpawnPoint() { @@ -791,7 +815,7 @@ } @SideOnly(Side.CLIENT) -@@ -3970,7 +4139,10 @@ +@@ -3970,7 +4145,10 @@ if (!this.loadedEntityList.contains(par1Entity)) { @@ -803,7 +827,7 @@ } } -@@ -3978,6 +4150,11 @@ +@@ -3978,6 +4156,11 @@ * Called when checking if a certain block can be mined or not. The 'spawn safe zone' check is located here. */ public boolean canMineBlock(EntityPlayer par1EntityPlayer, int par2, int par3, int par4) @@ -815,7 +839,7 @@ { return true; } -@@ -4098,8 +4275,7 @@ +@@ -4098,8 +4281,7 @@ */ public boolean isBlockHighHumidity(int par1, int par2, int par3) { @@ -825,7 +849,7 @@ } /** -@@ -4174,7 +4350,7 @@ +@@ -4174,7 +4356,7 @@ */ public int getHeight() { @@ -834,7 +858,7 @@ } /** -@@ -4182,7 +4358,7 @@ +@@ -4182,7 +4364,7 @@ */ public int getActualHeight() { @@ -843,7 +867,7 @@ } public IUpdatePlayerListBox getMinecartSoundUpdater(EntityMinecart par1EntityMinecart) -@@ -4225,7 +4401,7 @@ +@@ -4225,7 +4407,7 @@ */ public double getHorizon() { @@ -852,7 +876,7 @@ } /** -@@ -4294,30 +4470,28 @@ +@@ -4294,30 +4476,28 @@ public void func_96440_m(int par1, int par2, int par3, int par4) { @@ -904,7 +928,7 @@ } } } -@@ -4363,4 +4537,115 @@ +@@ -4363,4 +4543,115 @@ return MathHelper.clamp_float(f, 0.0F, flag ? 1.5F : 1.0F); }