lock quantumbridge inventory to 1 card or singularity
This commit is contained in:
@@ -20,30 +20,44 @@ package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
|
||||
public class ContainerQNB extends AEBaseContainer {
|
||||
public class ContainerQNB extends AEBaseContainer implements IOptionalSlotHost {
|
||||
|
||||
SlotRestrictedInput SINGULARITY;
|
||||
SlotRestrictedInput QUANTUM_CARD;
|
||||
OptionalSlotRestrictedInput SINGULARITY;
|
||||
OptionalSlotRestrictedInput QUANTUM_CARD;
|
||||
|
||||
public ContainerQNB(final InventoryPlayer ip, final TileQuantumBridge quantumBridge) {
|
||||
super(ip, quantumBridge, null);
|
||||
|
||||
SINGULARITY = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge
|
||||
.getInternalInventory(), 0, 80, 37, this.getInventoryPlayer());
|
||||
SINGULARITY = new OptionalSlotRestrictedInput(SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge
|
||||
.getInternalInventory(), this, 0, 80, 37, 0, this.getInventoryPlayer());
|
||||
this.addSlotToContainer(SINGULARITY.setStackLimit(1));
|
||||
|
||||
QUANTUM_CARD = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.CARD_QUANTUM, quantumBridge
|
||||
.getInternalInventory(), 1, 80, 55, this.getInventoryPlayer());
|
||||
QUANTUM_CARD = new OptionalSlotRestrictedInput(SlotRestrictedInput.PlacableItemType.CARD_QUANTUM, quantumBridge
|
||||
.getInternalInventory(), this, 1, 80, 55, 1, this.getInventoryPlayer());
|
||||
this.addSlotToContainer((QUANTUM_CARD).setStackLimit(1));
|
||||
|
||||
this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(int idx) {
|
||||
if (QUANTUM_CARD.getItemHandler().getStackInSlot(QUANTUM_CARD.slotNumber).isEmpty() &&
|
||||
SINGULARITY.getItemHandler().getStackInSlot(SINGULARITY.slotNumber).isEmpty()) {
|
||||
return true;
|
||||
} else if (idx == 0) {
|
||||
return QUANTUM_CARD.getItemHandler().getStackInSlot(QUANTUM_CARD.slotNumber).isEmpty();
|
||||
} else if (idx == 1) {
|
||||
return SINGULARITY.getItemHandler().getStackInSlot(SINGULARITY.slotNumber).isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,8 +352,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
viewCell.writeToNBT(data, "viewCell");
|
||||
upgrades.writeToNBT(data, "upgrades");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void saveChanges(NBTTagCompound data) {
|
||||
if (effectiveItem.getTagCompound() != null) {
|
||||
effectiveItem.getTagCompound().merge(data);
|
||||
|
||||
@@ -26,9 +26,6 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCraftRequest;
|
||||
import appeng.core.sync.packets.PacketTerminalUse;
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.materials.ItemMaterial;
|
||||
@@ -37,7 +34,6 @@ import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -52,16 +48,11 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.filter.AEItemDefinitionFilter;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -66,6 +68,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
this.getProxy().setValidSides(EnumSet.noneOf(EnumFacing.class));
|
||||
this.getProxy().setFlags(GridFlags.DENSE_CAPACITY);
|
||||
this.getProxy().setIdlePowerUsage(22);
|
||||
this.internalInventory.setFilter(new QuantumBridgeInventoryFilter());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -292,4 +295,24 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
public byte getCorner() {
|
||||
return this.corner;
|
||||
}
|
||||
|
||||
private class QuantumBridgeInventoryFilter implements IAEItemFilter {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
|
||||
if (inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(1).isEmpty() ) {
|
||||
if (slot == 0 && stack.isItemEqual(AEApi.instance().definitions().materials().qESingularity().maybeStack(1).get())) {
|
||||
return true;
|
||||
} else return slot == 1 && stack.isItemEqual(AEApi.instance().definitions().materials().cardQuantumLink().maybeStack(1).get());
|
||||
} else if (slot == 0 && inv.getStackInSlot(1).isEmpty()) {
|
||||
return true;
|
||||
}else return slot == 1 && inv.getStackInSlot(0).isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,15 +20,11 @@ package appeng.util.inv;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
|
||||
public interface IAEAppEngInventory {
|
||||
void saveChanges();
|
||||
|
||||
default void saveChanges(NBTTagCompound data) {
|
||||
}
|
||||
|
||||
void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user