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.AEBaseContainer;
|
||||||
|
import appeng.container.slot.IOptionalSlotHost;
|
||||||
|
import appeng.container.slot.OptionalSlotRestrictedInput;
|
||||||
import appeng.container.slot.SlotRestrictedInput;
|
import appeng.container.slot.SlotRestrictedInput;
|
||||||
import appeng.tile.qnb.TileQuantumBridge;
|
import appeng.tile.qnb.TileQuantumBridge;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
|
|
||||||
|
|
||||||
public class ContainerQNB extends AEBaseContainer {
|
public class ContainerQNB extends AEBaseContainer implements IOptionalSlotHost {
|
||||||
|
|
||||||
SlotRestrictedInput SINGULARITY;
|
OptionalSlotRestrictedInput SINGULARITY;
|
||||||
SlotRestrictedInput QUANTUM_CARD;
|
OptionalSlotRestrictedInput QUANTUM_CARD;
|
||||||
|
|
||||||
public ContainerQNB(final InventoryPlayer ip, final TileQuantumBridge quantumBridge) {
|
public ContainerQNB(final InventoryPlayer ip, final TileQuantumBridge quantumBridge) {
|
||||||
super(ip, quantumBridge, null);
|
super(ip, quantumBridge, null);
|
||||||
|
|
||||||
SINGULARITY = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge
|
SINGULARITY = new OptionalSlotRestrictedInput(SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge
|
||||||
.getInternalInventory(), 0, 80, 37, this.getInventoryPlayer());
|
.getInternalInventory(), this, 0, 80, 37, 0, this.getInventoryPlayer());
|
||||||
this.addSlotToContainer(SINGULARITY.setStackLimit(1));
|
this.addSlotToContainer(SINGULARITY.setStackLimit(1));
|
||||||
|
|
||||||
QUANTUM_CARD = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.CARD_QUANTUM, quantumBridge
|
QUANTUM_CARD = new OptionalSlotRestrictedInput(SlotRestrictedInput.PlacableItemType.CARD_QUANTUM, quantumBridge
|
||||||
.getInternalInventory(), 1, 80, 55, this.getInventoryPlayer());
|
.getInternalInventory(), this, 1, 80, 55, 1, this.getInventoryPlayer());
|
||||||
this.addSlotToContainer((QUANTUM_CARD).setStackLimit(1));
|
this.addSlotToContainer((QUANTUM_CARD).setStackLimit(1));
|
||||||
|
|
||||||
this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -353,7 +353,6 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
|||||||
upgrades.writeToNBT(data, "upgrades");
|
upgrades.writeToNBT(data, "upgrades");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveChanges(NBTTagCompound data) {
|
public void saveChanges(NBTTagCompound data) {
|
||||||
if (effectiveItem.getTagCompound() != null) {
|
if (effectiveItem.getTagCompound() != null) {
|
||||||
effectiveItem.getTagCompound().merge(data);
|
effectiveItem.getTagCompound().merge(data);
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ import appeng.api.util.IConfigManager;
|
|||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
import appeng.core.sync.GuiBridge;
|
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.CellConfig;
|
||||||
import appeng.items.contents.CellUpgrades;
|
import appeng.items.contents.CellUpgrades;
|
||||||
import appeng.items.materials.ItemMaterial;
|
import appeng.items.materials.ItemMaterial;
|
||||||
@@ -37,7 +34,6 @@ import appeng.util.ConfigManager;
|
|||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import baubles.api.BaubleType;
|
import baubles.api.BaubleType;
|
||||||
import baubles.api.IBauble;
|
import baubles.api.IBauble;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
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.math.Vec3d;
|
||||||
import net.minecraft.util.text.translation.I18n;
|
import net.minecraft.util.text.translation.I18n;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.event.MouseEvent;
|
|
||||||
import net.minecraftforge.fml.common.Optional;
|
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.common.network.IGuiHandler;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ import appeng.tile.grid.AENetworkInvTile;
|
|||||||
import appeng.tile.inventory.AppEngInternalInventory;
|
import appeng.tile.inventory.AppEngInternalInventory;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.inv.InvOperation;
|
import appeng.util.inv.InvOperation;
|
||||||
|
import appeng.util.inv.filter.AEItemDefinitionFilter;
|
||||||
|
import appeng.util.inv.filter.IAEItemFilter;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.ItemStack;
|
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().setValidSides(EnumSet.noneOf(EnumFacing.class));
|
||||||
this.getProxy().setFlags(GridFlags.DENSE_CAPACITY);
|
this.getProxy().setFlags(GridFlags.DENSE_CAPACITY);
|
||||||
this.getProxy().setIdlePowerUsage(22);
|
this.getProxy().setIdlePowerUsage(22);
|
||||||
|
this.internalInventory.setFilter(new QuantumBridgeInventoryFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -292,4 +295,24 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
|||||||
public byte getCorner() {
|
public byte getCorner() {
|
||||||
return this.corner;
|
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.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
|
||||||
public interface IAEAppEngInventory {
|
public interface IAEAppEngInventory {
|
||||||
void saveChanges();
|
void saveChanges();
|
||||||
|
|
||||||
default void saveChanges(NBTTagCompound data) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack);
|
void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user