Skip to content

Commit

Permalink
fuck double chests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tfarcenim committed Nov 11, 2019
1 parent db78417 commit 5e00398
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
org.gradle.jvmargs=-Xmx3G
mc_version=1.12.2
jei_version=4.15.0.289
mod_version=0.1.7
mod_version=0.1.7b
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ItemStack decrStackSize(int index, int count) {
ItemStack removed = itemHandler.extractItem(index, count, false);

if (!removed.isEmpty()) {
eventHandler.onCraftMatrixChanged(this);
onCraftMatrixChanged();
}

return removed;
Expand All @@ -49,6 +49,10 @@ public ItemStack decrStackSize(int index, int count) {
@Override
public void setInventorySlotContents(int index, ItemStack stack) {
itemHandler.setStackInSlot(index, stack);
onCraftMatrixChanged();
}

public void onCraftMatrixChanged(){
if (!doNotCallUpdates)eventHandler.onCraftMatrixChanged(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.network.play.server.SPacketSetSlot;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
Expand All @@ -36,6 +37,7 @@ public class CraftingStationContainer extends Container implements CraftingStati
public final World world;
private final EntityPlayer player;
private final CraftingStationTile tileEntity;
public BlockPos chestPosition;
public IRecipe lastRecipe;
protected IRecipe lastLastRecipe;
public boolean hasSideContainer;
Expand Down Expand Up @@ -72,7 +74,8 @@ public CraftingStationContainer(InventoryPlayer InventoryPlayer, World world, Bl

// try internal access first
if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,null)) {
inventoryTE = te;
if (te instanceof TileEntityChest)this.chestPosition = neighbor;
inventoryTE = te;
}
// try sided access else
else if(te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir.getOpposite())) {
Expand Down Expand Up @@ -115,6 +118,16 @@ private void addSideContainerSlots(TileEntity te, EnumFacing dir, int xPos, int
}
}

//update crafting
//clientonly
@Override
public void setAll(List<ItemStack> p_190896_1_) {
craftMatrix.setDoNotCallUpdates(true);
super.setAll(p_190896_1_);
craftMatrix.setDoNotCallUpdates(false);
craftMatrix.onCraftMatrixChanged();
}

@Override
public void onContainerClosed(EntityPlayer player) {
tileEntity.removeListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import com.tfar.craftingstation.CraftingStation;
import com.tfar.craftingstation.CraftingStationContainer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand Down Expand Up @@ -36,14 +35,18 @@ public class CraftingStationScreen extends GuiContainer {
private static final ResourceLocation SCROLLBAR = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png");
private static final ResourceLocation SCROLLBAR_BACKGROUND_AND_TAB = new ResourceLocation("textures/gui/container/creative_inventory/tab_items.png");


public static final ResourceLocation SECONDARY_GUI_TEXTURE = new ResourceLocation(CraftingStation.MODID, "textures/gui/secondary.png");

public CraftingStationScreen(CraftingStationContainer inv) {
super(inv);
realRows = inv.getRows();
topRow = 0;
currentScroll = 0;
CraftingStationContainer craftingStationContainer = (CraftingStationContainer) inventorySlots;
if(craftingStationContainer.chestPosition != null && craftingStationContainer.world.getTileEntity(craftingStationContainer.chestPosition)instanceof TileEntityChest) {
// Fix: chests don't update their single/double chest status clientside once accessed
((TileEntityChest) craftingStationContainer.world.getTileEntity(craftingStationContainer.chestPosition)).doubleChestHandler = null;
}
}

@Override
Expand Down

0 comments on commit 5e00398

Please sign in to comment.