All GUI compile errors fixed, switched to excludes over includes in gradle build and lots, LOTS of more fixes.

This commit is contained in:
Sebastian Hartte
2020-06-06 21:16:05 +02:00
parent bb453b0d35
commit ff042a394b
209 changed files with 4527 additions and 4479 deletions
@@ -33,10 +33,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.inventory.container.Slot;
import net.minecraft.inventory.container.*;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.items.IItemHandler;
@@ -89,7 +86,7 @@ public abstract class AEBaseContainer extends Container
private final HashMap<Integer, SyncData> syncData = new HashMap<>();
private boolean isContainerValid = true;
private String customName;
private ContainerOpenContext openContext;
private ContainerLocator locator;
private IMEInventoryHandler<IAEItemStack> cellInv;
private IEnergySource powerSrc;
private boolean sentCustomName;
@@ -1060,6 +1057,7 @@ public abstract class AEBaseContainer extends Container
private void sendCustomName()
{
// FIXME: Trash this, this is handled by NamedContainerProvider now
if( !this.sentCustomName )
{
this.sentCustomName = true;
@@ -1096,16 +1094,9 @@ public abstract class AEBaseContainer extends Container
if( this.getCustomName() != null )
{
try
{
NetworkHandler.instance()
.sendTo( new PacketValueConfig( "CustomName", this.getCustomName() ),
(ServerPlayerEntity) this.getPlayerInventory().player );
}
catch( final IOException e )
{
AELog.debug( e );
}
NetworkHandler.instance()
.sendTo( new PacketValueConfig( "CustomName", this.getCustomName() ),
(ServerPlayerEntity) this.getPlayerInventory().player );
}
}
}
@@ -1242,14 +1233,14 @@ public abstract class AEBaseContainer extends Container
this.isContainerValid = isContainerValid;
}
public ContainerOpenContext getOpenContext()
public ContainerLocator getLocator()
{
return this.openContext;
return this.locator;
}
public void setOpenContext( final ContainerOpenContext openContext )
public void setLocator(final ContainerLocator locator)
{
this.openContext = openContext;
this.locator = locator;
}
public IEnergySource getPowerSource()
@@ -1261,4 +1252,5 @@ public abstract class AEBaseContainer extends Container
{
this.powerSrc = powerSrc;
}
}
@@ -0,0 +1,187 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.container;
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.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
* located. This can be one of three ways:
*
* <ul>
* <li>A tile entity at a given block position.</li>
* <li>A part (i.e. cable bus part) at the side of a given block position.</li>
* <li>An item held by the player.</li>
* </ul>
*/
public final class ContainerLocator {
private enum Type {
ITEM,
BLOCK,
PART
}
private final Type type;
private final int itemIndex;
private final int dimensionId;
private final BlockPos blockPos;
private final AEPartLocation side;
private ContainerLocator(Type type, int itemIndex, int dimensionId, BlockPos blockPos, AEPartLocation side) {
this.type = type;
this.itemIndex = itemIndex;
this.dimensionId = dimensionId;
this.blockPos = blockPos;
this.side = side;
}
public static ContainerLocator forTileEntity(TileEntity te) {
if (te.getWorld() == null) {
throw new IllegalArgumentException("Cannot open a tile entity that is not in a world");
}
int dimensionId = te.getWorld().getDimension().getType().getId();
return new ContainerLocator(Type.BLOCK, -1, dimensionId, te.getPos(), null);
}
public static ContainerLocator forTileEntitySide(TileEntity te, Direction side) {
if (te.getWorld() == null) {
throw new IllegalArgumentException("Cannot open a tile entity that is not in a world");
}
int dimensionId = te.getWorld().getDimension().getType().getId();
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();
}
public static ContainerLocator forPart(AEBasePart part) {
IPartHost host = part.getHost();
DimensionalCoord pos = host.getLocation();
return new ContainerLocator(
Type.PART,
-1,
pos.getWorld().getDimension().getType().getId(),
pos.getBlockPos(),
part.getSide()
);
}
public boolean hasItemIndex() {
return type == Type.ITEM;
}
public int getItemIndex() {
Preconditions.checkState(type == Type.ITEM);
return itemIndex;
}
public int getDimensionId() {
return dimensionId;
}
public boolean hasBlockPos() {
return type == Type.BLOCK || type == Type.PART;
}
public BlockPos getBlockPos() {
Preconditions.checkState(type == Type.BLOCK || type == Type.PART);
return blockPos;
}
public boolean hasSide() {
return type == Type.PART;
}
public AEPartLocation getSide() {
Preconditions.checkState(type == Type.PART);
return side;
}
public void write(PacketBuffer buf) {
switch (type) {
case ITEM:
buf.writeByte(0);
buf.writeInt(itemIndex);
break;
case BLOCK:
buf.writeByte(1);
buf.writeInt(dimensionId);
buf.writeBlockPos(blockPos);
break;
case PART:
buf.writeByte(2);
buf.writeInt(dimensionId);
buf.writeBlockPos(blockPos);
buf.writeByte(side.ordinal());
break;
default:
throw new IllegalStateException("Unsupported ContainerLocator type: " + type);
}
}
public static ContainerLocator read(PacketBuffer buf) {
byte type = buf.readByte();
switch (type) {
case 0:
return new ContainerLocator(
Type.ITEM,
buf.readInt(),
-1,
null,
null
);
case 1:
return new ContainerLocator(
Type.BLOCK,
-1,
buf.readInt(),
buf.readBlockPos(),
null
);
case 2:
return new ContainerLocator(
Type.PART,
-1,
buf.readInt(),
buf.readBlockPos(),
AEPartLocation.values()[buf.readByte()]
);
default:
throw new DecoderException("ContainerLocator type out of range: " + type);
}
}
}
@@ -1,104 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.container;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.api.parts.IPart;
import appeng.api.util.AEPartLocation;
public class ContainerOpenContext
{
private final boolean isItem;
private World w;
private int x;
private int y;
private int z;
private AEPartLocation side;
public ContainerOpenContext( final Object myItem )
{
final boolean isWorld = myItem instanceof IPart || myItem instanceof TileEntity;
this.isItem = !isWorld;
}
public TileEntity getTile()
{
if( this.isItem )
{
return null;
}
return this.w.getTileEntity( new BlockPos( this.x, this.y, this.z ) );
}
public AEPartLocation getSide()
{
return this.side;
}
public void setSide( final AEPartLocation side )
{
this.side = side;
}
private int getZ()
{
return this.z;
}
public void setZ( final int z )
{
this.z = z;
}
private int getY()
{
return this.y;
}
public void setY( final int y )
{
this.y = y;
}
private int getX()
{
return this.x;
}
public void setX( final int x )
{
this.x = x;
}
private World getWorld()
{
return this.w;
}
public void setWorld( final World w )
{
this.w = w;
}
}
@@ -0,0 +1,43 @@
package appeng.container;
import appeng.core.AELog;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import java.util.HashMap;
import java.util.Map;
/**
* Allows opening containers generically.
*/
public final class ContainerOpener {
private ContainerOpener() {
}
private static final Map<ContainerType<? extends AEBaseContainer>, Opener<?>> registry = new HashMap<>();
public static <T extends AEBaseContainer> void addOpener(ContainerType<T> type, Opener<T> opener) {
registry.put(type, opener);
}
public static boolean openContainer(ContainerType<?> type, PlayerEntity player, ContainerLocator locator) {
Opener<?> opener = registry.get(type);
if (opener == null) {
AELog.warn("Trying to open container for unknown container type {}", type);
return false;
}
return opener.open(player, locator);
}
@FunctionalInterface
public interface Opener<T extends AEBaseContainer> {
boolean open(PlayerEntity player, ContainerLocator locator);
}
}
@@ -0,0 +1,110 @@
package appeng.container.helper;
import appeng.api.config.SecurityPermissions;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator;
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.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.network.NetworkHooks;
/**
* Helper for containers that can be opened for {@link appeng.api.parts.IPart parts} that are attached
* to a {@link appeng.api.parts.IPartHost part host}.
*
* @param <C>
* @param <P> The type of part this container is for.
*/
public final class PartContainerHelper<C extends AEBaseContainer, P extends IPart> {
private final Class<P> partClass;
private final ContainerFactory<P, C> factory;
private final SecurityPermissions requiredPermission;
public PartContainerHelper(ContainerFactory<P, C> factory, Class<P> partClass) {
this(factory, partClass, null);
}
public PartContainerHelper(ContainerFactory<P, C> factory, Class<P> partClass, SecurityPermissions requiredPermission) {
this.partClass = partClass;
this.factory = factory;
this.requiredPermission = requiredPermission;
}
/**
* Opens a container that is based around a single tile entity.
* The tile entity's position is encoded in the packet buffer.
*/
public C fromNetwork(int windowId, PlayerInventory inv, PacketBuffer packetBuf) {
BlockPos pos = packetBuf.readBlockPos();
TileEntity te = inv.player.world.getTileEntity(pos);
if (partClass.isInstance(te)) {
return factory.create(windowId, inv, partClass.cast(te));
}
return null;
}
public boolean open(PlayerEntity player, ContainerLocator locator) {
if (!(player instanceof ServerPlayerEntity)) {
// Cannot open containers on the client or for non-players
// FIXME logging?
return false;
}
if (!locator.hasBlockPos() || !locator.hasSide()) {
return false; // No block was clicked or the side is unknown
// FIXME: If no side is provided, should be try with INTERNAL???
}
TileEntity tileEntity = player.world.getTileEntity(locator.getBlockPos());
if (!(tileEntity instanceof IPartHost)) {
// FIXME logging?
return false; // Wrong tile entity at block position
}
IPartHost partHost = (IPartHost) tileEntity;
IPart part = partHost.getPart(locator.getSide());
if (!(partClass.isInstance(part))) {
// FIXME logging?
return false;
}
P actualPart = partClass.cast(tileEntity);
// 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
ITextComponent title = player.world.getBlockState(locator.getBlockPos()).getBlock().getNameTextComponent();
// FIXME: Check permissions...
if (requiredPermission != null) {
throw new IllegalStateException(); // NOT YET IMPLEMENTED
}
INamedContainerProvider container = new SimpleNamedContainerProvider(
(wnd, p, pl) -> {
C c = factory.create(wnd, p, actualPart);
// Set the original locator on the opened server-side container for it to more
// easily remember how to re-open after being closed.
c.setLocator(locator);
return c;
}, title
);
NetworkHooks.openGui((ServerPlayerEntity) player, container, locator.getBlockPos());
return true;
}
@FunctionalInterface
public interface ContainerFactory<T, C> {
C create(int windowId, PlayerInventory playerInv, T part);
}
}
@@ -0,0 +1,119 @@
package appeng.container.helper;
import appeng.api.config.SecurityPermissions;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator;
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.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.network.NetworkHooks;
/**
* Helper for containers that can be opened for a part <em>or</em> tile given that either
* implements a given interface.
*
* @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> {
private final Class<I> interfaceClass;
private final ContainerFactory<C, I> factory;
private final SecurityPermissions requiredPermission;
public PartOrTileContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass) {
this(factory, interfaceClass, null);
}
public PartOrTileContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass, SecurityPermissions requiredPermission) {
this.interfaceClass = interfaceClass;
this.factory = factory;
this.requiredPermission = requiredPermission;
}
/**
* Opens a container that is based around a single tile entity.
* The tile entity's position is encoded in the packet buffer.
*/
public C fromNetwork(int windowId, PlayerInventory inv, PacketBuffer packetBuf) {
I host = getHostFromLocator(inv.player, ContainerLocator.read(packetBuf));
if (host != null) {
return factory.create(windowId, inv, host);
}
return null;
}
public boolean open(PlayerEntity player, ContainerLocator locator) {
if (!(player instanceof ServerPlayerEntity)) {
// Cannot open containers on the client or for non-players
// FIXME logging?
return false;
}
I accessInterface = getHostFromLocator(player, locator);
// 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();
// FIXME: Check permissions...
if (requiredPermission != null) {
throw new IllegalStateException(); // NOT YET IMPLEMENTED
}
INamedContainerProvider container = new SimpleNamedContainerProvider(
(wnd, p, pl) -> {
C c = factory.create(wnd, p, accessInterface);
// Set the original locator on the opened server-side container for it to more
// easily remember how to re-open after being closed.
c.setLocator(locator);
return c;
}, title
);
NetworkHooks.openGui((ServerPlayerEntity) player, container, locator.getBlockPos());
return true;
}
private I getHostFromLocator(PlayerEntity player, ContainerLocator 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???
}
TileEntity tileEntity = player.world.getTileEntity(locator.getBlockPos());
// The tile entity itself can host a terminal (i.e. Chest!)
if (interfaceClass.isInstance(tileEntity)) {
return interfaceClass.cast(tileEntity);
} else if (tileEntity instanceof IPartHost) {
// But it could also be a part attached to the tile entity
IPartHost partHost = (IPartHost) tileEntity;
IPart part = partHost.getPart(locator.getSide());
if (interfaceClass.isInstance(part)) {
return interfaceClass.cast(part);
} else {
// FIXME: Logging?
return null;
}
} else {
// FIXME: Logging? Dont know how to obtain the terminal host
return null;
}
}
@FunctionalInterface
public interface ContainerFactory<C, I> {
C create(int windowId, PlayerInventory playerInv, I accessObj);
}
}
@@ -0,0 +1,91 @@
package appeng.container.helper;
import appeng.api.config.SecurityPermissions;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator;
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.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.network.NetworkHooks;
public final class TileContainerHelper<C extends AEBaseContainer, T extends TileEntity> {
private final Class<T> tileEntityClass;
private final ContainerFactory<T, C> factory;
private final SecurityPermissions requiredPermission;
public TileContainerHelper(ContainerFactory<T, C> factory, Class<T> tileEntityClass) {
this(factory, tileEntityClass, null);
}
public TileContainerHelper(ContainerFactory<T, C> factory, Class<T> tileEntityClass, SecurityPermissions requiredPermission) {
this.tileEntityClass = tileEntityClass;
this.factory = factory;
this.requiredPermission = requiredPermission;
}
/**
* Opens a container that is based around a single tile entity.
* The tile entity's position is encoded in the packet buffer.
*/
public C fromNetwork(int windowId, PlayerInventory inv, PacketBuffer packetBuf) {
BlockPos pos = packetBuf.readBlockPos();
TileEntity te = inv.player.world.getTileEntity(pos);
if (tileEntityClass.isInstance(te)) {
return factory.create(windowId, inv, tileEntityClass.cast(te));
}
return null;
}
public boolean open(PlayerEntity player, ContainerLocator locator) {
if (!(player instanceof ServerPlayerEntity)) {
// Cannot open containers on the client or for non-players
return false;
}
if (!locator.hasBlockPos()) {
return false; // No block was clicked
}
TileEntity tileEntity = player.world.getTileEntity(locator.getBlockPos());
if (!tileEntityClass.isInstance(tileEntity)) {
return false; // Wrong tile entity at block position
}
T te = tileEntityClass.cast(tileEntity);
// Use block name at position
ITextComponent title = player.world.getBlockState(locator.getBlockPos()).getBlock().getNameTextComponent();
// FIXME: Check permissions...
if (requiredPermission != null) {
throw new IllegalStateException(); // NOT YET IMPLEMENTED
}
INamedContainerProvider container = new SimpleNamedContainerProvider(
(wnd, p, pl) -> {
C c = factory.create(wnd, p, te);
// Set the original locator on the opened server-side container for it to more
// easily remember how to re-open after being closed.
c.setLocator(locator);
return c;
}, title
);
NetworkHooks.openGui((ServerPlayerEntity) player, container, locator.getBlockPos());
return true;
}
@FunctionalInterface
public interface ContainerFactory<T, C> {
C create(int windowId, PlayerInventory playerInv, T tileEntity);
}
}
@@ -21,13 +21,15 @@ package appeng.container.implementations;
import java.util.Iterator;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import appeng.core.Api;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.inventory.container.Slot;
import net.minecraft.inventory.container.*;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
@@ -54,18 +56,32 @@ import appeng.util.iterators.NullIterator;
public class ContainerCellWorkbench extends ContainerUpgradeable
{
public static ContainerType<ContainerCellWorkbench> TYPE;
private static final TileContainerHelper<ContainerCellWorkbench, TileCellWorkbench> helper
= new TileContainerHelper<>(ContainerCellWorkbench::new, TileCellWorkbench.class);
private final TileCellWorkbench workBench;
@GuiSync( 2 )
public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE;
private ItemStack prevStack = ItemStack.EMPTY;
private int lastUpgrades = 0;
public ContainerCellWorkbench(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileCellWorkbench te )
public ContainerCellWorkbench(int id, final PlayerInventory ip, final TileCellWorkbench te )
{
super( containerType, id, ip, te );
super( TYPE, id, ip, te );
this.workBench = te;
}
public static ContainerCellWorkbench fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
public void setFuzzy( final FuzzyMode valueOf )
{
final ICellWorkbenchItem cwi = this.workBench.getCell();
@@ -19,27 +19,43 @@
package appeng.container.implementations;
import appeng.api.config.SecurityPermissions;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.storage.TileChest;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
public class ContainerChest extends AEBaseContainer
{
private final TileChest chest;
public static ContainerType<ContainerChest> TYPE;
public ContainerChest( ContainerType<?> containerType, int id, final PlayerInventory ip, final TileChest chest )
private static final TileContainerHelper<ContainerChest, TileChest> helper
= new TileContainerHelper<>(ContainerChest::new, TileChest.class, SecurityPermissions.BUILD);
public ContainerChest( int id, final PlayerInventory ip, final TileChest chest )
{
super( containerType, id, ip, chest, null );
this.chest = chest;
super( TYPE, id, ip, chest, null );
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, this.chest.getInternalInventory(), 1, 80, 37, this
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, chest.getInternalInventory(), 1, 80, 37, this
.getPlayerInventory() ) );
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
}
public static ContainerChest fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
}
@@ -19,24 +19,32 @@
package appeng.container.implementations;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.CondenserOutput;
import appeng.api.config.Settings;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync;
import appeng.container.helper.TileContainerHelper;
import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.misc.TileCondenser;
import appeng.util.Platform;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.items.IItemHandler;
public class ContainerCondenser extends AEBaseContainer implements IProgressProvider
{
public static ContainerType<ContainerCondenser> TYPE;
private static final TileContainerHelper<ContainerCondenser, TileCondenser> helper
= new TileContainerHelper<>(ContainerCondenser::new, TileCondenser.class);
private final TileCondenser condenser;
@GuiSync( 0 )
public long requiredEnergy = 0;
@@ -45,9 +53,9 @@ public class ContainerCondenser extends AEBaseContainer implements IProgressProv
@GuiSync( 2 )
public CondenserOutput output = CondenserOutput.TRASH;
public ContainerCondenser(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileCondenser condenser )
public ContainerCondenser(int id, final PlayerInventory ip, final TileCondenser condenser )
{
super( containerType, id, ip, condenser, null );
super( TYPE, id, ip, condenser, null );
this.condenser = condenser;
IItemHandler inv = condenser.getInternalInventory();
@@ -60,6 +68,14 @@ public class ContainerCondenser extends AEBaseContainer implements IProgressProv
this.bindPlayerInventory( ip, 0, 197 - /* height of player inventory */82 );
}
public static ContainerCondenser fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
@Override
public void detectAndSendChanges()
{
@@ -21,9 +21,13 @@ package appeng.container.implementations;
import javax.annotation.Nonnull;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartOrTileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.Slot;
import net.minecraft.network.PacketBuffer;
import net.minecraft.world.World;
import appeng.api.config.SecurityPermissions;
@@ -41,16 +45,29 @@ import appeng.tile.inventory.AppEngInternalInventory;
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 final Slot craftingItem;
private IAEItemStack itemToCreate;
public ContainerCraftAmount(ContainerType<?> containerType, int id, PlayerInventory ip, final ITerminalHost te) {
super(containerType, id, ip, te);
public ContainerCraftAmount(int id, PlayerInventory ip, final ITerminalHost te) {
super(TYPE, id, ip, te);
this.craftingItem = new SlotInaccessible( new AppEngInternalInventory( null, 1 ), 0, 34, 53 );
this.addSlot( this.getCraftingItem() );
}
public static ContainerCraftAmount fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
@Override
public void detectAndSendChanges()
{
@@ -35,12 +35,20 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
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.core.AELog;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.me.helpers.PlayerSource;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
import appeng.util.Platform;
import com.google.common.collect.ImmutableSet;
import net.minecraft.entity.player.PlayerEntity;
@@ -48,6 +56,7 @@ import net.minecraft.entity.player.PlayerInventory;
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;
@@ -62,6 +71,19 @@ import java.util.concurrent.Future;
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);
public static ContainerCraftConfirm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final ArrayList<CraftingCPURecord> cpus = new ArrayList<>();
private Future<ICraftingJob> job;
private ICraftingJob result;
@@ -82,8 +104,8 @@ public class ContainerCraftConfirm extends AEBaseContainer
@GuiSync( 7 )
public String myName = "";
public ContainerCraftConfirm(ContainerType<?> containerType, int id, PlayerInventory ip, ITerminalHost te) {
super(containerType, id, ip, te);
public ContainerCraftConfirm(int id, PlayerInventory ip, ITerminalHost te) {
super(TYPE, id, ip, te);
}
public void cycleCpu( final boolean next )
@@ -314,28 +336,28 @@ public class ContainerCraftConfirm extends AEBaseContainer
public void startJob()
{
/* FIXME GuiBridge */ Object originalGui = null;
ContainerType<?> originalGui = null;
final IActionHost ah = this.getActionHost();
// FIXME if( ah instanceof WirelessTerminalGuiObject )
// FIXME {
// FIXME originalGui = GuiBridge.GUI_WIRELESS_TERM;
// FIXME }
// FIXME
// FIXME if( ah instanceof PartTerminal )
// FIXME {
// FIXME originalGui = GuiBridge.GUI_ME;
// FIXME }
// FIXME
// FIXME if( ah instanceof PartCraftingTerminal )
// FIXME {
// FIXME originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
// FIXME }
// FIXME
// FIXME if( ah instanceof PartPatternTerminal )
// FIXME {
// FIXME originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
// FIXME }
if( ah instanceof WirelessTerminalGuiObject)
{
originalGui = ContainerWirelessTerm.TYPE;
}
if( ah instanceof PartTerminal)
{
originalGui = ContainerMEMonitorable.TYPE;
}
if( ah instanceof PartCraftingTerminal)
{
originalGui = ContainerCraftingTerm.TYPE;
}
if( ah instanceof PartPatternTerminal)
{
originalGui = ContainerPatternTerm.TYPE;
}
if( this.result != null && !this.isSimulation() )
{
@@ -343,10 +365,9 @@ public class ContainerCraftConfirm extends AEBaseContainer
final ICraftingLink g = cc.submitJob( this.result, null, this.getSelectedCpu() == -1 ? null : this.cpus.get( this.getSelectedCpu() ).getCpu(), true,
this.getActionSrc() );
this.setAutoStart( false );
if( g != null && originalGui != null && this.getOpenContext() != null )
if( g != null && originalGui != null && this.getLocator() != null )
{
final TileEntity te = this.getOpenContext().getTile();
// FIXME Platform.openGUI( this.getPlayerInventory().player, te, this.getOpenContext().getSide(), originalGui );
ContainerOpener.openContainer(originalGui, getPlayerInventory().player, getLocator());
}
}
}
@@ -21,6 +21,9 @@ package appeng.container.implementations;
import java.io.IOException;
import appeng.api.config.SecurityPermissions;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import appeng.core.Api;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
@@ -49,12 +52,18 @@ import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.text.ITextComponent;
public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorHandlerReceiver<IAEItemStack>, ICustomNameObject
{
public static ContainerType<ContainerCraftingCPU> TYPE;
private static final TileContainerHelper<ContainerCraftingCPU, TileCraftingTile> helper
= new TileContainerHelper<>(ContainerCraftingCPU::new, TileCraftingTile.class, SecurityPermissions.CRAFT);
private final IItemList<IAEItemStack> list = Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createList();
private IGrid network;
private CraftingCPUCluster monitor = null;
@@ -63,6 +72,11 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
@GuiSync( 0 )
public long eta = -1;
private ContainerCraftingCPU(int id, final PlayerInventory ip, final TileCraftingTile te )
{
this( TYPE, id, ip, te );
}
public ContainerCraftingCPU(ContainerType<?> containerType, int id, final PlayerInventory ip, final Object te )
{
super( containerType, id, ip, te );
@@ -84,6 +98,14 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
}
}
public static ContainerCraftingCPU fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
protected void setCPU( final ICraftingCPU c )
{
if( c == this.getMonitor() )
@@ -100,14 +122,7 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
{
if( g instanceof PlayerEntity )
{
try
{
NetworkHandler.instance().sendTo( new PacketValueConfig( "CraftingStatus", "Clear" ), (ServerPlayerEntity) g );
}
catch( final IOException e )
{
AELog.debug( e );
}
NetworkHandler.instance().sendTo( new PacketValueConfig( "CraftingStatus", "Clear" ), (ServerPlayerEntity) g );
}
}
@@ -23,8 +23,13 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import appeng.api.config.SecurityPermissions;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartOrTileContainerHelper;
import appeng.container.helper.TileContainerHelper;
import com.google.common.collect.ImmutableSet;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import appeng.api.networking.crafting.ICraftingCPU;
@@ -33,11 +38,25 @@ import appeng.api.storage.ITerminalHost;
import appeng.container.guisync.GuiSync;
import appeng.util.Platform;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
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);
public static ContainerCraftingStatus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final List<CraftingCPURecord> cpus = new ArrayList<>();
@GuiSync( 5 )
public int selectedCpu = -1;
@@ -46,9 +65,9 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU
@GuiSync( 7 )
public String myName = "";
public ContainerCraftingStatus(ContainerType<?> containerType, int id, final PlayerInventory ip, final ITerminalHost te )
public ContainerCraftingStatus(int id, final PlayerInventory ip, final ITerminalHost te )
{
super( containerType, id, ip, te );
super( TYPE, id, ip, te );
}
@Override
@@ -19,6 +19,11 @@
package appeng.container.implementations;
import appeng.api.config.SecurityPermissions;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartOrTileContainerHelper;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.CraftingInventory;
@@ -26,6 +31,7 @@ import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.network.PacketBuffer;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
@@ -45,15 +51,28 @@ import appeng.util.inv.WrapperInvItemHandler;
public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IContainerCraftingPacket
{
public static ContainerType<ContainerCraftingTerm> TYPE;
private static final PartOrTileContainerHelper<ContainerCraftingTerm, ITerminalHost> helper
= new PartOrTileContainerHelper<>(ContainerCraftingTerm::new, ITerminalHost.class, SecurityPermissions.CRAFT);
public static ContainerCraftingTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final PartCraftingTerminal ct;
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 1 );
private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9];
private final SlotCraftingTerm outputSlot;
private IRecipe<CraftingInventory> currentRecipe;
public ContainerCraftingTerm(ContainerType<?> containerType, int id, final PlayerInventory ip, final ITerminalHost monitorable )
public ContainerCraftingTerm(int id, final PlayerInventory ip, final ITerminalHost monitorable )
{
super( containerType, id, ip, monitorable, false );
super( TYPE, id, ip, monitorable, false );
this.ct = (PartCraftingTerminal) monitorable;
final IItemHandler crafting = this.ct.getInventoryByName( "crafting" );
@@ -19,20 +19,37 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.storage.TileDrive;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
public class ContainerDrive extends AEBaseContainer
{
public ContainerDrive(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileDrive drive )
public static ContainerType<ContainerDrive> TYPE;
private static final TileContainerHelper<ContainerDrive, TileDrive> helper
= new TileContainerHelper<>(ContainerDrive::new, TileDrive.class);
public static ContainerDrive fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
public ContainerDrive(int id, final PlayerInventory ip, final TileDrive drive )
{
super( containerType, id, ip, drive, null );
super( TYPE, id, ip, drive, null );
for( int y = 0; y < 5; y++ )
{
@@ -45,4 +62,5 @@ public class ContainerDrive extends AEBaseContainer
this.bindPlayerInventory( ip, 0, 199 - /* height of player inventory */82 );
}
}
@@ -19,8 +19,12 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.FuzzyMode;
@@ -39,12 +43,25 @@ import appeng.util.Platform;
public class ContainerFormationPlane extends ContainerUpgradeable
{
public static ContainerType<ContainerFormationPlane> TYPE;
private static final PartContainerHelper<ContainerFormationPlane, PartFormationPlane> helper
= new PartContainerHelper<>(ContainerFormationPlane::new, PartFormationPlane.class, SecurityPermissions.BUILD);
public static ContainerFormationPlane fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
@GuiSync( 6 )
public YesNo placeMode;
public ContainerFormationPlane(ContainerType<?> containerType, int id, final PlayerInventory ip, final PartFormationPlane te )
public ContainerFormationPlane(int id, final PlayerInventory ip, final PartFormationPlane te )
{
super( containerType, id, ip, te );
super( TYPE, id, ip, te );
}
@Override
@@ -19,16 +19,12 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.inventory.container.SimpleNamedContainerProvider;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.items.IItemHandler;
import appeng.container.AEBaseContainer;
@@ -42,6 +38,17 @@ public class ContainerGrinder extends AEBaseContainer
public static ContainerType<ContainerGrinder> TYPE;
private static final TileContainerHelper<ContainerGrinder, TileGrinder> helper
= new TileContainerHelper<>(ContainerGrinder::new, TileGrinder.class);
public static ContainerGrinder fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
public ContainerGrinder(int id, final PlayerInventory ip, final TileGrinder grinder )
{
super( TYPE, id, ip, grinder, null );
@@ -61,21 +68,4 @@ public class ContainerGrinder extends AEBaseContainer
this.bindPlayerInventory( ip, 0, 176 - /* height of player inventory */82 );
}
public static ContainerGrinder fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
BlockPos pos = buf.readBlockPos();
TileEntity te = inv.player.world.getTileEntity(pos);
if (te instanceof TileGrinder) {
return new ContainerGrinder(windowId, inv, (TileGrinder) te);
}
return null;
}
public static void open(ServerPlayerEntity player, TileGrinder tile, ITextComponent title) {
BlockPos pos = tile.getPos();
INamedContainerProvider container = new SimpleNamedContainerProvider(
(wnd, p, pl) -> new ContainerGrinder(wnd, p, tile), title
);
NetworkHooks.openGui(player, container, pos);
}
}
@@ -19,8 +19,12 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.FullnessMode;
@@ -38,14 +42,27 @@ import appeng.util.Platform;
public class ContainerIOPort extends ContainerUpgradeable
{
public static ContainerType<ContainerIOPort> TYPE;
private static final TileContainerHelper<ContainerIOPort, TileIOPort> helper
= new TileContainerHelper<>(ContainerIOPort::new, TileIOPort.class, SecurityPermissions.BUILD);
public static ContainerIOPort fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
@GuiSync( 2 )
public FullnessMode fMode = FullnessMode.EMPTY;
@GuiSync( 3 )
public OperationMode opMode = OperationMode.EMPTY;
public ContainerIOPort(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileIOPort te )
public ContainerIOPort(int id, final PlayerInventory ip, final TileIOPort te )
{
super( containerType, id, ip, te );
super( TYPE, id, ip, te );
}
@Override
@@ -19,22 +19,25 @@
package appeng.container.implementations;
import appeng.api.definitions.IItemDefinition;
import appeng.api.features.IInscriberRecipe;
import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync;
import appeng.container.helper.TileContainerHelper;
import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.Api;
import appeng.tile.misc.TileInscriber;
import appeng.util.Platform;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.items.IItemHandler;
import appeng.api.definitions.IItemDefinition;
import appeng.api.features.IInscriberRecipe;
import appeng.container.guisync.GuiSync;
import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.misc.TileInscriber;
import appeng.util.Platform;
/**
* @author AlgorithmX2
@@ -45,6 +48,19 @@ import appeng.util.Platform;
public class ContainerInscriber extends ContainerUpgradeable implements IProgressProvider
{
public static ContainerType<ContainerInscriber> TYPE;
private static final TileContainerHelper<ContainerInscriber, TileInscriber> helper
= new TileContainerHelper<>(ContainerInscriber::new, TileInscriber.class);
public static ContainerInscriber fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final TileInscriber ti;
private final Slot top;
@@ -57,9 +73,9 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
@GuiSync( 3 )
public int processingTime = -1;
public ContainerInscriber(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileInscriber te )
public ContainerInscriber(int id, final PlayerInventory ip, final TileInscriber te )
{
super( containerType, id, ip, te );
super( TYPE, id, ip, te );
this.ti = te;
IItemHandler inv = te.getInternalInventory();
@@ -19,6 +19,9 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartOrTileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import appeng.api.config.SecurityPermissions;
@@ -32,11 +35,25 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
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);
public static ContainerInterface fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final DualityInterface myDuality;
@GuiSync( 3 )
@@ -45,9 +62,9 @@ public class ContainerInterface extends ContainerUpgradeable
@GuiSync( 4 )
public YesNo iTermMode = YesNo.YES;
public ContainerInterface(ContainerType<?> containerType, int id, final PlayerInventory ip, final IInterfaceHost te )
public ContainerInterface(int id, final PlayerInventory ip, final IInterfaceHost te )
{
super( containerType, id, ip, te.getInterfaceDuality().getHost() );
super( TYPE, id, ip, te.getInterfaceDuality().getHost() );
this.myDuality = te.getInterfaceDuality();
@@ -24,11 +24,17 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import appeng.api.config.SecurityPermissions;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartContainerHelper;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.Settings;
@@ -60,6 +66,19 @@ import appeng.util.inv.filter.IAEItemFilter;
public final class ContainerInterfaceTerminal extends AEBaseContainer
{
public static ContainerType<ContainerInterfaceTerminal> TYPE;
private static final PartContainerHelper<ContainerInterfaceTerminal, PartInterfaceTerminal> helper
= new PartContainerHelper<>(ContainerInterfaceTerminal::new, PartInterfaceTerminal.class, SecurityPermissions.BUILD);
public static ContainerInterfaceTerminal fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
/**
* this stuff is all server side..
*/
@@ -70,9 +89,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
private IGrid grid;
private CompoundNBT data = new CompoundNBT();
public ContainerInterfaceTerminal(ContainerType<?> containerType, int id, final PlayerInventory ip, final PartInterfaceTerminal anchor )
public ContainerInterfaceTerminal(int id, final PlayerInventory ip, final PartInterfaceTerminal anchor )
{
super( containerType, id, ip, anchor );
super( TYPE, id, ip, anchor );
if( Platform.isServer() )
{
@@ -19,10 +19,14 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartContainerHelper;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
@@ -43,6 +47,19 @@ import appeng.util.Platform;
public class ContainerLevelEmitter extends ContainerUpgradeable
{
public static ContainerType<ContainerLevelEmitter> TYPE;
private static final PartContainerHelper<ContainerLevelEmitter, PartLevelEmitter> helper
= new PartContainerHelper<>(ContainerLevelEmitter::new, PartLevelEmitter.class, SecurityPermissions.BUILD);
public static ContainerLevelEmitter fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final PartLevelEmitter lvlEmitter;
@OnlyIn( Dist.CLIENT )
@@ -54,9 +71,9 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
@GuiSync( 4 )
public YesNo cmType;
public ContainerLevelEmitter( ContainerType<?> containerType, int id, final PlayerInventory ip, final PartLevelEmitter te )
public ContainerLevelEmitter( int id, final PlayerInventory ip, final PartLevelEmitter te )
{
super( containerType, id, ip, te );
super( TYPE, id, ip, te );
this.lvlEmitter = te;
}
@@ -19,17 +19,13 @@
package appeng.container.implementations;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync;
import appeng.container.helper.TileContainerHelper;
import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.SlotMACPattern;
import appeng.container.slot.SlotOutput;
@@ -37,19 +33,39 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.items.misc.ItemEncodedPattern;
import appeng.tile.crafting.TileMolecularAssembler;
import appeng.util.Platform;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
public class ContainerMAC extends ContainerUpgradeable implements IProgressProvider
{
public static ContainerType<ContainerMAC> TYPE;
private static final TileContainerHelper<ContainerMAC, TileMolecularAssembler> helper
= new TileContainerHelper<>(ContainerMAC::new, TileMolecularAssembler.class);
public static ContainerMAC fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private static final int MAX_CRAFT_PROGRESS = 100;
private final TileMolecularAssembler tma;
@GuiSync( 4 )
public int craftProgress = 0;
public ContainerMAC(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileMolecularAssembler te )
public ContainerMAC(int id, final PlayerInventory ip, final TileMolecularAssembler te )
{
super( containerType, id, ip, te );
super( TYPE, id, ip, te );
this.tma = te;
}
@@ -24,6 +24,8 @@ import java.nio.BufferOverflowException;
import javax.annotation.Nonnull;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartOrTileContainerHelper;
import appeng.core.Api;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
@@ -31,6 +33,7 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import appeng.api.config.Actionable;
@@ -77,6 +80,19 @@ import appeng.util.Platform;
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack>
{
public static ContainerType<ContainerMEMonitorable> TYPE;
private static final PartOrTileContainerHelper<ContainerMEMonitorable, ITerminalHost> helper
= new PartOrTileContainerHelper<>(ContainerMEMonitorable::new, ITerminalHost.class);
public static ContainerMEMonitorable fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
private final IMEMonitor<IAEItemStack> monitor;
private final IItemList<IAEItemStack> items = Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createList();
@@ -90,10 +106,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
private IConfigManager serverCM;
private IGridNode networkNode;
public ContainerMEMonitorable( ContainerType<?> containerType, int id, final PlayerInventory ip, final ITerminalHost monitorable )
public ContainerMEMonitorable( int id, final PlayerInventory ip, final ITerminalHost monitorable )
{
this( containerType, id, ip, monitorable, true );
this( TYPE, id, ip, monitorable, true );
}
public ContainerMEMonitorable(ContainerType<?> containerType, int id, PlayerInventory ip, final ITerminalHost monitorable, final boolean bindInventory ) {
@@ -211,14 +226,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
{
if( crafter instanceof ServerPlayerEntity )
{
try
{
NetworkHandler.instance().sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (ServerPlayerEntity) crafter );
}
catch( final IOException e )
{
AELog.debug( e );
}
NetworkHandler.instance().sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (ServerPlayerEntity) crafter );
}
}
}
@@ -19,6 +19,9 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartOrTileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
@@ -27,20 +30,39 @@ import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.interfaces.IInventorySlotAware;
import net.minecraft.network.PacketBuffer;
public class ContainerMEPortableCell extends ContainerMEMonitorable
{
public static ContainerType<ContainerMEPortableCell> TYPE;
private static final PartOrTileContainerHelper<ContainerMEPortableCell, IPortableCell> helper
= new PartOrTileContainerHelper<>(ContainerMEPortableCell::new, IPortableCell.class);
public static ContainerMEPortableCell fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private double powerMultiplier = 0.5;
private final IPortableCell civ;
private int ticks = 0;
private final int slot;
public ContainerMEPortableCell(ContainerType<?> containerType, int id, final PlayerInventory ip, final IPortableCell monitorable )
public ContainerMEPortableCell(int id, final PlayerInventory ip, final IPortableCell monitorable )
{
super( containerType, id, ip, monitorable, false );
this(TYPE, id, ip, monitorable);
}
protected ContainerMEPortableCell(ContainerType<? extends ContainerMEPortableCell> type, int id, final PlayerInventory ip, final IPortableCell monitorable )
{
super( type, id, ip, monitorable, false );
if( monitorable instanceof IInventorySlotAware )
{
final int slotIndex = ( (IInventorySlotAware) monitorable ).getInventorySlot();
@@ -21,7 +21,9 @@ package appeng.container.implementations;
import java.io.IOException;
import appeng.api.parts.IPart;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartOrTileContainerHelper;
import appeng.container.helper.TileContainerHelper;
import appeng.core.Api;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
@@ -29,7 +31,6 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridBlock;
@@ -46,12 +47,25 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.network.PacketBuffer;
public class ContainerNetworkStatus extends AEBaseContainer
{
public static ContainerType<ContainerNetworkStatus> TYPE;
private static final PartOrTileContainerHelper<ContainerNetworkStatus, INetworkTool> helper
= new PartOrTileContainerHelper<>(ContainerNetworkStatus::new, INetworkTool.class);
public static ContainerNetworkStatus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
@GuiSync( 0 )
public long avgAddition;
@GuiSync( 1 )
@@ -63,8 +77,8 @@ public class ContainerNetworkStatus extends AEBaseContainer
private IGrid network;
private int delay = 40;
public ContainerNetworkStatus(ContainerType<?> containerType, int id, PlayerInventory ip, final INetworkTool te) {
super(containerType, id, ip, null, null);
public ContainerNetworkStatus(int id, PlayerInventory ip, final INetworkTool te) {
super(TYPE, id, ip, null, null);
final IGridHost host = te.getGridHost();
if( host != null )
@@ -19,28 +19,45 @@
package appeng.container.implementations;
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.slot.SlotRestrictedInput;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import net.minecraft.network.PacketBuffer;
public class ContainerNetworkTool extends AEBaseContainer
{
public static ContainerType<ContainerNetworkTool> TYPE;
private static final PartOrTileContainerHelper<ContainerNetworkTool, INetworkTool> helper
= new PartOrTileContainerHelper<>(ContainerNetworkTool::new, INetworkTool.class);
public static ContainerNetworkTool fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final INetworkTool toolInv;
@GuiSync( 1 )
public boolean facadeMode;
public ContainerNetworkTool(ContainerType<?> containerType, int id, final PlayerInventory ip, final INetworkTool te )
public ContainerNetworkTool(int id, final PlayerInventory ip, final INetworkTool te )
{
super( containerType, id, ip, null, null );
super( TYPE, id, ip, null, null );
this.toolInv = te;
this.lockPlayerInventorySlot( ip.currentItem );
@@ -20,14 +20,18 @@ package appeng.container.implementations;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
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.slot.*;
import appeng.core.Api;
import appeng.core.sync.packets.PacketPatternSlot;
@@ -58,6 +62,7 @@ import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
@@ -70,6 +75,19 @@ import java.util.Optional;
public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket
{
public static ContainerType<ContainerPatternTerm> TYPE;
private static final PartOrTileContainerHelper<ContainerPatternTerm, ITerminalHost> helper
= new PartOrTileContainerHelper<>(ContainerPatternTerm::new, ITerminalHost.class, SecurityPermissions.CRAFT);
public static ContainerPatternTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final PartPatternTerminal patternTerminal;
private final AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 );
private final IItemHandler crafting;
@@ -85,9 +103,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
@GuiSync( 96 )
public boolean substitute = false;
public ContainerPatternTerm(ContainerType<?> type, int id, final PlayerInventory ip, final ITerminalHost monitorable )
public ContainerPatternTerm(int id, final PlayerInventory ip, final ITerminalHost monitorable )
{
super( type, id, ip, monitorable, false );
super( TYPE, id, ip, monitorable, false );
this.patternTerminal = (PartPatternTerminal) monitorable;
final IItemHandler patternInv = this.getPatternTerminal().getInventoryByName( "pattern" );
@@ -19,10 +19,13 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartOrTileContainerHelper;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -38,6 +41,19 @@ import appeng.util.Platform;
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);
public static ContainerPriority fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final IPriorityHost priHost;
@OnlyIn( Dist.CLIENT )
@@ -45,9 +61,9 @@ public class ContainerPriority extends AEBaseContainer
@GuiSync( 2 )
public long PriorityValue = -1;
public ContainerPriority(ContainerType<?> containerType, int id, final PlayerInventory ip, final IPriorityHost te )
public ContainerPriority(int id, final PlayerInventory ip, final IPriorityHost te )
{
super( containerType, id, ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) );
super( TYPE, id, ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) );
this.priHost = te;
}
@@ -19,24 +19,43 @@
package appeng.container.implementations;
import appeng.api.config.SecurityPermissions;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.qnb.TileQuantumBridge;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
public class ContainerQNB extends AEBaseContainer
{
public ContainerQNB(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileQuantumBridge quantumBridge )
public static ContainerType<ContainerQNB> TYPE;
private static final TileContainerHelper<ContainerQNB, TileQuantumBridge> helper
= new TileContainerHelper<>(ContainerQNB::new, TileQuantumBridge.class, SecurityPermissions.BUILD);
public static ContainerQNB fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
public ContainerQNB(int id, final PlayerInventory ip, final TileQuantumBridge quantumBridge )
{
super( containerType, id, ip, quantumBridge, null );
super( TYPE, id, ip, quantumBridge, null );
this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge
.getInternalInventory(), 0, 80, 37, this.getPlayerInventory() ) ).setStackLimit( 1 ) );
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
}
}
@@ -21,12 +21,15 @@ package appeng.container.implementations;
import javax.annotation.Nonnull;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartOrTileContainerHelper;
import appeng.core.Api;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import net.minecraftforge.items.IItemHandler;
@@ -42,14 +45,27 @@ import appeng.util.Platform;
public class ContainerQuartzKnife extends AEBaseContainer
{
public static ContainerType<ContainerQuartzKnife> TYPE;
private static final PartOrTileContainerHelper<ContainerQuartzKnife, QuartzKnifeObj> helper
= new PartOrTileContainerHelper<>(ContainerQuartzKnife::new, QuartzKnifeObj.class);
public static ContainerQuartzKnife fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final QuartzKnifeObj toolInv;
private final IItemHandler inSlot = new AppEngInternalInventory( null, 1, 1 );
private String myName = "";
public ContainerQuartzKnife(ContainerType<?> containerType, int id, final PlayerInventory ip, final QuartzKnifeObj te )
public ContainerQuartzKnife(int id, final PlayerInventory ip, final QuartzKnifeObj te )
{
super( containerType, id, ip, null, null );
super( TYPE, id, ip, null, null );
this.toolInv = te;
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.METAL_INGOTS, this.inSlot, 0, 94, 44, ip ) );
@@ -19,12 +19,16 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartOrTileContainerHelper;
import appeng.container.helper.TileContainerHelper;
import appeng.core.Api;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.IContainerListener;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.SecurityPermissions;
@@ -44,6 +48,11 @@ import appeng.util.inv.InvOperation;
public class ContainerSecurityStation extends ContainerMEMonitorable implements IAEAppEngInventory
{
public static ContainerType<ContainerSecurityStation> TYPE;
private static final PartOrTileContainerHelper<ContainerSecurityStation, ITerminalHost> helper
= new PartOrTileContainerHelper<>(ContainerSecurityStation::new, ITerminalHost.class, SecurityPermissions.SECURITY);
private final SlotRestrictedInput configSlot;
private final AppEngInternalInventory wirelessEncoder = new AppEngInternalInventory( this, 2 );
@@ -55,9 +64,9 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
@GuiSync( 0 )
public int permissionMode = 0;
public ContainerSecurityStation(ContainerType<?> containerType, int id, final PlayerInventory ip, final ITerminalHost monitorable )
public ContainerSecurityStation(int id, final PlayerInventory ip, final ITerminalHost monitorable )
{
super( containerType, id, ip, monitorable, false );
super( TYPE, id, ip, monitorable, false );
this.securityBox = (TileSecurityStation) monitorable;
@@ -71,6 +80,14 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
this.bindPlayerInventory( ip, 0, 0 );
}
public static ContainerSecurityStation fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
public void toggleSetting( final String value, final PlayerEntity player )
{
try
@@ -19,28 +19,26 @@
package appeng.container.implementations;
import appeng.core.AppEng;
import net.minecraft.client.Minecraft;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import appeng.tile.storage.TileSkyChest;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.inventory.container.SimpleNamedContainerProvider;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.network.NetworkHooks;
public class ContainerSkyChest extends AEBaseContainer
{
public static ContainerType<ContainerSkyChest> TYPE;
public static ContainerType<ContainerSkyChest> TYPE;
private static final TileContainerHelper<ContainerSkyChest, TileSkyChest> helper
= new TileContainerHelper<>(ContainerSkyChest::new, TileSkyChest.class);
private final TileSkyChest chest;
@@ -63,20 +61,11 @@ public class ContainerSkyChest extends AEBaseContainer
}
public static ContainerSkyChest fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
BlockPos pos = buf.readBlockPos();
TileEntity te = inv.player.world.getTileEntity(pos);
if (te instanceof TileSkyChest) {
return new ContainerSkyChest(windowId, inv, (TileSkyChest) te);
}
return null;
return helper.fromNetwork(windowId, inv, buf);
}
public static void open(ServerPlayerEntity player, TileSkyChest tile, ITextComponent title) {
BlockPos pos = tile.getPos();
INamedContainerProvider container = new SimpleNamedContainerProvider(
(wnd, p, pl) -> new ContainerSkyChest(wnd, p, tile), title
);
NetworkHooks.openGui(player, container, pos);
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
@Override
@@ -19,6 +19,9 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import appeng.api.config.SecurityPermissions;
@@ -34,11 +37,17 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
public class ContainerSpatialIOPort extends AEBaseContainer
{
public static ContainerType<ContainerSpatialIOPort> TYPE;
private static final TileContainerHelper<ContainerSpatialIOPort, TileSpatialIOPort> helper
= new TileContainerHelper<>(ContainerSpatialIOPort::new, TileSpatialIOPort.class, SecurityPermissions.BUILD);
@GuiSync( 0 )
public long currentPower;
@GuiSync( 1 )
@@ -57,9 +66,9 @@ public class ContainerSpatialIOPort extends AEBaseContainer
@GuiSync( 33 )
public int zSize;
public ContainerSpatialIOPort(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileSpatialIOPort spatialIOPort )
public ContainerSpatialIOPort(int id, final PlayerInventory ip, final TileSpatialIOPort spatialIOPort )
{
super( containerType, id, ip, spatialIOPort, null );
super( TYPE, id, ip, spatialIOPort, null );
if( Platform.isServer() )
{
@@ -74,6 +83,14 @@ public class ContainerSpatialIOPort extends AEBaseContainer
this.bindPlayerInventory( ip, 0, 197 - /* height of player inventory */82 );
}
public static ContainerSpatialIOPort fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
@Override
public void detectAndSendChanges()
{
@@ -21,10 +21,15 @@ package appeng.container.implementations;
import java.util.Iterator;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartContainerHelper;
import appeng.container.helper.TileContainerHelper;
import appeng.core.Api;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.AccessRestriction;
@@ -50,6 +55,19 @@ import appeng.util.iterators.NullIterator;
public class ContainerStorageBus extends ContainerUpgradeable
{
public static ContainerType<ContainerStorageBus> TYPE;
private static final PartContainerHelper<ContainerStorageBus, PartStorageBus> helper
= new PartContainerHelper<>(ContainerStorageBus::new, PartStorageBus.class, SecurityPermissions.BUILD);
public static ContainerStorageBus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final PartStorageBus storageBus;
@GuiSync( 3 )
@@ -58,9 +76,9 @@ public class ContainerStorageBus extends ContainerUpgradeable
@GuiSync( 4 )
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
public ContainerStorageBus(ContainerType<?> containerType, int id, final PlayerInventory ip, final PartStorageBus te )
public ContainerStorageBus(int id, final PlayerInventory ip, final PartStorageBus te )
{
super( containerType, id, ip, te );
super( TYPE, id, ip, te );
this.storageBus = te;
}
@@ -19,12 +19,21 @@
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 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;
@@ -55,6 +64,19 @@ import appeng.util.Platform;
public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSlotHost
{
public static ContainerType<ContainerUpgradeable> TYPE;
private static final PartOrTileContainerHelper<ContainerUpgradeable, IUpgradeableHost> helper
= new PartOrTileContainerHelper<>(ContainerUpgradeable::new, IUpgradeableHost.class, SecurityPermissions.BUILD);
public static ContainerUpgradeable fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final IUpgradeableHost upgradeable;
@GuiSync( 0 )
public RedstoneMode rsMode = RedstoneMode.IGNORE;
@@ -67,6 +89,11 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
private int tbSlot;
private NetworkToolViewer tbInventory;
public ContainerUpgradeable(int id, final PlayerInventory ip, final IUpgradeableHost te )
{
this(TYPE, id, ip, te);
}
public ContainerUpgradeable(ContainerType<?> containerType, int id, final PlayerInventory ip, final IUpgradeableHost te )
{
super( containerType, id, ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) );
@@ -19,6 +19,9 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import appeng.container.AEBaseContainer;
@@ -28,19 +31,34 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.misc.TileVibrationChamber;
import appeng.util.Platform;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
public class ContainerVibrationChamber extends AEBaseContainer implements IProgressProvider
{
public static ContainerType<ContainerVibrationChamber> TYPE;
private static final TileContainerHelper<ContainerVibrationChamber, TileVibrationChamber> helper
= new TileContainerHelper<>(ContainerVibrationChamber::new, TileVibrationChamber.class);
public static ContainerVibrationChamber fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final TileVibrationChamber vibrationChamber;
@GuiSync( 0 )
public int burnSpeed = 0;
@GuiSync( 1 )
public int remainingBurnTime = 0;
public ContainerVibrationChamber(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileVibrationChamber vibrationChamber )
public ContainerVibrationChamber(int id, final PlayerInventory ip, final TileVibrationChamber vibrationChamber )
{
super( containerType, id, ip, vibrationChamber, null );
super( TYPE, id, ip, vibrationChamber, null );
this.vibrationChamber = vibrationChamber;
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.FUEL, vibrationChamber.getInternalInventory(), 0, 80, 37, this
@@ -19,6 +19,10 @@
package appeng.container.implementations;
import appeng.api.config.SecurityPermissions;
import appeng.container.ContainerLocator;
import appeng.container.helper.TileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import appeng.container.AEBaseContainer;
@@ -27,24 +31,36 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig;
import appeng.tile.networking.TileWireless;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
public class ContainerWireless extends AEBaseContainer
{
private final TileWireless wirelessTerminal;
public static ContainerType<ContainerWireless> TYPE;
private static final TileContainerHelper<ContainerWireless, TileWireless> helper
= new TileContainerHelper<>(ContainerWireless::new, TileWireless.class, SecurityPermissions.BUILD);
public static ContainerWireless fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final SlotRestrictedInput boosterSlot;
@GuiSync( 1 )
public long range = 0;
@GuiSync( 2 )
public long drain = 0;
public ContainerWireless(ContainerType<?> containerType, int id, final PlayerInventory ip, final TileWireless te )
public ContainerWireless(int id, final PlayerInventory ip, final TileWireless te )
{
super( containerType, id, ip, te, null );
this.wirelessTerminal = te;
super( TYPE, id, ip, te, null );
this.addSlot( this.boosterSlot = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.RANGE_BOOSTER, this.wirelessTerminal
this.addSlot( this.boosterSlot = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.RANGE_BOOSTER, te
.getInternalInventory(), 0, 80, 47, this.getPlayerInventory() ) );
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
@@ -19,6 +19,10 @@
package appeng.container.implementations;
import appeng.container.ContainerLocator;
import appeng.container.helper.PartContainerHelper;
import appeng.container.helper.PartOrTileContainerHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import appeng.core.AEConfig;
@@ -26,16 +30,30 @@ import appeng.core.localization.PlayerMessages;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.util.Platform;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.network.PacketBuffer;
public class ContainerWirelessTerm extends ContainerMEPortableCell
{
public static ContainerType<ContainerWirelessTerm> TYPE;
private static final PartOrTileContainerHelper<ContainerWirelessTerm, WirelessTerminalGuiObject> helper
= new PartOrTileContainerHelper<>(ContainerWirelessTerm::new, WirelessTerminalGuiObject.class);
public static ContainerWirelessTerm fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
return helper.fromNetwork(windowId, inv, buf);
}
public static boolean open(PlayerEntity player, ContainerLocator locator) {
return helper.open(player, locator);
}
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
public ContainerWirelessTerm(ContainerType<?> containerType, int id, final PlayerInventory ip, final WirelessTerminalGuiObject gui )
public ContainerWirelessTerm(int id, final PlayerInventory ip, final WirelessTerminalGuiObject gui )
{
super( containerType, id, ip, gui );
super( TYPE, id, ip, gui );
this.wirelessTerminalGUIObject = gui;
}
@@ -22,12 +22,12 @@ package appeng.container.implementations;
import javax.annotation.Nonnull;
import appeng.api.networking.crafting.ICraftingCPU;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.util.text.ITextComponent;
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
{
private final ITextComponent myName;
private final ICraftingCPU cpu;
private final long size;