From 9010f1d7e7539e192e4be46e22cff9b07132b914 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Wed, 21 Dec 2016 11:14:36 -0800 Subject: [PATCH] Add hook to allow any block to respond to filtered block updates like the Observer block (#3547) --- .../net/minecraft/block/Block.java.patch | 15 +++++++++++++-- .../net/minecraft/block/BlockObserver.java.patch | 15 +++++++++++++++ .../net/minecraft/world/World.java.patch | 14 ++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 patches/minecraft/net/minecraft/block/BlockObserver.java.patch diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index 7c4bbadd10..c485d39d48 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -197,7 +197,7 @@ public SoundType func_185467_w() { return this.field_149762_H; -@@ -908,6 +932,1166 @@ +@@ -908,6 +932,1177 @@ { } @@ -1130,6 +1130,17 @@ + public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor){} + + /** ++ * Called on an Observer block whenever an update for an Observer is received. ++ * ++ * @param observerState The Observer block's state. ++ * @param world The current world. ++ * @param observerPos The Observer block's position. ++ * @param changedBlock The updated block. ++ * @param changedBlockPos The updated block's position. ++ */ ++ public void observedNeighborChange(IBlockState observerState, World world, BlockPos observerPos, Block changedBlock, BlockPos changedBlockPos){} ++ ++ /** + * 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 pos Block position in world @@ -1364,7 +1375,7 @@ public static void func_149671_p() { func_176215_a(0, field_176230_a, (new BlockAir()).func_149663_c("air")); -@@ -1201,14 +2385,7 @@ +@@ -1201,14 +2396,7 @@ } else { diff --git a/patches/minecraft/net/minecraft/block/BlockObserver.java.patch b/patches/minecraft/net/minecraft/block/BlockObserver.java.patch new file mode 100644 index 0000000000..ba62fd8ad1 --- /dev/null +++ b/patches/minecraft/net/minecraft/block/BlockObserver.java.patch @@ -0,0 +1,15 @@ +--- ../src-base/minecraft/net/minecraft/block/BlockObserver.java ++++ ../src-work/minecraft/net/minecraft/block/BlockObserver.java +@@ -145,4 +145,12 @@ + { + return this.func_176223_P().func_177226_a(field_176387_N, EnumFacing.func_82600_a(p_176203_1_ & 7)); + } ++ ++ /* ======================================== FORGE START =====================================*/ ++ @Override ++ public void observedNeighborChange(IBlockState observerState, World world, BlockPos observerPos, Block changedBlock, BlockPos changedBlockPos) ++ { ++ func_190962_b(observerState, world, observerPos, changedBlock, changedBlockPos); ++ } ++ /* ========================================= FORGE END ======================================*/ + } diff --git a/patches/minecraft/net/minecraft/world/World.java.patch b/patches/minecraft/net/minecraft/world/World.java.patch index 553beaa1a9..0d877dc524 100644 --- a/patches/minecraft/net/minecraft/world/World.java.patch +++ b/patches/minecraft/net/minecraft/world/World.java.patch @@ -153,6 +153,20 @@ if (p_175695_3_ != EnumFacing.WEST) { this.func_190524_a(p_175695_1_.func_177976_e(), p_175695_2_, p_175695_1_); +@@ -521,11 +572,11 @@ + { + IBlockState iblockstate = this.func_180495_p(p_190529_1_); + +- if (iblockstate.func_177230_c() == Blocks.field_190976_dk) ++ if (true) + { + try + { +- ((BlockObserver)iblockstate.func_177230_c()).func_190962_b(iblockstate, this, p_190529_1_, p_190529_2_, p_190529_3_); ++ iblockstate.func_177230_c().observedNeighborChange(iblockstate, this, p_190529_1_, p_190529_2_, p_190529_3_); + } + catch (Throwable throwable) + { @@ -582,7 +633,7 @@ { IBlockState iblockstate = this.func_180495_p(blockpos);