Skip to content

Commit

Permalink
Fix seared furnaces not updating temperature required on stack size c…
Browse files Browse the repository at this point in the history
…hange (#3733)
  • Loading branch information
KnightMiner committed Mar 28, 2019
1 parent 30a587e commit f5d7b2a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ContainerSearedFurnace extends ContainerMultiModule<TileSearedFurna
public ContainerSearedFurnace(InventoryPlayer inventoryPlayer, TileSearedFurnace tile) {
super(tile);

sideInventory = new ContainerSideInventory<>(tile, 0, 0, calcColumns());
sideInventory = new ContainerSearedFurnaceSideInventory(tile, 0, 0, calcColumns());
addSubContainer(sideInventory, true);

// player stuffs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package slimeknights.tconstruct.smeltery.inventory;

import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler;
import slimeknights.tconstruct.smeltery.tileentity.TileSearedFurnace;
import slimeknights.tconstruct.tools.common.inventory.ContainerSideInventory;

public class ContainerSearedFurnaceSideInventory extends ContainerSideInventory<TileSearedFurnace> {

public ContainerSearedFurnaceSideInventory(TileSearedFurnace tile, int x, int y, int columns) {
super(tile, x, y, columns);
}

@Override
protected Slot createSlot(IItemHandler itemHandler, int index, int x, int y) {
return new SearedFurnaceSlot(tile, itemHandler, index, x, y);
}

private static class SearedFurnaceSlot extends SlotItemHandler {

private TileSearedFurnace tile;
private int index;
public SearedFurnaceSlot(TileSearedFurnace tile, IItemHandler itemHandler, int index, int xPosition, int yPosition) {
super(itemHandler, index, xPosition, yPosition);
this.tile = tile;
this.index = index;
}

@Override
public boolean isItemValid(ItemStack stack) {
return true;
}

@Override
public int getItemStackLimit(ItemStack stack) {
return 16;
}

@Override
public void onSlotChanged() {
// don't update client side, its going to sync in a tick or two
if(!tile.getWorld().isRemote) {
this.tile.updateHeatRequired(index);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void update() {

/* Grabs the heat for a furnace */
@Override
protected void updateHeatRequired(int index) {
public void updateHeatRequired(int index) {
ItemStack stack = getStackInSlot(index);
if(!stack.isEmpty()) {
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
Expand All @@ -88,6 +88,7 @@ protected void updateHeatRequired(int index) {
}
else {
// if its too big, set the error state
setHeatRequiredForSlot(index, 0);
itemTemperatures[index] = -1;
}

Expand Down

0 comments on commit f5d7b2a

Please sign in to comment.