From 5db6f158f89882fffee4d0b8dde579e6aac5cad2 Mon Sep 17 00:00:00 2001 From: Take Weiland Date: Tue, 30 Jun 2020 00:58:22 +0200 Subject: [PATCH] Fix IItemHandler wrappers for chests not updating both chests (#6875) --- .../tileentity/ChestTileEntity.java.patch | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/patches/minecraft/net/minecraft/tileentity/ChestTileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/ChestTileEntity.java.patch index 44dcdc22f..ffcd94134 100644 --- a/patches/minecraft/net/minecraft/tileentity/ChestTileEntity.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/ChestTileEntity.java.patch @@ -17,7 +17,7 @@ TileEntity tileentity = p_195481_0_.func_175625_s(p_195481_1_); if (tileentity instanceof ChestTileEntity) { return ((ChestTileEntity)tileentity).field_145987_o; -@@ -221,4 +222,56 @@ +@@ -221,4 +222,39 @@ protected Container func_213906_a(int p_213906_1_, PlayerInventory p_213906_2_) { return ChestContainer.func_216992_a(p_213906_1_, p_213906_2_, this); } @@ -46,25 +46,8 @@ + if (!(state.func_177230_c() instanceof ChestBlock)) { + return new net.minecraftforge.items.wrapper.InvWrapper(this); + } -+ ChestType type = state.func_177229_b(ChestBlock.field_196314_b); -+ if (type != ChestType.SINGLE) { -+ BlockPos opos = this.func_174877_v().func_177972_a(ChestBlock.func_196311_i(state)); -+ BlockState ostate = this.func_145831_w().func_180495_p(opos); -+ if (state.func_177230_c() == ostate.func_177230_c()) { -+ ChestType otype = ostate.func_177229_b(ChestBlock.field_196314_b); -+ if (otype != ChestType.SINGLE && type != otype && state.func_177229_b(ChestBlock.field_176459_a) == ostate.func_177229_b(ChestBlock.field_176459_a)) { -+ TileEntity ote = this.func_145831_w().func_175625_s(opos); -+ if (ote instanceof ChestTileEntity) { -+ IInventory top = type == ChestType.RIGHT ? this : (IInventory)ote; -+ IInventory bottom = type == ChestType.RIGHT ? (IInventory)ote : this; -+ return new net.minecraftforge.items.wrapper.CombinedInvWrapper( -+ new net.minecraftforge.items.wrapper.InvWrapper(top), -+ new net.minecraftforge.items.wrapper.InvWrapper(bottom)); -+ } -+ } -+ } -+ } -+ return new net.minecraftforge.items.wrapper.InvWrapper(this); ++ IInventory inv = ChestBlock.func_226916_a_((ChestBlock) state.func_177230_c(), state, func_145831_w(), func_174877_v(), true); ++ return new net.minecraftforge.items.wrapper.InvWrapper(inv == null ? this : inv); + } + + @Override