Hopefully fix the disappearing issue with the chests. Closes #142
This commit is contained in:
parent
ba6bf6831f
commit
d4fc2424b2
|
@ -0,0 +1,184 @@
|
||||||
|
/*
|
||||||
|
* BluSunrize
|
||||||
|
* Copyright (c) 2017
|
||||||
|
*
|
||||||
|
* This code is licensed under "Blu's License of Common Sense"
|
||||||
|
* Details can be found in the license file in the root folder of this project
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cpw.mods.ironchest.common.lib;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import cpw.mods.ironchest.common.tileentity.chest.TileEntityIronChest;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
|
public class ICChestInventoryHandler implements IItemHandlerModifiable
|
||||||
|
{
|
||||||
|
int slots;
|
||||||
|
|
||||||
|
TileEntityIronChest inv;
|
||||||
|
|
||||||
|
int slotOffset;
|
||||||
|
|
||||||
|
boolean[] canInsert;
|
||||||
|
|
||||||
|
boolean[] canExtract;
|
||||||
|
|
||||||
|
public ICChestInventoryHandler(int slots, TileEntityIronChest inventory, int slotOffset, boolean[] canInsert, boolean[] canExtract)
|
||||||
|
{
|
||||||
|
this.slots = slots;
|
||||||
|
this.inv = inventory;
|
||||||
|
this.slotOffset = slotOffset;
|
||||||
|
this.canInsert = canInsert;
|
||||||
|
this.canExtract = canExtract;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICChestInventoryHandler(int slots, TileEntityIronChest inventory)
|
||||||
|
{
|
||||||
|
this(slots, inventory, 0, new boolean[slots], new boolean[slots]);
|
||||||
|
for (int i = 0; i < slots; i++)
|
||||||
|
this.canExtract[i] = this.canInsert[i] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICChestInventoryHandler(int slots, TileEntityIronChest inventory, int slotOffset, boolean canInsert, boolean canExtract)
|
||||||
|
{
|
||||||
|
this(slots, inventory, slotOffset, new boolean[slots], new boolean[slots]);
|
||||||
|
for (int i = 0; i < slots; i++)
|
||||||
|
{
|
||||||
|
this.canInsert[i] = canInsert;
|
||||||
|
this.canExtract[i] = canExtract;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlots()
|
||||||
|
{
|
||||||
|
return slots;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slot)
|
||||||
|
{
|
||||||
|
return this.inv.getItems().get(this.slotOffset + slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
|
||||||
|
{
|
||||||
|
if (!canInsert[slot] || stack.isEmpty())
|
||||||
|
return stack;
|
||||||
|
stack = stack.copy();
|
||||||
|
|
||||||
|
if (!inv.isItemValidForSlot(this.slotOffset + slot, stack))
|
||||||
|
return stack;
|
||||||
|
|
||||||
|
int offsetSlot = this.slotOffset + slot;
|
||||||
|
ItemStack currentStack = inv.getItems().get(offsetSlot);
|
||||||
|
|
||||||
|
if (currentStack.isEmpty())
|
||||||
|
{
|
||||||
|
int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit());
|
||||||
|
if (accepted < stack.getCount())
|
||||||
|
{
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
inv.getItems().set(offsetSlot, stack.splitStack(accepted));
|
||||||
|
inv.markDirty();
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stack.shrink(accepted);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
inv.getItems().set(offsetSlot, stack);
|
||||||
|
inv.markDirty();
|
||||||
|
}
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!ItemHandlerHelper.canItemStacksStack(stack, currentStack))
|
||||||
|
return stack;
|
||||||
|
|
||||||
|
int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - currentStack.getCount();
|
||||||
|
if (accepted < stack.getCount())
|
||||||
|
{
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
ItemStack newStack = stack.splitStack(accepted);
|
||||||
|
newStack.grow(currentStack.getCount());
|
||||||
|
inv.getItems().set(offsetSlot, newStack);
|
||||||
|
inv.markDirty();
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stack.shrink(accepted);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
ItemStack newStack = stack.copy();
|
||||||
|
newStack.grow(currentStack.getCount());
|
||||||
|
inv.getItems().set(offsetSlot, newStack);
|
||||||
|
inv.markDirty();
|
||||||
|
}
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack extractItem(int slot, int amount, boolean simulate)
|
||||||
|
{
|
||||||
|
if (!canExtract[slot] || amount == 0)
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
|
||||||
|
int offsetSlot = this.slotOffset + slot;
|
||||||
|
ItemStack currentStack = inv.getItems().get(offsetSlot);
|
||||||
|
|
||||||
|
if (currentStack.isEmpty())
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
|
||||||
|
int extracted = Math.min(currentStack.getCount(), amount);
|
||||||
|
|
||||||
|
ItemStack copy = currentStack.copy();
|
||||||
|
copy.setCount(extracted);
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
if (extracted < currentStack.getCount())
|
||||||
|
currentStack.shrink(extracted);
|
||||||
|
else
|
||||||
|
currentStack = ItemStack.EMPTY;
|
||||||
|
inv.getItems().set(offsetSlot, currentStack);
|
||||||
|
inv.markDirty();
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlotLimit(int slot)
|
||||||
|
{
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
|
||||||
|
{
|
||||||
|
inv.getItems().set(this.slotOffset + slot, stack);
|
||||||
|
inv.markDirty();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,184 @@
|
||||||
|
/*
|
||||||
|
* BluSunrize
|
||||||
|
* Copyright (c) 2017
|
||||||
|
*
|
||||||
|
* This code is licensed under "Blu's License of Common Sense"
|
||||||
|
* Details can be found in the license file in the root folder of this project
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cpw.mods.ironchest.common.lib;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import cpw.mods.ironchest.common.tileentity.shulker.TileEntityIronShulkerBox;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
|
public class ICShulkerInventoryHandler implements IItemHandlerModifiable
|
||||||
|
{
|
||||||
|
int slots;
|
||||||
|
|
||||||
|
TileEntityIronShulkerBox inv;
|
||||||
|
|
||||||
|
int slotOffset;
|
||||||
|
|
||||||
|
boolean[] canInsert;
|
||||||
|
|
||||||
|
boolean[] canExtract;
|
||||||
|
|
||||||
|
public ICShulkerInventoryHandler(int slots, TileEntityIronShulkerBox inventory, int slotOffset, boolean[] canInsert, boolean[] canExtract)
|
||||||
|
{
|
||||||
|
this.slots = slots;
|
||||||
|
this.inv = inventory;
|
||||||
|
this.slotOffset = slotOffset;
|
||||||
|
this.canInsert = canInsert;
|
||||||
|
this.canExtract = canExtract;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICShulkerInventoryHandler(int slots, TileEntityIronShulkerBox inventory)
|
||||||
|
{
|
||||||
|
this(slots, inventory, 0, new boolean[slots], new boolean[slots]);
|
||||||
|
for (int i = 0; i < slots; i++)
|
||||||
|
this.canExtract[i] = this.canInsert[i] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICShulkerInventoryHandler(int slots, TileEntityIronShulkerBox inventory, int slotOffset, boolean canInsert, boolean canExtract)
|
||||||
|
{
|
||||||
|
this(slots, inventory, slotOffset, new boolean[slots], new boolean[slots]);
|
||||||
|
for (int i = 0; i < slots; i++)
|
||||||
|
{
|
||||||
|
this.canInsert[i] = canInsert;
|
||||||
|
this.canExtract[i] = canExtract;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlots()
|
||||||
|
{
|
||||||
|
return slots;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slot)
|
||||||
|
{
|
||||||
|
return this.inv.getItems().get(this.slotOffset + slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
|
||||||
|
{
|
||||||
|
if (!canInsert[slot] || stack.isEmpty())
|
||||||
|
return stack;
|
||||||
|
stack = stack.copy();
|
||||||
|
|
||||||
|
if (!inv.isItemValidForSlot(this.slotOffset + slot, stack))
|
||||||
|
return stack;
|
||||||
|
|
||||||
|
int offsetSlot = this.slotOffset + slot;
|
||||||
|
ItemStack currentStack = inv.getItems().get(offsetSlot);
|
||||||
|
|
||||||
|
if (currentStack.isEmpty())
|
||||||
|
{
|
||||||
|
int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit());
|
||||||
|
if (accepted < stack.getCount())
|
||||||
|
{
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
inv.getItems().set(offsetSlot, stack.splitStack(accepted));
|
||||||
|
inv.markDirty();
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stack.shrink(accepted);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
inv.getItems().set(offsetSlot, stack);
|
||||||
|
inv.markDirty();
|
||||||
|
}
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!ItemHandlerHelper.canItemStacksStack(stack, currentStack))
|
||||||
|
return stack;
|
||||||
|
|
||||||
|
int accepted = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - currentStack.getCount();
|
||||||
|
if (accepted < stack.getCount())
|
||||||
|
{
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
ItemStack newStack = stack.splitStack(accepted);
|
||||||
|
newStack.grow(currentStack.getCount());
|
||||||
|
inv.getItems().set(offsetSlot, newStack);
|
||||||
|
inv.markDirty();
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stack.shrink(accepted);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
ItemStack newStack = stack.copy();
|
||||||
|
newStack.grow(currentStack.getCount());
|
||||||
|
inv.getItems().set(offsetSlot, newStack);
|
||||||
|
inv.markDirty();
|
||||||
|
}
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack extractItem(int slot, int amount, boolean simulate)
|
||||||
|
{
|
||||||
|
if (!canExtract[slot] || amount == 0)
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
|
||||||
|
int offsetSlot = this.slotOffset + slot;
|
||||||
|
ItemStack currentStack = inv.getItems().get(offsetSlot);
|
||||||
|
|
||||||
|
if (currentStack.isEmpty())
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
|
||||||
|
int extracted = Math.min(currentStack.getCount(), amount);
|
||||||
|
|
||||||
|
ItemStack copy = currentStack.copy();
|
||||||
|
copy.setCount(extracted);
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
if (extracted < currentStack.getCount())
|
||||||
|
currentStack.shrink(extracted);
|
||||||
|
else
|
||||||
|
currentStack = ItemStack.EMPTY;
|
||||||
|
inv.getItems().set(offsetSlot, currentStack);
|
||||||
|
inv.markDirty();
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlotLimit(int slot)
|
||||||
|
{
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
|
||||||
|
{
|
||||||
|
inv.getItems().set(this.slotOffset + slot, stack);
|
||||||
|
inv.markDirty();
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,7 @@ import cpw.mods.ironchest.common.blocks.chest.BlockIronChest;
|
||||||
import cpw.mods.ironchest.common.blocks.chest.IronChestType;
|
import cpw.mods.ironchest.common.blocks.chest.IronChestType;
|
||||||
import cpw.mods.ironchest.common.core.IronChestBlocks;
|
import cpw.mods.ironchest.common.core.IronChestBlocks;
|
||||||
import cpw.mods.ironchest.common.gui.chest.ContainerIronChest;
|
import cpw.mods.ironchest.common.gui.chest.ContainerIronChest;
|
||||||
|
import cpw.mods.ironchest.common.lib.ICChestInventoryHandler;
|
||||||
import cpw.mods.ironchest.common.network.MessageCrystalChestSync;
|
import cpw.mods.ironchest.common.network.MessageCrystalChestSync;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
@ -39,8 +40,11 @@ import net.minecraft.util.datafix.DataFixer;
|
||||||
import net.minecraft.util.datafix.FixTypes;
|
import net.minecraft.util.datafix.FixTypes;
|
||||||
import net.minecraft.util.datafix.walkers.ItemStackDataLists;
|
import net.minecraft.util.datafix.walkers.ItemStackDataLists;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
public class TileEntityIronChest extends TileEntityLockableLoot implements ITickable
|
public class TileEntityIronChest extends TileEntityLockableLoot implements ITickable
|
||||||
{
|
{
|
||||||
|
@ -640,4 +644,23 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
{
|
{
|
||||||
fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityIronChest.class, new String[] { "Items" }));
|
fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityIronChest.class, new String[] { "Items" }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||||
|
{
|
||||||
|
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||||
|
return true;
|
||||||
|
return super.hasCapability(capability, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
IItemHandler insertionHandler = new ICChestInventoryHandler(this.getType().size, this);
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> T getCapability(Capability<T> capability, EnumFacing facing)
|
||||||
|
{
|
||||||
|
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||||
|
return (T) insertionHandler;
|
||||||
|
return super.getCapability(capability, facing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import cpw.mods.ironchest.IronChest;
|
||||||
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
|
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
|
||||||
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
|
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
|
||||||
import cpw.mods.ironchest.common.gui.shulker.ContainerIronShulkerBox;
|
import cpw.mods.ironchest.common.gui.shulker.ContainerIronShulkerBox;
|
||||||
|
import cpw.mods.ironchest.common.lib.ICShulkerInventoryHandler;
|
||||||
import cpw.mods.ironchest.common.network.MessageCrystalShulkerSync;
|
import cpw.mods.ironchest.common.network.MessageCrystalShulkerSync;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockShulkerBox;
|
import net.minecraft.block.BlockShulkerBox;
|
||||||
|
@ -48,9 +49,12 @@ import net.minecraft.util.datafix.DataFixer;
|
||||||
import net.minecraft.util.datafix.FixTypes;
|
import net.minecraft.util.datafix.FixTypes;
|
||||||
import net.minecraft.util.datafix.walkers.ItemStackDataLists;
|
import net.minecraft.util.datafix.walkers.ItemStackDataLists;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements ITickable, ISidedInventory
|
public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements ITickable, ISidedInventory
|
||||||
{
|
{
|
||||||
|
@ -75,12 +79,19 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
|
||||||
private boolean hadStuff;
|
private boolean hadStuff;
|
||||||
|
|
||||||
private boolean hasBeenCleared;
|
private boolean hasBeenCleared;
|
||||||
|
|
||||||
private int openCount;
|
private int openCount;
|
||||||
|
|
||||||
private AnimationStatus animationStatus;
|
private AnimationStatus animationStatus;
|
||||||
|
|
||||||
private float progress;
|
private float progress;
|
||||||
|
|
||||||
private float progressOld;
|
private float progressOld;
|
||||||
|
|
||||||
private EnumDyeColor color;
|
private EnumDyeColor color;
|
||||||
|
|
||||||
private boolean destroyedByCreativePlayer;
|
private boolean destroyedByCreativePlayer;
|
||||||
|
|
||||||
private boolean hasBeenUpgraded;
|
private boolean hasBeenUpgraded;
|
||||||
|
|
||||||
/** The Variant of the Shulker Box (Not Color) */
|
/** The Variant of the Shulker Box (Not Color) */
|
||||||
|
@ -783,7 +794,8 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
|
||||||
return this.isDestroyedByCreativePlayer() && (!this.isEmpty() || this.hasCustomName() || this.lootTable != null);
|
return this.isDestroyedByCreativePlayer() && (!this.isEmpty() || this.hasCustomName() || this.lootTable != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getDrop(IBlockState state, boolean inBreakBlock) {
|
public ItemStack getDrop(IBlockState state, boolean inBreakBlock)
|
||||||
|
{
|
||||||
BlockIronShulkerBox block = (BlockIronShulkerBox) state.getBlock();
|
BlockIronShulkerBox block = (BlockIronShulkerBox) state.getBlock();
|
||||||
if (!isCleared() && (!inBreakBlock || shouldDropInBreakBlock()))
|
if (!isCleared() && (!inBreakBlock || shouldDropInBreakBlock()))
|
||||||
{
|
{
|
||||||
|
@ -831,4 +843,23 @@ public class TileEntityIronShulkerBox extends TileEntityLockableLoot implements
|
||||||
{
|
{
|
||||||
fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityIronShulkerBox.class, new String[] { "Items" }));
|
fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntityIronShulkerBox.class, new String[] { "Items" }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||||
|
{
|
||||||
|
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||||
|
return true;
|
||||||
|
return super.hasCapability(capability, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
IItemHandler insertionHandler = new ICShulkerInventoryHandler(this.getType().size, this);
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> T getCapability(Capability<T> capability, EnumFacing facing)
|
||||||
|
{
|
||||||
|
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||||
|
return (T) insertionHandler;
|
||||||
|
return super.getCapability(capability, facing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue