mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Fix SidedInvWrapper accessing wrong slots for setStackInSlot. (#2797)
Fix DoubleChestItemHandler not implementing IItemHandlerModifiable
This commit is contained in:
1 parent
9c9107c434
commit
8fdd76bae1
2 files changed
+21
-2
No files matched your search
@@ -12,7 +12,7 @@ import java.lang.ref.WeakReference;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest> implements IItemHandler
|
||||
public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest> implements IItemHandlerModifiable
|
||||
{
|
||||
// Dummy cache value to signify that we have checked and definitely found no adjacent chests
|
||||
public static final VanillaDoubleChestItemHandler NO_ADJACENT_CHESTS_INSTANCE = new VanillaDoubleChestItemHandler(null, null, false);
|
||||
@@ -91,6 +91,22 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
|
||||
return chest != null ? chest.getStackInSlot(targetSlot) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStackInSlot(int slot, ItemStack stack)
|
||||
{
|
||||
boolean accessingUpperChest = slot < 27;
|
||||
int targetSlot = accessingUpperChest ? slot : slot - 27;
|
||||
TileEntityChest chest = getChest(accessingUpperChest);
|
||||
if (chest != null)
|
||||
{
|
||||
IItemHandler singleHandler = chest.getSingleChestHandler();
|
||||
if (singleHandler instanceof IItemHandlerModifiable)
|
||||
{
|
||||
((IItemHandlerModifiable) singleHandler).setStackInSlot(targetSlot, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
|
||||
{
|
||||
|
||||
@@ -144,7 +144,10 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
@Override
|
||||
public void setStackInSlot(int slot, ItemStack stack)
|
||||
{
|
||||
inv.setInventorySlotContents(slot, stack);
|
||||
int slot1 = getSlot(inv, slot, side);
|
||||
|
||||
if (slot1 != -1)
|
||||
inv.setInventorySlotContents(slot1, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user