Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Ok so first of I'm assuming its the container that's not working correctly. I've been updating to 1.8 and this is the first major issue I've run into. Well more like two problems.

 

One of my Tile Entities will accept an item however it will immediately spit it back out but create a copy of the item in the correct slot with a stack size of zero.

 

The other Tile Entity just eats the item and nothing happens.

 

I copied my code over from 1.7.10, and using TheGreyGhost's MinecraftByExample updated it to 1.8. I'm not entirely sure where exactly my issue is so if you need anything to help just let me know.

 

Any help is much appreciated.

 

Container that spits item out:

 

 

public class ContainerCrusher extends ContainerHC

{

private int lastCrushTime;

private TileEntityCrusher tileEntity;

 

public ContainerCrusher(InventoryPlayer inventoryPlayer, TileEntityCrusher te)

{

this.addSlotToContainer(new Slot(te, 0, 56, 34));

this.addSlotToContainer(new Slot(te, 1, 116, 34));

this.addSlotToContainer(new Slot(te, 2, 8, 62));

this.addPlayerSlots(inventoryPlayer, 8, 84);

 

this.tileEntity = te;

}

 

@Override

public void addCraftingToCrafters(ICrafting p_75132_1_)

{

super.addCraftingToCrafters(p_75132_1_);

p_75132_1_.sendProgressBarUpdate(this, 0, this.tileEntity.getCrushTime());

p_75132_1_.sendProgressBarUpdate(this, 1, this.tileEntity.getCrushTime());

 

p_75132_1_.func_175173_a(this, this.tileEntity);

}

 

@Override

public boolean canInteractWith(EntityPlayer playerIn)

{

return tileEntity.isUseableByPlayer(playerIn);

}

 

@Override

public void detectAndSendChanges()

{

super.detectAndSendChanges();

 

for (Object crafter : this.crafters)

{

ICrafting icrafting = (ICrafting) crafter;

 

if (this.lastCrushTime != this.tileEntity.getCrushTime())

{

icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.getCrushTime());

}

}

 

this.lastCrushTime = this.tileEntity.getField(0);

}

 

@Override

public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)

{

ItemStack itemstack = null;

Slot slot = (Slot) this.inventorySlots.get(slotIndex);

 

if (slot != null && slot.getHasStack())

{

ItemStack itemstack1 = slot.getStack();

itemstack = itemstack1.copy();

 

//Change accordingly from here...

if (slotIndex < 3)

{

if (!this.mergeItemStack(itemstack1, 3, 39, true))

{

return null;

}

}

else

{

if (itemstack1.stackSize == 1)

{

for (int i = 0; i < 3; i++)

{

//Shift click single items only

Slot shiftedInSlot = ((Slot) inventorySlots.get(i));

if (!shiftedInSlot.getHasStack() && shiftedInSlot.isItemValid(itemstack1))

{

mergeItemStack(itemstack1, i, i + 1, false);

}

}

return null;

}

}

//..to here.

 

if (itemstack1.stackSize == 0)

{

slot.putStack((ItemStack) null);

}

else

{

slot.onSlotChanged();

}

 

if (itemstack1.stackSize == itemstack.stackSize)

{

return null;

}

 

slot.onPickupFromSlot(player, itemstack1);

}

 

return itemstack;

}

 

@SideOnly(Side.CLIENT)

public void updateProgressBar(int p_75137_1_, int p_75137_2_)

{

if (p_75137_1_ == 0)

{

this.tileEntity.setCrushTime(p_75137_2_);

}

}

}

 

 

 

Container that eats items

 

 

public class ContainerLaserFurnace extends ContainerHC

{

private int lastCookTime;

private TileEntityLaserFurnace te;

 

public ContainerLaserFurnace(InventoryPlayer inventoryPlayer, TileEntityLaserFurnace te)

{

this.addSlotToContainer(new Slot(te, 0, 56, 17));

this.addSlotToContainer(new Slot(te, 1, 116, 35));

this.addSlotToContainer(new Slot(te, 2, 8, 62));

 

this.addPlayerSlots(inventoryPlayer, 8, 84);

this.te = te;

}

 

@Override

public void addCraftingToCrafters(ICrafting p_75132_1_)

{

super.addCraftingToCrafters(p_75132_1_);

p_75132_1_.sendProgressBarUpdate(this, 0, this.te.getFurnaceCookTime());

p_75132_1_.sendProgressBarUpdate(this, 1, this.te.getFurnaceCookTime());

 

p_75132_1_.func_175173_a(this, te);

}

 

@Override

public boolean canInteractWith(EntityPlayer p_75145_1_)

{

return te.isUseableByPlayer(p_75145_1_);

}

 

@Override

public void detectAndSendChanges()

{

super.detectAndSendChanges();

 

for (int i = 0; i < this.crafters.size(); ++i)

{

ICrafting icrafting = (ICrafting) this.crafters.get(i);

 

if (this.lastCookTime != this.te.getFurnaceCookTime())

{

icrafting.sendProgressBarUpdate(this, 0, this.te.getFurnaceCookTime());

}

}

 

this.lastCookTime = this.te.getFurnaceCookTime();

}

 

@Override

public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)

{

ItemStack itemstack = null;

Slot slot = (Slot) this.inventorySlots.get(slotIndex);

 

if (slot != null && slot.getHasStack())

{

ItemStack itemstack1 = slot.getStack();

itemstack = itemstack1.copy();

 

//Change accordingly from here...

if (slotIndex < 3)

{

if (!this.mergeItemStack(itemstack1, 3, 39, true))

{

return null;

}

}

else

{

if (itemstack1.stackSize == 1)

{

for (int i = 0; i < 3; i++)

{

//Shift click single items only

Slot shiftedInSlot = ((Slot) inventorySlots.get(i));

if (!shiftedInSlot.getHasStack() && shiftedInSlot.isItemValid(itemstack1))

{

mergeItemStack(itemstack1, i, i + 1, false);

}

}

return null;

}

}

//..to here.

 

if (itemstack1.stackSize == 0)

{

slot.putStack((ItemStack) null);

}

else

{

slot.onSlotChanged();

}

 

if (itemstack1.stackSize == itemstack.stackSize)

{

return null;

}

 

slot.onPickupFromSlot(player, itemstack1);

}

 

return itemstack;

}

 

@SideOnly(Side.CLIENT)

public void updateProgressBar(int p_75137_1_, int p_75137_2_)

{

if (p_75137_1_ == 0)

{

this.te.setFurnaceCookTime(p_75137_2_);

}

}

}

 

 

 

Base Container

 

 

public abstract class ContainerHC extends Container

{

protected void addPlayerSlots(InventoryPlayer playerInventory, int x, int y)

{

for (int i = 0; i < 3; ++i)

{

for (int j = 0; j < 9; ++j)

{

addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, x + j * 18, y + i * 18));

}

}

 

for (int i = 0; i < 9; ++i)

{

addSlotToContainer(new Slot(playerInventory, i, x + i * 18, y + 58));

}

}

}

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.