shits broke

This commit is contained in:
Mohammad-Ali Minaie
2017-04-10 01:11:09 -04:00
parent 79bcbcb16f
commit 6cca149ebb
2 changed files with 72 additions and 7 deletions

View File

@@ -122,10 +122,10 @@ public class Breaker extends CustomContainerFacing implements ITileEntityProvide
} }
if(pItem.getItem() instanceof WorkMallet){ if(pItem.getItem() instanceof WorkMallet){
System.out.println(pItem);
tile.setSlotStack(0, pItem); tile.setSlotStack(0, pItem);
pItem.shrink(1); pItem.shrink(1);
tile.updateBlock(); System.out.println(tile.getSlotStack(0) + " " + tile.getSlotListSize());
System.out.println(tile.getSlotStack(0));
return true; return true;
} }

View File

@@ -5,10 +5,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import java.util.List;
/** /**
* Created by mminaie on 4/9/17. * Created by mminaie on 4/9/17.
*/ */
public class TileBreaker extends TileBaseSlot { public class TileBreaker extends BaseTile {
private float charge; private float charge;
@@ -22,6 +24,68 @@ public class TileBreaker extends TileBaseSlot {
public NonNullList<ItemStack> slotList = NonNullList.<ItemStack>withSize(2, ItemStack.EMPTY); public NonNullList<ItemStack> slotList = NonNullList.<ItemStack>withSize(2, ItemStack.EMPTY);
// ***************************************************************************** //
// Controls
// ***************************************************************************** //
// ***************************************************************************** //
// get
//
public NonNullList<ItemStack> getSlotList()
{
return this.slotList;
}
public ItemStack getSlotStack(int i)
{
return this.slotList.get(i);
}
public int getSlotListSize()
{
return slotList.size();
}
public int getSlotLimit()
{
//return ((ShelfBasic)this.getBlockType()).getShelfSize();
//return 1;
return 64;
}
public ItemStack decrStackSize(int index, int count)
{
return ItemStackHelper.getAndSplit(this.getSlotList(), index, count);
}
public ItemStack incrementStackSize(List<ItemStack> stacks, int index, int count) {
Integer tempCount = ((ItemStack)stacks.get(index)).getCount();
ItemStack tempStack = ((ItemStack)stacks.get(index));
if(tempCount + count > 64) {
tempStack.setCount(64);
}
if(tempCount + count <= 64) {
tempStack.setCount(tempCount + count);
}
return tempStack;
}
// ***************************************************************************** //
// set
//
public void setSlotStack(int index, ItemStack stack)
{
this.slotList.set(index, stack);
this.markDirty();
this.updateBlock();
}
public void clearSlots()
{
this.slotList.clear();
}
// ***************************************************************************** // // ***************************************************************************** //
// NBT // NBT
@@ -30,17 +94,18 @@ public class TileBreaker extends TileBaseSlot {
public NBTTagCompound readNBT(NBTTagCompound nbt) public NBTTagCompound readNBT(NBTTagCompound nbt)
{ {
super.readNBT(nbt); super.readNBT(nbt);
this.charge = nbt.getFloat("charge"); this.slotList = NonNullList.<ItemStack>withSize(this.getSlotListSize(), ItemStack.EMPTY);
ItemStackHelper.loadAllItems(nbt, this.slotList);
return nbt; return nbt;
} }
@Override @Override
public NBTTagCompound writeNBT(NBTTagCompound nbt) public NBTTagCompound writeNBT(NBTTagCompound nbt)
{ {
nbt.setFloat("charge", this.charge);
super.writeNBT(nbt); super.writeNBT(nbt);
ItemStackHelper.saveAllItems(nbt, this.slotList);
return nbt; return nbt;
} }
} }