mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 23:03:01 +00:00
Some work on bins, fix tank bug
This commit is contained in:
1 parent
4b5c8498a3
commit
9c53f1be66
3 files changed
+113
-6
No files matched your search
@@ -184,6 +184,7 @@ public class BlockBasic extends Block
|
||||
entityplayer.openGui(Mekanism.instance, 18, world, x, y, z);
|
||||
}
|
||||
else {
|
||||
entityplayer.inventory.onInventoryChanged();
|
||||
tileEntity.sendPacketToRenderer();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,19 +2,29 @@ package mekanism.common.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class TileEntityBin extends TileEntityContainerBlock
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory
|
||||
{
|
||||
public int itemCount;
|
||||
public ItemStack itemType;
|
||||
|
||||
public TileEntityBin()
|
||||
public ItemStack getStack()
|
||||
{
|
||||
super("Bin");
|
||||
if(itemCount > 0)
|
||||
{
|
||||
ItemStack ret = itemType.copy();
|
||||
ret.stackSize = Math.min(64, itemCount);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,4 +87,100 @@ public class TileEntityBin extends TileEntityContainerBlock
|
||||
itemType = new ItemStack(dataStream.readInt(), 0, dataStream.readInt());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotID)
|
||||
{
|
||||
if(slotID == 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return getStack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotID, int amount)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotID)
|
||||
{
|
||||
return getStackInSlot(slotID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest() {}
|
||||
|
||||
@Override
|
||||
public void closeChest() {}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return itemType == null || itemType.isItemEqual(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
if(side == 1)
|
||||
{
|
||||
return new int[] {1};
|
||||
}
|
||||
else {
|
||||
return new int[] {0};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return isItemValidForSlot(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public abstract class TileEntityContainerBlock extends TileEntityBasicBlock implements ISidedInventory, IInventory, ISustainedInventory
|
||||
public abstract class TileEntityContainerBlock extends TileEntityBasicBlock implements ISidedInventory, ISustainedInventory
|
||||
{
|
||||
/** The inventory slot itemstacks used by this block. */
|
||||
public ItemStack[] inventory;
|
||||
|
||||
Reference in new issue
Block a user