Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Dupe with FieldKit #644

Open
wants to merge 4 commits into
base: master-MC1.12
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions core/src/main/java/binnie/core/gui/minecraft/ContainerCraftGUI.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package binnie.core.gui.minecraft;

import binnie.core.BinnieCore;
import binnie.core.gui.fieldkit.WindowFieldKit;
import binnie.core.gui.minecraft.control.ControlSlot;
import binnie.core.gui.minecraft.control.EnumHighlighting;
import binnie.core.machines.IMachine;
import binnie.core.machines.Machine;
import binnie.core.machines.errors.ErrorState;
import binnie.core.machines.errors.IErrorStateSource;
import binnie.core.machines.network.INetwork;
import binnie.core.machines.power.IPoweredMachine;
import binnie.core.machines.power.IProcess;
import binnie.core.machines.power.ITankMachine;
import binnie.core.machines.power.PowerInfo;
import binnie.core.machines.power.ProcessInfo;
import binnie.core.machines.power.TankInfo;
import binnie.core.machines.power.*;
import binnie.core.machines.transfer.TransferRequest;
import binnie.core.machines.transfer.TransferResult;
import binnie.core.network.packet.MessageContainerUpdate;
Expand All @@ -22,11 +18,7 @@
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.ClickType;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.*;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
Expand All @@ -37,12 +29,7 @@
import net.minecraftforge.items.wrapper.InvWrapper;

import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.*;

public class ContainerCraftGUI extends Container {
private final Set<EntityPlayer> crafters = Sets.newConcurrentHashSet();
Expand Down Expand Up @@ -106,13 +93,28 @@ public void onContainerClosed(final EntityPlayer playerIn) {

@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player) {
ItemStack item = player.getHeldItemMainhand();
if(this.window instanceof WindowFieldKit) {
if(closeIfNecessary(item, player) || slotNum >= 0 && getSlot(slotNum).getStack() == item) {
player.closeScreen();
return ItemStack.EMPTY;
}
}
final Slot slot = this.getSlot(slotNum);
if (slot instanceof CustomSlot && ((CustomSlot) slot).handleClick()) {
((CustomSlot) slot).onSlotClick(this, dragType, clickType, player);
return player.inventory.getItemStack();
}
return super.slotClick(slotNum, dragType, clickType, player);
}
private boolean closeIfNecessary(ItemStack stack, EntityPlayer player) {
if (!stack.getItem().equals(BinnieCore.getFieldKit())) {
player.closeScreen();
return true;
}
return false;
}


public void sendNBTToClient(final String key, final NBTTagCompound nbt) {
this.syncedNBT.put(key, nbt);
Expand Down