I'm trying to create a block with TileEntity and the tutorial I'm following to set up the basics for the inventory slots has brought me grinding to a halt.
It seems to not recognise the method getStackInSlotOnClosing anymore for ItemStack and I was just wondering if anyone knew of the new method required or if there's a better way of doing things now we're on 1.8.9?
public ItemStack[] inv;
public String name;
public CropTilesBase() {
this.inv = new ItemStack[this.getSizeInventory()];
}
public String getCustomName() {
return this.name;
}
public void setCustomName(String name) {
this.name = name;
}
@Override
public String getName() {
return this.hasCustomName() ? this.name : "container.alchemicalDuster";
}
@Override
public boolean hasCustomName() {
return this.name != null && !this.name.equals("");
}
@Override
public IChatComponent getDisplayName() {
return this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatComponentTranslation(this.getName());
}
@Override
public int getSizeInventory() {
return 3;
}
@Override
public ItemStack getStackInSlot(int slot) {
if(slot < 0 || slot >= this.getSizeInventory())
return null;
return this.inv[slot];
}
@Override
public ItemStack decrStackSize(int slot, int amt) {
if(this.getStackInSlot(slot) != null) {
ItemStack stack;
if(this.getStackInSlot(slot).stackSize <= amt) {
stack = this.getStackInSlot(slot);
this.setInventorySlotContents(slot, null);
this.markDirty();
return stack;
}else{
stack = this.getStackInSlot(slot).splitStack(amt);
if(this.getStackInSlot(slot).stackSize <= 0) {
this.setInventorySlotContents(slot, null);
}else{
this.setInventorySlotContents(slot, this.getStackInSlot(slot));
}
this.markDirty();
return stack;
}
}else{
return null;
}
}
[b]@Override
public ItemStack getStackInSlotOnClosing(int slot) {
ItemStack stack = this.getStackInSlot(slot);
this.setInventorySlotContents(slot, null);
return stack;[/b]
}
It's not urgently needed as I have other things I can be getting on with in the mean time (wanting to add tool materials and custom tools and such) so it's not like I desperately need this, but I'd like to be able to come back to it at some point and get this sorted. Thanks guys!