diff --git a/1.11/src/main/java/nmd/primal/forgecraft/blocks/Breaker.java b/1.11/src/main/java/nmd/primal/forgecraft/blocks/Breaker.java index 5e444719..1879782a 100644 --- a/1.11/src/main/java/nmd/primal/forgecraft/blocks/Breaker.java +++ b/1.11/src/main/java/nmd/primal/forgecraft/blocks/Breaker.java @@ -43,7 +43,7 @@ import java.util.concurrent.ThreadLocalRandom; /** * Created by mminaie on 4/9/17. */ -public class Breaker extends CustomContainerFacing implements ITileEntityProvider { +public class Breaker extends CustomContainerFacing { public static final PropertyBool ACTIVE = PropertyBool.create("active"); @@ -60,6 +60,7 @@ public class Breaker extends CustomContainerFacing implements ITileEntityProvide public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitx, float hity, float hitz) { if(!world.isRemote){ + System.out.println("tile: " + pos); TileBreaker tile = (TileBreaker) world.getTileEntity(pos); ItemStack pItem = player.inventory.getCurrentItem(); if(state.getValue(ACTIVE) == true && player.isSneaking() && pItem.isEmpty()){ @@ -125,7 +126,7 @@ public class Breaker extends CustomContainerFacing implements ITileEntityProvide System.out.println(pItem); tile.setSlotStack(0, pItem); pItem.shrink(1); - System.out.println(tile.getSlotStack(0) + " " + tile.getSlotListSize()); + return true; } diff --git a/1.11/src/main/java/nmd/primal/forgecraft/tiles/TileBreaker.java b/1.11/src/main/java/nmd/primal/forgecraft/tiles/TileBreaker.java index 8b15db53..0669e3c1 100644 --- a/1.11/src/main/java/nmd/primal/forgecraft/tiles/TileBreaker.java +++ b/1.11/src/main/java/nmd/primal/forgecraft/tiles/TileBreaker.java @@ -1,16 +1,19 @@ package nmd.primal.forgecraft.tiles; +import net.minecraft.block.state.IBlockState; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ITickable; import net.minecraft.util.NonNullList; +import net.minecraft.world.World; import java.util.List; /** * Created by mminaie on 4/9/17. */ -public class TileBreaker extends BaseTile { +public class TileBreaker extends TileBaseSlot implements ITickable { private float charge; @@ -22,71 +25,19 @@ public class TileBreaker extends BaseTile { this.charge = charge; } - public NonNullList slotList = NonNullList.withSize(2, ItemStack.EMPTY); + //public NonNullList slotList = NonNullList.withSize(2, ItemStack.EMPTY); - // ***************************************************************************** // - // Controls - // ***************************************************************************** // - - // ***************************************************************************** // - // get - // - public NonNullList 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 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); + @Override + public void update () { + World world = this.getWorld(); + if (!world.isRemote) { + IBlockState state = world.getBlockState(this.pos); + for(int i =0; i < this.getSlotListSize(); i++) { + System.out.println(this.getSlotStack(i)); + } } - 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 // ***************************************************************************** // @@ -94,18 +45,16 @@ public class TileBreaker extends BaseTile { public NBTTagCompound readNBT(NBTTagCompound nbt) { super.readNBT(nbt); - this.slotList = NonNullList.withSize(this.getSlotListSize(), ItemStack.EMPTY); - ItemStackHelper.loadAllItems(nbt, this.slotList); - + this.charge = nbt.getFloat("charge"); return nbt; } @Override public NBTTagCompound writeNBT(NBTTagCompound nbt) { + nbt.setFloat("charge", this.charge); super.writeNBT(nbt); - ItemStackHelper.saveAllItems(nbt, this.slotList); - return nbt; } + }