Implements opening containers from items with and without a block context.
This commit is contained in:
@@ -23,16 +23,16 @@ import appeng.api.parts.IPartHost;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
/**
|
||||
* Describes how a container the player has opened was originally
|
||||
@@ -47,7 +47,16 @@ import org.apache.commons.lang3.NotImplementedException;
|
||||
public final class ContainerLocator {
|
||||
|
||||
private enum Type {
|
||||
ITEM,
|
||||
/**
|
||||
* An item used from the player's inventory.
|
||||
*/
|
||||
PLAYER_INVENTORY,
|
||||
/**
|
||||
* An item used from the player's inventory, but right-clicked
|
||||
* on a block face, has block position and side in addition to the
|
||||
* above.
|
||||
*/
|
||||
PLAYER_INVENTORY_WITH_BLOCK_CONTEXT,
|
||||
BLOCK,
|
||||
PART
|
||||
}
|
||||
@@ -82,9 +91,38 @@ public final class ContainerLocator {
|
||||
return new ContainerLocator(Type.PART, -1, dimensionId, te.getPos(), AEPartLocation.fromFacing(side));
|
||||
}
|
||||
|
||||
public static ContainerLocator forHand(Hand hand) {
|
||||
// FIXME can we get an inventory location for the hand?
|
||||
throw new IllegalStateException();
|
||||
/**
|
||||
* Construct a container locator for an item being used on a block. The item could still open a container
|
||||
* for itself, but it might also open a special container for the block being right-clicked.
|
||||
*/
|
||||
public static ContainerLocator forItemUseContext(ItemUseContext context) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Cannot open a container without a player");
|
||||
}
|
||||
int dimensionId = player.world.getDimension().getType().getId();
|
||||
int slot = getPlayerInventorySlotFromHand(player, context.getHand());
|
||||
AEPartLocation side = AEPartLocation.fromFacing(context.getFace());
|
||||
return new ContainerLocator(Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, slot, dimensionId, context.getPos(), side);
|
||||
}
|
||||
|
||||
public static ContainerLocator forHand(PlayerEntity player, Hand hand) {
|
||||
int slot = getPlayerInventorySlotFromHand(player, hand);
|
||||
return new ContainerLocator(Type.PLAYER_INVENTORY, slot, -1, null, null);
|
||||
}
|
||||
|
||||
private static int getPlayerInventorySlotFromHand(PlayerEntity player, Hand hand) {
|
||||
ItemStack is = player.getHeldItem(hand);
|
||||
if (is.isEmpty()) {
|
||||
throw new IllegalArgumentException("Cannot open an item-inventory with empty hands");
|
||||
}
|
||||
int invSize = player.inventory.getSizeInventory();
|
||||
for (int i = 0; i < invSize; i++) {
|
||||
if (player.inventory.getStackInSlot(i) == is) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Could not find item held in hand " + hand + " in player inventory");
|
||||
}
|
||||
|
||||
public static ContainerLocator forPart(AEBasePart part) {
|
||||
@@ -100,11 +138,11 @@ public final class ContainerLocator {
|
||||
}
|
||||
|
||||
public boolean hasItemIndex() {
|
||||
return type == Type.ITEM;
|
||||
return type == Type.PLAYER_INVENTORY || type == Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT;
|
||||
}
|
||||
|
||||
public int getItemIndex() {
|
||||
Preconditions.checkState(type == Type.ITEM);
|
||||
Preconditions.checkState(hasItemIndex());
|
||||
return itemIndex;
|
||||
}
|
||||
|
||||
@@ -113,36 +151,43 @@ public final class ContainerLocator {
|
||||
}
|
||||
|
||||
public boolean hasBlockPos() {
|
||||
return type == Type.BLOCK || type == Type.PART;
|
||||
return type == Type.BLOCK || type == Type.PART || type == Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT;
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos() {
|
||||
Preconditions.checkState(type == Type.BLOCK || type == Type.PART);
|
||||
Preconditions.checkState(hasBlockPos());
|
||||
return blockPos;
|
||||
}
|
||||
|
||||
public boolean hasSide() {
|
||||
return type == Type.PART;
|
||||
return type == Type.PART || type == Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT;
|
||||
}
|
||||
|
||||
public AEPartLocation getSide() {
|
||||
Preconditions.checkState(type == Type.PART);
|
||||
Preconditions.checkState(hasSide());
|
||||
return side;
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buf) {
|
||||
switch (type) {
|
||||
case ITEM:
|
||||
case PLAYER_INVENTORY:
|
||||
buf.writeByte(0);
|
||||
buf.writeInt(itemIndex);
|
||||
break;
|
||||
case BLOCK:
|
||||
case PLAYER_INVENTORY_WITH_BLOCK_CONTEXT:
|
||||
buf.writeByte(1);
|
||||
buf.writeInt(itemIndex);
|
||||
buf.writeInt(dimensionId);
|
||||
buf.writeBlockPos(blockPos);
|
||||
buf.writeByte(side.ordinal());
|
||||
break;
|
||||
case BLOCK:
|
||||
buf.writeByte(22);
|
||||
buf.writeInt(dimensionId);
|
||||
buf.writeBlockPos(blockPos);
|
||||
break;
|
||||
case PART:
|
||||
buf.writeByte(2);
|
||||
buf.writeByte(3);
|
||||
buf.writeInt(dimensionId);
|
||||
buf.writeBlockPos(blockPos);
|
||||
buf.writeByte(side.ordinal());
|
||||
@@ -157,13 +202,21 @@ public final class ContainerLocator {
|
||||
switch (type) {
|
||||
case 0:
|
||||
return new ContainerLocator(
|
||||
Type.ITEM,
|
||||
Type.PLAYER_INVENTORY,
|
||||
buf.readInt(),
|
||||
-1,
|
||||
null,
|
||||
null
|
||||
);
|
||||
case 1:
|
||||
return new ContainerLocator(
|
||||
Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT,
|
||||
buf.readInt(),
|
||||
buf.readInt(),
|
||||
buf.readBlockPos(),
|
||||
AEPartLocation.values()[buf.readByte()]
|
||||
);
|
||||
case 2:
|
||||
return new ContainerLocator(
|
||||
Type.BLOCK,
|
||||
-1,
|
||||
@@ -171,7 +224,7 @@ public final class ContainerLocator {
|
||||
buf.readBlockPos(),
|
||||
null
|
||||
);
|
||||
case 2:
|
||||
case 3:
|
||||
return new ContainerLocator(
|
||||
Type.PART,
|
||||
-1,
|
||||
@@ -184,4 +237,25 @@ public final class ContainerLocator {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder result = new StringBuilder(type.name());
|
||||
result.append('{');
|
||||
if (hasItemIndex()) {
|
||||
result.append("slot=").append(itemIndex).append(',');
|
||||
}
|
||||
if (hasBlockPos()) {
|
||||
result.append("dim=").append(dimensionId).append(',');
|
||||
result.append("pos=").append(blockPos).append(',');
|
||||
}
|
||||
if (hasSide()) {
|
||||
result.append("side=").append(side).append(',');
|
||||
}
|
||||
if (result.charAt(result.length() - 1) == ',') {
|
||||
result.setLength(result.length() - 1);
|
||||
}
|
||||
result.append('}');
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+72
-16
@@ -1,26 +1,30 @@
|
||||
package appeng.container.helper;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.core.AELog;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.inventory.container.SimpleNamedContainerProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
/**
|
||||
@@ -29,18 +33,17 @@ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
*
|
||||
* @param <C>
|
||||
*/
|
||||
// FIXME: This is also used in contexts where access is via an item that implements I or exposes I via IGuiItemObject
|
||||
public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> extends AbstractContainerHelper {
|
||||
public final class ContainerHelper<C extends AEBaseContainer, I> extends AbstractContainerHelper {
|
||||
|
||||
private final Class<I> interfaceClass;
|
||||
|
||||
private final ContainerFactory<C, I> factory;
|
||||
|
||||
public PartOrTileContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass) {
|
||||
public ContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass) {
|
||||
this(factory, interfaceClass, null);
|
||||
}
|
||||
|
||||
public PartOrTileContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass, SecurityPermissions requiredPermission) {
|
||||
public ContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass, SecurityPermissions requiredPermission) {
|
||||
super(requiredPermission);
|
||||
this.interfaceClass = interfaceClass;
|
||||
this.factory = factory;
|
||||
@@ -75,10 +78,7 @@ public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> exten
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use block name at position
|
||||
// FIXME: this is not right, we'd need to check the part's item stack, or custom naming interface impl
|
||||
// FIXME: Should move this up, because at this point, it's hard to know where the terminal host came from (part or tile)
|
||||
ITextComponent title = player.world.getBlockState(locator.getBlockPos()).getBlock().getNameTextComponent();
|
||||
ITextComponent title = findContainerTitle(player.world, locator, accessInterface);
|
||||
|
||||
INamedContainerProvider container = new SimpleNamedContainerProvider(
|
||||
(wnd, p, pl) -> {
|
||||
@@ -94,7 +94,31 @@ public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> exten
|
||||
return true;
|
||||
}
|
||||
|
||||
private ITextComponent findContainerTitle(World world, ContainerLocator locator, I accessInterface) {
|
||||
|
||||
if (accessInterface instanceof ICustomNameObject) {
|
||||
ICustomNameObject customNameObject = (ICustomNameObject) accessInterface;
|
||||
if (customNameObject.hasCustomInventoryName()) {
|
||||
return customNameObject.getCustomInventoryName();
|
||||
}
|
||||
}
|
||||
|
||||
// Use block name at position
|
||||
// FIXME: this is not right, we'd need to check the part's item stack, or custom naming interface impl
|
||||
// FIXME: Should move this up, because at this point, it's hard to know where the terminal host came from (part or tile)
|
||||
if (locator.hasBlockPos()) {
|
||||
return world.getBlockState(locator.getBlockPos()).getBlock().getNameTextComponent();
|
||||
}
|
||||
|
||||
return new StringTextComponent("Unknown");
|
||||
|
||||
}
|
||||
|
||||
private I getHostFromLocator(PlayerEntity player, ContainerLocator locator) {
|
||||
if (locator.hasItemIndex()) {
|
||||
return getHostFromPlayerInventory(player, locator);
|
||||
}
|
||||
|
||||
if (!locator.hasBlockPos() || !locator.hasSide()) {
|
||||
return null; // No block was clicked or the side is unknown
|
||||
// FIXME: If no side is provided, should be try with INTERNAL???
|
||||
@@ -116,7 +140,7 @@ public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> exten
|
||||
if (interfaceClass.isInstance(part)) {
|
||||
return interfaceClass.cast(part);
|
||||
} else {
|
||||
AELog.debug("Trying to open a container @ {} for a {}, but the container requires {}",
|
||||
AELog.debug("Trying to open a container @ %s for a %s, but the container requires %s",
|
||||
locator, part.getClass(), interfaceClass);
|
||||
return null;
|
||||
}
|
||||
@@ -126,6 +150,38 @@ public final class PartOrTileContainerHelper<C extends AEBaseContainer, I> exten
|
||||
}
|
||||
}
|
||||
|
||||
private I getHostFromPlayerInventory(PlayerEntity player, ContainerLocator locator) {
|
||||
|
||||
ItemStack it = player.inventory.getStackInSlot(locator.getItemIndex());
|
||||
|
||||
if (it.isEmpty()) {
|
||||
AELog.debug("Cannot open container for player %s since they no longer hold the item in slot %d",
|
||||
player, locator.hasItemIndex());
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( it.getItem() instanceof IGuiItem )
|
||||
{
|
||||
IGuiItem guiItem = (IGuiItem) it.getItem();
|
||||
// Optionally contains the block the item was used on to open the container
|
||||
BlockPos blockPos = locator.hasBlockPos() ? locator.getBlockPos() : null;
|
||||
IGuiItemObject guiObject = guiItem.getGuiObject(it, locator.getItemIndex(), player.world, blockPos);
|
||||
if (interfaceClass.isInstance(guiObject)) {
|
||||
return interfaceClass.cast(guiObject);
|
||||
}
|
||||
}
|
||||
|
||||
if( interfaceClass.isAssignableFrom(WirelessTerminalGuiObject.class) )
|
||||
{
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler( it );
|
||||
if ( wh != null) {
|
||||
return interfaceClass.cast(new WirelessTerminalGuiObject(wh, it, player, locator.getItemIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ContainerFactory<C, I> {
|
||||
C create(int windowId, PlayerInventory playerInv, I accessObj);
|
||||
@@ -22,7 +22,7 @@ package appeng.container.implementations;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -47,8 +47,8 @@ public class ContainerCraftAmount extends AEBaseContainer
|
||||
|
||||
public static ContainerType<ContainerCraftAmount> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerCraftAmount, ITerminalHost> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerCraftAmount::new, ITerminalHost.class, SecurityPermissions.CRAFT);
|
||||
private static final ContainerHelper<ContainerCraftAmount, ITerminalHost> helper
|
||||
= new ContainerHelper<>(ContainerCraftAmount::new, ITerminalHost.class, SecurityPermissions.CRAFT);
|
||||
|
||||
private final Slot craftingItem;
|
||||
private IAEItemStack itemToCreate;
|
||||
|
||||
@@ -39,8 +39,7 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.TileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
@@ -57,7 +56,6 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.IContainerListener;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -73,8 +71,8 @@ public class ContainerCraftConfirm extends AEBaseContainer
|
||||
|
||||
public static ContainerType<ContainerCraftConfirm> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerCraftConfirm, ITerminalHost> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerCraftConfirm::new, ITerminalHost.class, SecurityPermissions.CRAFT);
|
||||
private static final ContainerHelper<ContainerCraftConfirm, ITerminalHost> helper
|
||||
= new ContainerHelper<>(ContainerCraftConfirm::new, ITerminalHost.class, SecurityPermissions.CRAFT);
|
||||
|
||||
public static ContainerCraftConfirm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
@@ -25,8 +25,7 @@ import java.util.List;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.TileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -46,8 +45,8 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU
|
||||
|
||||
public static ContainerType<ContainerCraftingStatus> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerCraftingStatus, ITerminalHost> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerCraftingStatus::new, ITerminalHost.class, SecurityPermissions.CRAFT);
|
||||
private static final ContainerHelper<ContainerCraftingStatus, ITerminalHost> helper
|
||||
= new ContainerHelper<>(ContainerCraftingStatus::new, ITerminalHost.class, SecurityPermissions.CRAFT);
|
||||
|
||||
public static ContainerCraftingStatus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
@@ -21,8 +21,7 @@ package appeng.container.implementations;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.TileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -53,8 +52,8 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
|
||||
|
||||
public static ContainerType<ContainerCraftingTerm> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerCraftingTerm, ITerminalHost> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerCraftingTerm::new, ITerminalHost.class, SecurityPermissions.CRAFT);
|
||||
private static final ContainerHelper<ContainerCraftingTerm, ITerminalHost> helper
|
||||
= new ContainerHelper<>(ContainerCraftingTerm::new, ITerminalHost.class, SecurityPermissions.CRAFT);
|
||||
|
||||
public static ContainerCraftingTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
@@ -20,7 +20,7 @@ package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
@@ -43,8 +43,8 @@ public class ContainerInterface extends ContainerUpgradeable
|
||||
|
||||
public static ContainerType<ContainerInterface> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerInterface, IInterfaceHost> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerInterface::new, IInterfaceHost.class, SecurityPermissions.BUILD);
|
||||
private static final ContainerHelper<ContainerInterface, IInterfaceHost> helper
|
||||
= new ContainerHelper<>(ContainerInterface::new, IInterfaceHost.class, SecurityPermissions.BUILD);
|
||||
|
||||
public static ContainerInterface fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
@@ -24,8 +24,9 @@ import java.nio.BufferOverflowException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@@ -82,8 +83,8 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
|
||||
public static ContainerType<ContainerMEMonitorable> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerMEMonitorable, ITerminalHost> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerMEMonitorable::new, ITerminalHost.class);
|
||||
private static final ContainerHelper<ContainerMEMonitorable, ITerminalHost> helper
|
||||
= new ContainerHelper<>(ContainerMEMonitorable::new, ITerminalHost.class);
|
||||
|
||||
public static ContainerMEMonitorable fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
@@ -116,7 +117,8 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
id,
|
||||
ip,
|
||||
monitorable instanceof TileEntity ? (TileEntity) monitorable : null,
|
||||
monitorable instanceof IPart ? (IPart) monitorable : null );
|
||||
monitorable instanceof IPart ? (IPart) monitorable : null,
|
||||
monitorable instanceof IGuiItemObject ? (IGuiItemObject) monitorable : null);
|
||||
|
||||
this.host = monitorable;
|
||||
this.clientCM = new ConfigManager( this );
|
||||
@@ -166,7 +168,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
final IGrid g = node.getGrid();
|
||||
if( g != null )
|
||||
{
|
||||
this.setPowerSource( new ChannelPowerSrc( this.networkNode, (IEnergySource) g.getCache( IEnergyGrid.class ) ) );
|
||||
this.setPowerSource( new ChannelPowerSrc( this.networkNode, g.getCache( IEnergyGrid.class )) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -38,8 +38,8 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
|
||||
|
||||
public static ContainerType<ContainerMEPortableCell> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerMEPortableCell, IPortableCell> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerMEPortableCell::new, IPortableCell.class);
|
||||
private static final ContainerHelper<ContainerMEPortableCell, IPortableCell> helper
|
||||
= new ContainerHelper<>(ContainerMEPortableCell::new, IPortableCell.class);
|
||||
|
||||
public static ContainerMEPortableCell fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
@@ -22,8 +22,7 @@ package appeng.container.implementations;
|
||||
import java.io.IOException;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.TileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@@ -55,8 +54,8 @@ public class ContainerNetworkStatus extends AEBaseContainer
|
||||
|
||||
public static ContainerType<ContainerNetworkStatus> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerNetworkStatus, INetworkTool> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerNetworkStatus::new, INetworkTool.class);
|
||||
private static final ContainerHelper<ContainerNetworkStatus, INetworkTool> helper
|
||||
= new ContainerHelper<>(ContainerNetworkStatus::new, INetworkTool.class);
|
||||
|
||||
public static ContainerNetworkStatus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
@@ -23,8 +23,7 @@ import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.TileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@@ -39,8 +38,8 @@ public class ContainerNetworkTool extends AEBaseContainer
|
||||
|
||||
public static ContainerType<ContainerNetworkTool> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerNetworkTool, INetworkTool> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerNetworkTool::new, INetworkTool.class);
|
||||
private static final ContainerHelper<ContainerNetworkTool, INetworkTool> helper
|
||||
= new ContainerHelper<>(ContainerNetworkTool::new, INetworkTool.class);
|
||||
|
||||
public static ContainerNetworkTool fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
@@ -31,8 +31,7 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.TileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
@@ -77,8 +76,8 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
|
||||
public static ContainerType<ContainerPatternTerm> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerPatternTerm, ITerminalHost> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerPatternTerm::new, ITerminalHost.class, SecurityPermissions.CRAFT);
|
||||
private static final ContainerHelper<ContainerPatternTerm, ITerminalHost> helper
|
||||
= new ContainerHelper<>(ContainerPatternTerm::new, ITerminalHost.class, SecurityPermissions.CRAFT);
|
||||
|
||||
public static ContainerPatternTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
@@ -20,7 +20,7 @@ package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@@ -43,8 +43,8 @@ public class ContainerPriority extends AEBaseContainer
|
||||
|
||||
public static ContainerType<ContainerPriority> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerPriority, IPriorityHost> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerPriority::new, IPriorityHost.class, SecurityPermissions.BUILD);
|
||||
private static final ContainerHelper<ContainerPriority, IPriorityHost> helper
|
||||
= new ContainerHelper<>(ContainerPriority::new, IPriorityHost.class, SecurityPermissions.BUILD);
|
||||
|
||||
public static ContainerPriority fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
@@ -22,7 +22,7 @@ package appeng.container.implementations;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -47,8 +47,8 @@ public class ContainerQuartzKnife extends AEBaseContainer
|
||||
|
||||
public static ContainerType<ContainerQuartzKnife> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerQuartzKnife, QuartzKnifeObj> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerQuartzKnife::new, QuartzKnifeObj.class);
|
||||
private static final ContainerHelper<ContainerQuartzKnife, QuartzKnifeObj> helper
|
||||
= new ContainerHelper<>(ContainerQuartzKnife::new, QuartzKnifeObj.class);
|
||||
|
||||
public static ContainerQuartzKnife fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
@@ -20,8 +20,7 @@ package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.TileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -50,8 +49,8 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
|
||||
|
||||
public static ContainerType<ContainerSecurityStation> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerSecurityStation, ITerminalHost> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerSecurityStation::new, ITerminalHost.class, SecurityPermissions.SECURITY);
|
||||
private static final ContainerHelper<ContainerSecurityStation, ITerminalHost> helper
|
||||
= new ContainerHelper<>(ContainerSecurityStation::new, ITerminalHost.class, SecurityPermissions.SECURITY);
|
||||
|
||||
private final SlotRestrictedInput configSlot;
|
||||
|
||||
|
||||
@@ -20,20 +20,15 @@ package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartContainerHelper;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
@@ -66,8 +61,8 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
||||
|
||||
public static ContainerType<ContainerUpgradeable> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerUpgradeable, IUpgradeableHost> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerUpgradeable::new, IUpgradeableHost.class, SecurityPermissions.BUILD);
|
||||
private static final ContainerHelper<ContainerUpgradeable, IUpgradeableHost> helper
|
||||
= new ContainerHelper<>(ContainerUpgradeable::new, IUpgradeableHost.class, SecurityPermissions.BUILD);
|
||||
|
||||
public static ContainerUpgradeable fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
@@ -130,7 +125,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
||||
{
|
||||
this.lockPlayerInventorySlot( x );
|
||||
this.tbSlot = x;
|
||||
this.tbInventory = (NetworkToolViewer) ( (IGuiItem) pii.getItem() ).getGuiObject( pii, w, new BlockPos( xCoord, yCoord, zCoord ) );
|
||||
this.tbInventory = (NetworkToolViewer) ( (IGuiItem) pii.getItem() ).getGuiObject( pii, x, w, new BlockPos( xCoord, yCoord, zCoord ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@ package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.helper.PartContainerHelper;
|
||||
import appeng.container.helper.PartOrTileContainerHelper;
|
||||
import appeng.container.helper.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
@@ -38,8 +37,8 @@ public class ContainerWirelessTerm extends ContainerMEPortableCell
|
||||
|
||||
public static ContainerType<ContainerWirelessTerm> TYPE;
|
||||
|
||||
private static final PartOrTileContainerHelper<ContainerWirelessTerm, WirelessTerminalGuiObject> helper
|
||||
= new PartOrTileContainerHelper<>(ContainerWirelessTerm::new, WirelessTerminalGuiObject.class);
|
||||
private static final ContainerHelper<ContainerWirelessTerm, WirelessTerminalGuiObject> helper
|
||||
= new ContainerHelper<>(ContainerWirelessTerm::new, WirelessTerminalGuiObject.class);
|
||||
|
||||
public static ContainerWirelessTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
|
||||
Reference in New Issue
Block a user