pick 97420a31d The big reformat of 2020
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,13 +18,10 @@
|
||||
|
||||
package appeng.container;
|
||||
|
||||
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.parts.AEBasePart;
|
||||
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;
|
||||
@@ -34,14 +31,19 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.parts.AEBasePart;
|
||||
|
||||
/**
|
||||
* Describes how a container the player has opened was originally
|
||||
* located. This can be one of three ways:
|
||||
* 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>
|
||||
* <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 {
|
||||
@@ -52,13 +54,10 @@ public final class ContainerLocator {
|
||||
*/
|
||||
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.
|
||||
* 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
|
||||
PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, BLOCK, PART
|
||||
}
|
||||
|
||||
private final Type type;
|
||||
@@ -92,8 +91,9 @@ public final class ContainerLocator {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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();
|
||||
@@ -103,7 +103,8 @@ public final class ContainerLocator {
|
||||
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);
|
||||
return new ContainerLocator(Type.PLAYER_INVENTORY_WITH_BLOCK_CONTEXT, slot, dimensionId, context.getPos(),
|
||||
side);
|
||||
}
|
||||
|
||||
public static ContainerLocator forHand(PlayerEntity player, Hand hand) {
|
||||
@@ -128,13 +129,8 @@ public final class ContainerLocator {
|
||||
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()
|
||||
);
|
||||
return new ContainerLocator(Type.PART, -1, pos.getWorld().getDimension().getType().getId(), pos.getBlockPos(),
|
||||
part.getSide());
|
||||
}
|
||||
|
||||
public boolean hasItemIndex() {
|
||||
@@ -201,37 +197,15 @@ public final class ContainerLocator {
|
||||
byte type = buf.readByte();
|
||||
switch (type) {
|
||||
case 0:
|
||||
return new ContainerLocator(
|
||||
Type.PLAYER_INVENTORY,
|
||||
buf.readInt(),
|
||||
-1,
|
||||
null,
|
||||
null
|
||||
);
|
||||
return new ContainerLocator(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()]
|
||||
);
|
||||
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,
|
||||
buf.readInt(),
|
||||
buf.readBlockPos(),
|
||||
null
|
||||
);
|
||||
return new ContainerLocator(Type.BLOCK, -1, buf.readInt(), buf.readBlockPos(), null);
|
||||
case 3:
|
||||
return new ContainerLocator(
|
||||
Type.PART,
|
||||
-1,
|
||||
buf.readInt(),
|
||||
buf.readBlockPos(),
|
||||
AEPartLocation.values()[buf.readByte()]
|
||||
);
|
||||
return new ContainerLocator(Type.PART, -1, buf.readInt(), buf.readBlockPos(),
|
||||
AEPartLocation.values()[buf.readByte()]);
|
||||
default:
|
||||
throw new DecoderException("ContainerLocator type out of range: " + type);
|
||||
}
|
||||
|
||||
@@ -18,25 +18,20 @@
|
||||
|
||||
package appeng.container;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
|
||||
|
||||
/*
|
||||
* Totally useless container that does nothing.
|
||||
*/
|
||||
public class ContainerNull extends Container
|
||||
{
|
||||
public class ContainerNull extends Container {
|
||||
|
||||
public ContainerNull()
|
||||
{
|
||||
super( null, 0 );
|
||||
}
|
||||
public ContainerNull() {
|
||||
super(null, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith( final PlayerEntity PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(final PlayerEntity PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package appeng.container;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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;
|
||||
import appeng.core.AELog;
|
||||
|
||||
/**
|
||||
* Allows opening containers generically.
|
||||
|
||||
@@ -18,21 +18,18 @@
|
||||
|
||||
package appeng.container.guisync;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* Annotates that this field should be synchronized between the server and client.
|
||||
* Requires the field to be public.
|
||||
* Annotates that this field should be synchronized between the server and
|
||||
* client. Requires the field to be public.
|
||||
*/
|
||||
@Retention( RetentionPolicy.RUNTIME )
|
||||
@Target( ElementType.FIELD )
|
||||
public @interface GuiSync
|
||||
{
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface GuiSync {
|
||||
|
||||
int value();
|
||||
int value();
|
||||
}
|
||||
|
||||
@@ -18,187 +18,129 @@
|
||||
|
||||
package appeng.container.guisync;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.IContainerListener;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketProgressBar;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.IContainerListener;
|
||||
|
||||
public class SyncData {
|
||||
|
||||
public class SyncData
|
||||
{
|
||||
private final AEBaseContainer source;
|
||||
private final Field field;
|
||||
private final int channel;
|
||||
private Object clientVersion;
|
||||
|
||||
private final AEBaseContainer source;
|
||||
private final Field field;
|
||||
private final int channel;
|
||||
private Object clientVersion;
|
||||
public SyncData(final AEBaseContainer container, final Field field, final GuiSync annotation) {
|
||||
this.clientVersion = null;
|
||||
this.source = container;
|
||||
this.field = field;
|
||||
this.channel = annotation.value();
|
||||
}
|
||||
|
||||
public SyncData( final AEBaseContainer container, final Field field, final GuiSync annotation )
|
||||
{
|
||||
this.clientVersion = null;
|
||||
this.source = container;
|
||||
this.field = field;
|
||||
this.channel = annotation.value();
|
||||
}
|
||||
public int getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
public int getChannel()
|
||||
{
|
||||
return this.channel;
|
||||
}
|
||||
public void tick(final IContainerListener c) {
|
||||
try {
|
||||
final Object val = this.field.get(this.source);
|
||||
if (val != null && this.clientVersion == null) {
|
||||
this.send(c, val);
|
||||
} else if (!val.equals(this.clientVersion)) {
|
||||
this.send(c, val);
|
||||
}
|
||||
} catch (final IllegalArgumentException | IllegalAccessException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
|
||||
public void tick( final IContainerListener c )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Object val = this.field.get( this.source );
|
||||
if( val != null && this.clientVersion == null )
|
||||
{
|
||||
this.send( c, val );
|
||||
}
|
||||
else if( !val.equals( this.clientVersion ) )
|
||||
{
|
||||
this.send( c, val );
|
||||
}
|
||||
}
|
||||
catch( final IllegalArgumentException | IllegalAccessException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void send(final IContainerListener o, final Object val) {
|
||||
if (val instanceof String) {
|
||||
if (o instanceof ServerPlayerEntity) {
|
||||
NetworkHandler.instance().sendTo(new PacketValueConfig("SyncDat." + this.channel, (String) val),
|
||||
(ServerPlayerEntity) o);
|
||||
}
|
||||
} else if (this.field.getType().isEnum()) {
|
||||
o.sendWindowProperty(this.source, this.channel, ((Enum) val).ordinal());
|
||||
} else if (val instanceof Long || val.getClass() == long.class) {
|
||||
if (o instanceof ServerPlayerEntity) {
|
||||
NetworkHandler.instance().sendTo(new PacketProgressBar(this.channel, (Long) val),
|
||||
(ServerPlayerEntity) o);
|
||||
}
|
||||
} else if (val instanceof Boolean || val.getClass() == boolean.class) {
|
||||
o.sendWindowProperty(this.source, this.channel, ((Boolean) val) ? 1 : 0);
|
||||
} else {
|
||||
o.sendWindowProperty(this.source, this.channel, (Integer) val);
|
||||
}
|
||||
|
||||
private void send( final IContainerListener o, final Object val )
|
||||
{
|
||||
if( val instanceof String )
|
||||
{
|
||||
if( o instanceof ServerPlayerEntity)
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketValueConfig( "SyncDat." + this.channel, (String) val ), (ServerPlayerEntity) o );
|
||||
}
|
||||
}
|
||||
else if( this.field.getType().isEnum() )
|
||||
{
|
||||
o.sendWindowProperty( this.source, this.channel, ( (Enum) val ).ordinal() );
|
||||
}
|
||||
else if( val instanceof Long || val.getClass() == long.class )
|
||||
{
|
||||
if( o instanceof ServerPlayerEntity )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketProgressBar( this.channel, (Long) val ), (ServerPlayerEntity) o );
|
||||
}
|
||||
}
|
||||
else if( val instanceof Boolean || val.getClass() == boolean.class )
|
||||
{
|
||||
o.sendWindowProperty( this.source, this.channel, ( (Boolean) val ) ? 1 : 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
o.sendWindowProperty( this.source, this.channel, (Integer) val );
|
||||
}
|
||||
this.clientVersion = val;
|
||||
}
|
||||
|
||||
this.clientVersion = val;
|
||||
}
|
||||
public void update(final Object val) {
|
||||
try {
|
||||
final Object oldValue = this.field.get(this.source);
|
||||
if (val instanceof String) {
|
||||
this.updateString(oldValue, (String) val);
|
||||
} else {
|
||||
this.updateValue(oldValue, (Long) val);
|
||||
}
|
||||
} catch (final IllegalArgumentException e) {
|
||||
AELog.debug(e);
|
||||
} catch (final IllegalAccessException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void update( final Object val )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Object oldValue = this.field.get( this.source );
|
||||
if( val instanceof String )
|
||||
{
|
||||
this.updateString( oldValue, (String) val );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.updateValue( oldValue, (Long) val );
|
||||
}
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
private void updateString(final Object oldValue, final String val) {
|
||||
try {
|
||||
this.field.set(this.source, val);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
AELog.debug(e);
|
||||
} catch (final IllegalAccessException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateString( final Object oldValue, final String val )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.field.set( this.source, val );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
private void updateValue(final Object oldValue, final long val) {
|
||||
try {
|
||||
if (this.field.getType().isEnum()) {
|
||||
final EnumSet<? extends Enum> valList = EnumSet.allOf((Class<? extends Enum>) this.field.getType());
|
||||
for (final Enum e : valList) {
|
||||
if (e.ordinal() == val) {
|
||||
this.field.set(this.source, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.field.getType().equals(int.class)) {
|
||||
this.field.set(this.source, (int) val);
|
||||
} else if (this.field.getType().equals(long.class)) {
|
||||
this.field.set(this.source, val);
|
||||
} else if (this.field.getType().equals(boolean.class)) {
|
||||
this.field.set(this.source, val == 1);
|
||||
} else if (this.field.getType().equals(Integer.class)) {
|
||||
this.field.set(this.source, (int) val);
|
||||
} else if (this.field.getType().equals(Long.class)) {
|
||||
this.field.set(this.source, val);
|
||||
} else if (this.field.getType().equals(Boolean.class)) {
|
||||
this.field.set(this.source, val == 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateValue( final Object oldValue, final long val )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( this.field.getType().isEnum() )
|
||||
{
|
||||
final EnumSet<? extends Enum> valList = EnumSet.allOf( (Class<? extends Enum>) this.field.getType() );
|
||||
for( final Enum e : valList )
|
||||
{
|
||||
if( e.ordinal() == val )
|
||||
{
|
||||
this.field.set( this.source, e );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( this.field.getType().equals( int.class ) )
|
||||
{
|
||||
this.field.set( this.source, (int) val );
|
||||
}
|
||||
else if( this.field.getType().equals( long.class ) )
|
||||
{
|
||||
this.field.set( this.source, val );
|
||||
}
|
||||
else if( this.field.getType().equals( boolean.class ) )
|
||||
{
|
||||
this.field.set( this.source, val == 1 );
|
||||
}
|
||||
else if( this.field.getType().equals( Integer.class ) )
|
||||
{
|
||||
this.field.set( this.source, (int) val );
|
||||
}
|
||||
else if( this.field.getType().equals( Long.class ) )
|
||||
{
|
||||
this.field.set( this.source, val );
|
||||
}
|
||||
else if( this.field.getType().equals( Boolean.class ) )
|
||||
{
|
||||
this.field.set( this.source, val == 1 );
|
||||
}
|
||||
}
|
||||
|
||||
this.source.onUpdate( this.field.getName(), oldValue, this.field.get( this.source ) );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
this.source.onUpdate(this.field.getName(), oldValue, this.field.get(this.source));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
AELog.debug(e);
|
||||
} catch (final IllegalAccessException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.util.EnumCycler;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
@@ -44,242 +40,210 @@ import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.slot.OptionalSlotRestrictedInput;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.util.EnumCycler;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.WrapperSupplierItemHandler;
|
||||
import appeng.util.iterators.NullIterator;
|
||||
|
||||
public class ContainerCellWorkbench extends ContainerUpgradeable {
|
||||
|
||||
public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||
{
|
||||
public static ContainerType<ContainerCellWorkbench> TYPE;
|
||||
|
||||
public static ContainerType<ContainerCellWorkbench> TYPE;
|
||||
private static final ContainerHelper<ContainerCellWorkbench, TileCellWorkbench> helper = new ContainerHelper<>(
|
||||
ContainerCellWorkbench::new, TileCellWorkbench.class);
|
||||
|
||||
private static final ContainerHelper<ContainerCellWorkbench, TileCellWorkbench> helper
|
||||
= new ContainerHelper<>(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;
|
||||
|
||||
private final TileCellWorkbench workBench;
|
||||
@GuiSync( 2 )
|
||||
public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE;
|
||||
private ItemStack prevStack = ItemStack.EMPTY;
|
||||
private int lastUpgrades = 0;
|
||||
public ContainerCellWorkbench(int id, final PlayerInventory ip, final TileCellWorkbench te) {
|
||||
super(TYPE, id, ip, te);
|
||||
this.workBench = te;
|
||||
}
|
||||
|
||||
public ContainerCellWorkbench(int id, final PlayerInventory ip, final TileCellWorkbench 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 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 static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
public void setFuzzy(final FuzzyMode valueOf) {
|
||||
final ICellWorkbenchItem cwi = this.workBench.getCell();
|
||||
if (cwi != null) {
|
||||
cwi.setFuzzyMode(this.workBench.getInventoryByName("cell").getStackInSlot(0), valueOf);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFuzzy( final FuzzyMode valueOf )
|
||||
{
|
||||
final ICellWorkbenchItem cwi = this.workBench.getCell();
|
||||
if( cwi != null )
|
||||
{
|
||||
cwi.setFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ), valueOf );
|
||||
}
|
||||
}
|
||||
public void nextWorkBenchCopyMode() {
|
||||
this.workBench.getConfigManager().putSetting(Settings.COPY_MODE, EnumCycler.next(this.getWorkBenchCopyMode()));
|
||||
}
|
||||
|
||||
public void nextWorkBenchCopyMode()
|
||||
{
|
||||
this.workBench.getConfigManager().putSetting( Settings.COPY_MODE, EnumCycler.next( this.getWorkBenchCopyMode() ) );
|
||||
}
|
||||
private CopyMode getWorkBenchCopyMode() {
|
||||
return (CopyMode) this.workBench.getConfigManager().getSetting(Settings.COPY_MODE);
|
||||
}
|
||||
|
||||
private CopyMode getWorkBenchCopyMode()
|
||||
{
|
||||
return (CopyMode) this.workBench.getConfigManager().getSetting( Settings.COPY_MODE );
|
||||
}
|
||||
@Override
|
||||
protected int getHeight() {
|
||||
return 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 251;
|
||||
}
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
final IItemHandler cell = this.getUpgradeable().getInventoryByName("cell");
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8,
|
||||
this.getPlayerInv()));
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
final IItemHandler cell = this.getUpgradeable().getInventoryByName( "cell" );
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8, this.getPlayerInv() ) );
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName("config");
|
||||
final WrapperSupplierItemHandler upgradeInventory = new WrapperSupplierItemHandler(
|
||||
this::getCellUpgradeInventory);
|
||||
// null, 3 * 8 );
|
||||
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
|
||||
final WrapperSupplierItemHandler upgradeInventory = new WrapperSupplierItemHandler( this::getCellUpgradeInventory );
|
||||
// null, 3 * 8 );
|
||||
int offset = 0;
|
||||
final int y = 29;
|
||||
final int x = 8;
|
||||
for (int w = 0; w < 7; w++) {
|
||||
for (int z = 0; z < 9; z++) {
|
||||
this.addSlot(new SlotFakeTypeOnly(inv, offset, x + z * 18, y + w * 18));
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
final int y = 29;
|
||||
final int x = 8;
|
||||
for( int w = 0; w < 7; w++ )
|
||||
{
|
||||
for( int z = 0; z < 9; z++ )
|
||||
{
|
||||
this.addSlot( new SlotFakeTypeOnly( inv, offset, x + z * 18, y + w * 18 ) );
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
for (int zz = 0; zz < 3; zz++) {
|
||||
for (int z = 0; z < 8; z++) {
|
||||
final int iSLot = zz * 8 + z;
|
||||
this.addSlot(new OptionalSlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES,
|
||||
upgradeInventory, this, iSLot, 187 + zz * 18, 8 + 18 * z, iSLot, this.getPlayerInventory()));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if ( supportCapacity() ) { for (int w = 0; w < 2; w++) for (int z = 0; z < 9;
|
||||
* z++) addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, offset++,
|
||||
* x, y, z, w, 1 ) ); for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++)
|
||||
* addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, offset++, x, y,
|
||||
* z, w + 2, 2 ) ); for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++)
|
||||
* addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, offset++, x, y,
|
||||
* z, w + 4, 3 ) ); }
|
||||
*/
|
||||
}
|
||||
|
||||
for( int zz = 0; zz < 3; zz++ )
|
||||
{
|
||||
for( int z = 0; z < 8; z++ )
|
||||
{
|
||||
final int iSLot = zz * 8 + z;
|
||||
this.addSlot(
|
||||
new OptionalSlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgradeInventory, this, iSLot, 187 + zz * 18, 8 + 18 * z, iSLot, this
|
||||
.getPlayerInventory() ) );
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if ( supportCapacity() ) { for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new
|
||||
* OptionalSlotFakeTypeOnly( inv, this, offset++, x, y, z, w, 1 ) );
|
||||
* for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly(
|
||||
* inv, this, offset++, x, y, z, w + 2, 2 ) );
|
||||
* for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly(
|
||||
* inv, this, offset++, x, y, z, w + 4, 3 ) ); }
|
||||
*/
|
||||
}
|
||||
@Override
|
||||
public int availableUpgrades() {
|
||||
final ItemStack is = this.workBench.getInventoryByName("cell").getStackInSlot(0);
|
||||
if (this.prevStack != is) {
|
||||
this.prevStack = is;
|
||||
this.lastUpgrades = this.getCellUpgradeInventory().getSlots();
|
||||
}
|
||||
return this.lastUpgrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
final ItemStack is = this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
|
||||
if( this.prevStack != is )
|
||||
{
|
||||
this.prevStack = is;
|
||||
this.lastUpgrades = this.getCellUpgradeInventory().getSlots();
|
||||
}
|
||||
return this.lastUpgrades;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
final ItemStack is = this.workBench.getInventoryByName("cell").getStackInSlot(0);
|
||||
if (Platform.isServer()) {
|
||||
for (final IContainerListener listener : this.listeners) {
|
||||
if (this.prevStack != is) {
|
||||
// if the bars changed an item was probably made, so just send shit!
|
||||
for (final Slot s : this.inventorySlots) {
|
||||
if (s instanceof OptionalSlotRestrictedInput) {
|
||||
final OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s;
|
||||
listener.sendSlotContents(this, sri.slotNumber, sri.getStack());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
final ItemStack is = this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
for( final IContainerListener listener : this.listeners )
|
||||
{
|
||||
if( this.prevStack != is )
|
||||
{
|
||||
// if the bars changed an item was probably made, so just send shit!
|
||||
for( final Slot s : this.inventorySlots )
|
||||
{
|
||||
if( s instanceof OptionalSlotRestrictedInput )
|
||||
{
|
||||
final OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s;
|
||||
listener.sendSlotContents( this, sri.slotNumber, sri.getStack() );
|
||||
}
|
||||
}
|
||||
if (listener instanceof ServerPlayerEntity) {
|
||||
((ServerPlayerEntity) listener).isChangingQuantityOnly = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( listener instanceof ServerPlayerEntity )
|
||||
{
|
||||
( (ServerPlayerEntity) listener ).isChangingQuantityOnly = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setCopyMode(this.getWorkBenchCopyMode());
|
||||
this.setFuzzyMode(this.getWorkBenchFuzzyMode());
|
||||
}
|
||||
|
||||
this.setCopyMode( this.getWorkBenchCopyMode() );
|
||||
this.setFuzzyMode( this.getWorkBenchFuzzyMode() );
|
||||
}
|
||||
this.prevStack = is;
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
this.prevStack = is;
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
return idx < this.availableUpgrades();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled( final int idx )
|
||||
{
|
||||
return idx < this.availableUpgrades();
|
||||
}
|
||||
public IItemHandler getCellUpgradeInventory() {
|
||||
final IItemHandler upgradeInventory = this.workBench.getCellUpgradeInventory();
|
||||
|
||||
public IItemHandler getCellUpgradeInventory()
|
||||
{
|
||||
final IItemHandler upgradeInventory = this.workBench.getCellUpgradeInventory();
|
||||
return upgradeInventory == null ? EmptyHandler.INSTANCE : upgradeInventory;
|
||||
}
|
||||
|
||||
return upgradeInventory == null ? EmptyHandler.INSTANCE : upgradeInventory;
|
||||
}
|
||||
@Override
|
||||
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
|
||||
if (field.equals("copyMode")) {
|
||||
this.workBench.getConfigManager().putSetting(Settings.COPY_MODE, this.getCopyMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate( final String field, final Object oldValue, final Object newValue )
|
||||
{
|
||||
if( field.equals( "copyMode" ) )
|
||||
{
|
||||
this.workBench.getConfigManager().putSetting( Settings.COPY_MODE, this.getCopyMode() );
|
||||
}
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
}
|
||||
|
||||
super.onUpdate( field, oldValue, newValue );
|
||||
}
|
||||
public void clear() {
|
||||
ItemHandlerUtil.clear(this.getUpgradeable().getInventoryByName("config"));
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
ItemHandlerUtil.clear( this.getUpgradeable().getInventoryByName( "config" ) );
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
private FuzzyMode getWorkBenchFuzzyMode() {
|
||||
final ICellWorkbenchItem cwi = this.workBench.getCell();
|
||||
if (cwi != null) {
|
||||
return cwi.getFuzzyMode(this.workBench.getInventoryByName("cell").getStackInSlot(0));
|
||||
}
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
|
||||
private FuzzyMode getWorkBenchFuzzyMode()
|
||||
{
|
||||
final ICellWorkbenchItem cwi = this.workBench.getCell();
|
||||
if( cwi != null )
|
||||
{
|
||||
return cwi.getFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ) );
|
||||
}
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
public void partition() {
|
||||
|
||||
public void partition()
|
||||
{
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName("config");
|
||||
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
|
||||
final ItemStack is = this.getUpgradeable().getInventoryByName("cell").getStackInSlot(0);
|
||||
final IStorageChannel channel = is.getItem() instanceof IStorageCell
|
||||
? ((IStorageCell) is.getItem()).getChannel()
|
||||
: AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
|
||||
final ItemStack is = this.getUpgradeable().getInventoryByName( "cell" ).getStackInSlot( 0 );
|
||||
final IStorageChannel channel = is.getItem() instanceof IStorageCell ? ( (IStorageCell) is.getItem() ).getChannel() : AEApi.instance()
|
||||
.storage()
|
||||
.getStorageChannel( IItemStorageChannel.class );
|
||||
final IMEInventory cellInv = AEApi.instance().registries().cell().getCellInventory(is, null, channel);
|
||||
|
||||
final IMEInventory cellInv = AEApi.instance().registries().cell().getCellInventory( is, null, channel );
|
||||
Iterator<IAEStack> i = new NullIterator<>();
|
||||
if (cellInv != null) {
|
||||
final IItemList list = cellInv.getAvailableItems(channel.createList());
|
||||
i = list.iterator();
|
||||
}
|
||||
|
||||
Iterator<IAEStack> i = new NullIterator<>();
|
||||
if( cellInv != null )
|
||||
{
|
||||
final IItemList list = cellInv.getAvailableItems( channel.createList() );
|
||||
i = list.iterator();
|
||||
}
|
||||
for (int x = 0; x < inv.getSlots(); x++) {
|
||||
if (i.hasNext()) {
|
||||
// TODO: check if ok
|
||||
final ItemStack g = i.next().asItemStackRepresentation();
|
||||
ItemHandlerUtil.setStackInSlot(inv, x, g);
|
||||
} else {
|
||||
ItemHandlerUtil.setStackInSlot(inv, x, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
for( int x = 0; x < inv.getSlots(); x++ )
|
||||
{
|
||||
if( i.hasNext() )
|
||||
{
|
||||
// TODO: check if ok
|
||||
final ItemStack g = i.next().asItemStackRepresentation();
|
||||
ItemHandlerUtil.setStackInSlot( inv, x, g );
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.EMPTY );
|
||||
}
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
public CopyMode getCopyMode() {
|
||||
return this.copyMode;
|
||||
}
|
||||
|
||||
public CopyMode getCopyMode()
|
||||
{
|
||||
return this.copyMode;
|
||||
}
|
||||
|
||||
private void setCopyMode( final CopyMode copyMode )
|
||||
{
|
||||
this.copyMode = copyMode;
|
||||
}
|
||||
private void setCopyMode(final CopyMode copyMode) {
|
||||
this.copyMode = copyMode;
|
||||
}
|
||||
}
|
||||
@@ -18,44 +18,40 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
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;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.storage.TileChest;
|
||||
|
||||
public class ContainerChest extends AEBaseContainer
|
||||
{
|
||||
public class ContainerChest extends AEBaseContainer {
|
||||
|
||||
public static ContainerType<ContainerChest> TYPE;
|
||||
public static ContainerType<ContainerChest> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerChest, TileChest> helper
|
||||
= new ContainerHelper<>(ContainerChest::new, TileChest.class, SecurityPermissions.BUILD);
|
||||
private static final ContainerHelper<ContainerChest, TileChest> helper = new ContainerHelper<>(ContainerChest::new,
|
||||
TileChest.class, SecurityPermissions.BUILD);
|
||||
|
||||
public ContainerChest( int id, final PlayerInventory ip, final TileChest chest )
|
||||
{
|
||||
super( TYPE, id, ip, chest, null );
|
||||
public ContainerChest(int id, final PlayerInventory ip, final TileChest chest) {
|
||||
super(TYPE, id, ip, chest, null);
|
||||
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, chest.getInternalInventory(), 1, 80, 37, this
|
||||
.getPlayerInventory() ) );
|
||||
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 );
|
||||
}
|
||||
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 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);
|
||||
}
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,11 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
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.CondenserOutput;
|
||||
import appeng.api.config.Settings;
|
||||
@@ -30,87 +35,74 @@ 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 class ContainerCondenser extends AEBaseContainer implements IProgressProvider
|
||||
{
|
||||
public static ContainerType<ContainerCondenser> TYPE;
|
||||
|
||||
public static ContainerType<ContainerCondenser> TYPE;
|
||||
private static final ContainerHelper<ContainerCondenser, TileCondenser> helper = new ContainerHelper<>(
|
||||
ContainerCondenser::new, TileCondenser.class);
|
||||
|
||||
private static final ContainerHelper<ContainerCondenser, TileCondenser> helper
|
||||
= new ContainerHelper<>(ContainerCondenser::new, TileCondenser.class);
|
||||
private final TileCondenser condenser;
|
||||
@GuiSync(0)
|
||||
public long requiredEnergy = 0;
|
||||
@GuiSync(1)
|
||||
public long storedPower = 0;
|
||||
@GuiSync(2)
|
||||
public CondenserOutput output = CondenserOutput.TRASH;
|
||||
|
||||
private final TileCondenser condenser;
|
||||
@GuiSync( 0 )
|
||||
public long requiredEnergy = 0;
|
||||
@GuiSync( 1 )
|
||||
public long storedPower = 0;
|
||||
@GuiSync( 2 )
|
||||
public CondenserOutput output = CondenserOutput.TRASH;
|
||||
public ContainerCondenser(int id, final PlayerInventory ip, final TileCondenser condenser) {
|
||||
super(TYPE, id, ip, condenser, null);
|
||||
this.condenser = condenser;
|
||||
|
||||
public ContainerCondenser(int id, final PlayerInventory ip, final TileCondenser condenser )
|
||||
{
|
||||
super( TYPE, id, ip, condenser, null );
|
||||
this.condenser = condenser;
|
||||
IItemHandler inv = condenser.getInternalInventory();
|
||||
|
||||
IItemHandler inv = condenser.getInternalInventory();
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.TRASH, inv, 0, 51, 52, ip));
|
||||
this.addSlot(new SlotOutput(inv, 1, 105, 52, -1));
|
||||
this.addSlot(
|
||||
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.STORAGE_COMPONENT, inv, 2, 101, 26, ip))
|
||||
.setStackLimit(1));
|
||||
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.TRASH, inv, 0, 51, 52, ip ) );
|
||||
this.addSlot( new SlotOutput( inv, 1, 105, 52, -1 ) );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_COMPONENT, inv, 2, 101, 26, ip ) ).setStackLimit( 1 ) );
|
||||
this.bindPlayerInventory(ip, 0, 197 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isServer()) {
|
||||
final double maxStorage = this.condenser.getStorage();
|
||||
final double requiredEnergy = this.condenser.getRequiredPower();
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
final double maxStorage = this.condenser.getStorage();
|
||||
final double requiredEnergy = this.condenser.getRequiredPower();
|
||||
this.requiredEnergy = requiredEnergy == 0 ? (int) maxStorage : (int) Math.min(requiredEnergy, maxStorage);
|
||||
this.storedPower = (int) this.condenser.getStoredPower();
|
||||
this.setOutput((CondenserOutput) this.condenser.getConfigManager().getSetting(Settings.CONDENSER_OUTPUT));
|
||||
}
|
||||
|
||||
this.requiredEnergy = requiredEnergy == 0 ? (int) maxStorage : (int) Math.min( requiredEnergy, maxStorage );
|
||||
this.storedPower = (int) this.condenser.getStoredPower();
|
||||
this.setOutput( (CondenserOutput) this.condenser.getConfigManager().getSetting( Settings.CONDENSER_OUTPUT ) );
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public int getCurrentProgress() {
|
||||
return (int) this.storedPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentProgress()
|
||||
{
|
||||
return (int) this.storedPower;
|
||||
}
|
||||
@Override
|
||||
public int getMaxProgress() {
|
||||
return (int) this.requiredEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxProgress()
|
||||
{
|
||||
return (int) this.requiredEnergy;
|
||||
}
|
||||
public CondenserOutput getOutput() {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
public CondenserOutput getOutput()
|
||||
{
|
||||
return this.output;
|
||||
}
|
||||
|
||||
private void setOutput( final CondenserOutput output )
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
private void setOutput(final CondenserOutput output) {
|
||||
this.output = output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -36,72 +34,64 @@ import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.me.helpers.PlayerSource;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
||||
public class ContainerCraftAmount extends AEBaseContainer {
|
||||
|
||||
public class ContainerCraftAmount extends AEBaseContainer
|
||||
{
|
||||
public static ContainerType<ContainerCraftAmount> TYPE;
|
||||
|
||||
public static ContainerType<ContainerCraftAmount> TYPE;
|
||||
private static final ContainerHelper<ContainerCraftAmount, ITerminalHost> helper = new ContainerHelper<>(
|
||||
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;
|
||||
|
||||
private final Slot craftingItem;
|
||||
private IAEItemStack itemToCreate;
|
||||
public ContainerCraftAmount(int id, PlayerInventory ip, final ITerminalHost te) {
|
||||
super(TYPE, 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());
|
||||
}
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
this.verifyPermissions(SecurityPermissions.CRAFT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
this.verifyPermissions( SecurityPermissions.CRAFT, false );
|
||||
}
|
||||
public IGrid getGrid() {
|
||||
final IActionHost h = ((IActionHost) this.getTarget());
|
||||
return h.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
public IGrid getGrid()
|
||||
{
|
||||
final IActionHost h = ( (IActionHost) this.getTarget() );
|
||||
return h.getActionableNode().getGrid();
|
||||
}
|
||||
public World getWorld() {
|
||||
return this.getPlayerInv().player.world;
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return this.getPlayerInv().player.world;
|
||||
}
|
||||
public IActionSource getActionSrc() {
|
||||
return new PlayerSource(this.getPlayerInv().player, (IActionHost) this.getTarget());
|
||||
}
|
||||
|
||||
public IActionSource getActionSrc()
|
||||
{
|
||||
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
|
||||
}
|
||||
public Slot getCraftingItem() {
|
||||
return this.craftingItem;
|
||||
}
|
||||
|
||||
public Slot getCraftingItem()
|
||||
{
|
||||
return this.craftingItem;
|
||||
}
|
||||
public IAEItemStack getItemToCraft() {
|
||||
return this.itemToCreate;
|
||||
}
|
||||
|
||||
public IAEItemStack getItemToCraft()
|
||||
{
|
||||
return this.itemToCreate;
|
||||
}
|
||||
|
||||
public void setItemToCraft( @Nonnull final IAEItemStack itemToCreate )
|
||||
{
|
||||
this.itemToCreate = itemToCreate;
|
||||
}
|
||||
public void setItemToCraft(@Nonnull final IAEItemStack itemToCreate) {
|
||||
this.itemToCreate = itemToCreate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,23 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
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.IContainerListener;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -48,446 +65,356 @@ 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;
|
||||
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.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
|
||||
public class ContainerCraftConfirm extends AEBaseContainer
|
||||
{
|
||||
|
||||
public static ContainerType<ContainerCraftConfirm> TYPE;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
@GuiSync( 0 )
|
||||
public long bytesUsed;
|
||||
@GuiSync( 1 )
|
||||
public long cpuBytesAvail;
|
||||
@GuiSync( 2 )
|
||||
public int cpuCoProcessors;
|
||||
@GuiSync( 3 )
|
||||
public boolean autoStart = false;
|
||||
@GuiSync( 4 )
|
||||
public boolean simulation = true;
|
||||
@GuiSync( 5 )
|
||||
public int selectedCpu = -1;
|
||||
@GuiSync( 6 )
|
||||
public boolean noCPU = true;
|
||||
@GuiSync( 7 )
|
||||
public String myName = "";
|
||||
|
||||
public ContainerCraftConfirm(int id, PlayerInventory ip, ITerminalHost te) {
|
||||
super(TYPE, id, ip, te);
|
||||
}
|
||||
|
||||
public void cycleCpu( final boolean next )
|
||||
{
|
||||
if( next )
|
||||
{
|
||||
this.setSelectedCpu( this.getSelectedCpu() + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setSelectedCpu( this.getSelectedCpu() - 1 );
|
||||
}
|
||||
|
||||
if( this.getSelectedCpu() < -1 )
|
||||
{
|
||||
this.setSelectedCpu( this.cpus.size() - 1 );
|
||||
}
|
||||
else if( this.getSelectedCpu() >= this.cpus.size() )
|
||||
{
|
||||
this.setSelectedCpu( -1 );
|
||||
}
|
||||
|
||||
if( this.getSelectedCpu() == -1 )
|
||||
{
|
||||
this.setCpuAvailableBytes( 0 );
|
||||
this.setCpuCoProcessors( 0 );
|
||||
this.setName( "" );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setName( this.cpus.get( this.getSelectedCpu() ).getName().getString() );
|
||||
this.setCpuAvailableBytes( this.cpus.get( this.getSelectedCpu() ).getSize() );
|
||||
this.setCpuCoProcessors( this.cpus.get( this.getSelectedCpu() ).getProcessors() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
|
||||
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
|
||||
int matches = 0;
|
||||
boolean changed = false;
|
||||
for( final ICraftingCPU c : cpuSet )
|
||||
{
|
||||
boolean found = false;
|
||||
for( final CraftingCPURecord ccr : this.cpus )
|
||||
{
|
||||
if( ccr.getCpu() == c )
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
final boolean matched = this.cpuMatches( c );
|
||||
|
||||
if( matched )
|
||||
{
|
||||
matches++;
|
||||
}
|
||||
|
||||
if( found == !matched )
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( changed || this.cpus.size() != matches )
|
||||
{
|
||||
this.cpus.clear();
|
||||
for( final ICraftingCPU c : cpuSet )
|
||||
{
|
||||
if( this.cpuMatches( c ) )
|
||||
{
|
||||
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
|
||||
}
|
||||
}
|
||||
|
||||
this.sendCPUs();
|
||||
}
|
||||
|
||||
this.setNoCPU( this.cpus.isEmpty() );
|
||||
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if( this.getJob() != null && this.getJob().isDone() )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.result = this.getJob().get();
|
||||
|
||||
if( !this.result.isSimulation() )
|
||||
{
|
||||
this.setSimulation( false );
|
||||
if( this.isAutoStart() )
|
||||
{
|
||||
this.startJob();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setSimulation( true );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 );
|
||||
final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 );
|
||||
final PacketMEInventoryUpdate c = this.result.isSimulation() ? new PacketMEInventoryUpdate( (byte) 2 ) : null;
|
||||
|
||||
final IItemList<IAEItemStack> plan = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
this.result.populatePlan( plan );
|
||||
|
||||
this.setUsedBytes( this.result.getByteTotal() );
|
||||
|
||||
for( final IAEItemStack out : plan )
|
||||
{
|
||||
|
||||
IAEItemStack o = out.copy();
|
||||
o.reset();
|
||||
o.setStackSize( out.getStackSize() );
|
||||
|
||||
final IAEItemStack p = out.copy();
|
||||
p.reset();
|
||||
p.setStackSize( out.getCountRequestable() );
|
||||
|
||||
final IStorageGrid sg = this.getGrid().getCache( IStorageGrid.class );
|
||||
final IMEInventory<IAEItemStack> items = sg.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
|
||||
IAEItemStack m = null;
|
||||
if( c != null && this.result.isSimulation() )
|
||||
{
|
||||
m = o.copy();
|
||||
o = items.extractItems( o, Actionable.SIMULATE, this.getActionSource() );
|
||||
|
||||
if( o == null )
|
||||
{
|
||||
o = m.copy();
|
||||
o.setStackSize( 0 );
|
||||
}
|
||||
|
||||
m.setStackSize( m.getStackSize() - o.getStackSize() );
|
||||
}
|
||||
|
||||
if( o.getStackSize() > 0 )
|
||||
{
|
||||
a.appendItem( o );
|
||||
}
|
||||
|
||||
if( p.getStackSize() > 0 )
|
||||
{
|
||||
b.appendItem( p );
|
||||
}
|
||||
|
||||
if( c != null && m != null && m.getStackSize() > 0 )
|
||||
{
|
||||
c.appendItem( m );
|
||||
}
|
||||
}
|
||||
|
||||
for( final Object g : this.listeners )
|
||||
{
|
||||
if( g instanceof PlayerEntity )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( a, (ServerPlayerEntity) g );
|
||||
NetworkHandler.instance().sendTo( b, (ServerPlayerEntity) g );
|
||||
if( c != null )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( c, (ServerPlayerEntity) g );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
this.getPlayerInv().player.sendMessage( new StringTextComponent( "Error: " + e.toString() ) );
|
||||
AELog.debug( e );
|
||||
this.setValidContainer( false );
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
this.setJob( null );
|
||||
}
|
||||
this.verifyPermissions( SecurityPermissions.CRAFT, false );
|
||||
}
|
||||
|
||||
private IGrid getGrid()
|
||||
{
|
||||
final IActionHost h = ( (IActionHost) this.getTarget() );
|
||||
return h.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
private boolean cpuMatches( final ICraftingCPU c )
|
||||
{
|
||||
return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy();
|
||||
}
|
||||
|
||||
private void sendCPUs()
|
||||
{
|
||||
Collections.sort( this.cpus );
|
||||
|
||||
if( this.getSelectedCpu() >= this.cpus.size() )
|
||||
{
|
||||
this.setSelectedCpu( -1 );
|
||||
this.setCpuAvailableBytes( 0 );
|
||||
this.setCpuCoProcessors( 0 );
|
||||
this.setName( "" );
|
||||
}
|
||||
else if( this.getSelectedCpu() != -1 )
|
||||
{
|
||||
this.setName( this.cpus.get( this.getSelectedCpu() ).getName().getString() );
|
||||
this.setCpuAvailableBytes( this.cpus.get( this.getSelectedCpu() ).getSize() );
|
||||
this.setCpuCoProcessors( this.cpus.get( this.getSelectedCpu() ).getProcessors() );
|
||||
}
|
||||
}
|
||||
|
||||
public void startJob()
|
||||
{
|
||||
ContainerType<?> originalGui = null;
|
||||
|
||||
final IActionHost ah = this.getActionHost();
|
||||
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() )
|
||||
{
|
||||
final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
|
||||
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.getLocator() != null )
|
||||
{
|
||||
ContainerOpener.openContainer(originalGui, getPlayerInventory().player, getLocator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IActionSource getActionSrc()
|
||||
{
|
||||
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener( final IContainerListener c )
|
||||
{
|
||||
super.removeListener( c );
|
||||
if( this.getJob() != null )
|
||||
{
|
||||
this.getJob().cancel( true );
|
||||
this.setJob( null );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
super.onContainerClosed( par1PlayerEntity );
|
||||
if( this.getJob() != null )
|
||||
{
|
||||
this.getJob().cancel( true );
|
||||
this.setJob( null );
|
||||
}
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return this.getPlayerInv().player.world;
|
||||
}
|
||||
|
||||
public boolean isAutoStart()
|
||||
{
|
||||
return this.autoStart;
|
||||
}
|
||||
|
||||
public void setAutoStart( final boolean autoStart )
|
||||
{
|
||||
this.autoStart = autoStart;
|
||||
}
|
||||
|
||||
public long getUsedBytes()
|
||||
{
|
||||
return this.bytesUsed;
|
||||
}
|
||||
|
||||
private void setUsedBytes( final long bytesUsed )
|
||||
{
|
||||
this.bytesUsed = bytesUsed;
|
||||
}
|
||||
|
||||
public long getCpuAvailableBytes()
|
||||
{
|
||||
return this.cpuBytesAvail;
|
||||
}
|
||||
|
||||
private void setCpuAvailableBytes( final long cpuBytesAvail )
|
||||
{
|
||||
this.cpuBytesAvail = cpuBytesAvail;
|
||||
}
|
||||
|
||||
public int getCpuCoProcessors()
|
||||
{
|
||||
return this.cpuCoProcessors;
|
||||
}
|
||||
|
||||
private void setCpuCoProcessors( final int cpuCoProcessors )
|
||||
{
|
||||
this.cpuCoProcessors = cpuCoProcessors;
|
||||
}
|
||||
|
||||
public int getSelectedCpu()
|
||||
{
|
||||
return this.selectedCpu;
|
||||
}
|
||||
|
||||
private void setSelectedCpu( final int selectedCpu )
|
||||
{
|
||||
this.selectedCpu = selectedCpu;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.myName;
|
||||
}
|
||||
|
||||
private void setName( @Nonnull final String myName )
|
||||
{
|
||||
this.myName = myName;
|
||||
}
|
||||
|
||||
public boolean hasNoCPU()
|
||||
{
|
||||
return this.noCPU;
|
||||
}
|
||||
|
||||
private void setNoCPU( final boolean noCPU )
|
||||
{
|
||||
this.noCPU = noCPU;
|
||||
}
|
||||
|
||||
public boolean isSimulation()
|
||||
{
|
||||
return this.simulation;
|
||||
}
|
||||
|
||||
private void setSimulation( final boolean simulation )
|
||||
{
|
||||
this.simulation = simulation;
|
||||
}
|
||||
|
||||
private Future<ICraftingJob> getJob()
|
||||
{
|
||||
return this.job;
|
||||
}
|
||||
|
||||
public void setJob( final Future<ICraftingJob> job )
|
||||
{
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
public class ContainerCraftConfirm extends AEBaseContainer {
|
||||
|
||||
public static ContainerType<ContainerCraftConfirm> TYPE;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
@GuiSync(0)
|
||||
public long bytesUsed;
|
||||
@GuiSync(1)
|
||||
public long cpuBytesAvail;
|
||||
@GuiSync(2)
|
||||
public int cpuCoProcessors;
|
||||
@GuiSync(3)
|
||||
public boolean autoStart = false;
|
||||
@GuiSync(4)
|
||||
public boolean simulation = true;
|
||||
@GuiSync(5)
|
||||
public int selectedCpu = -1;
|
||||
@GuiSync(6)
|
||||
public boolean noCPU = true;
|
||||
@GuiSync(7)
|
||||
public String myName = "";
|
||||
|
||||
public ContainerCraftConfirm(int id, PlayerInventory ip, ITerminalHost te) {
|
||||
super(TYPE, id, ip, te);
|
||||
}
|
||||
|
||||
public void cycleCpu(final boolean next) {
|
||||
if (next) {
|
||||
this.setSelectedCpu(this.getSelectedCpu() + 1);
|
||||
} else {
|
||||
this.setSelectedCpu(this.getSelectedCpu() - 1);
|
||||
}
|
||||
|
||||
if (this.getSelectedCpu() < -1) {
|
||||
this.setSelectedCpu(this.cpus.size() - 1);
|
||||
} else if (this.getSelectedCpu() >= this.cpus.size()) {
|
||||
this.setSelectedCpu(-1);
|
||||
}
|
||||
|
||||
if (this.getSelectedCpu() == -1) {
|
||||
this.setCpuAvailableBytes(0);
|
||||
this.setCpuCoProcessors(0);
|
||||
this.setName("");
|
||||
} else {
|
||||
this.setName(this.cpus.get(this.getSelectedCpu()).getName().getString());
|
||||
this.setCpuAvailableBytes(this.cpus.get(this.getSelectedCpu()).getSize());
|
||||
this.setCpuCoProcessors(this.cpus.get(this.getSelectedCpu()).getProcessors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
|
||||
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
|
||||
int matches = 0;
|
||||
boolean changed = false;
|
||||
for (final ICraftingCPU c : cpuSet) {
|
||||
boolean found = false;
|
||||
for (final CraftingCPURecord ccr : this.cpus) {
|
||||
if (ccr.getCpu() == c) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
final boolean matched = this.cpuMatches(c);
|
||||
|
||||
if (matched) {
|
||||
matches++;
|
||||
}
|
||||
|
||||
if (found == !matched) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed || this.cpus.size() != matches) {
|
||||
this.cpus.clear();
|
||||
for (final ICraftingCPU c : cpuSet) {
|
||||
if (this.cpuMatches(c)) {
|
||||
this.cpus.add(new CraftingCPURecord(c.getAvailableStorage(), c.getCoProcessors(), c));
|
||||
}
|
||||
}
|
||||
|
||||
this.sendCPUs();
|
||||
}
|
||||
|
||||
this.setNoCPU(this.cpus.isEmpty());
|
||||
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (this.getJob() != null && this.getJob().isDone()) {
|
||||
try {
|
||||
this.result = this.getJob().get();
|
||||
|
||||
if (!this.result.isSimulation()) {
|
||||
this.setSimulation(false);
|
||||
if (this.isAutoStart()) {
|
||||
this.startJob();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
this.setSimulation(true);
|
||||
}
|
||||
|
||||
try {
|
||||
final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate((byte) 0);
|
||||
final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate((byte) 1);
|
||||
final PacketMEInventoryUpdate c = this.result.isSimulation() ? new PacketMEInventoryUpdate((byte) 2)
|
||||
: null;
|
||||
|
||||
final IItemList<IAEItemStack> plan = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.result.populatePlan(plan);
|
||||
|
||||
this.setUsedBytes(this.result.getByteTotal());
|
||||
|
||||
for (final IAEItemStack out : plan) {
|
||||
|
||||
IAEItemStack o = out.copy();
|
||||
o.reset();
|
||||
o.setStackSize(out.getStackSize());
|
||||
|
||||
final IAEItemStack p = out.copy();
|
||||
p.reset();
|
||||
p.setStackSize(out.getCountRequestable());
|
||||
|
||||
final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class);
|
||||
final IMEInventory<IAEItemStack> items = sg
|
||||
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
|
||||
IAEItemStack m = null;
|
||||
if (c != null && this.result.isSimulation()) {
|
||||
m = o.copy();
|
||||
o = items.extractItems(o, Actionable.SIMULATE, this.getActionSource());
|
||||
|
||||
if (o == null) {
|
||||
o = m.copy();
|
||||
o.setStackSize(0);
|
||||
}
|
||||
|
||||
m.setStackSize(m.getStackSize() - o.getStackSize());
|
||||
}
|
||||
|
||||
if (o.getStackSize() > 0) {
|
||||
a.appendItem(o);
|
||||
}
|
||||
|
||||
if (p.getStackSize() > 0) {
|
||||
b.appendItem(p);
|
||||
}
|
||||
|
||||
if (c != null && m != null && m.getStackSize() > 0) {
|
||||
c.appendItem(m);
|
||||
}
|
||||
}
|
||||
|
||||
for (final Object g : this.listeners) {
|
||||
if (g instanceof PlayerEntity) {
|
||||
NetworkHandler.instance().sendTo(a, (ServerPlayerEntity) g);
|
||||
NetworkHandler.instance().sendTo(b, (ServerPlayerEntity) g);
|
||||
if (c != null) {
|
||||
NetworkHandler.instance().sendTo(c, (ServerPlayerEntity) g);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
// :P
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
this.getPlayerInv().player.sendMessage(new StringTextComponent("Error: " + e.toString()));
|
||||
AELog.debug(e);
|
||||
this.setValidContainer(false);
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
this.setJob(null);
|
||||
}
|
||||
this.verifyPermissions(SecurityPermissions.CRAFT, false);
|
||||
}
|
||||
|
||||
private IGrid getGrid() {
|
||||
final IActionHost h = ((IActionHost) this.getTarget());
|
||||
return h.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
private boolean cpuMatches(final ICraftingCPU c) {
|
||||
return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy();
|
||||
}
|
||||
|
||||
private void sendCPUs() {
|
||||
Collections.sort(this.cpus);
|
||||
|
||||
if (this.getSelectedCpu() >= this.cpus.size()) {
|
||||
this.setSelectedCpu(-1);
|
||||
this.setCpuAvailableBytes(0);
|
||||
this.setCpuCoProcessors(0);
|
||||
this.setName("");
|
||||
} else if (this.getSelectedCpu() != -1) {
|
||||
this.setName(this.cpus.get(this.getSelectedCpu()).getName().getString());
|
||||
this.setCpuAvailableBytes(this.cpus.get(this.getSelectedCpu()).getSize());
|
||||
this.setCpuCoProcessors(this.cpus.get(this.getSelectedCpu()).getProcessors());
|
||||
}
|
||||
}
|
||||
|
||||
public void startJob() {
|
||||
ContainerType<?> originalGui = null;
|
||||
|
||||
final IActionHost ah = this.getActionHost();
|
||||
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()) {
|
||||
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
|
||||
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.getLocator() != null) {
|
||||
ContainerOpener.openContainer(originalGui, getPlayerInventory().player, getLocator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IActionSource getActionSrc() {
|
||||
return new PlayerSource(this.getPlayerInv().player, (IActionHost) this.getTarget());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(final IContainerListener c) {
|
||||
super.removeListener(c);
|
||||
if (this.getJob() != null) {
|
||||
this.getJob().cancel(true);
|
||||
this.setJob(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(final PlayerEntity par1PlayerEntity) {
|
||||
super.onContainerClosed(par1PlayerEntity);
|
||||
if (this.getJob() != null) {
|
||||
this.getJob().cancel(true);
|
||||
this.setJob(null);
|
||||
}
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.getPlayerInv().player.world;
|
||||
}
|
||||
|
||||
public boolean isAutoStart() {
|
||||
return this.autoStart;
|
||||
}
|
||||
|
||||
public void setAutoStart(final boolean autoStart) {
|
||||
this.autoStart = autoStart;
|
||||
}
|
||||
|
||||
public long getUsedBytes() {
|
||||
return this.bytesUsed;
|
||||
}
|
||||
|
||||
private void setUsedBytes(final long bytesUsed) {
|
||||
this.bytesUsed = bytesUsed;
|
||||
}
|
||||
|
||||
public long getCpuAvailableBytes() {
|
||||
return this.cpuBytesAvail;
|
||||
}
|
||||
|
||||
private void setCpuAvailableBytes(final long cpuBytesAvail) {
|
||||
this.cpuBytesAvail = cpuBytesAvail;
|
||||
}
|
||||
|
||||
public int getCpuCoProcessors() {
|
||||
return this.cpuCoProcessors;
|
||||
}
|
||||
|
||||
private void setCpuCoProcessors(final int cpuCoProcessors) {
|
||||
this.cpuCoProcessors = cpuCoProcessors;
|
||||
}
|
||||
|
||||
public int getSelectedCpu() {
|
||||
return this.selectedCpu;
|
||||
}
|
||||
|
||||
private void setSelectedCpu(final int selectedCpu) {
|
||||
this.selectedCpu = selectedCpu;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.myName;
|
||||
}
|
||||
|
||||
private void setName(@Nonnull final String myName) {
|
||||
this.myName = myName;
|
||||
}
|
||||
|
||||
public boolean hasNoCPU() {
|
||||
return this.noCPU;
|
||||
}
|
||||
|
||||
private void setNoCPU(final boolean noCPU) {
|
||||
this.noCPU = noCPU;
|
||||
}
|
||||
|
||||
public boolean isSimulation() {
|
||||
return this.simulation;
|
||||
}
|
||||
|
||||
private void setSimulation(final boolean simulation) {
|
||||
this.simulation = simulation;
|
||||
}
|
||||
|
||||
private Future<ICraftingJob> getJob() {
|
||||
return this.job;
|
||||
}
|
||||
|
||||
public void setJob(final Future<ICraftingJob> job) {
|
||||
this.job = job;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,18 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
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.IContainerListener;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.crafting.CraftingItemList;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
@@ -40,7 +41,9 @@ 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.guisync.GuiSync;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
@@ -49,249 +52,205 @@ import appeng.me.cluster.IAEMultiBlock;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
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 class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorHandlerReceiver<IAEItemStack>, ICustomNameObject
|
||||
{
|
||||
public static ContainerType<ContainerCraftingCPU> TYPE;
|
||||
|
||||
public static ContainerType<ContainerCraftingCPU> TYPE;
|
||||
private static final ContainerHelper<ContainerCraftingCPU, TileCraftingTile> helper = new ContainerHelper<>(
|
||||
ContainerCraftingCPU::new, TileCraftingTile.class, SecurityPermissions.CRAFT);
|
||||
|
||||
private static final ContainerHelper<ContainerCraftingCPU, TileCraftingTile> helper
|
||||
= new ContainerHelper<>(ContainerCraftingCPU::new, TileCraftingTile.class, SecurityPermissions.CRAFT);
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
private IGrid network;
|
||||
private CraftingCPUCluster monitor = null;
|
||||
private ITextComponent cpuName = null;
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
private IGrid network;
|
||||
private CraftingCPUCluster monitor = null;
|
||||
private ITextComponent cpuName = null;
|
||||
@GuiSync(0)
|
||||
public long eta = -1;
|
||||
|
||||
@GuiSync( 0 )
|
||||
public long eta = -1;
|
||||
private ContainerCraftingCPU(int id, final PlayerInventory ip, final TileCraftingTile te) {
|
||||
this(TYPE, id, ip, te);
|
||||
}
|
||||
|
||||
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);
|
||||
final IActionHost host = (IActionHost) (te instanceof IActionHost ? te : null);
|
||||
|
||||
public ContainerCraftingCPU(ContainerType<?> containerType, int id, final PlayerInventory ip, final Object te )
|
||||
{
|
||||
super( containerType, id, ip, te );
|
||||
final IActionHost host = (IActionHost) ( te instanceof IActionHost ? te : null );
|
||||
if (host != null && host.getActionableNode() != null) {
|
||||
this.setNetwork(host.getActionableNode().getGrid());
|
||||
}
|
||||
|
||||
if( host != null && host.getActionableNode() != null )
|
||||
{
|
||||
this.setNetwork( host.getActionableNode().getGrid() );
|
||||
}
|
||||
if (te instanceof TileCraftingTile) {
|
||||
this.setCPU((ICraftingCPU) ((IAEMultiBlock) te).getCluster());
|
||||
}
|
||||
|
||||
if( te instanceof TileCraftingTile )
|
||||
{
|
||||
this.setCPU( (ICraftingCPU) ( (IAEMultiBlock) te ).getCluster() );
|
||||
}
|
||||
if (this.getNetwork() == null && Platform.isServer()) {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
|
||||
if( this.getNetwork() == null && Platform.isServer() )
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
}
|
||||
public static ContainerCraftingCPU fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
protected void setCPU(final ICraftingCPU c) {
|
||||
if (c == this.getMonitor()) {
|
||||
return;
|
||||
}
|
||||
|
||||
protected void setCPU( final ICraftingCPU c )
|
||||
{
|
||||
if( c == this.getMonitor() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.getMonitor() != null) {
|
||||
this.getMonitor().removeListener(this);
|
||||
}
|
||||
|
||||
if( this.getMonitor() != null )
|
||||
{
|
||||
this.getMonitor().removeListener( this );
|
||||
}
|
||||
for (final Object g : this.listeners) {
|
||||
if (g instanceof PlayerEntity) {
|
||||
NetworkHandler.instance().sendTo(new PacketValueConfig("CraftingStatus", "Clear"),
|
||||
(ServerPlayerEntity) g);
|
||||
}
|
||||
}
|
||||
|
||||
for( final Object g : this.listeners )
|
||||
{
|
||||
if( g instanceof PlayerEntity )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketValueConfig( "CraftingStatus", "Clear" ), (ServerPlayerEntity) g );
|
||||
}
|
||||
}
|
||||
if (c instanceof CraftingCPUCluster) {
|
||||
this.cpuName = c.getName();
|
||||
this.setMonitor((CraftingCPUCluster) c);
|
||||
this.list.resetStatus();
|
||||
this.getMonitor().getListOfItem(this.list, CraftingItemList.ALL);
|
||||
this.getMonitor().addListener(this, null);
|
||||
this.setEstimatedTime(0);
|
||||
} else {
|
||||
this.setMonitor(null);
|
||||
this.cpuName = null;
|
||||
this.setEstimatedTime(-1);
|
||||
}
|
||||
}
|
||||
|
||||
if( c instanceof CraftingCPUCluster )
|
||||
{
|
||||
this.cpuName = c.getName();
|
||||
this.setMonitor( (CraftingCPUCluster) c );
|
||||
this.list.resetStatus();
|
||||
this.getMonitor().getListOfItem( this.list, CraftingItemList.ALL );
|
||||
this.getMonitor().addListener( this, null );
|
||||
this.setEstimatedTime( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setMonitor( null );
|
||||
this.cpuName = null;
|
||||
this.setEstimatedTime( -1 );
|
||||
}
|
||||
}
|
||||
public void cancelCrafting() {
|
||||
if (this.getMonitor() != null) {
|
||||
this.getMonitor().cancel();
|
||||
}
|
||||
this.setEstimatedTime(-1);
|
||||
}
|
||||
|
||||
public void cancelCrafting()
|
||||
{
|
||||
if( this.getMonitor() != null )
|
||||
{
|
||||
this.getMonitor().cancel();
|
||||
}
|
||||
this.setEstimatedTime( -1 );
|
||||
}
|
||||
@Override
|
||||
public void removeListener(final IContainerListener c) {
|
||||
super.removeListener(c);
|
||||
|
||||
@Override
|
||||
public void removeListener( final IContainerListener c )
|
||||
{
|
||||
super.removeListener( c );
|
||||
if (this.listeners.isEmpty() && this.getMonitor() != null) {
|
||||
this.getMonitor().removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
if( this.listeners.isEmpty() && this.getMonitor() != null )
|
||||
{
|
||||
this.getMonitor().removeListener( this );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onContainerClosed(final PlayerEntity player) {
|
||||
super.onContainerClosed(player);
|
||||
if (this.getMonitor() != null) {
|
||||
this.getMonitor().removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( final PlayerEntity player )
|
||||
{
|
||||
super.onContainerClosed( player );
|
||||
if( this.getMonitor() != null )
|
||||
{
|
||||
this.getMonitor().removeListener( this );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isServer() && this.getMonitor() != null && !this.list.isEmpty()) {
|
||||
try {
|
||||
if (this.getEstimatedTime() >= 0) {
|
||||
final long elapsedTime = this.getMonitor().getElapsedTime();
|
||||
final double remainingItems = this.getMonitor().getRemainingItemCount();
|
||||
final double startItems = this.getMonitor().getStartItemCount();
|
||||
final long eta = (long) (elapsedTime / Math.max(1d, (startItems - remainingItems))
|
||||
* remainingItems);
|
||||
this.setEstimatedTime(eta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( Platform.isServer() && this.getMonitor() != null && !this.list.isEmpty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( this.getEstimatedTime() >= 0 )
|
||||
{
|
||||
final long elapsedTime = this.getMonitor().getElapsedTime();
|
||||
final double remainingItems = this.getMonitor().getRemainingItemCount();
|
||||
final double startItems = this.getMonitor().getStartItemCount();
|
||||
final long eta = (long) ( elapsedTime / Math.max( 1d, ( startItems - remainingItems ) ) * remainingItems );
|
||||
this.setEstimatedTime( eta );
|
||||
}
|
||||
final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate((byte) 0);
|
||||
final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate((byte) 1);
|
||||
final PacketMEInventoryUpdate c = new PacketMEInventoryUpdate((byte) 2);
|
||||
|
||||
final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 );
|
||||
final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 );
|
||||
final PacketMEInventoryUpdate c = new PacketMEInventoryUpdate( (byte) 2 );
|
||||
for (final IAEItemStack out : this.list) {
|
||||
a.appendItem(this.getMonitor().getItemStack(out, CraftingItemList.STORAGE));
|
||||
b.appendItem(this.getMonitor().getItemStack(out, CraftingItemList.ACTIVE));
|
||||
c.appendItem(this.getMonitor().getItemStack(out, CraftingItemList.PENDING));
|
||||
}
|
||||
|
||||
for( final IAEItemStack out : this.list )
|
||||
{
|
||||
a.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.STORAGE ) );
|
||||
b.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.ACTIVE ) );
|
||||
c.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.PENDING ) );
|
||||
}
|
||||
this.list.resetStatus();
|
||||
|
||||
this.list.resetStatus();
|
||||
for (final Object g : this.listeners) {
|
||||
if (g instanceof PlayerEntity) {
|
||||
if (!a.isEmpty()) {
|
||||
NetworkHandler.instance().sendTo(a, (ServerPlayerEntity) g);
|
||||
}
|
||||
|
||||
for( final Object g : this.listeners )
|
||||
{
|
||||
if( g instanceof PlayerEntity )
|
||||
{
|
||||
if( !a.isEmpty() )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( a, (ServerPlayerEntity) g );
|
||||
}
|
||||
if (!b.isEmpty()) {
|
||||
NetworkHandler.instance().sendTo(b, (ServerPlayerEntity) g);
|
||||
}
|
||||
|
||||
if( !b.isEmpty() )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( b, (ServerPlayerEntity) g );
|
||||
}
|
||||
if (!c.isEmpty()) {
|
||||
NetworkHandler.instance().sendTo(c, (ServerPlayerEntity) g);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
if( !c.isEmpty() )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( c, (ServerPlayerEntity) g );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public boolean isValid(final Object verificationToken) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( final Object verificationToken )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void postChange(final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change,
|
||||
final IActionSource actionSource) {
|
||||
for (IAEItemStack is : change) {
|
||||
is = is.copy();
|
||||
is.setStackSize(1);
|
||||
this.list.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource actionSource )
|
||||
{
|
||||
for( IAEItemStack is : change )
|
||||
{
|
||||
is = is.copy();
|
||||
is.setStackSize( 1 );
|
||||
this.list.add( is );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onListUpdate() {
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public ITextComponent getCustomInventoryName() {
|
||||
return this.cpuName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getCustomInventoryName()
|
||||
{
|
||||
return this.cpuName;
|
||||
}
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return this.cpuName != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return this.cpuName != null;
|
||||
}
|
||||
public long getEstimatedTime() {
|
||||
return this.eta;
|
||||
}
|
||||
|
||||
public long getEstimatedTime()
|
||||
{
|
||||
return this.eta;
|
||||
}
|
||||
private void setEstimatedTime(final long eta) {
|
||||
this.eta = eta;
|
||||
}
|
||||
|
||||
private void setEstimatedTime( final long eta )
|
||||
{
|
||||
this.eta = eta;
|
||||
}
|
||||
CraftingCPUCluster getMonitor() {
|
||||
return this.monitor;
|
||||
}
|
||||
|
||||
CraftingCPUCluster getMonitor()
|
||||
{
|
||||
return this.monitor;
|
||||
}
|
||||
private void setMonitor(final CraftingCPUCluster monitor) {
|
||||
this.monitor = monitor;
|
||||
}
|
||||
|
||||
private void setMonitor( final CraftingCPUCluster monitor )
|
||||
{
|
||||
this.monitor = monitor;
|
||||
}
|
||||
IGrid getNetwork() {
|
||||
return this.network;
|
||||
}
|
||||
|
||||
IGrid getNetwork()
|
||||
{
|
||||
return this.network;
|
||||
}
|
||||
|
||||
private void setNetwork( final IGrid network )
|
||||
{
|
||||
this.network = network;
|
||||
}
|
||||
private void setNetwork(final IGrid network) {
|
||||
this.network = network;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,181 +18,146 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.ContainerLocator;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
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;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerCraftingStatus extends ContainerCraftingCPU
|
||||
{
|
||||
public class ContainerCraftingStatus extends ContainerCraftingCPU {
|
||||
|
||||
public static ContainerType<ContainerCraftingStatus> TYPE;
|
||||
public static ContainerType<ContainerCraftingStatus> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerCraftingStatus, ITerminalHost> helper
|
||||
= new ContainerHelper<>(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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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;
|
||||
@GuiSync( 6 )
|
||||
public boolean noCPU = true;
|
||||
@GuiSync( 7 )
|
||||
public String myName = "";
|
||||
private final List<CraftingCPURecord> cpus = new ArrayList<>();
|
||||
@GuiSync(5)
|
||||
public int selectedCpu = -1;
|
||||
@GuiSync(6)
|
||||
public boolean noCPU = true;
|
||||
@GuiSync(7)
|
||||
public String myName = "";
|
||||
|
||||
public ContainerCraftingStatus(int id, final PlayerInventory ip, final ITerminalHost te )
|
||||
{
|
||||
super( TYPE, id, ip, te );
|
||||
}
|
||||
public ContainerCraftingStatus(int id, final PlayerInventory ip, final ITerminalHost te) {
|
||||
super(TYPE, id, ip, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( Platform.isServer() && this.getNetwork() != null )
|
||||
{
|
||||
final ICraftingGrid cc = this.getNetwork().getCache( ICraftingGrid.class );
|
||||
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isServer() && this.getNetwork() != null) {
|
||||
final ICraftingGrid cc = this.getNetwork().getCache(ICraftingGrid.class);
|
||||
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
|
||||
int matches = 0;
|
||||
boolean changed = false;
|
||||
for( final ICraftingCPU c : cpuSet )
|
||||
{
|
||||
boolean found = false;
|
||||
for( final CraftingCPURecord ccr : this.cpus )
|
||||
{
|
||||
if( ccr.getCpu() == c )
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
int matches = 0;
|
||||
boolean changed = false;
|
||||
for (final ICraftingCPU c : cpuSet) {
|
||||
boolean found = false;
|
||||
for (final CraftingCPURecord ccr : this.cpus) {
|
||||
if (ccr.getCpu() == c) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
final boolean matched = this.cpuMatches( c );
|
||||
final boolean matched = this.cpuMatches(c);
|
||||
|
||||
if( matched )
|
||||
{
|
||||
matches++;
|
||||
}
|
||||
if (matched) {
|
||||
matches++;
|
||||
}
|
||||
|
||||
if( found == !matched )
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (found == !matched) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( changed || this.cpus.size() != matches )
|
||||
{
|
||||
this.cpus.clear();
|
||||
for( final ICraftingCPU c : cpuSet )
|
||||
{
|
||||
if( this.cpuMatches( c ) )
|
||||
{
|
||||
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
|
||||
}
|
||||
}
|
||||
if (changed || this.cpus.size() != matches) {
|
||||
this.cpus.clear();
|
||||
for (final ICraftingCPU c : cpuSet) {
|
||||
if (this.cpuMatches(c)) {
|
||||
this.cpus.add(new CraftingCPURecord(c.getAvailableStorage(), c.getCoProcessors(), c));
|
||||
}
|
||||
}
|
||||
|
||||
this.sendCPUs();
|
||||
}
|
||||
this.sendCPUs();
|
||||
}
|
||||
|
||||
this.noCPU = this.cpus.isEmpty();
|
||||
}
|
||||
this.noCPU = this.cpus.isEmpty();
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
private boolean cpuMatches( final ICraftingCPU c )
|
||||
{
|
||||
return c.isBusy();
|
||||
}
|
||||
private boolean cpuMatches(final ICraftingCPU c) {
|
||||
return c.isBusy();
|
||||
}
|
||||
|
||||
private void sendCPUs()
|
||||
{
|
||||
Collections.sort( this.cpus );
|
||||
private void sendCPUs() {
|
||||
Collections.sort(this.cpus);
|
||||
|
||||
if( this.selectedCpu >= this.cpus.size() )
|
||||
{
|
||||
this.selectedCpu = -1;
|
||||
this.myName = "";
|
||||
}
|
||||
else if( this.selectedCpu != -1 )
|
||||
{
|
||||
this.myName = this.cpus.get( this.selectedCpu ).getName().getString();
|
||||
}
|
||||
if (this.selectedCpu >= this.cpus.size()) {
|
||||
this.selectedCpu = -1;
|
||||
this.myName = "";
|
||||
} else if (this.selectedCpu != -1) {
|
||||
this.myName = this.cpus.get(this.selectedCpu).getName().getString();
|
||||
}
|
||||
|
||||
if( this.selectedCpu == -1 && this.cpus.size() > 0 )
|
||||
{
|
||||
this.selectedCpu = 0;
|
||||
}
|
||||
if (this.selectedCpu == -1 && this.cpus.size() > 0) {
|
||||
this.selectedCpu = 0;
|
||||
}
|
||||
|
||||
if( this.selectedCpu != -1 )
|
||||
{
|
||||
if( this.cpus.get( this.selectedCpu ).getCpu() != this.getMonitor() )
|
||||
{
|
||||
this.setCPU( this.cpus.get( this.selectedCpu ).getCpu() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setCPU( null );
|
||||
}
|
||||
}
|
||||
if (this.selectedCpu != -1) {
|
||||
if (this.cpus.get(this.selectedCpu).getCpu() != this.getMonitor()) {
|
||||
this.setCPU(this.cpus.get(this.selectedCpu).getCpu());
|
||||
}
|
||||
} else {
|
||||
this.setCPU(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void cycleCpu( final boolean next )
|
||||
{
|
||||
if( next )
|
||||
{
|
||||
this.selectedCpu++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.selectedCpu--;
|
||||
}
|
||||
public void cycleCpu(final boolean next) {
|
||||
if (next) {
|
||||
this.selectedCpu++;
|
||||
} else {
|
||||
this.selectedCpu--;
|
||||
}
|
||||
|
||||
if( this.selectedCpu < -1 )
|
||||
{
|
||||
this.selectedCpu = this.cpus.size() - 1;
|
||||
}
|
||||
else if( this.selectedCpu >= this.cpus.size() )
|
||||
{
|
||||
this.selectedCpu = -1;
|
||||
}
|
||||
if (this.selectedCpu < -1) {
|
||||
this.selectedCpu = this.cpus.size() - 1;
|
||||
} else if (this.selectedCpu >= this.cpus.size()) {
|
||||
this.selectedCpu = -1;
|
||||
}
|
||||
|
||||
if( this.selectedCpu == -1 && this.cpus.size() > 0 )
|
||||
{
|
||||
this.selectedCpu = 0;
|
||||
}
|
||||
if (this.selectedCpu == -1 && this.cpus.size() > 0) {
|
||||
this.selectedCpu = 0;
|
||||
}
|
||||
|
||||
if( this.selectedCpu == -1 )
|
||||
{
|
||||
this.myName = "";
|
||||
this.setCPU( null );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.myName = this.cpus.get( this.selectedCpu ).getName().getString();
|
||||
this.setCPU( this.cpus.get( this.selectedCpu ).getCpu() );
|
||||
}
|
||||
}
|
||||
if (this.selectedCpu == -1) {
|
||||
this.myName = "";
|
||||
this.setCPU(null);
|
||||
} else {
|
||||
this.myName = this.cpus.get(this.selectedCpu).getName().getString();
|
||||
this.setCPU(this.cpus.get(this.selectedCpu).getCpu());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
@@ -34,7 +31,9 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotCraftingTerm;
|
||||
@@ -45,115 +44,101 @@ import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
|
||||
public class ContainerCraftingTerm extends ContainerMEMonitorable
|
||||
implements IAEAppEngInventory, IContainerCraftingPacket {
|
||||
|
||||
public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IContainerCraftingPacket
|
||||
{
|
||||
public static ContainerType<ContainerCraftingTerm> TYPE;
|
||||
|
||||
public static ContainerType<ContainerCraftingTerm> TYPE;
|
||||
private static final ContainerHelper<ContainerCraftingTerm, ITerminalHost> helper = new ContainerHelper<>(
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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(int id, final PlayerInventory ip, final ITerminalHost monitorable) {
|
||||
super(TYPE, id, ip, monitorable, false);
|
||||
this.ct = (PartCraftingTerminal) monitorable;
|
||||
|
||||
public ContainerCraftingTerm(int id, final PlayerInventory ip, final ITerminalHost monitorable )
|
||||
{
|
||||
super( TYPE, id, ip, monitorable, false );
|
||||
this.ct = (PartCraftingTerminal) monitorable;
|
||||
final IItemHandler crafting = this.ct.getInventoryByName("crafting");
|
||||
|
||||
final IItemHandler crafting = this.ct.getInventoryByName( "crafting" );
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
this.addSlot(this.craftingSlots[x + y * 3] = new SlotCraftingMatrix(this, crafting, x + y * 3,
|
||||
37 + x * 18, -72 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for( int y = 0; y < 3; y++ )
|
||||
{
|
||||
for( int x = 0; x < 3; x++ )
|
||||
{
|
||||
this.addSlot( this.craftingSlots[x + y * 3] = new SlotCraftingMatrix( this, crafting, x + y * 3, 37 + x * 18, -72 + y * 18 ) );
|
||||
}
|
||||
}
|
||||
this.addSlot(this.outputSlot = new SlotCraftingTerm(this.getPlayerInv().player, this.getActionSource(),
|
||||
this.getPowerSource(), monitorable, crafting, crafting, this.output, 131, -72 + 18, this));
|
||||
|
||||
this.addSlot( this.outputSlot = new SlotCraftingTerm( this.getPlayerInv().player, this.getActionSource(), this
|
||||
.getPowerSource(), monitorable, crafting, crafting, this.output, 131, -72 + 18, this ) );
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
|
||||
this.bindPlayerInventory( ip, 0, 0 );
|
||||
this.onCraftMatrixChanged(new WrapperInvItemHandler(crafting));
|
||||
}
|
||||
|
||||
this.onCraftMatrixChanged( new WrapperInvItemHandler( crafting ) );
|
||||
}
|
||||
/**
|
||||
* Callback for when the crafting matrix is changed.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Callback for when the crafting matrix is changed.
|
||||
*/
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventory) {
|
||||
final ContainerNull cn = new ContainerNull();
|
||||
final CraftingInventory ic = new CraftingInventory(cn, 3, 3);
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged( IInventory inventory )
|
||||
{
|
||||
final ContainerNull cn = new ContainerNull();
|
||||
final CraftingInventory ic = new CraftingInventory( cn, 3, 3 );
|
||||
for (int x = 0; x < 9; x++) {
|
||||
ic.setInventorySlotContents(x, this.craftingSlots[x].getStack());
|
||||
}
|
||||
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
ic.setInventorySlotContents( x, this.craftingSlots[x].getStack() );
|
||||
}
|
||||
if (this.currentRecipe == null || !this.currentRecipe.matches(ic, this.getPlayerInv().player.world)) {
|
||||
World world = this.getPlayerInv().player.world;
|
||||
this.currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null);
|
||||
}
|
||||
|
||||
if( this.currentRecipe == null || !this.currentRecipe.matches( ic, this.getPlayerInv().player.world ) )
|
||||
{
|
||||
World world = this.getPlayerInv().player.world;
|
||||
this.currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null);
|
||||
}
|
||||
if (this.currentRecipe == null) {
|
||||
this.outputSlot.putStack(ItemStack.EMPTY);
|
||||
} else {
|
||||
final ItemStack craftingResult = this.currentRecipe.getCraftingResult(ic);
|
||||
|
||||
if( this.currentRecipe == null )
|
||||
{
|
||||
this.outputSlot.putStack( ItemStack.EMPTY );
|
||||
}
|
||||
else
|
||||
{
|
||||
final ItemStack craftingResult = this.currentRecipe.getCraftingResult( ic );
|
||||
this.outputSlot.putStack(craftingResult);
|
||||
}
|
||||
}
|
||||
|
||||
this.outputSlot.putStack( craftingResult );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
|
||||
@Override
|
||||
public void saveChanges()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
if (name.equals("player")) {
|
||||
return new PlayerInvWrapper(this.getPlayerInventory());
|
||||
}
|
||||
return this.ct.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "player" ) )
|
||||
{
|
||||
return new PlayerInvWrapper( this.getPlayerInventory() );
|
||||
}
|
||||
return this.ct.getInventoryByName( name );
|
||||
}
|
||||
@Override
|
||||
public boolean useRealItems() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useRealItems()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public IRecipe<CraftingInventory> getCurrentRecipe()
|
||||
{
|
||||
return this.currentRecipe;
|
||||
}
|
||||
public IRecipe<CraftingInventory> getCurrentRecipe() {
|
||||
return this.currentRecipe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,49 +18,43 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
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;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
|
||||
public class ContainerDrive extends AEBaseContainer
|
||||
{
|
||||
public class ContainerDrive extends AEBaseContainer {
|
||||
|
||||
public static ContainerType<ContainerDrive> TYPE;
|
||||
public static ContainerType<ContainerDrive> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerDrive, TileDrive> helper
|
||||
= new ContainerHelper<>(ContainerDrive::new, TileDrive.class);
|
||||
private static final ContainerHelper<ContainerDrive, TileDrive> helper = new ContainerHelper<>(ContainerDrive::new,
|
||||
TileDrive.class);
|
||||
|
||||
public static ContainerDrive fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
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 static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
|
||||
public ContainerDrive(int id, final PlayerInventory ip, final TileDrive drive )
|
||||
{
|
||||
super( TYPE, id, ip, drive, null );
|
||||
public ContainerDrive(int id, final PlayerInventory ip, final TileDrive drive) {
|
||||
super(TYPE, id, ip, drive, null);
|
||||
|
||||
for( int y = 0; y < 5; y++ )
|
||||
{
|
||||
for( int x = 0; x < 2; x++ )
|
||||
{
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, drive
|
||||
.getInternalInventory(), x + y * 2, 71 + x * 18, 14 + y * 18, this.getPlayerInventory() ) );
|
||||
}
|
||||
}
|
||||
for (int y = 0; y < 5; y++) {
|
||||
for (int x = 0; x < 2; x++) {
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.STORAGE_CELLS,
|
||||
drive.getInternalInventory(), x + y * 2, 71 + x * 18, 14 + y * 18, this.getPlayerInventory()));
|
||||
}
|
||||
}
|
||||
|
||||
this.bindPlayerInventory( ip, 0, 199 - /* height of player inventory */82 );
|
||||
}
|
||||
this.bindPlayerInventory(ip, 0, 199 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -32,124 +29,105 @@ import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.slot.OptionalSlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerFormationPlane extends ContainerUpgradeable {
|
||||
|
||||
public class ContainerFormationPlane extends ContainerUpgradeable
|
||||
{
|
||||
public static ContainerType<ContainerFormationPlane> TYPE;
|
||||
|
||||
public static ContainerType<ContainerFormationPlane> TYPE;
|
||||
private static final ContainerHelper<ContainerFormationPlane, PartFormationPlane> helper = new ContainerHelper<>(
|
||||
ContainerFormationPlane::new, PartFormationPlane.class, SecurityPermissions.BUILD);
|
||||
|
||||
private static final ContainerHelper<ContainerFormationPlane, PartFormationPlane> helper
|
||||
= new ContainerHelper<>(ContainerFormationPlane::new, PartFormationPlane.class, SecurityPermissions.BUILD);
|
||||
public static ContainerFormationPlane fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
@GuiSync(6)
|
||||
public YesNo placeMode;
|
||||
|
||||
@GuiSync( 6 )
|
||||
public YesNo placeMode;
|
||||
public ContainerFormationPlane(int id, final PlayerInventory ip, final PartFormationPlane te) {
|
||||
super(TYPE, id, ip, te);
|
||||
}
|
||||
|
||||
public ContainerFormationPlane(int id, final PlayerInventory ip, final PartFormationPlane te )
|
||||
{
|
||||
super( TYPE, id, ip, te );
|
||||
}
|
||||
@Override
|
||||
protected int getHeight() {
|
||||
return 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 251;
|
||||
}
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
final IItemHandler config = this.getUpgradeable().getInventoryByName("config");
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
if (y < 2) {
|
||||
this.addSlot(new SlotFakeTypeOnly(config, y * 9 + x, xo + x * 18, yo + y * 18));
|
||||
} else {
|
||||
this.addSlot(new OptionalSlotFakeTypeOnly(config, this, y * 9 + x, xo, yo, x, y, y - 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final IItemHandler config = this.getUpgradeable().getInventoryByName( "config" );
|
||||
for( int y = 0; y < 7; y++ )
|
||||
{
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
if( y < 2 )
|
||||
{
|
||||
this.addSlot( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.addSlot( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades");
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
|
||||
this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18,
|
||||
this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187,
|
||||
8 + 18 * 2, this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187,
|
||||
8 + 18 * 3, this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187,
|
||||
8 + 18 * 4, this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
|
||||
this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
@Override
|
||||
protected boolean supportCapacity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int availableUpgrades() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
if (Platform.isServer()) {
|
||||
this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE));
|
||||
this.setPlaceMode((YesNo) this.getUpgradeable().getConfigManager().getSetting(Settings.PLACE_BLOCK));
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.setFuzzyMode( (FuzzyMode) this.getUpgradeable().getConfigManager().getSetting( Settings.FUZZY_MODE ) );
|
||||
this.setPlaceMode( (YesNo) this.getUpgradeable().getConfigManager().getSetting( Settings.PLACE_BLOCK ) );
|
||||
}
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled( final int idx )
|
||||
{
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
return upgrades > idx;
|
||||
}
|
||||
|
||||
return upgrades > idx;
|
||||
}
|
||||
public YesNo getPlaceMode() {
|
||||
return this.placeMode;
|
||||
}
|
||||
|
||||
public YesNo getPlaceMode()
|
||||
{
|
||||
return this.placeMode;
|
||||
}
|
||||
|
||||
private void setPlaceMode( final YesNo placeMode )
|
||||
{
|
||||
this.placeMode = placeMode;
|
||||
}
|
||||
private void setPlaceMode(final YesNo placeMode) {
|
||||
this.placeMode = placeMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -28,44 +25,47 @@ import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
|
||||
public class ContainerGrinder extends AEBaseContainer
|
||||
{
|
||||
public class ContainerGrinder extends AEBaseContainer {
|
||||
|
||||
public static ContainerType<ContainerGrinder> TYPE;
|
||||
public static ContainerType<ContainerGrinder> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerGrinder, TileGrinder> helper
|
||||
= new ContainerHelper<>(ContainerGrinder::new, TileGrinder.class);
|
||||
private static final ContainerHelper<ContainerGrinder, TileGrinder> helper = new ContainerHelper<>(
|
||||
ContainerGrinder::new, TileGrinder.class);
|
||||
|
||||
public static ContainerGrinder fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
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 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 );
|
||||
public ContainerGrinder(int id, final PlayerInventory ip, final TileGrinder grinder) {
|
||||
super(TYPE, id, ip, grinder, null);
|
||||
|
||||
IItemHandler inv = grinder.getInternalInventory();
|
||||
IItemHandler inv = grinder.getInternalInventory();
|
||||
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, inv, 0, 12, 17, this.getPlayerInventory() ) );
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, inv, 1, 12 + 18, 17, this.getPlayerInventory() ) );
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, inv, 2, 12 + 36, 17, this.getPlayerInventory() ) );
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ORE, inv, 0, 12, 17,
|
||||
this.getPlayerInventory()));
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ORE, inv, 1, 12 + 18, 17,
|
||||
this.getPlayerInventory()));
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ORE, inv, 2, 12 + 36, 17,
|
||||
this.getPlayerInventory()));
|
||||
|
||||
this.addSlot( new SlotInaccessible( inv, 6, 80, 40 ) );
|
||||
this.addSlot(new SlotInaccessible(inv, 6, 80, 40));
|
||||
|
||||
this.addSlot( new SlotOutput( inv, 3, 112, 63, 2 * 16 + 15 ) );
|
||||
this.addSlot( new SlotOutput( inv, 4, 112 + 18, 63, 2 * 16 + 15 ) );
|
||||
this.addSlot( new SlotOutput( inv, 5, 112 + 36, 63, 2 * 16 + 15 ) );
|
||||
this.addSlot(new SlotOutput(inv, 3, 112, 63, 2 * 16 + 15));
|
||||
this.addSlot(new SlotOutput(inv, 4, 112 + 18, 63, 2 * 16 + 15));
|
||||
this.addSlot(new SlotOutput(inv, 5, 112 + 36, 63, 2 * 16 + 15));
|
||||
|
||||
this.bindPlayerInventory( ip, 0, 176 - /* height of player inventory */82 );
|
||||
}
|
||||
this.bindPlayerInventory(ip, 0, 176 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,5 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
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 appeng.util.Platform;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
@@ -27,9 +14,23 @@ import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
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 appeng.util.Platform;
|
||||
|
||||
/**
|
||||
* Helper for containers that can be opened for a part <em>or</em> tile given that either
|
||||
* implements a given interface.
|
||||
* Helper for containers that can be opened for a part <em>or</em> tile given
|
||||
* that either implements a given interface.
|
||||
*
|
||||
* @param <C>
|
||||
*/
|
||||
@@ -45,15 +46,16 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
|
||||
this(factory, interfaceClass, null);
|
||||
}
|
||||
|
||||
public ContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass, SecurityPermissions requiredPermission) {
|
||||
public ContainerHelper(ContainerFactory<C, I> factory, Class<I> interfaceClass,
|
||||
SecurityPermissions requiredPermission) {
|
||||
this.requiredPermission = requiredPermission;
|
||||
this.interfaceClass = interfaceClass;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a container that is based around a single tile entity.
|
||||
* The tile entity's position is encoded in the packet buffer.
|
||||
* 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));
|
||||
@@ -82,15 +84,13 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
|
||||
|
||||
ITextComponent title = findContainerTitle(player.world, locator, accessInterface);
|
||||
|
||||
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
|
||||
);
|
||||
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::write);
|
||||
|
||||
return true;
|
||||
@@ -106,8 +106,10 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
|
||||
}
|
||||
|
||||
// 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)
|
||||
// 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();
|
||||
}
|
||||
@@ -147,8 +149,8 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
|
||||
if (interfaceClass.isInstance(part)) {
|
||||
return interfaceClass.cast(part);
|
||||
} else {
|
||||
AELog.debug("Trying to open a container @ %s for a %s, but the container requires %s",
|
||||
locator, part.getClass(), interfaceClass);
|
||||
AELog.debug("Trying to open a container @ %s for a %s, but the container requires %s", locator,
|
||||
part.getClass(), interfaceClass);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
@@ -162,13 +164,12 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
|
||||
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());
|
||||
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 )
|
||||
{
|
||||
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;
|
||||
@@ -178,10 +179,9 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
|
||||
}
|
||||
}
|
||||
|
||||
if( interfaceClass.isAssignableFrom(WirelessTerminalGuiObject.class) )
|
||||
{
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler( it );
|
||||
if ( wh != null) {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
@@ -196,8 +196,7 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
|
||||
|
||||
private boolean checkPermission(PlayerEntity player, Object accessInterface) {
|
||||
|
||||
if (requiredPermission != null)
|
||||
{
|
||||
if (requiredPermission != null) {
|
||||
return Platform.checkPermissions(player, accessInterface, requiredPermission, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -32,129 +29,114 @@ import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerIOPort extends ContainerUpgradeable {
|
||||
|
||||
public class ContainerIOPort extends ContainerUpgradeable
|
||||
{
|
||||
public static ContainerType<ContainerIOPort> TYPE;
|
||||
|
||||
public static ContainerType<ContainerIOPort> TYPE;
|
||||
private static final ContainerHelper<ContainerIOPort, TileIOPort> helper = new ContainerHelper<>(
|
||||
ContainerIOPort::new, TileIOPort.class, SecurityPermissions.BUILD);
|
||||
|
||||
private static final ContainerHelper<ContainerIOPort, TileIOPort> helper
|
||||
= new ContainerHelper<>(ContainerIOPort::new, TileIOPort.class, SecurityPermissions.BUILD);
|
||||
public static ContainerIOPort fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@GuiSync( 2 )
|
||||
public FullnessMode fMode = FullnessMode.EMPTY;
|
||||
@GuiSync( 3 )
|
||||
public OperationMode opMode = OperationMode.EMPTY;
|
||||
public ContainerIOPort(int id, final PlayerInventory ip, final TileIOPort te) {
|
||||
super(TYPE, id, ip, te);
|
||||
}
|
||||
|
||||
public ContainerIOPort(int id, final PlayerInventory ip, final TileIOPort te )
|
||||
{
|
||||
super( TYPE, id, ip, te );
|
||||
}
|
||||
@Override
|
||||
protected int getHeight() {
|
||||
return 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 166;
|
||||
}
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
int offX = 19;
|
||||
int offY = 17;
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
int offX = 19;
|
||||
int offY = 17;
|
||||
final IItemHandler cells = this.getUpgradeable().getInventoryByName("cells");
|
||||
|
||||
final IItemHandler cells = this.getUpgradeable().getInventoryByName( "cells" );
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 2; x++) {
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, cells,
|
||||
x + y * 2, offX + x * 18, offY + y * 18, this.getPlayerInventory()));
|
||||
}
|
||||
}
|
||||
|
||||
for( int y = 0; y < 3; y++ )
|
||||
{
|
||||
for( int x = 0; x < 2; x++ )
|
||||
{
|
||||
this.addSlot(
|
||||
new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, cells, x + y * 2, offX + x * 18, offY + y * 18, this
|
||||
.getPlayerInventory() ) );
|
||||
}
|
||||
}
|
||||
offX = 122;
|
||||
offY = 17;
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 2; x++) {
|
||||
this.addSlot(new SlotOutput(cells, 6 + x + y * 2, offX + x * 18, offY + y * 18,
|
||||
SlotRestrictedInput.PlacableItemType.STORAGE_CELLS.IIcon));
|
||||
}
|
||||
}
|
||||
|
||||
offX = 122;
|
||||
offY = 17;
|
||||
for( int y = 0; y < 3; y++ )
|
||||
{
|
||||
for( int x = 0; x < 2; x++ )
|
||||
{
|
||||
this.addSlot(
|
||||
new SlotOutput( cells, 6 + x + y * 2, offX + x * 18, offY + y * 18, SlotRestrictedInput.PlacableItemType.STORAGE_CELLS.IIcon ) );
|
||||
}
|
||||
}
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades");
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
|
||||
this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18,
|
||||
this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187,
|
||||
8 + 18 * 2, this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
|
||||
this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
@Override
|
||||
protected boolean supportCapacity() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int availableUpgrades() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
if (Platform.isServer()) {
|
||||
this.setOperationMode(
|
||||
(OperationMode) this.getUpgradeable().getConfigManager().getSetting(Settings.OPERATION_MODE));
|
||||
this.setFullMode(
|
||||
(FullnessMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FULLNESS_MODE));
|
||||
this.setRedStoneMode(
|
||||
(RedstoneMode) this.getUpgradeable().getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED));
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.setOperationMode( (OperationMode) this.getUpgradeable().getConfigManager().getSetting( Settings.OPERATION_MODE ) );
|
||||
this.setFullMode( (FullnessMode) this.getUpgradeable().getConfigManager().getSetting( Settings.FULLNESS_MODE ) );
|
||||
this.setRedStoneMode( (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ) );
|
||||
}
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
public FullnessMode getFullMode() {
|
||||
return this.fMode;
|
||||
}
|
||||
|
||||
public FullnessMode getFullMode()
|
||||
{
|
||||
return this.fMode;
|
||||
}
|
||||
private void setFullMode(final FullnessMode fMode) {
|
||||
this.fMode = fMode;
|
||||
}
|
||||
|
||||
private void setFullMode( final FullnessMode fMode )
|
||||
{
|
||||
this.fMode = fMode;
|
||||
}
|
||||
public OperationMode getOperationMode() {
|
||||
return this.opMode;
|
||||
}
|
||||
|
||||
public OperationMode getOperationMode()
|
||||
{
|
||||
return this.opMode;
|
||||
}
|
||||
|
||||
private void setOperationMode( final OperationMode opMode )
|
||||
{
|
||||
this.opMode = opMode;
|
||||
}
|
||||
private void setOperationMode(final OperationMode opMode) {
|
||||
this.opMode = opMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
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.AEApi;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
@@ -30,14 +37,6 @@ import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.misc.InscriberRecipes;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
@@ -45,139 +44,128 @@ import net.minecraftforge.items.IItemHandler;
|
||||
* @version rv2
|
||||
* @since rv0
|
||||
*/
|
||||
public class ContainerInscriber extends ContainerUpgradeable implements IProgressProvider
|
||||
{
|
||||
public class ContainerInscriber extends ContainerUpgradeable implements IProgressProvider {
|
||||
|
||||
public static ContainerType<ContainerInscriber> TYPE;
|
||||
public static ContainerType<ContainerInscriber> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerInscriber, TileInscriber> helper
|
||||
= new ContainerHelper<>(ContainerInscriber::new, TileInscriber.class);
|
||||
private static final ContainerHelper<ContainerInscriber, TileInscriber> helper = new ContainerHelper<>(
|
||||
ContainerInscriber::new, TileInscriber.class);
|
||||
|
||||
public static ContainerInscriber fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
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);
|
||||
}
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
|
||||
private final TileInscriber ti;
|
||||
private final TileInscriber ti;
|
||||
|
||||
private final Slot top;
|
||||
private final Slot middle;
|
||||
private final Slot bottom;
|
||||
private final Slot top;
|
||||
private final Slot middle;
|
||||
private final Slot bottom;
|
||||
|
||||
@GuiSync( 2 )
|
||||
public int maxProcessingTime = -1;
|
||||
@GuiSync(2)
|
||||
public int maxProcessingTime = -1;
|
||||
|
||||
@GuiSync( 3 )
|
||||
public int processingTime = -1;
|
||||
@GuiSync(3)
|
||||
public int processingTime = -1;
|
||||
|
||||
public ContainerInscriber(int id, final PlayerInventory ip, final TileInscriber te )
|
||||
{
|
||||
super( TYPE, id, ip, te );
|
||||
this.ti = te;
|
||||
public ContainerInscriber(int id, final PlayerInventory ip, final TileInscriber te) {
|
||||
super(TYPE, id, ip, te);
|
||||
this.ti = te;
|
||||
|
||||
IItemHandler inv = te.getInternalInventory();
|
||||
IItemHandler inv = te.getInternalInventory();
|
||||
|
||||
SlotRestrictedInput top = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, inv, 0, 45, 16, this.getPlayerInventory());
|
||||
top.setStackLimit(1);
|
||||
this.top = this.addSlot(top);
|
||||
SlotRestrictedInput bottom = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, inv, 1, 45, 62, this.getPlayerInventory());
|
||||
bottom.setStackLimit(1);
|
||||
this.bottom = this.addSlot(bottom);
|
||||
SlotRestrictedInput middle = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, inv, 2, 63, 39, this.getPlayerInventory() );
|
||||
middle.setStackLimit(1);
|
||||
this.middle = this.addSlot(middle);
|
||||
SlotRestrictedInput top = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, inv, 0,
|
||||
45, 16, this.getPlayerInventory());
|
||||
top.setStackLimit(1);
|
||||
this.top = this.addSlot(top);
|
||||
SlotRestrictedInput bottom = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, inv,
|
||||
1, 45, 62, this.getPlayerInventory());
|
||||
bottom.setStackLimit(1);
|
||||
this.bottom = this.addSlot(bottom);
|
||||
SlotRestrictedInput middle = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, inv,
|
||||
2, 63, 39, this.getPlayerInventory());
|
||||
middle.setStackLimit(1);
|
||||
this.middle = this.addSlot(middle);
|
||||
|
||||
this.addSlot( new SlotOutput( inv, 3, 113, 40, -1 ) );
|
||||
}
|
||||
this.addSlot(new SlotOutput(inv, 3, 113, 40, -1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 176;
|
||||
}
|
||||
@Override
|
||||
protected int getHeight() {
|
||||
return 176;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Overridden super.setupConfig to prevent setting up the fake slots
|
||||
*/
|
||||
protected void setupConfig()
|
||||
{
|
||||
this.setupUpgrades();
|
||||
}
|
||||
@Override
|
||||
/**
|
||||
* Overridden super.setupConfig to prevent setting up the fake slots
|
||||
*/
|
||||
protected void setupConfig() {
|
||||
this.setupUpgrades();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected boolean supportCapacity() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
@Override
|
||||
public int availableUpgrades() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.standardDetectAndSendChanges();
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.standardDetectAndSendChanges();
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.maxProcessingTime = this.ti.getMaxProcessingTime();
|
||||
this.processingTime = this.ti.getProcessingTime();
|
||||
}
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
this.maxProcessingTime = this.ti.getMaxProcessingTime();
|
||||
this.processingTime = this.ti.getProcessingTime();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidForSlot( final Slot s, final ItemStack is )
|
||||
{
|
||||
final ItemStack top = this.ti.getInternalInventory().getStackInSlot( 0 );
|
||||
final ItemStack bot = this.ti.getInternalInventory().getStackInSlot( 1 );
|
||||
@Override
|
||||
public boolean isValidForSlot(final Slot s, final ItemStack is) {
|
||||
final ItemStack top = this.ti.getInternalInventory().getStackInSlot(0);
|
||||
final ItemStack bot = this.ti.getInternalInventory().getStackInSlot(1);
|
||||
|
||||
if( s == this.middle )
|
||||
{
|
||||
IItemDefinition press = AEApi.instance().definitions().materials().namePress();
|
||||
if( press.isSameAs( top ) || press.isSameAs( bot ) )
|
||||
{
|
||||
return !press.isSameAs( is );
|
||||
}
|
||||
if (s == this.middle) {
|
||||
IItemDefinition press = AEApi.instance().definitions().materials().namePress();
|
||||
if (press.isSameAs(top) || press.isSameAs(bot)) {
|
||||
return !press.isSameAs(is);
|
||||
}
|
||||
|
||||
return InscriberRecipes.findRecipe(ti.getWorld(), is, top, bot, false) != null;
|
||||
}
|
||||
else if( ( s == this.top && !bot.isEmpty() ) || ( s == this.bottom && !top.isEmpty() ) ) {
|
||||
ItemStack otherSlot;
|
||||
if (s == this.top) {
|
||||
otherSlot = this.bottom.getStack();
|
||||
} else {
|
||||
otherSlot = this.top.getStack();
|
||||
}
|
||||
return InscriberRecipes.findRecipe(ti.getWorld(), is, top, bot, false) != null;
|
||||
} else if ((s == this.top && !bot.isEmpty()) || (s == this.bottom && !top.isEmpty())) {
|
||||
ItemStack otherSlot;
|
||||
if (s == this.top) {
|
||||
otherSlot = this.bottom.getStack();
|
||||
} else {
|
||||
otherSlot = this.top.getStack();
|
||||
}
|
||||
|
||||
// name presses
|
||||
final IItemDefinition namePress = AEApi.instance().definitions().materials().namePress();
|
||||
if (namePress.isSameAs(otherSlot)) {
|
||||
return namePress.isSameAs(is);
|
||||
}
|
||||
// name presses
|
||||
final IItemDefinition namePress = AEApi.instance().definitions().materials().namePress();
|
||||
if (namePress.isSameAs(otherSlot)) {
|
||||
return namePress.isSameAs(is);
|
||||
}
|
||||
|
||||
// everything else
|
||||
// test for a partial recipe match (ignoring the middle slot)
|
||||
return InscriberRecipes.isValidOptionalIngredientCombination(ti.getWorld(), is, otherSlot);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// everything else
|
||||
// test for a partial recipe match (ignoring the middle slot)
|
||||
return InscriberRecipes.isValidOptionalIngredientCombination(ti.getWorld(), is, otherSlot);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentProgress()
|
||||
{
|
||||
return this.processingTime;
|
||||
}
|
||||
@Override
|
||||
public int getCurrentProgress() {
|
||||
return this.processingTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxProgress()
|
||||
{
|
||||
return this.maxProcessingTime;
|
||||
}
|
||||
@Override
|
||||
public int getMaxProgress() {
|
||||
return this.maxProcessingTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,121 +18,105 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotNormal;
|
||||
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 class ContainerInterface extends ContainerUpgradeable
|
||||
{
|
||||
public static ContainerType<ContainerInterface> TYPE;
|
||||
|
||||
public static ContainerType<ContainerInterface> TYPE;
|
||||
private static final ContainerHelper<ContainerInterface, IInterfaceHost> helper = new ContainerHelper<>(
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
private final DualityInterface myDuality;
|
||||
|
||||
private final DualityInterface myDuality;
|
||||
@GuiSync(3)
|
||||
public YesNo bMode = YesNo.NO;
|
||||
|
||||
@GuiSync( 3 )
|
||||
public YesNo bMode = YesNo.NO;
|
||||
@GuiSync(4)
|
||||
public YesNo iTermMode = YesNo.YES;
|
||||
|
||||
@GuiSync( 4 )
|
||||
public YesNo iTermMode = YesNo.YES;
|
||||
public ContainerInterface(int id, final PlayerInventory ip, final IInterfaceHost te) {
|
||||
super(TYPE, id, ip, te.getInterfaceDuality().getHost());
|
||||
|
||||
public ContainerInterface(int id, final PlayerInventory ip, final IInterfaceHost te )
|
||||
{
|
||||
super( TYPE, id, ip, te.getInterfaceDuality().getHost() );
|
||||
this.myDuality = te.getInterfaceDuality();
|
||||
|
||||
this.myDuality = te.getInterfaceDuality();
|
||||
for (int x = 0; x < DualityInterface.NUMBER_OF_PATTERN_SLOTS; x++) {
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN,
|
||||
this.myDuality.getPatterns(), x, 8 + 18 * x, 90 + 7, this.getPlayerInventory()));
|
||||
}
|
||||
|
||||
for( int x = 0; x < DualityInterface.NUMBER_OF_PATTERN_SLOTS; x++ )
|
||||
{
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, this.myDuality
|
||||
.getPatterns(), x, 8 + 18 * x, 90 + 7, this.getPlayerInventory() ) );
|
||||
}
|
||||
for (int x = 0; x < DualityInterface.NUMBER_OF_CONFIG_SLOTS; x++) {
|
||||
this.addSlot(new SlotFake(this.myDuality.getConfig(), x, 8 + 18 * x, 35));
|
||||
}
|
||||
|
||||
for( int x = 0; x < DualityInterface.NUMBER_OF_CONFIG_SLOTS; x++ )
|
||||
{
|
||||
this.addSlot( new SlotFake( this.myDuality.getConfig(), x, 8 + 18 * x, 35 ) );
|
||||
}
|
||||
for (int x = 0; x < DualityInterface.NUMBER_OF_STORAGE_SLOTS; x++) {
|
||||
this.addSlot(new SlotNormal(this.myDuality.getStorage(), x, 8 + 18 * x, 35 + 18));
|
||||
}
|
||||
}
|
||||
|
||||
for( int x = 0; x < DualityInterface.NUMBER_OF_STORAGE_SLOTS; x++ )
|
||||
{
|
||||
this.addSlot( new SlotNormal( this.myDuality.getStorage(), x, 8 + 18 * x, 35 + 18 ) );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected int getHeight() {
|
||||
return 211;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 211;
|
||||
}
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
this.setupUpgrades();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
this.setupUpgrades();
|
||||
}
|
||||
@Override
|
||||
public int availableUpgrades() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
protected void loadSettingsFromHost(final IConfigManager cm) {
|
||||
this.setBlockingMode((YesNo) cm.getSetting(Settings.BLOCK));
|
||||
this.setInterfaceTerminalMode((YesNo) cm.getSetting(Settings.INTERFACE_TERMINAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadSettingsFromHost( final IConfigManager cm )
|
||||
{
|
||||
this.setBlockingMode( (YesNo) cm.getSetting( Settings.BLOCK ) );
|
||||
this.setInterfaceTerminalMode( (YesNo) cm.getSetting( Settings.INTERFACE_TERMINAL ) );
|
||||
}
|
||||
public YesNo getBlockingMode() {
|
||||
return this.bMode;
|
||||
}
|
||||
|
||||
public YesNo getBlockingMode()
|
||||
{
|
||||
return this.bMode;
|
||||
}
|
||||
private void setBlockingMode(final YesNo bMode) {
|
||||
this.bMode = bMode;
|
||||
}
|
||||
|
||||
private void setBlockingMode( final YesNo bMode )
|
||||
{
|
||||
this.bMode = bMode;
|
||||
}
|
||||
public YesNo getInterfaceTerminalMode() {
|
||||
return this.iTermMode;
|
||||
}
|
||||
|
||||
public YesNo getInterfaceTerminalMode()
|
||||
{
|
||||
return this.iTermMode;
|
||||
}
|
||||
|
||||
private void setInterfaceTerminalMode( final YesNo iTermMode )
|
||||
{
|
||||
this.iTermMode = iTermMode;
|
||||
}
|
||||
private void setInterfaceTerminalMode(final YesNo iTermMode) {
|
||||
this.iTermMode = iTermMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,29 +18,28 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
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.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCompressedNBT;
|
||||
import appeng.helpers.DualityInterface;
|
||||
@@ -60,394 +59,325 @@ import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.WrapperRangeItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
|
||||
public final class ContainerInterfaceTerminal extends AEBaseContainer
|
||||
{
|
||||
|
||||
public static ContainerType<ContainerInterfaceTerminal> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerInterfaceTerminal, PartInterfaceTerminal> helper
|
||||
= new ContainerHelper<>(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..
|
||||
*/
|
||||
|
||||
private static long autoBase = Long.MIN_VALUE;
|
||||
private final Map<IInterfaceHost, InvTracker> diList = new HashMap<>();
|
||||
private final Map<Long, InvTracker> byId = new HashMap<>();
|
||||
private IGrid grid;
|
||||
private CompoundNBT data = new CompoundNBT();
|
||||
|
||||
public ContainerInterfaceTerminal(int id, final PlayerInventory ip, final PartInterfaceTerminal anchor )
|
||||
{
|
||||
super( TYPE, id, ip, anchor );
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.grid = anchor.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
this.bindPlayerInventory( ip, 0, 222 - /* height of player inventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if( this.grid == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
boolean missing = false;
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
if( host != null )
|
||||
{
|
||||
final IGridNode agn = host.getActionableNode();
|
||||
if( agn != null && agn.isActive() )
|
||||
{
|
||||
for( final IGridNode gn : this.grid.getMachines( TileInterface.class ) )
|
||||
{
|
||||
if( gn.isActive() )
|
||||
{
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
if( ih.getInterfaceDuality().getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.NO )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final InvTracker t = this.diList.get( ih );
|
||||
|
||||
if( t == null )
|
||||
{
|
||||
missing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
if( !t.unlocalizedName.equals( dual.getTermName() ) )
|
||||
{
|
||||
missing = true;
|
||||
}
|
||||
}
|
||||
|
||||
total++;
|
||||
}
|
||||
}
|
||||
|
||||
for( final IGridNode gn : this.grid.getMachines( PartInterface.class ) )
|
||||
{
|
||||
if( gn.isActive() )
|
||||
{
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
if( ih.getInterfaceDuality().getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.NO )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final InvTracker t = this.diList.get( ih );
|
||||
|
||||
if( t == null )
|
||||
{
|
||||
missing = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
if( !t.unlocalizedName.equals( dual.getTermName() ) )
|
||||
{
|
||||
missing = true;
|
||||
}
|
||||
}
|
||||
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( total != this.diList.size() || missing )
|
||||
{
|
||||
this.regenList( this.data );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( final Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet() )
|
||||
{
|
||||
final InvTracker inv = en.getValue();
|
||||
for( int x = 0; x < inv.server.getSlots(); x++ )
|
||||
{
|
||||
if( this.isDifferent( inv.server.getStackInSlot( x ), inv.client.getStackInSlot( x ) ) )
|
||||
{
|
||||
this.addItems( this.data, inv, x, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !this.data.isEmpty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketCompressedNBT( this.data ), (ServerPlayerEntity) this.getPlayerInv().player );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
this.data = new CompoundNBT();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction( final ServerPlayerEntity player, final InventoryAction action, final int slot, final long id )
|
||||
{
|
||||
final InvTracker inv = this.byId.get( id );
|
||||
if( inv != null )
|
||||
{
|
||||
final ItemStack is = inv.server.getStackInSlot( slot );
|
||||
final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty();
|
||||
|
||||
final InventoryAdaptor playerHand = new AdaptorItemHandler( new WrapperCursorItemHandler( player.inventory ) );
|
||||
|
||||
final IItemHandler theSlot = new WrapperFilteredItemHandler( new WrapperRangeItemHandler( inv.server, slot, slot + 1 ), new PatternSlotFilter() );
|
||||
final InventoryAdaptor interfaceSlot = new AdaptorItemHandler( theSlot );
|
||||
|
||||
switch( action )
|
||||
{
|
||||
case PICKUP_OR_SET_DOWN:
|
||||
|
||||
if( hasItemInHand )
|
||||
{
|
||||
ItemStack inSlot = theSlot.getStackInSlot( 0 );
|
||||
if( inSlot.isEmpty() )
|
||||
{
|
||||
player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
inSlot = inSlot.copy();
|
||||
final ItemStack inHand = player.inventory.getItemStack().copy();
|
||||
|
||||
ItemHandlerUtil.setStackInSlot( theSlot, 0, ItemStack.EMPTY );
|
||||
player.inventory.setItemStack( ItemStack.EMPTY );
|
||||
|
||||
player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) );
|
||||
|
||||
if( player.inventory.getItemStack().isEmpty() )
|
||||
{
|
||||
player.inventory.setItemStack( inSlot );
|
||||
}
|
||||
else
|
||||
{
|
||||
player.inventory.setItemStack( inHand );
|
||||
ItemHandlerUtil.setStackInSlot( theSlot, 0, inSlot );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( theSlot, 0, playerHand.addItems( theSlot.getStackInSlot( 0 ) ) );
|
||||
}
|
||||
|
||||
break;
|
||||
case SPLIT_OR_PLACE_SINGLE:
|
||||
|
||||
if( hasItemInHand )
|
||||
{
|
||||
ItemStack extra = playerHand.removeItems( 1, ItemStack.EMPTY, null );
|
||||
if( !extra.isEmpty() )
|
||||
{
|
||||
extra = interfaceSlot.addItems( extra );
|
||||
}
|
||||
if( !extra.isEmpty() )
|
||||
{
|
||||
playerHand.addItems( extra );
|
||||
}
|
||||
}
|
||||
else if( !is.isEmpty() )
|
||||
{
|
||||
ItemStack extra = interfaceSlot.removeItems( ( is.getCount() + 1 ) / 2, ItemStack.EMPTY, null );
|
||||
if( !extra.isEmpty() )
|
||||
{
|
||||
extra = playerHand.addItems( extra );
|
||||
}
|
||||
if( !extra.isEmpty() )
|
||||
{
|
||||
interfaceSlot.addItems( extra );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case SHIFT_CLICK:
|
||||
|
||||
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( player );
|
||||
|
||||
ItemHandlerUtil.setStackInSlot( theSlot, 0, playerInv.addItems( theSlot.getStackInSlot( 0 ) ) );
|
||||
|
||||
break;
|
||||
case MOVE_REGION:
|
||||
|
||||
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor( player );
|
||||
for( int x = 0; x < inv.server.getSlots(); x++ )
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( inv.server, x, playerInvAd.addItems( inv.server.getStackInSlot( x ) ) );
|
||||
}
|
||||
|
||||
break;
|
||||
case CREATIVE_DUPLICATE:
|
||||
|
||||
if( player.abilities.isCreativeMode && !hasItemInHand )
|
||||
{
|
||||
player.inventory.setItemStack( is.isEmpty() ? ItemStack.EMPTY : is.copy() );
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateHeld( player );
|
||||
}
|
||||
}
|
||||
|
||||
private void regenList( final CompoundNBT data )
|
||||
{
|
||||
this.byId.clear();
|
||||
this.diList.clear();
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
if( host != null )
|
||||
{
|
||||
final IGridNode agn = host.getActionableNode();
|
||||
if( agn != null && agn.isActive() )
|
||||
{
|
||||
for( final IGridNode gn : this.grid.getMachines( TileInterface.class ) )
|
||||
{
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
if( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES )
|
||||
{
|
||||
this.diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName().getString() ) );
|
||||
}
|
||||
}
|
||||
|
||||
for( final IGridNode gn : this.grid.getMachines( PartInterface.class ) )
|
||||
{
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
if( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES )
|
||||
{
|
||||
this.diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName().getString() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.putBoolean("clear", true);
|
||||
|
||||
for( final Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet() )
|
||||
{
|
||||
final InvTracker inv = en.getValue();
|
||||
this.byId.put( inv.which, inv );
|
||||
this.addItems( data, inv, 0, inv.server.getSlots() );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDifferent( final ItemStack a, final ItemStack b )
|
||||
{
|
||||
if( a.isEmpty() && b.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( a.isEmpty() || b.isEmpty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return !ItemStack.areItemStacksEqual( a, b );
|
||||
}
|
||||
|
||||
private void addItems( final CompoundNBT data, final InvTracker inv, final int offset, final int length )
|
||||
{
|
||||
final String name = '=' + Long.toString( inv.which, Character.MAX_RADIX );
|
||||
final CompoundNBT tag = data.getCompound( name );
|
||||
|
||||
if( tag.isEmpty() )
|
||||
{
|
||||
tag.putLong( "sortBy", inv.sortBy );
|
||||
tag.putString("un", inv.unlocalizedName);
|
||||
}
|
||||
|
||||
for( int x = 0; x < length; x++ )
|
||||
{
|
||||
final CompoundNBT itemNBT = new CompoundNBT();
|
||||
|
||||
final ItemStack is = inv.server.getStackInSlot( x + offset );
|
||||
|
||||
// "update" client side.
|
||||
ItemHandlerUtil.setStackInSlot( inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy() );
|
||||
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
is.write(itemNBT);
|
||||
}
|
||||
|
||||
tag.put( Integer.toString( x + offset ), itemNBT );
|
||||
}
|
||||
|
||||
data.put( name, tag );
|
||||
}
|
||||
|
||||
private static class InvTracker
|
||||
{
|
||||
|
||||
private final long sortBy;
|
||||
private final long which = autoBase++;
|
||||
private final String unlocalizedName;
|
||||
private final IItemHandler client;
|
||||
private final IItemHandler server;
|
||||
|
||||
public InvTracker( final DualityInterface dual, final IItemHandler patterns, final String unlocalizedName )
|
||||
{
|
||||
this.server = patterns;
|
||||
this.client = new AppEngInternalInventory( null, this.server.getSlots() );
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.sortBy = dual.getSortValue();
|
||||
}
|
||||
}
|
||||
|
||||
private static class PatternSlotFilter implements IAEItemFilter
|
||||
{
|
||||
@Override
|
||||
public boolean allowExtract( IItemHandler inv, int slot, int amount )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
|
||||
{
|
||||
return !stack.isEmpty() && stack.getItem() instanceof ItemEncodedPattern;
|
||||
}
|
||||
}
|
||||
public final class ContainerInterfaceTerminal extends AEBaseContainer {
|
||||
|
||||
public static ContainerType<ContainerInterfaceTerminal> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerInterfaceTerminal, PartInterfaceTerminal> helper = new ContainerHelper<>(
|
||||
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..
|
||||
*/
|
||||
|
||||
private static long autoBase = Long.MIN_VALUE;
|
||||
private final Map<IInterfaceHost, InvTracker> diList = new HashMap<>();
|
||||
private final Map<Long, InvTracker> byId = new HashMap<>();
|
||||
private IGrid grid;
|
||||
private CompoundNBT data = new CompoundNBT();
|
||||
|
||||
public ContainerInterfaceTerminal(int id, final PlayerInventory ip, final PartInterfaceTerminal anchor) {
|
||||
super(TYPE, id, ip, anchor);
|
||||
|
||||
if (Platform.isServer()) {
|
||||
this.grid = anchor.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
this.bindPlayerInventory(ip, 0, 222 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (this.grid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
boolean missing = false;
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
if (host != null) {
|
||||
final IGridNode agn = host.getActionableNode();
|
||||
if (agn != null && agn.isActive()) {
|
||||
for (final IGridNode gn : this.grid.getMachines(TileInterface.class)) {
|
||||
if (gn.isActive()) {
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
if (ih.getInterfaceDuality().getConfigManager()
|
||||
.getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final InvTracker t = this.diList.get(ih);
|
||||
|
||||
if (t == null) {
|
||||
missing = true;
|
||||
} else {
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
if (!t.unlocalizedName.equals(dual.getTermName())) {
|
||||
missing = true;
|
||||
}
|
||||
}
|
||||
|
||||
total++;
|
||||
}
|
||||
}
|
||||
|
||||
for (final IGridNode gn : this.grid.getMachines(PartInterface.class)) {
|
||||
if (gn.isActive()) {
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
if (ih.getInterfaceDuality().getConfigManager()
|
||||
.getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final InvTracker t = this.diList.get(ih);
|
||||
|
||||
if (t == null) {
|
||||
missing = true;
|
||||
} else {
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
if (!t.unlocalizedName.equals(dual.getTermName())) {
|
||||
missing = true;
|
||||
}
|
||||
}
|
||||
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (total != this.diList.size() || missing) {
|
||||
this.regenList(this.data);
|
||||
} else {
|
||||
for (final Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet()) {
|
||||
final InvTracker inv = en.getValue();
|
||||
for (int x = 0; x < inv.server.getSlots(); x++) {
|
||||
if (this.isDifferent(inv.server.getStackInSlot(x), inv.client.getStackInSlot(x))) {
|
||||
this.addItems(this.data, inv, x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.data.isEmpty()) {
|
||||
try {
|
||||
NetworkHandler.instance().sendTo(new PacketCompressedNBT(this.data),
|
||||
(ServerPlayerEntity) this.getPlayerInv().player);
|
||||
} catch (final IOException e) {
|
||||
// :P
|
||||
}
|
||||
|
||||
this.data = new CompoundNBT();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(final ServerPlayerEntity player, final InventoryAction action, final int slot, final long id) {
|
||||
final InvTracker inv = this.byId.get(id);
|
||||
if (inv != null) {
|
||||
final ItemStack is = inv.server.getStackInSlot(slot);
|
||||
final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty();
|
||||
|
||||
final InventoryAdaptor playerHand = new AdaptorItemHandler(new WrapperCursorItemHandler(player.inventory));
|
||||
|
||||
final IItemHandler theSlot = new WrapperFilteredItemHandler(
|
||||
new WrapperRangeItemHandler(inv.server, slot, slot + 1), new PatternSlotFilter());
|
||||
final InventoryAdaptor interfaceSlot = new AdaptorItemHandler(theSlot);
|
||||
|
||||
switch (action) {
|
||||
case PICKUP_OR_SET_DOWN:
|
||||
|
||||
if (hasItemInHand) {
|
||||
ItemStack inSlot = theSlot.getStackInSlot(0);
|
||||
if (inSlot.isEmpty()) {
|
||||
player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack()));
|
||||
} else {
|
||||
inSlot = inSlot.copy();
|
||||
final ItemStack inHand = player.inventory.getItemStack().copy();
|
||||
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, ItemStack.EMPTY);
|
||||
player.inventory.setItemStack(ItemStack.EMPTY);
|
||||
|
||||
player.inventory.setItemStack(interfaceSlot.addItems(inHand.copy()));
|
||||
|
||||
if (player.inventory.getItemStack().isEmpty()) {
|
||||
player.inventory.setItemStack(inSlot);
|
||||
} else {
|
||||
player.inventory.setItemStack(inHand);
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, inSlot);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, playerHand.addItems(theSlot.getStackInSlot(0)));
|
||||
}
|
||||
|
||||
break;
|
||||
case SPLIT_OR_PLACE_SINGLE:
|
||||
|
||||
if (hasItemInHand) {
|
||||
ItemStack extra = playerHand.removeItems(1, ItemStack.EMPTY, null);
|
||||
if (!extra.isEmpty()) {
|
||||
extra = interfaceSlot.addItems(extra);
|
||||
}
|
||||
if (!extra.isEmpty()) {
|
||||
playerHand.addItems(extra);
|
||||
}
|
||||
} else if (!is.isEmpty()) {
|
||||
ItemStack extra = interfaceSlot.removeItems((is.getCount() + 1) / 2, ItemStack.EMPTY, null);
|
||||
if (!extra.isEmpty()) {
|
||||
extra = playerHand.addItems(extra);
|
||||
}
|
||||
if (!extra.isEmpty()) {
|
||||
interfaceSlot.addItems(extra);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case SHIFT_CLICK:
|
||||
|
||||
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player);
|
||||
|
||||
ItemHandlerUtil.setStackInSlot(theSlot, 0, playerInv.addItems(theSlot.getStackInSlot(0)));
|
||||
|
||||
break;
|
||||
case MOVE_REGION:
|
||||
|
||||
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player);
|
||||
for (int x = 0; x < inv.server.getSlots(); x++) {
|
||||
ItemHandlerUtil.setStackInSlot(inv.server, x,
|
||||
playerInvAd.addItems(inv.server.getStackInSlot(x)));
|
||||
}
|
||||
|
||||
break;
|
||||
case CREATIVE_DUPLICATE:
|
||||
|
||||
if (player.abilities.isCreativeMode && !hasItemInHand) {
|
||||
player.inventory.setItemStack(is.isEmpty() ? ItemStack.EMPTY : is.copy());
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void regenList(final CompoundNBT data) {
|
||||
this.byId.clear();
|
||||
this.diList.clear();
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
if (host != null) {
|
||||
final IGridNode agn = host.getActionableNode();
|
||||
if (agn != null && agn.isActive()) {
|
||||
for (final IGridNode gn : this.grid.getMachines(TileInterface.class)) {
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) {
|
||||
this.diList.put(ih, new InvTracker(dual, dual.getPatterns(), dual.getTermName().getString()));
|
||||
}
|
||||
}
|
||||
|
||||
for (final IGridNode gn : this.grid.getMachines(PartInterface.class)) {
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) {
|
||||
this.diList.put(ih, new InvTracker(dual, dual.getPatterns(), dual.getTermName().getString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.putBoolean("clear", true);
|
||||
|
||||
for (final Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet()) {
|
||||
final InvTracker inv = en.getValue();
|
||||
this.byId.put(inv.which, inv);
|
||||
this.addItems(data, inv, 0, inv.server.getSlots());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDifferent(final ItemStack a, final ItemStack b) {
|
||||
if (a.isEmpty() && b.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a.isEmpty() || b.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !ItemStack.areItemStacksEqual(a, b);
|
||||
}
|
||||
|
||||
private void addItems(final CompoundNBT data, final InvTracker inv, final int offset, final int length) {
|
||||
final String name = '=' + Long.toString(inv.which, Character.MAX_RADIX);
|
||||
final CompoundNBT tag = data.getCompound(name);
|
||||
|
||||
if (tag.isEmpty()) {
|
||||
tag.putLong("sortBy", inv.sortBy);
|
||||
tag.putString("un", inv.unlocalizedName);
|
||||
}
|
||||
|
||||
for (int x = 0; x < length; x++) {
|
||||
final CompoundNBT itemNBT = new CompoundNBT();
|
||||
|
||||
final ItemStack is = inv.server.getStackInSlot(x + offset);
|
||||
|
||||
// "update" client side.
|
||||
ItemHandlerUtil.setStackInSlot(inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy());
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
is.write(itemNBT);
|
||||
}
|
||||
|
||||
tag.put(Integer.toString(x + offset), itemNBT);
|
||||
}
|
||||
|
||||
data.put(name, tag);
|
||||
}
|
||||
|
||||
private static class InvTracker {
|
||||
|
||||
private final long sortBy;
|
||||
private final long which = autoBase++;
|
||||
private final String unlocalizedName;
|
||||
private final IItemHandler client;
|
||||
private final IItemHandler server;
|
||||
|
||||
public InvTracker(final DualityInterface dual, final IItemHandler patterns, final String unlocalizedName) {
|
||||
this.server = patterns;
|
||||
this.client = new AppEngInternalInventory(null, this.server.getSlots());
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.sortBy = dual.getSortValue();
|
||||
}
|
||||
}
|
||||
|
||||
private static class PatternSlotFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
|
||||
return !stack.isEmpty() && stack.getItem() instanceof ItemEncodedPattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@@ -35,155 +33,133 @@ import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerLevelEmitter extends ContainerUpgradeable {
|
||||
|
||||
public class ContainerLevelEmitter extends ContainerUpgradeable
|
||||
{
|
||||
public static ContainerType<ContainerLevelEmitter> TYPE;
|
||||
|
||||
public static ContainerType<ContainerLevelEmitter> TYPE;
|
||||
private static final ContainerHelper<ContainerLevelEmitter, PartLevelEmitter> helper = new ContainerHelper<>(
|
||||
ContainerLevelEmitter::new, PartLevelEmitter.class, SecurityPermissions.BUILD);
|
||||
|
||||
private static final ContainerHelper<ContainerLevelEmitter, PartLevelEmitter> helper
|
||||
= new ContainerHelper<>(ContainerLevelEmitter::new, PartLevelEmitter.class, SecurityPermissions.BUILD);
|
||||
public static ContainerLevelEmitter fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
private final PartLevelEmitter lvlEmitter;
|
||||
|
||||
private final PartLevelEmitter lvlEmitter;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private TextFieldWidget textField;
|
||||
@GuiSync(2)
|
||||
public LevelType lvType;
|
||||
@GuiSync(3)
|
||||
public long EmitterValue = -1;
|
||||
@GuiSync(4)
|
||||
public YesNo cmType;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private TextFieldWidget textField;
|
||||
@GuiSync( 2 )
|
||||
public LevelType lvType;
|
||||
@GuiSync( 3 )
|
||||
public long EmitterValue = -1;
|
||||
@GuiSync( 4 )
|
||||
public YesNo cmType;
|
||||
public ContainerLevelEmitter(int id, final PlayerInventory ip, final PartLevelEmitter te) {
|
||||
super(TYPE, id, ip, te);
|
||||
this.lvlEmitter = te;
|
||||
}
|
||||
|
||||
public ContainerLevelEmitter( int id, final PlayerInventory ip, final PartLevelEmitter te )
|
||||
{
|
||||
super( TYPE, id, ip, te );
|
||||
this.lvlEmitter = te;
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void setTextField(final TextFieldWidget level) {
|
||||
this.textField = level;
|
||||
this.textField.setText(String.valueOf(this.EmitterValue));
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void setTextField( final TextFieldWidget level )
|
||||
{
|
||||
this.textField = level;
|
||||
this.textField.setText( String.valueOf( this.EmitterValue ) );
|
||||
}
|
||||
public void setLevel(final long l, final PlayerEntity player) {
|
||||
this.lvlEmitter.setReportingValue(l);
|
||||
this.EmitterValue = l;
|
||||
}
|
||||
|
||||
public void setLevel( final long l, final PlayerEntity player )
|
||||
{
|
||||
this.lvlEmitter.setReportingValue( l );
|
||||
this.EmitterValue = l;
|
||||
}
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades");
|
||||
if (this.availableUpgrades() > 0) {
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
|
||||
this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
if (this.availableUpgrades() > 1) {
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187,
|
||||
8 + 18, this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
if (this.availableUpgrades() > 2) {
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187,
|
||||
8 + 18 * 2, this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
if (this.availableUpgrades() > 3) {
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187,
|
||||
8 + 18 * 3, this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
|
||||
if( this.availableUpgrades() > 0 )
|
||||
{
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
if( this.availableUpgrades() > 1 )
|
||||
{
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
if( this.availableUpgrades() > 2 )
|
||||
{
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
if( this.availableUpgrades() > 3 )
|
||||
{
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName("config");
|
||||
final int y = 40;
|
||||
final int x = 80 + 44;
|
||||
this.addSlot(new SlotFakeTypeOnly(inv, 0, x, y));
|
||||
}
|
||||
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
|
||||
final int y = 40;
|
||||
final int x = 80 + 44;
|
||||
this.addSlot( new SlotFakeTypeOnly( inv, 0, x, y ) );
|
||||
}
|
||||
@Override
|
||||
protected boolean supportCapacity() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int availableUpgrades() {
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
if (Platform.isServer()) {
|
||||
this.EmitterValue = this.lvlEmitter.getReportingValue();
|
||||
this.setCraftingMode(
|
||||
(YesNo) this.getUpgradeable().getConfigManager().getSetting(Settings.CRAFT_VIA_REDSTONE));
|
||||
this.setLevelMode((LevelType) this.getUpgradeable().getConfigManager().getSetting(Settings.LEVEL_TYPE));
|
||||
this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE));
|
||||
this.setRedStoneMode(
|
||||
(RedstoneMode) this.getUpgradeable().getConfigManager().getSetting(Settings.REDSTONE_EMITTER));
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.EmitterValue = this.lvlEmitter.getReportingValue();
|
||||
this.setCraftingMode( (YesNo) this.getUpgradeable().getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE ) );
|
||||
this.setLevelMode( (LevelType) this.getUpgradeable().getConfigManager().getSetting( Settings.LEVEL_TYPE ) );
|
||||
this.setFuzzyMode( (FuzzyMode) this.getUpgradeable().getConfigManager().getSetting( Settings.FUZZY_MODE ) );
|
||||
this.setRedStoneMode( (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) );
|
||||
}
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
|
||||
if (field.equals("EmitterValue")) {
|
||||
if (this.textField != null) {
|
||||
this.textField.setText(String.valueOf(this.EmitterValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate( final String field, final Object oldValue, final Object newValue )
|
||||
{
|
||||
if( field.equals( "EmitterValue" ) )
|
||||
{
|
||||
if( this.textField != null )
|
||||
{
|
||||
this.textField.setText( String.valueOf( this.EmitterValue ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public YesNo getCraftingMode() {
|
||||
return this.cmType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YesNo getCraftingMode()
|
||||
{
|
||||
return this.cmType;
|
||||
}
|
||||
@Override
|
||||
public void setCraftingMode(final YesNo cmType) {
|
||||
this.cmType = cmType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCraftingMode( final YesNo cmType )
|
||||
{
|
||||
this.cmType = cmType;
|
||||
}
|
||||
public LevelType getLevelMode() {
|
||||
return this.lvType;
|
||||
}
|
||||
|
||||
public LevelType getLevelMode()
|
||||
{
|
||||
return this.lvType;
|
||||
}
|
||||
|
||||
private void setLevelMode( final LevelType lvType )
|
||||
{
|
||||
this.lvType = lvType;
|
||||
}
|
||||
private void setLevelMode(final LevelType lvType) {
|
||||
this.lvType = lvType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
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;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
@@ -33,152 +40,125 @@ 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 class ContainerMAC extends ContainerUpgradeable implements IProgressProvider
|
||||
{
|
||||
public static ContainerType<ContainerMAC> TYPE;
|
||||
|
||||
public static ContainerType<ContainerMAC> TYPE;
|
||||
private static final ContainerHelper<ContainerMAC, TileMolecularAssembler> helper = new ContainerHelper<>(
|
||||
ContainerMAC::new, TileMolecularAssembler.class);
|
||||
|
||||
private static final ContainerHelper<ContainerMAC, TileMolecularAssembler> helper
|
||||
= new ContainerHelper<>(ContainerMAC::new, TileMolecularAssembler.class);
|
||||
public static ContainerMAC fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
private static final int MAX_CRAFT_PROGRESS = 100;
|
||||
private final TileMolecularAssembler tma;
|
||||
@GuiSync( 4 )
|
||||
public int craftProgress = 0;
|
||||
public ContainerMAC(int id, final PlayerInventory ip, final TileMolecularAssembler te) {
|
||||
super(TYPE, id, ip, te);
|
||||
this.tma = te;
|
||||
}
|
||||
|
||||
public ContainerMAC(int id, final PlayerInventory ip, final TileMolecularAssembler te )
|
||||
{
|
||||
super( TYPE, id, ip, te );
|
||||
this.tma = te;
|
||||
}
|
||||
public boolean isValidItemForSlot(final int slotIndex, final ItemStack i) {
|
||||
final IItemHandler mac = this.getUpgradeable().getInventoryByName("mac");
|
||||
|
||||
public boolean isValidItemForSlot( final int slotIndex, final ItemStack i )
|
||||
{
|
||||
final IItemHandler mac = this.getUpgradeable().getInventoryByName( "mac" );
|
||||
final ItemStack is = mac.getStackInSlot(10);
|
||||
if (is.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ItemStack is = mac.getStackInSlot( 10 );
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (is.getItem() instanceof ItemEncodedPattern) {
|
||||
final World w = this.getTileEntity().getWorld();
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
final ICraftingPatternDetails ph = iep.getPatternForItem(is, w);
|
||||
if (ph.isCraftable()) {
|
||||
return ph.isValidItemForSlot(slotIndex, i, w);
|
||||
}
|
||||
}
|
||||
|
||||
if( is.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
final World w = this.getTileEntity().getWorld();
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
final ICraftingPatternDetails ph = iep.getPatternForItem( is, w );
|
||||
if( ph.isCraftable() )
|
||||
{
|
||||
return ph.isValidItemForSlot( slotIndex, i, w );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected int getHeight() {
|
||||
return 197;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 197;
|
||||
}
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
int offX = 29;
|
||||
int offY = 30;
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
int offX = 29;
|
||||
int offY = 30;
|
||||
final IItemHandler mac = this.getUpgradeable().getInventoryByName("mac");
|
||||
|
||||
final IItemHandler mac = this.getUpgradeable().getInventoryByName( "mac" );
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
final SlotMACPattern s = new SlotMACPattern(this, mac, x + y * 3, offX + x * 18, offY + y * 18);
|
||||
this.addSlot(s);
|
||||
}
|
||||
}
|
||||
|
||||
for( int y = 0; y < 3; y++ )
|
||||
{
|
||||
for( int x = 0; x < 3; x++ )
|
||||
{
|
||||
final SlotMACPattern s = new SlotMACPattern( this, mac, x + y * 3, offX + x * 18, offY + y * 18 );
|
||||
this.addSlot( s );
|
||||
}
|
||||
}
|
||||
offX = 126;
|
||||
offY = 16;
|
||||
|
||||
offX = 126;
|
||||
offY = 16;
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODED_CRAFTING_PATTERN, mac, 10,
|
||||
offX, offY, this.getPlayerInventory()));
|
||||
this.addSlot(new SlotOutput(mac, 9, offX, offY + 32, -1));
|
||||
|
||||
this.addSlot(
|
||||
new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_CRAFTING_PATTERN, mac, 10, offX, offY, this.getPlayerInventory() ) );
|
||||
this.addSlot( new SlotOutput( mac, 9, offX, offY + 32, -1 ) );
|
||||
offX = 122;
|
||||
offY = 17;
|
||||
|
||||
offX = 122;
|
||||
offY = 17;
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades");
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
|
||||
this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18,
|
||||
this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187,
|
||||
8 + 18 * 2, this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187,
|
||||
8 + 18 * 3, this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187,
|
||||
8 + 18 * 4, this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
|
||||
this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
@Override
|
||||
protected boolean supportCapacity() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int availableUpgrades() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
if (Platform.isServer()) {
|
||||
this.setRedStoneMode(
|
||||
(RedstoneMode) this.getUpgradeable().getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED));
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.setRedStoneMode( (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ) );
|
||||
}
|
||||
this.craftProgress = this.tma.getCraftingProgress();
|
||||
|
||||
this.craftProgress = this.tma.getCraftingProgress();
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public int getCurrentProgress() {
|
||||
return this.craftProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentProgress()
|
||||
{
|
||||
return this.craftProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxProgress()
|
||||
{
|
||||
return MAX_CRAFT_PROGRESS;
|
||||
}
|
||||
@Override
|
||||
public int getMaxProgress() {
|
||||
return MAX_CRAFT_PROGRESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,14 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.BufferOverflowException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
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.item.ItemStack;
|
||||
@@ -43,6 +40,7 @@ import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
@@ -65,6 +63,7 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.AELog;
|
||||
@@ -76,403 +75,320 @@ import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerMEMonitorable extends AEBaseContainer
|
||||
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack> {
|
||||
|
||||
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack>
|
||||
{
|
||||
public static ContainerType<ContainerMEMonitorable> TYPE;
|
||||
|
||||
public static ContainerType<ContainerMEMonitorable> TYPE;
|
||||
private static final ContainerHelper<ContainerMEMonitorable, ITerminalHost> helper = new ContainerHelper<>(
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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 = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final IConfigManager clientCM;
|
||||
private final ITerminalHost host;
|
||||
@GuiSync(99)
|
||||
public boolean canAccessViewCells = false;
|
||||
@GuiSync(98)
|
||||
public boolean hasPower = false;
|
||||
private IConfigManagerHost gui;
|
||||
private IConfigManager serverCM;
|
||||
private IGridNode networkNode;
|
||||
|
||||
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
|
||||
private final IMEMonitor<IAEItemStack> monitor;
|
||||
private final IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
private final IConfigManager clientCM;
|
||||
private final ITerminalHost host;
|
||||
@GuiSync( 99 )
|
||||
public boolean canAccessViewCells = false;
|
||||
@GuiSync( 98 )
|
||||
public boolean hasPower = false;
|
||||
private IConfigManagerHost gui;
|
||||
private IConfigManager serverCM;
|
||||
private IGridNode networkNode;
|
||||
public ContainerMEMonitorable(int id, final PlayerInventory ip, final ITerminalHost monitorable) {
|
||||
this(TYPE, id, ip, monitorable, true);
|
||||
}
|
||||
|
||||
public ContainerMEMonitorable( int id, final PlayerInventory ip, final ITerminalHost monitorable )
|
||||
{
|
||||
this( TYPE, id, ip, monitorable, true );
|
||||
}
|
||||
public ContainerMEMonitorable(ContainerType<?> containerType, int id, PlayerInventory ip,
|
||||
final ITerminalHost monitorable, final boolean bindInventory) {
|
||||
super(containerType, id, ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null,
|
||||
monitorable instanceof IPart ? (IPart) monitorable : null,
|
||||
monitorable instanceof IGuiItemObject ? (IGuiItemObject) monitorable : null);
|
||||
|
||||
public ContainerMEMonitorable(ContainerType<?> containerType, int id, PlayerInventory ip, final ITerminalHost monitorable, final boolean bindInventory ) {
|
||||
super( containerType,
|
||||
id,
|
||||
ip,
|
||||
monitorable instanceof TileEntity ? (TileEntity) monitorable : null,
|
||||
monitorable instanceof IPart ? (IPart) monitorable : null,
|
||||
monitorable instanceof IGuiItemObject ? (IGuiItemObject) monitorable : null);
|
||||
this.host = monitorable;
|
||||
this.clientCM = new ConfigManager(this);
|
||||
|
||||
this.host = monitorable;
|
||||
this.clientCM = new ConfigManager( this );
|
||||
this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
|
||||
this.clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
this.clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
this.clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
if (Platform.isServer()) {
|
||||
this.serverCM = monitorable.getConfigManager();
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.serverCM = monitorable.getConfigManager();
|
||||
this.monitor = monitorable
|
||||
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
if (this.monitor != null) {
|
||||
this.monitor.addListener(this, null);
|
||||
|
||||
this.monitor = monitorable.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
if( this.monitor != null )
|
||||
{
|
||||
this.monitor.addListener( this, null );
|
||||
this.setCellInventory(this.monitor);
|
||||
|
||||
this.setCellInventory( this.monitor );
|
||||
if (monitorable instanceof IPortableCell) {
|
||||
this.setPowerSource((IEnergySource) monitorable);
|
||||
} else if (monitorable instanceof IMEChest) {
|
||||
this.setPowerSource((IEnergySource) monitorable);
|
||||
} else if (monitorable instanceof IGridHost || monitorable instanceof IActionHost) {
|
||||
final IGridNode node;
|
||||
if (monitorable instanceof IGridHost) {
|
||||
node = ((IGridHost) monitorable).getGridNode(AEPartLocation.INTERNAL);
|
||||
} else if (monitorable instanceof IActionHost) {
|
||||
node = ((IActionHost) monitorable).getActionableNode();
|
||||
} else {
|
||||
node = null;
|
||||
}
|
||||
|
||||
if( monitorable instanceof IPortableCell )
|
||||
{
|
||||
this.setPowerSource( (IEnergySource) monitorable );
|
||||
}
|
||||
else if( monitorable instanceof IMEChest )
|
||||
{
|
||||
this.setPowerSource( (IEnergySource) monitorable );
|
||||
}
|
||||
else if( monitorable instanceof IGridHost || monitorable instanceof IActionHost )
|
||||
{
|
||||
final IGridNode node;
|
||||
if( monitorable instanceof IGridHost )
|
||||
{
|
||||
node = ( (IGridHost) monitorable ).getGridNode( AEPartLocation.INTERNAL );
|
||||
}
|
||||
else if( monitorable instanceof IActionHost )
|
||||
{
|
||||
node = ( (IActionHost) monitorable ).getActionableNode();
|
||||
}
|
||||
else
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
if (node != null) {
|
||||
this.networkNode = node;
|
||||
final IGrid g = node.getGrid();
|
||||
if (g != null) {
|
||||
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
this.monitor = null;
|
||||
}
|
||||
|
||||
if( node != null )
|
||||
{
|
||||
this.networkNode = node;
|
||||
final IGrid g = node.getGrid();
|
||||
if( g != null )
|
||||
{
|
||||
this.setPowerSource( new ChannelPowerSrc( this.networkNode, g.getCache( IEnergyGrid.class )) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.monitor = null;
|
||||
}
|
||||
this.canAccessViewCells = false;
|
||||
if (monitorable instanceof IViewCellStorage) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
this.cellView[y] = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.VIEW_CELL,
|
||||
((IViewCellStorage) monitorable).getViewCellStorage(), y, 206, y * 18 + 8,
|
||||
this.getPlayerInventory());
|
||||
this.cellView[y].setAllowEdit(this.canAccessViewCells);
|
||||
this.addSlot(this.cellView[y]);
|
||||
}
|
||||
}
|
||||
|
||||
this.canAccessViewCells = false;
|
||||
if( monitorable instanceof IViewCellStorage )
|
||||
{
|
||||
for( int y = 0; y < 5; y++ )
|
||||
{
|
||||
this.cellView[y] = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.VIEW_CELL, ( (IViewCellStorage) monitorable )
|
||||
.getViewCellStorage(), y, 206, y * 18 + 8, this.getPlayerInventory() );
|
||||
this.cellView[y].setAllowEdit( this.canAccessViewCells );
|
||||
this.addSlot( this.cellView[y] );
|
||||
}
|
||||
}
|
||||
if (bindInventory) {
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if( bindInventory )
|
||||
{
|
||||
this.bindPlayerInventory( ip, 0, 0 );
|
||||
}
|
||||
}
|
||||
public IGridNode getNetworkNode() {
|
||||
return this.networkNode;
|
||||
}
|
||||
|
||||
public IGridNode getNetworkNode()
|
||||
{
|
||||
return this.networkNode;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isServer()) {
|
||||
if (this.monitor != this.host
|
||||
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))) {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( this.monitor != this.host.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) )
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
for (final Settings set : this.serverCM.getSettings()) {
|
||||
final Enum<?> sideLocal = this.serverCM.getSetting(set);
|
||||
final Enum<?> sideRemote = this.clientCM.getSetting(set);
|
||||
|
||||
for( final Settings set : this.serverCM.getSettings() )
|
||||
{
|
||||
final Enum<?> sideLocal = this.serverCM.getSetting( set );
|
||||
final Enum<?> sideRemote = this.clientCM.getSetting( set );
|
||||
if (sideLocal != sideRemote) {
|
||||
this.clientCM.putSetting(set, sideLocal);
|
||||
for (final IContainerListener crafter : this.listeners) {
|
||||
if (crafter instanceof ServerPlayerEntity) {
|
||||
NetworkHandler.instance().sendTo(new PacketValueConfig(set.name(), sideLocal.name()),
|
||||
(ServerPlayerEntity) crafter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( sideLocal != sideRemote )
|
||||
{
|
||||
this.clientCM.putSetting( set, sideLocal );
|
||||
for( final IContainerListener crafter : this.listeners )
|
||||
{
|
||||
if( crafter instanceof ServerPlayerEntity )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (ServerPlayerEntity) crafter );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.items.isEmpty()) {
|
||||
try {
|
||||
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
|
||||
|
||||
if( !this.items.isEmpty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
|
||||
final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
|
||||
final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
for (final IAEItemStack is : this.items) {
|
||||
final IAEItemStack send = monitorCache.findPrecise(is);
|
||||
if (send == null) {
|
||||
is.setStackSize(0);
|
||||
piu.appendItem(is);
|
||||
} else {
|
||||
piu.appendItem(send);
|
||||
}
|
||||
}
|
||||
|
||||
for( final IAEItemStack is : this.items )
|
||||
{
|
||||
final IAEItemStack send = monitorCache.findPrecise( is );
|
||||
if( send == null )
|
||||
{
|
||||
is.setStackSize( 0 );
|
||||
piu.appendItem( is );
|
||||
}
|
||||
else
|
||||
{
|
||||
piu.appendItem( send );
|
||||
}
|
||||
}
|
||||
if (!piu.isEmpty()) {
|
||||
this.items.resetStatus();
|
||||
|
||||
if( !piu.isEmpty() )
|
||||
{
|
||||
this.items.resetStatus();
|
||||
for (final Object c : this.listeners) {
|
||||
if (c instanceof PlayerEntity) {
|
||||
NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
for( final Object c : this.listeners )
|
||||
{
|
||||
if( c instanceof PlayerEntity )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
this.updatePowerStatus();
|
||||
|
||||
this.updatePowerStatus();
|
||||
final boolean oldAccessible = this.canAccessViewCells;
|
||||
this.canAccessViewCells = this.hasAccess(SecurityPermissions.BUILD, false);
|
||||
if (this.canAccessViewCells != oldAccessible) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
if (this.cellView[y] != null) {
|
||||
this.cellView[y].setAllowEdit(this.canAccessViewCells);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final boolean oldAccessible = this.canAccessViewCells;
|
||||
this.canAccessViewCells = this.hasAccess( SecurityPermissions.BUILD, false );
|
||||
if( this.canAccessViewCells != oldAccessible )
|
||||
{
|
||||
for( int y = 0; y < 5; y++ )
|
||||
{
|
||||
if( this.cellView[y] != null )
|
||||
{
|
||||
this.cellView[y].setAllowEdit( this.canAccessViewCells );
|
||||
}
|
||||
}
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
protected void updatePowerStatus() {
|
||||
try {
|
||||
if (this.networkNode != null) {
|
||||
this.setPowered(this.networkNode.isActive());
|
||||
} else if (this.getPowerSource() instanceof IEnergyGrid) {
|
||||
this.setPowered(((IEnergyGrid) this.getPowerSource()).isNetworkPowered());
|
||||
} else {
|
||||
this.setPowered(
|
||||
this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8);
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
protected void updatePowerStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
if( this.networkNode != null )
|
||||
{
|
||||
this.setPowered( this.networkNode.isActive() );
|
||||
}
|
||||
else if( this.getPowerSource() instanceof IEnergyGrid )
|
||||
{
|
||||
this.setPowered( ( (IEnergyGrid) this.getPowerSource() ).isNetworkPowered() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setPowered( this.getPowerSource().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8 );
|
||||
}
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
|
||||
if (field.equals("canAccessViewCells")) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
if (this.cellView[y] != null) {
|
||||
this.cellView[y].setAllowEdit(this.canAccessViewCells);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate( final String field, final Object oldValue, final Object newValue )
|
||||
{
|
||||
if( field.equals( "canAccessViewCells" ) )
|
||||
{
|
||||
for( int y = 0; y < 5; y++ )
|
||||
{
|
||||
if( this.cellView[y] != null )
|
||||
{
|
||||
this.cellView[y].setAllowEdit( this.canAccessViewCells );
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
}
|
||||
|
||||
super.onUpdate( field, oldValue, newValue );
|
||||
}
|
||||
@Override
|
||||
public void addListener(final IContainerListener c) {
|
||||
super.addListener(c);
|
||||
|
||||
@Override
|
||||
public void addListener( final IContainerListener c )
|
||||
{
|
||||
super.addListener( c );
|
||||
this.queueInventory(c);
|
||||
}
|
||||
|
||||
this.queueInventory( c );
|
||||
}
|
||||
private void queueInventory(final IContainerListener c) {
|
||||
if (Platform.isServer() && c instanceof PlayerEntity && this.monitor != null) {
|
||||
try {
|
||||
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
|
||||
|
||||
private void queueInventory( final IContainerListener c )
|
||||
{
|
||||
if( Platform.isServer() && c instanceof PlayerEntity && this.monitor != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
|
||||
for (final IAEItemStack send : monitorCache) {
|
||||
try {
|
||||
piu.appendItem(send);
|
||||
} catch (final BufferOverflowException boe) {
|
||||
NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c);
|
||||
|
||||
for( final IAEItemStack send : monitorCache )
|
||||
{
|
||||
try
|
||||
{
|
||||
piu.appendItem( send );
|
||||
}
|
||||
catch( final BufferOverflowException boe )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c );
|
||||
piu = new PacketMEInventoryUpdate();
|
||||
piu.appendItem(send);
|
||||
}
|
||||
}
|
||||
|
||||
piu = new PacketMEInventoryUpdate();
|
||||
piu.appendItem( send );
|
||||
}
|
||||
}
|
||||
NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c);
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void removeListener(final IContainerListener c) {
|
||||
super.removeListener(c);
|
||||
|
||||
@Override
|
||||
public void removeListener( final IContainerListener c )
|
||||
{
|
||||
super.removeListener( c );
|
||||
if (this.listeners.isEmpty() && this.monitor != null) {
|
||||
this.monitor.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
if( this.listeners.isEmpty() && this.monitor != null )
|
||||
{
|
||||
this.monitor.removeListener( this );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onContainerClosed(final PlayerEntity player) {
|
||||
super.onContainerClosed(player);
|
||||
if (this.monitor != null) {
|
||||
this.monitor.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( final PlayerEntity player )
|
||||
{
|
||||
super.onContainerClosed( player );
|
||||
if( this.monitor != null )
|
||||
{
|
||||
this.monitor.removeListener( this );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isValid(final Object verificationToken) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( final Object verificationToken )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void postChange(final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change,
|
||||
final IActionSource source) {
|
||||
for (final IAEItemStack is : change) {
|
||||
this.items.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource source )
|
||||
{
|
||||
for( final IAEItemStack is : change )
|
||||
{
|
||||
this.items.add( is );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onListUpdate() {
|
||||
for (final IContainerListener c : this.listeners) {
|
||||
this.queueInventory(c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
for( final IContainerListener c : this.listeners )
|
||||
{
|
||||
this.queueInventory( c );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue) {
|
||||
if (this.getGui() != null) {
|
||||
this.getGui().updateSetting(manager, settingName, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue )
|
||||
{
|
||||
if( this.getGui() != null )
|
||||
{
|
||||
this.getGui().updateSetting( manager, settingName, newValue );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
if (Platform.isServer()) {
|
||||
return this.serverCM;
|
||||
}
|
||||
return this.clientCM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
return this.serverCM;
|
||||
}
|
||||
return this.clientCM;
|
||||
}
|
||||
public ItemStack[] getViewCells() {
|
||||
final ItemStack[] list = new ItemStack[this.cellView.length];
|
||||
|
||||
public ItemStack[] getViewCells()
|
||||
{
|
||||
final ItemStack[] list = new ItemStack[this.cellView.length];
|
||||
for (int x = 0; x < this.cellView.length; x++) {
|
||||
list[x] = this.cellView[x].getStack();
|
||||
}
|
||||
|
||||
for( int x = 0; x < this.cellView.length; x++ )
|
||||
{
|
||||
list[x] = this.cellView[x].getStack();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
public SlotRestrictedInput getCellViewSlot(final int index) {
|
||||
return this.cellView[index];
|
||||
}
|
||||
|
||||
public SlotRestrictedInput getCellViewSlot( final int index )
|
||||
{
|
||||
return this.cellView[index];
|
||||
}
|
||||
public boolean isPowered() {
|
||||
return this.hasPower;
|
||||
}
|
||||
|
||||
public boolean isPowered()
|
||||
{
|
||||
return this.hasPower;
|
||||
}
|
||||
private void setPowered(final boolean isPowered) {
|
||||
this.hasPower = isPowered;
|
||||
}
|
||||
|
||||
private void setPowered( final boolean isPowered )
|
||||
{
|
||||
this.hasPower = isPowered;
|
||||
}
|
||||
private IConfigManagerHost getGui() {
|
||||
return this.gui;
|
||||
}
|
||||
|
||||
private IConfigManagerHost getGui()
|
||||
{
|
||||
return this.gui;
|
||||
}
|
||||
|
||||
public void setGui( @Nonnull final IConfigManagerHost gui )
|
||||
{
|
||||
this.gui = gui;
|
||||
}
|
||||
public void setGui(@Nonnull final IConfigManagerHost gui) {
|
||||
this.gui = gui;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,103 +18,88 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
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 appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
public class ContainerMEPortableCell extends ContainerMEMonitorable {
|
||||
|
||||
public class ContainerMEPortableCell extends ContainerMEMonitorable
|
||||
{
|
||||
public static ContainerType<ContainerMEPortableCell> TYPE;
|
||||
|
||||
public static ContainerType<ContainerMEPortableCell> TYPE;
|
||||
private static final ContainerHelper<ContainerMEPortableCell, IPortableCell> helper = new ContainerHelper<>(
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
private double powerMultiplier = 0.5;
|
||||
|
||||
private double powerMultiplier = 0.5;
|
||||
private final IPortableCell civ;
|
||||
private int ticks = 0;
|
||||
private final int slot;
|
||||
|
||||
private final IPortableCell civ;
|
||||
private int ticks = 0;
|
||||
private final int slot;
|
||||
public ContainerMEPortableCell(int id, final PlayerInventory ip, final IPortableCell monitorable) {
|
||||
this(TYPE, id, ip, monitorable);
|
||||
}
|
||||
|
||||
public ContainerMEPortableCell(int id, final PlayerInventory ip, final IPortableCell monitorable )
|
||||
{
|
||||
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();
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
this.slot = slotIndex;
|
||||
} else {
|
||||
this.slot = -1;
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
}
|
||||
this.civ = monitorable;
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
|
||||
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();
|
||||
this.lockPlayerInventorySlot( slotIndex );
|
||||
this.slot = slotIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.slot = -1;
|
||||
this.lockPlayerInventorySlot( ip.currentItem );
|
||||
}
|
||||
this.civ = monitorable;
|
||||
this.bindPlayerInventory( ip, 0, 0 );
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem()
|
||||
: this.getPlayerInv().getStackInSlot(this.slot);
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot( this.slot );
|
||||
if (this.civ == null || currentItem.isEmpty()) {
|
||||
this.setValidContainer(false);
|
||||
} else if (this.civ != null && !this.civ.getItemStack().isEmpty() && currentItem != this.civ.getItemStack()) {
|
||||
if (ItemStack.areItemsEqual(this.civ.getItemStack(), currentItem)) {
|
||||
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack());
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
|
||||
if( this.civ == null || currentItem.isEmpty() )
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
else if( this.civ != null && !this.civ.getItemStack().isEmpty() && currentItem != this.civ.getItemStack() )
|
||||
{
|
||||
if( ItemStack.areItemsEqual( this.civ.getItemStack(), currentItem ) )
|
||||
{
|
||||
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.civ.getItemStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
}
|
||||
// drain 1 ae t
|
||||
this.ticks++;
|
||||
if (this.ticks > 10) {
|
||||
this.civ.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE,
|
||||
PowerMultiplier.CONFIG);
|
||||
this.ticks = 0;
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
// drain 1 ae t
|
||||
this.ticks++;
|
||||
if( this.ticks > 10 )
|
||||
{
|
||||
this.civ.extractAEPower( this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
this.ticks = 0;
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
private double getPowerMultiplier() {
|
||||
return this.powerMultiplier;
|
||||
}
|
||||
|
||||
private double getPowerMultiplier()
|
||||
{
|
||||
return this.powerMultiplier;
|
||||
}
|
||||
|
||||
void setPowerMultiplier( final double powerMultiplier )
|
||||
{
|
||||
this.powerMultiplier = powerMultiplier;
|
||||
}
|
||||
void setPowerMultiplier(final double powerMultiplier) {
|
||||
this.powerMultiplier = powerMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,14 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
@@ -40,168 +39,141 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
public class ContainerNetworkStatus extends AEBaseContainer {
|
||||
|
||||
public class ContainerNetworkStatus extends AEBaseContainer
|
||||
{
|
||||
public static ContainerType<ContainerNetworkStatus> TYPE;
|
||||
|
||||
public static ContainerType<ContainerNetworkStatus> TYPE;
|
||||
private static final ContainerHelper<ContainerNetworkStatus, INetworkTool> helper = new ContainerHelper<>(
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
@GuiSync(0)
|
||||
public long avgAddition;
|
||||
@GuiSync(1)
|
||||
public long powerUsage;
|
||||
@GuiSync(2)
|
||||
public long currentPower;
|
||||
@GuiSync(3)
|
||||
public long maxPower;
|
||||
private IGrid network;
|
||||
private int delay = 40;
|
||||
|
||||
@GuiSync( 0 )
|
||||
public long avgAddition;
|
||||
@GuiSync( 1 )
|
||||
public long powerUsage;
|
||||
@GuiSync( 2 )
|
||||
public long currentPower;
|
||||
@GuiSync( 3 )
|
||||
public long maxPower;
|
||||
private IGrid network;
|
||||
private int delay = 40;
|
||||
public ContainerNetworkStatus(int id, PlayerInventory ip, final INetworkTool te) {
|
||||
super(TYPE, id, ip, null, null);
|
||||
final IGridHost host = te.getGridHost();
|
||||
|
||||
public ContainerNetworkStatus(int id, PlayerInventory ip, final INetworkTool te) {
|
||||
super(TYPE, id, ip, null, null);
|
||||
final IGridHost host = te.getGridHost();
|
||||
if (host != null) {
|
||||
this.findNode(host, AEPartLocation.INTERNAL);
|
||||
for (final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS) {
|
||||
this.findNode(host, d);
|
||||
}
|
||||
}
|
||||
|
||||
if( host != null )
|
||||
{
|
||||
this.findNode( host, AEPartLocation.INTERNAL );
|
||||
for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS )
|
||||
{
|
||||
this.findNode( host, d );
|
||||
}
|
||||
}
|
||||
if (this.network == null && Platform.isServer()) {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
|
||||
if( this.network == null && Platform.isServer() )
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
}
|
||||
private void findNode(final IGridHost host, final AEPartLocation d) {
|
||||
if (this.network == null) {
|
||||
final IGridNode node = host.getGridNode(d);
|
||||
if (node != null) {
|
||||
this.network = node.getGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void findNode( final IGridHost host, final AEPartLocation d )
|
||||
{
|
||||
if( this.network == null )
|
||||
{
|
||||
final IGridNode node = host.getGridNode( d );
|
||||
if( node != null )
|
||||
{
|
||||
this.network = node.getGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.delay++;
|
||||
if (Platform.isServer() && this.delay > 15 && this.network != null) {
|
||||
this.delay = 0;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.delay++;
|
||||
if( Platform.isServer() && this.delay > 15 && this.network != null )
|
||||
{
|
||||
this.delay = 0;
|
||||
final IEnergyGrid eg = this.network.getCache(IEnergyGrid.class);
|
||||
if (eg != null) {
|
||||
this.setAverageAddition((long) (100.0 * eg.getAvgPowerInjection()));
|
||||
this.setPowerUsage((long) (100.0 * eg.getAvgPowerUsage()));
|
||||
this.setCurrentPower((long) (100.0 * eg.getStoredPower()));
|
||||
this.setMaxPower((long) (100.0 * eg.getMaxStoredPower()));
|
||||
}
|
||||
|
||||
final IEnergyGrid eg = this.network.getCache( IEnergyGrid.class );
|
||||
if( eg != null )
|
||||
{
|
||||
this.setAverageAddition( (long) ( 100.0 * eg.getAvgPowerInjection() ) );
|
||||
this.setPowerUsage( (long) ( 100.0 * eg.getAvgPowerUsage() ) );
|
||||
this.setCurrentPower( (long) ( 100.0 * eg.getStoredPower() ) );
|
||||
this.setMaxPower( (long) ( 100.0 * eg.getMaxStoredPower() ) );
|
||||
}
|
||||
try {
|
||||
final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
|
||||
try
|
||||
{
|
||||
final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
for (final Class<? extends IGridHost> machineClass : this.network.getMachinesClasses()) {
|
||||
final IItemList<IAEItemStack> list = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
for (final IGridNode machine : this.network.getMachines(machineClass)) {
|
||||
final IGridBlock blk = machine.getGridBlock();
|
||||
final ItemStack is = blk.getMachineRepresentation();
|
||||
if (!is.isEmpty()) {
|
||||
final IAEItemStack ais = AEItemStack.fromItemStack(is);
|
||||
ais.setStackSize(1);
|
||||
ais.setCountRequestable((long) (blk.getIdlePowerUsage() * 100.0));
|
||||
list.add(ais);
|
||||
}
|
||||
}
|
||||
|
||||
for( final Class<? extends IGridHost> machineClass : this.network.getMachinesClasses() )
|
||||
{
|
||||
final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
for( final IGridNode machine : this.network.getMachines( machineClass ) )
|
||||
{
|
||||
final IGridBlock blk = machine.getGridBlock();
|
||||
final ItemStack is = blk.getMachineRepresentation();
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
final IAEItemStack ais = AEItemStack.fromItemStack( is );
|
||||
ais.setStackSize( 1 );
|
||||
ais.setCountRequestable( (long) ( blk.getIdlePowerUsage() * 100.0 ) );
|
||||
list.add( ais );
|
||||
}
|
||||
}
|
||||
for (final IAEItemStack ais : list) {
|
||||
piu.appendItem(ais);
|
||||
}
|
||||
}
|
||||
|
||||
for( final IAEItemStack ais : list )
|
||||
{
|
||||
piu.appendItem( ais );
|
||||
}
|
||||
}
|
||||
for (final Object c : this.listeners) {
|
||||
if (c instanceof PlayerEntity) {
|
||||
NetworkHandler.instance().sendTo(piu, (ServerPlayerEntity) c);
|
||||
}
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
for( final Object c : this.listeners )
|
||||
{
|
||||
if( c instanceof PlayerEntity )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( piu, (ServerPlayerEntity) c );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
public long getCurrentPower() {
|
||||
return this.currentPower;
|
||||
}
|
||||
|
||||
public long getCurrentPower()
|
||||
{
|
||||
return this.currentPower;
|
||||
}
|
||||
private void setCurrentPower(final long currentPower) {
|
||||
this.currentPower = currentPower;
|
||||
}
|
||||
|
||||
private void setCurrentPower( final long currentPower )
|
||||
{
|
||||
this.currentPower = currentPower;
|
||||
}
|
||||
public long getMaxPower() {
|
||||
return this.maxPower;
|
||||
}
|
||||
|
||||
public long getMaxPower()
|
||||
{
|
||||
return this.maxPower;
|
||||
}
|
||||
private void setMaxPower(final long maxPower) {
|
||||
this.maxPower = maxPower;
|
||||
}
|
||||
|
||||
private void setMaxPower( final long maxPower )
|
||||
{
|
||||
this.maxPower = maxPower;
|
||||
}
|
||||
public long getAverageAddition() {
|
||||
return this.avgAddition;
|
||||
}
|
||||
|
||||
public long getAverageAddition()
|
||||
{
|
||||
return this.avgAddition;
|
||||
}
|
||||
private void setAverageAddition(final long avgAddition) {
|
||||
this.avgAddition = avgAddition;
|
||||
}
|
||||
|
||||
private void setAverageAddition( final long avgAddition )
|
||||
{
|
||||
this.avgAddition = avgAddition;
|
||||
}
|
||||
public long getPowerUsage() {
|
||||
return this.powerUsage;
|
||||
}
|
||||
|
||||
public long getPowerUsage()
|
||||
{
|
||||
return this.powerUsage;
|
||||
}
|
||||
|
||||
private void setPowerUsage( final long powerUsage )
|
||||
{
|
||||
this.powerUsage = powerUsage;
|
||||
}
|
||||
private void setPowerUsage(final long powerUsage) {
|
||||
this.powerUsage = powerUsage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,6 @@
|
||||
|
||||
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.slot.SlotRestrictedInput;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -31,94 +25,84 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
|
||||
public class ContainerNetworkTool extends AEBaseContainer
|
||||
{
|
||||
public class ContainerNetworkTool extends AEBaseContainer {
|
||||
|
||||
public static ContainerType<ContainerNetworkTool> TYPE;
|
||||
public static ContainerType<ContainerNetworkTool> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerNetworkTool, INetworkTool> helper
|
||||
= new ContainerHelper<>(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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
|
||||
private final INetworkTool toolInv;
|
||||
private final INetworkTool toolInv;
|
||||
|
||||
@GuiSync( 1 )
|
||||
public boolean facadeMode;
|
||||
@GuiSync(1)
|
||||
public boolean facadeMode;
|
||||
|
||||
public ContainerNetworkTool(int id, final PlayerInventory ip, final INetworkTool te )
|
||||
{
|
||||
super( TYPE, id, ip, null, null );
|
||||
this.toolInv = te;
|
||||
public ContainerNetworkTool(int id, final PlayerInventory ip, final INetworkTool te) {
|
||||
super(TYPE, id, ip, null, null);
|
||||
this.toolInv = te;
|
||||
|
||||
this.lockPlayerInventorySlot( ip.currentItem );
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
|
||||
for( int y = 0; y < 3; y++ )
|
||||
{
|
||||
for( int x = 0; x < 3; x++ )
|
||||
{
|
||||
this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, te
|
||||
.getInventory(), y * 3 + x, 80 - 18 + x * 18, 37 - 18 + y * 18, this.getPlayerInventory() ) ) );
|
||||
}
|
||||
}
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, te.getInventory(),
|
||||
y * 3 + x, 80 - 18 + x * 18, 37 - 18 + y * 18, this.getPlayerInventory())));
|
||||
}
|
||||
}
|
||||
|
||||
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
|
||||
}
|
||||
this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
public void toggleFacadeMode()
|
||||
{
|
||||
public void toggleFacadeMode() {
|
||||
final CompoundNBT data = this.toolInv.getItemStack().getOrCreateTag();
|
||||
data.putBoolean("hideFacades", !data.getBoolean( "hideFacades" ));
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
data.putBoolean("hideFacades", !data.getBoolean("hideFacades"));
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
final ItemStack currentItem = this.getPlayerInv().getCurrentItem();
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
final ItemStack currentItem = this.getPlayerInv().getCurrentItem();
|
||||
|
||||
if( currentItem != this.toolInv.getItemStack() )
|
||||
{
|
||||
if( !currentItem.isEmpty() )
|
||||
{
|
||||
if( ItemStack.areItemsEqual( this.toolInv.getItemStack(), currentItem ) )
|
||||
{
|
||||
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
}
|
||||
if (currentItem != this.toolInv.getItemStack()) {
|
||||
if (!currentItem.isEmpty()) {
|
||||
if (ItemStack.areItemsEqual(this.toolInv.getItemStack(), currentItem)) {
|
||||
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem,
|
||||
this.toolInv.getItemStack());
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
|
||||
if( this.isValidContainer() )
|
||||
{
|
||||
if (this.isValidContainer()) {
|
||||
final CompoundNBT data = currentItem.getOrCreateTag();
|
||||
this.setFacadeMode( data.getBoolean( "hideFacades" ) );
|
||||
}
|
||||
this.setFacadeMode(data.getBoolean("hideFacades"));
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
public boolean isFacadeMode()
|
||||
{
|
||||
return this.facadeMode;
|
||||
}
|
||||
public boolean isFacadeMode() {
|
||||
return this.facadeMode;
|
||||
}
|
||||
|
||||
private void setFacadeMode( final boolean facadeMode )
|
||||
{
|
||||
this.facadeMode = facadeMode;
|
||||
}
|
||||
private void setFacadeMode(final boolean facadeMode) {
|
||||
this.facadeMode = facadeMode;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@@ -32,81 +30,72 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerPriority extends AEBaseContainer {
|
||||
|
||||
public class ContainerPriority extends AEBaseContainer
|
||||
{
|
||||
public static ContainerType<ContainerPriority> TYPE;
|
||||
|
||||
public static ContainerType<ContainerPriority> TYPE;
|
||||
private static final ContainerHelper<ContainerPriority, IPriorityHost> helper = new ContainerHelper<>(
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
private final IPriorityHost priHost;
|
||||
|
||||
private final IPriorityHost priHost;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private TextFieldWidget textField;
|
||||
@GuiSync(2)
|
||||
public long PriorityValue = -1;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private TextFieldWidget textField;
|
||||
@GuiSync( 2 )
|
||||
public long PriorityValue = -1;
|
||||
public ContainerPriority(int id, final PlayerInventory ip, final IPriorityHost te) {
|
||||
super(TYPE, id, ip, (TileEntity) (te instanceof TileEntity ? te : null),
|
||||
(IPart) (te instanceof IPart ? te : null));
|
||||
this.priHost = te;
|
||||
}
|
||||
|
||||
public ContainerPriority(int id, final PlayerInventory ip, final IPriorityHost te )
|
||||
{
|
||||
super( TYPE, id, ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) );
|
||||
this.priHost = te;
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void setTextField(final TextFieldWidget level) {
|
||||
this.textField = level;
|
||||
this.textField.setText(String.valueOf(this.PriorityValue));
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void setTextField( final TextFieldWidget level )
|
||||
{
|
||||
this.textField = level;
|
||||
this.textField.setText( String.valueOf( this.PriorityValue ) );
|
||||
}
|
||||
public void setPriority(final int newValue, final PlayerEntity player) {
|
||||
this.priHost.setPriority(newValue);
|
||||
this.PriorityValue = newValue;
|
||||
}
|
||||
|
||||
public void setPriority( final int newValue, final PlayerEntity player )
|
||||
{
|
||||
this.priHost.setPriority( newValue );
|
||||
this.PriorityValue = newValue;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
if (Platform.isServer()) {
|
||||
this.PriorityValue = this.priHost.getPriority();
|
||||
}
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.PriorityValue = this.priHost.getPriority();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
|
||||
if (field.equals("PriorityValue")) {
|
||||
if (this.textField != null) {
|
||||
this.textField.setText(String.valueOf(this.PriorityValue));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate( final String field, final Object oldValue, final Object newValue )
|
||||
{
|
||||
if( field.equals( "PriorityValue" ) )
|
||||
{
|
||||
if( this.textField != null )
|
||||
{
|
||||
this.textField.setText( String.valueOf( this.PriorityValue ) );
|
||||
}
|
||||
}
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
}
|
||||
|
||||
super.onUpdate( field, oldValue, newValue );
|
||||
}
|
||||
|
||||
public IPriorityHost getPriorityHost()
|
||||
{
|
||||
return this.priHost;
|
||||
}
|
||||
public IPriorityHost getPriorityHost() {
|
||||
return this.priHost;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,44 +18,40 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
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;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
|
||||
public class ContainerQNB extends AEBaseContainer
|
||||
{
|
||||
public class ContainerQNB extends AEBaseContainer {
|
||||
|
||||
public static ContainerType<ContainerQNB> TYPE;
|
||||
public static ContainerType<ContainerQNB> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerQNB, TileQuantumBridge> helper
|
||||
= new ContainerHelper<>(ContainerQNB::new, TileQuantumBridge.class, SecurityPermissions.BUILD);
|
||||
private static final ContainerHelper<ContainerQNB, TileQuantumBridge> helper = new ContainerHelper<>(
|
||||
ContainerQNB::new, TileQuantumBridge.class, SecurityPermissions.BUILD);
|
||||
|
||||
public static ContainerQNB fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
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 static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
|
||||
public ContainerQNB(int id, final PlayerInventory ip, final TileQuantumBridge quantumBridge )
|
||||
{
|
||||
super( TYPE, id, ip, quantumBridge, null );
|
||||
public ContainerQNB(int id, final PlayerInventory ip, final TileQuantumBridge quantumBridge) {
|
||||
super(TYPE, id, ip, quantumBridge, null);
|
||||
|
||||
this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge
|
||||
.getInternalInventory(), 0, 80, 37, this.getPlayerInventory() ) ).setStackLimit( 1 ) );
|
||||
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 );
|
||||
}
|
||||
this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -34,159 +32,135 @@ import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerQuartzKnife extends AEBaseContainer {
|
||||
|
||||
public class ContainerQuartzKnife extends AEBaseContainer
|
||||
{
|
||||
public static ContainerType<ContainerQuartzKnife> TYPE;
|
||||
|
||||
public static ContainerType<ContainerQuartzKnife> TYPE;
|
||||
private static final ContainerHelper<ContainerQuartzKnife, QuartzKnifeObj> helper = new ContainerHelper<>(
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
private final QuartzKnifeObj toolInv;
|
||||
|
||||
private final QuartzKnifeObj toolInv;
|
||||
private final IItemHandler inSlot = new AppEngInternalInventory(null, 1, 1);
|
||||
private String myName = "";
|
||||
|
||||
private final IItemHandler inSlot = new AppEngInternalInventory( null, 1, 1 );
|
||||
private String myName = "";
|
||||
public ContainerQuartzKnife(int id, final PlayerInventory ip, final QuartzKnifeObj te) {
|
||||
super(TYPE, id, ip, null, null);
|
||||
this.toolInv = te;
|
||||
|
||||
public ContainerQuartzKnife(int id, final PlayerInventory ip, final QuartzKnifeObj te )
|
||||
{
|
||||
super( TYPE, id, ip, null, null );
|
||||
this.toolInv = te;
|
||||
this.addSlot(
|
||||
new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.METAL_INGOTS, this.inSlot, 0, 94, 44, ip));
|
||||
this.addSlot(new QuartzKniveSlot(this.inSlot, 0, 134, 44, -1));
|
||||
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.METAL_INGOTS, this.inSlot, 0, 94, 44, ip ) );
|
||||
this.addSlot( new QuartzKniveSlot( this.inSlot, 0, 134, 44, -1 ) );
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
|
||||
this.lockPlayerInventorySlot( ip.currentItem );
|
||||
this.bindPlayerInventory(ip, 0, 184 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
this.bindPlayerInventory( ip, 0, 184 - /* height of player inventory */82 );
|
||||
}
|
||||
public void setName(final String value) {
|
||||
this.myName = value;
|
||||
}
|
||||
|
||||
public void setName( final String value )
|
||||
{
|
||||
this.myName = value;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
final ItemStack currentItem = this.getPlayerInv().getCurrentItem();
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
final ItemStack currentItem = this.getPlayerInv().getCurrentItem();
|
||||
if (currentItem != this.toolInv.getItemStack()) {
|
||||
if (!currentItem.isEmpty()) {
|
||||
if (ItemStack.areItemsEqual(this.toolInv.getItemStack(), currentItem)) {
|
||||
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem,
|
||||
this.toolInv.getItemStack());
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
|
||||
if( currentItem != this.toolInv.getItemStack() )
|
||||
{
|
||||
if( !currentItem.isEmpty() )
|
||||
{
|
||||
if( ItemStack.areItemsEqual( this.toolInv.getItemStack(), currentItem ) )
|
||||
{
|
||||
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public void onContainerClosed(final PlayerEntity par1PlayerEntity) {
|
||||
if (this.inSlot.getStackInSlot(0) != null) {
|
||||
par1PlayerEntity.dropItem(this.inSlot.getStackInSlot(0), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
if( this.inSlot.getStackInSlot( 0 ) != null )
|
||||
{
|
||||
par1PlayerEntity.dropItem( this.inSlot.getStackInSlot( 0 ), false );
|
||||
}
|
||||
}
|
||||
private class QuartzKniveSlot extends SlotOutput {
|
||||
QuartzKniveSlot(IItemHandler a, int b, int c, int d, int i) {
|
||||
super(a, b, c, d, i);
|
||||
}
|
||||
|
||||
private class QuartzKniveSlot extends SlotOutput
|
||||
{
|
||||
QuartzKniveSlot( IItemHandler a, int b, int c, int d, int i )
|
||||
{
|
||||
super( a, b, c, d, i );
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
final IItemHandler baseInv = this.getItemHandler();
|
||||
final ItemStack input = baseInv.getStackInSlot(0);
|
||||
if (input == ItemStack.EMPTY) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
final IItemHandler baseInv = this.getItemHandler();
|
||||
final ItemStack input = baseInv.getStackInSlot( 0 );
|
||||
if( input == ItemStack.EMPTY )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( SlotRestrictedInput.isMetalIngot( input ) )
|
||||
{
|
||||
if( ContainerQuartzKnife.this.myName.length() > 0 )
|
||||
{
|
||||
return AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).map(namePressStack ->
|
||||
{
|
||||
if (SlotRestrictedInput.isMetalIngot(input)) {
|
||||
if (ContainerQuartzKnife.this.myName.length() > 0) {
|
||||
return AEApi.instance().definitions().materials().namePress().maybeStack(1).map(namePressStack -> {
|
||||
final CompoundNBT compound = namePressStack.getOrCreateTag();
|
||||
compound.putString("InscribeName", ContainerQuartzKnife.this.myName);
|
||||
compound.putString("InscribeName", ContainerQuartzKnife.this.myName);
|
||||
|
||||
return namePressStack;
|
||||
} ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return namePressStack;
|
||||
}).orElse(ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack decrStackSize( int amount )
|
||||
{
|
||||
ItemStack ret = this.getStack();
|
||||
if( !ret.isEmpty() )
|
||||
{
|
||||
this.makePlate();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack decrStackSize(int amount) {
|
||||
ItemStack ret = this.getStack();
|
||||
if (!ret.isEmpty()) {
|
||||
this.makePlate();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack stack )
|
||||
{
|
||||
if( stack.isEmpty() )
|
||||
{
|
||||
this.makePlate();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void putStack(final ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
this.makePlate();
|
||||
}
|
||||
}
|
||||
|
||||
private void makePlate()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( !this.getItemHandler().extractItem( 0, 1, false ).isEmpty() )
|
||||
{
|
||||
final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack();
|
||||
final ItemStack before = item.copy();
|
||||
item.damageItem( 1, ContainerQuartzKnife.this.getPlayerInv().player, p -> {
|
||||
ContainerQuartzKnife.this.getPlayerInv()
|
||||
.setInventorySlotContents( ContainerQuartzKnife.this.getPlayerInv().currentItem, ItemStack.EMPTY );
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( ContainerQuartzKnife.this.getPlayerInv().player, before, null ) );
|
||||
} );
|
||||
private void makePlate() {
|
||||
if (Platform.isServer()) {
|
||||
if (!this.getItemHandler().extractItem(0, 1, false).isEmpty()) {
|
||||
final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack();
|
||||
final ItemStack before = item.copy();
|
||||
item.damageItem(1, ContainerQuartzKnife.this.getPlayerInv().player, p -> {
|
||||
ContainerQuartzKnife.this.getPlayerInv().setInventorySlotContents(
|
||||
ContainerQuartzKnife.this.getPlayerInv().currentItem, ItemStack.EMPTY);
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(
|
||||
ContainerQuartzKnife.this.getPlayerInv().player, before, null));
|
||||
});
|
||||
|
||||
ContainerQuartzKnife.this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ContainerQuartzKnife.this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -34,6 +32,7 @@ import appeng.api.features.INetworkEncodable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.items.IBiometricCard;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
@@ -42,167 +41,142 @@ import appeng.tile.misc.TileSecurityStation;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
public class ContainerSecurityStation extends ContainerMEMonitorable implements IAEAppEngInventory {
|
||||
|
||||
public class ContainerSecurityStation extends ContainerMEMonitorable implements IAEAppEngInventory
|
||||
{
|
||||
public static ContainerType<ContainerSecurityStation> TYPE;
|
||||
|
||||
public static ContainerType<ContainerSecurityStation> TYPE;
|
||||
private static final ContainerHelper<ContainerSecurityStation, ITerminalHost> helper = new ContainerHelper<>(
|
||||
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;
|
||||
|
||||
private final SlotRestrictedInput configSlot;
|
||||
private final AppEngInternalInventory wirelessEncoder = new AppEngInternalInventory(this, 2);
|
||||
|
||||
private final AppEngInternalInventory wirelessEncoder = new AppEngInternalInventory( this, 2 );
|
||||
private final SlotRestrictedInput wirelessIn;
|
||||
private final SlotOutput wirelessOut;
|
||||
|
||||
private final SlotRestrictedInput wirelessIn;
|
||||
private final SlotOutput wirelessOut;
|
||||
private final TileSecurityStation securityBox;
|
||||
@GuiSync(0)
|
||||
public int permissionMode = 0;
|
||||
|
||||
private final TileSecurityStation securityBox;
|
||||
@GuiSync( 0 )
|
||||
public int permissionMode = 0;
|
||||
public ContainerSecurityStation(int id, final PlayerInventory ip, final ITerminalHost monitorable) {
|
||||
super(TYPE, id, ip, monitorable, false);
|
||||
|
||||
public ContainerSecurityStation(int id, final PlayerInventory ip, final ITerminalHost monitorable )
|
||||
{
|
||||
super( TYPE, id, ip, monitorable, false );
|
||||
this.securityBox = (TileSecurityStation) monitorable;
|
||||
|
||||
this.securityBox = (TileSecurityStation) monitorable;
|
||||
this.addSlot(this.configSlot = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.BIOMETRIC_CARD,
|
||||
this.securityBox.getConfigSlot(), 0, 37, -33, ip));
|
||||
|
||||
this.addSlot( this.configSlot = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BIOMETRIC_CARD, this.securityBox
|
||||
.getConfigSlot(), 0, 37, -33, ip ) );
|
||||
this.addSlot(this.wirelessIn = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODABLE_ITEM,
|
||||
this.wirelessEncoder, 0, 212, 10, ip));
|
||||
this.addSlot(this.wirelessOut = new SlotOutput(this.wirelessEncoder, 1, 212, 68, -1));
|
||||
|
||||
this.addSlot(
|
||||
this.wirelessIn = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODABLE_ITEM, this.wirelessEncoder, 0, 212, 10, ip ) );
|
||||
this.addSlot( this.wirelessOut = new SlotOutput( this.wirelessEncoder, 1, 212, 68, -1 ) );
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
|
||||
this.bindPlayerInventory( ip, 0, 0 );
|
||||
}
|
||||
public static ContainerSecurityStation fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
|
||||
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 static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
public void toggleSetting(final String value, final PlayerEntity player) {
|
||||
try {
|
||||
final SecurityPermissions permission = SecurityPermissions.valueOf(value);
|
||||
|
||||
public void toggleSetting( final String value, final PlayerEntity player )
|
||||
{
|
||||
try
|
||||
{
|
||||
final SecurityPermissions permission = SecurityPermissions.valueOf( value );
|
||||
final ItemStack a = this.configSlot.getStack();
|
||||
if (!a.isEmpty() && a.getItem() instanceof IBiometricCard) {
|
||||
final IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||
if (bc.hasPermission(a, permission)) {
|
||||
bc.removePermission(a, permission);
|
||||
} else {
|
||||
bc.addPermission(a, permission);
|
||||
}
|
||||
}
|
||||
} catch (final EnumConstantNotPresentException ex) {
|
||||
// :(
|
||||
}
|
||||
}
|
||||
|
||||
final ItemStack a = this.configSlot.getStack();
|
||||
if( !a.isEmpty() && a.getItem() instanceof IBiometricCard )
|
||||
{
|
||||
final IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||
if( bc.hasPermission( a, permission ) )
|
||||
{
|
||||
bc.removePermission( a, permission );
|
||||
}
|
||||
else
|
||||
{
|
||||
bc.addPermission( a, permission );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( final EnumConstantNotPresentException ex )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.verifyPermissions(SecurityPermissions.SECURITY, false);
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.SECURITY, false );
|
||||
this.setPermissionMode(0);
|
||||
|
||||
this.setPermissionMode( 0 );
|
||||
final ItemStack a = this.configSlot.getStack();
|
||||
if (!a.isEmpty() && a.getItem() instanceof IBiometricCard) {
|
||||
final IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||
|
||||
final ItemStack a = this.configSlot.getStack();
|
||||
if( !a.isEmpty() && a.getItem() instanceof IBiometricCard )
|
||||
{
|
||||
final IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||
for (final SecurityPermissions sp : bc.getPermissions(a)) {
|
||||
this.setPermissionMode(this.getPermissionMode() | (1 << sp.ordinal()));
|
||||
}
|
||||
}
|
||||
|
||||
for( final SecurityPermissions sp : bc.getPermissions( a ) )
|
||||
{
|
||||
this.setPermissionMode( this.getPermissionMode() | ( 1 << sp.ordinal() ) );
|
||||
}
|
||||
}
|
||||
this.updatePowerStatus();
|
||||
|
||||
this.updatePowerStatus();
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public void onContainerClosed(final PlayerEntity player) {
|
||||
super.onContainerClosed(player);
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( final PlayerEntity player )
|
||||
{
|
||||
super.onContainerClosed( player );
|
||||
if (this.wirelessIn.getHasStack()) {
|
||||
player.dropItem(this.wirelessIn.getStack(), false);
|
||||
}
|
||||
|
||||
if( this.wirelessIn.getHasStack() )
|
||||
{
|
||||
player.dropItem( this.wirelessIn.getStack(), false );
|
||||
}
|
||||
if (this.wirelessOut.getHasStack()) {
|
||||
player.dropItem(this.wirelessOut.getStack(), false);
|
||||
}
|
||||
}
|
||||
|
||||
if( this.wirelessOut.getHasStack() )
|
||||
{
|
||||
player.dropItem( this.wirelessOut.getStack(), false );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges()
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
if (!this.wirelessOut.getHasStack()) {
|
||||
if (this.wirelessIn.getHasStack()) {
|
||||
final ItemStack term = this.wirelessIn.getStack().copy();
|
||||
INetworkEncodable networkEncodable = null;
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
if( !this.wirelessOut.getHasStack() )
|
||||
{
|
||||
if( this.wirelessIn.getHasStack() )
|
||||
{
|
||||
final ItemStack term = this.wirelessIn.getStack().copy();
|
||||
INetworkEncodable networkEncodable = null;
|
||||
if (term.getItem() instanceof INetworkEncodable) {
|
||||
networkEncodable = (INetworkEncodable) term.getItem();
|
||||
}
|
||||
|
||||
if( term.getItem() instanceof INetworkEncodable )
|
||||
{
|
||||
networkEncodable = (INetworkEncodable) term.getItem();
|
||||
}
|
||||
final IWirelessTermHandler wTermHandler = AEApi.instance().registries().wireless()
|
||||
.getWirelessTerminalHandler(term);
|
||||
if (wTermHandler != null) {
|
||||
networkEncodable = wTermHandler;
|
||||
}
|
||||
|
||||
final IWirelessTermHandler wTermHandler = AEApi.instance().registries().wireless().getWirelessTerminalHandler( term );
|
||||
if( wTermHandler != null )
|
||||
{
|
||||
networkEncodable = wTermHandler;
|
||||
}
|
||||
if (networkEncodable != null) {
|
||||
networkEncodable.setEncryptionKey(term, String.valueOf(this.securityBox.getSecurityKey()), "");
|
||||
|
||||
if( networkEncodable != null )
|
||||
{
|
||||
networkEncodable.setEncryptionKey( term, String.valueOf( this.securityBox.getSecurityKey() ), "" );
|
||||
this.wirelessIn.putStack(ItemStack.EMPTY);
|
||||
this.wirelessOut.putStack(term);
|
||||
|
||||
this.wirelessIn.putStack( ItemStack.EMPTY );
|
||||
this.wirelessOut.putStack( term );
|
||||
// update the two slots in question...
|
||||
for (final IContainerListener listener : this.listeners) {
|
||||
listener.sendSlotContents(this, this.wirelessIn.slotNumber, this.wirelessIn.getStack());
|
||||
listener.sendSlotContents(this, this.wirelessOut.slotNumber, this.wirelessOut.getStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update the two slots in question...
|
||||
for( final IContainerListener listener : this.listeners )
|
||||
{
|
||||
listener.sendSlotContents( this, this.wirelessIn.slotNumber, this.wirelessIn.getStack() );
|
||||
listener.sendSlotContents( this, this.wirelessOut.slotNumber, this.wirelessOut.getStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public int getPermissionMode() {
|
||||
return this.permissionMode;
|
||||
}
|
||||
|
||||
public int getPermissionMode()
|
||||
{
|
||||
return this.permissionMode;
|
||||
}
|
||||
|
||||
private void setPermissionMode( final int permissionMode )
|
||||
{
|
||||
this.permissionMode = permissionMode;
|
||||
}
|
||||
private void setPermissionMode(final int permissionMode) {
|
||||
this.permissionMode = permissionMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,60 +18,52 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
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.inventory.container.ContainerType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.slot.SlotNormal;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
|
||||
public class ContainerSkyChest extends AEBaseContainer
|
||||
{
|
||||
public class ContainerSkyChest extends AEBaseContainer {
|
||||
|
||||
public static ContainerType<ContainerSkyChest> TYPE;
|
||||
public static ContainerType<ContainerSkyChest> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerSkyChest, TileSkyChest> helper
|
||||
= new ContainerHelper<>(ContainerSkyChest::new, TileSkyChest.class);
|
||||
private static final ContainerHelper<ContainerSkyChest, TileSkyChest> helper = new ContainerHelper<>(
|
||||
ContainerSkyChest::new, TileSkyChest.class);
|
||||
|
||||
private final TileSkyChest chest;
|
||||
|
||||
private final TileSkyChest chest;
|
||||
public ContainerSkyChest(int id, final PlayerInventory ip, final TileSkyChest chest) {
|
||||
super(TYPE, id, ip, chest, null);
|
||||
this.chest = chest;
|
||||
|
||||
public ContainerSkyChest(int id, final PlayerInventory ip, final TileSkyChest chest )
|
||||
{
|
||||
super( TYPE, id, ip, chest, null );
|
||||
this.chest = chest;
|
||||
for (int y = 0; y < 4; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
this.addSlot(new SlotNormal(this.chest.getInternalInventory(), y * 9 + x, 8 + 18 * x, 24 + 18 * y));
|
||||
}
|
||||
}
|
||||
|
||||
for( int y = 0; y < 4; y++ )
|
||||
{
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
this.addSlot( new SlotNormal( this.chest.getInternalInventory(), y * 9 + x, 8 + 18 * x, 24 + 18 * y ) );
|
||||
}
|
||||
}
|
||||
this.chest.openInventory(ip.player);
|
||||
|
||||
this.chest.openInventory( ip.player );
|
||||
this.bindPlayerInventory(ip, 0, 195 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
this.bindPlayerInventory( ip, 0, 195 - /* height of player inventory */82 );
|
||||
}
|
||||
public static ContainerSkyChest fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
|
||||
public static ContainerSkyChest 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 static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
super.onContainerClosed( par1PlayerEntity );
|
||||
this.chest.closeInventory( par1PlayerEntity );
|
||||
}
|
||||
@Override
|
||||
public void onContainerClosed(final PlayerEntity par1PlayerEntity) {
|
||||
super.onContainerClosed(par1PlayerEntity);
|
||||
this.chest.closeInventory(par1PlayerEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
@@ -31,146 +30,127 @@ import appeng.api.networking.spatial.ISpatialCache;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
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 class ContainerSpatialIOPort extends AEBaseContainer
|
||||
{
|
||||
public static ContainerType<ContainerSpatialIOPort> TYPE;
|
||||
|
||||
public static ContainerType<ContainerSpatialIOPort> TYPE;
|
||||
private static final ContainerHelper<ContainerSpatialIOPort, TileSpatialIOPort> helper = new ContainerHelper<>(
|
||||
ContainerSpatialIOPort::new, TileSpatialIOPort.class, SecurityPermissions.BUILD);
|
||||
|
||||
private static final ContainerHelper<ContainerSpatialIOPort, TileSpatialIOPort> helper
|
||||
= new ContainerHelper<>(ContainerSpatialIOPort::new, TileSpatialIOPort.class, SecurityPermissions.BUILD);
|
||||
@GuiSync(0)
|
||||
public long currentPower;
|
||||
@GuiSync(1)
|
||||
public long maxPower;
|
||||
@GuiSync(2)
|
||||
public long reqPower;
|
||||
@GuiSync(3)
|
||||
public long eff;
|
||||
private IGrid network;
|
||||
private int delay = 40;
|
||||
|
||||
@GuiSync( 0 )
|
||||
public long currentPower;
|
||||
@GuiSync( 1 )
|
||||
public long maxPower;
|
||||
@GuiSync( 2 )
|
||||
public long reqPower;
|
||||
@GuiSync( 3 )
|
||||
public long eff;
|
||||
private IGrid network;
|
||||
private int delay = 40;
|
||||
@GuiSync(31)
|
||||
public int xSize;
|
||||
@GuiSync(32)
|
||||
public int ySize;
|
||||
@GuiSync(33)
|
||||
public int zSize;
|
||||
|
||||
@GuiSync( 31 )
|
||||
public int xSize;
|
||||
@GuiSync( 32 )
|
||||
public int ySize;
|
||||
@GuiSync( 33 )
|
||||
public int zSize;
|
||||
public ContainerSpatialIOPort(int id, final PlayerInventory ip, final TileSpatialIOPort spatialIOPort) {
|
||||
super(TYPE, id, ip, spatialIOPort, null);
|
||||
|
||||
public ContainerSpatialIOPort(int id, final PlayerInventory ip, final TileSpatialIOPort spatialIOPort )
|
||||
{
|
||||
super( TYPE, id, ip, spatialIOPort, null );
|
||||
if (Platform.isServer()) {
|
||||
this.network = spatialIOPort.getGridNode(AEPartLocation.INTERNAL).getGrid();
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.network = spatialIOPort.getGridNode( AEPartLocation.INTERNAL ).getGrid();
|
||||
}
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS,
|
||||
spatialIOPort.getInternalInventory(), 0, 52, 48, this.getPlayerInventory()));
|
||||
this.addSlot(new SlotOutput(spatialIOPort.getInternalInventory(), 1, 113, 48,
|
||||
SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS.IIcon));
|
||||
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS, spatialIOPort
|
||||
.getInternalInventory(), 0, 52, 48, this.getPlayerInventory() ) );
|
||||
this.addSlot(
|
||||
new SlotOutput( spatialIOPort.getInternalInventory(), 1, 113, 48, SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS.IIcon ) );
|
||||
this.bindPlayerInventory(ip, 0, 197 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
if (Platform.isServer()) {
|
||||
this.delay++;
|
||||
if (this.delay > 15 && this.network != null) {
|
||||
this.delay = 0;
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.delay++;
|
||||
if( this.delay > 15 && this.network != null )
|
||||
{
|
||||
this.delay = 0;
|
||||
final IEnergyGrid eg = this.network.getCache(IEnergyGrid.class);
|
||||
final ISpatialCache sc = this.network.getCache(ISpatialCache.class);
|
||||
if (eg != null) {
|
||||
this.setCurrentPower((long) (100.0 * eg.getStoredPower()));
|
||||
this.setMaxPower((long) (100.0 * eg.getMaxStoredPower()));
|
||||
this.setRequiredPower((long) (100.0 * sc.requiredPower()));
|
||||
this.setEfficency((long) (100.0f * sc.currentEfficiency()));
|
||||
|
||||
final IEnergyGrid eg = this.network.getCache( IEnergyGrid.class );
|
||||
final ISpatialCache sc = this.network.getCache( ISpatialCache.class );
|
||||
if( eg != null )
|
||||
{
|
||||
this.setCurrentPower( (long) ( 100.0 * eg.getStoredPower() ) );
|
||||
this.setMaxPower( (long) ( 100.0 * eg.getMaxStoredPower() ) );
|
||||
this.setRequiredPower( (long) ( 100.0 * sc.requiredPower() ) );
|
||||
this.setEfficency( (long) ( 100.0f * sc.currentEfficiency() ) );
|
||||
final DimensionalCoord min = sc.getMin();
|
||||
final DimensionalCoord max = sc.getMax();
|
||||
|
||||
final DimensionalCoord min = sc.getMin();
|
||||
final DimensionalCoord max = sc.getMax();
|
||||
if (min != null && max != null && sc.isValidRegion()) {
|
||||
this.xSize = sc.getMax().x - sc.getMin().x - 1;
|
||||
this.ySize = sc.getMax().y - sc.getMin().y - 1;
|
||||
this.zSize = sc.getMax().z - sc.getMin().z - 1;
|
||||
} else {
|
||||
this.xSize = 0;
|
||||
this.ySize = 0;
|
||||
this.zSize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( min != null && max != null && sc.isValidRegion() )
|
||||
{
|
||||
this.xSize = sc.getMax().x - sc.getMin().x - 1;
|
||||
this.ySize = sc.getMax().y - sc.getMin().y - 1;
|
||||
this.zSize = sc.getMax().z - sc.getMin().z - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.xSize = 0;
|
||||
this.ySize = 0;
|
||||
this.zSize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
public long getCurrentPower() {
|
||||
return this.currentPower;
|
||||
}
|
||||
|
||||
public long getCurrentPower()
|
||||
{
|
||||
return this.currentPower;
|
||||
}
|
||||
private void setCurrentPower(final long currentPower) {
|
||||
this.currentPower = currentPower;
|
||||
}
|
||||
|
||||
private void setCurrentPower( final long currentPower )
|
||||
{
|
||||
this.currentPower = currentPower;
|
||||
}
|
||||
public long getMaxPower() {
|
||||
return this.maxPower;
|
||||
}
|
||||
|
||||
public long getMaxPower()
|
||||
{
|
||||
return this.maxPower;
|
||||
}
|
||||
private void setMaxPower(final long maxPower) {
|
||||
this.maxPower = maxPower;
|
||||
}
|
||||
|
||||
private void setMaxPower( final long maxPower )
|
||||
{
|
||||
this.maxPower = maxPower;
|
||||
}
|
||||
public long getRequiredPower() {
|
||||
return this.reqPower;
|
||||
}
|
||||
|
||||
public long getRequiredPower()
|
||||
{
|
||||
return this.reqPower;
|
||||
}
|
||||
private void setRequiredPower(final long reqPower) {
|
||||
this.reqPower = reqPower;
|
||||
}
|
||||
|
||||
private void setRequiredPower( final long reqPower )
|
||||
{
|
||||
this.reqPower = reqPower;
|
||||
}
|
||||
public long getEfficency() {
|
||||
return this.eff;
|
||||
}
|
||||
|
||||
public long getEfficency()
|
||||
{
|
||||
return this.eff;
|
||||
}
|
||||
|
||||
private void setEfficency( final long eff )
|
||||
{
|
||||
this.eff = eff;
|
||||
}
|
||||
private void setEfficency(final long eff) {
|
||||
this.eff = eff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
@@ -40,6 +38,7 @@ import appeng.api.storage.IMEInventory;
|
||||
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.guisync.GuiSync;
|
||||
import appeng.container.slot.OptionalSlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
@@ -49,171 +48,143 @@ import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.iterators.NullIterator;
|
||||
|
||||
public class ContainerStorageBus extends ContainerUpgradeable {
|
||||
|
||||
public class ContainerStorageBus extends ContainerUpgradeable
|
||||
{
|
||||
public static ContainerType<ContainerStorageBus> TYPE;
|
||||
|
||||
public static ContainerType<ContainerStorageBus> TYPE;
|
||||
private static final ContainerHelper<ContainerStorageBus, PartStorageBus> helper = new ContainerHelper<>(
|
||||
ContainerStorageBus::new, PartStorageBus.class, SecurityPermissions.BUILD);
|
||||
|
||||
private static final ContainerHelper<ContainerStorageBus, PartStorageBus> helper
|
||||
= new ContainerHelper<>(ContainerStorageBus::new, PartStorageBus.class, SecurityPermissions.BUILD);
|
||||
public static ContainerStorageBus fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
private final PartStorageBus storageBus;
|
||||
|
||||
private final PartStorageBus storageBus;
|
||||
@GuiSync(3)
|
||||
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
|
||||
|
||||
@GuiSync( 3 )
|
||||
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
|
||||
@GuiSync(4)
|
||||
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
|
||||
|
||||
@GuiSync( 4 )
|
||||
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
|
||||
public ContainerStorageBus(int id, final PlayerInventory ip, final PartStorageBus te) {
|
||||
super(TYPE, id, ip, te);
|
||||
this.storageBus = te;
|
||||
}
|
||||
|
||||
public ContainerStorageBus(int id, final PlayerInventory ip, final PartStorageBus te )
|
||||
{
|
||||
super( TYPE, id, ip, te );
|
||||
this.storageBus = te;
|
||||
}
|
||||
@Override
|
||||
protected int getHeight() {
|
||||
return 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 251;
|
||||
}
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
final IItemHandler config = this.getUpgradeable().getInventoryByName("config");
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
if (y < 2) {
|
||||
this.addSlot(new SlotFakeTypeOnly(config, y * 9 + x, xo + x * 18, yo + y * 18));
|
||||
} else {
|
||||
this.addSlot(new OptionalSlotFakeTypeOnly(config, this, y * 9 + x, xo, yo, x, y, y - 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final IItemHandler config = this.getUpgradeable().getInventoryByName( "config" );
|
||||
for( int y = 0; y < 7; y++ )
|
||||
{
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
if( y < 2 )
|
||||
{
|
||||
this.addSlot( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.addSlot( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades");
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
|
||||
this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18,
|
||||
this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187,
|
||||
8 + 18 * 2, this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187,
|
||||
8 + 18 * 3, this.getPlayerInventory())).setNotDraggable());
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187,
|
||||
8 + 18 * 4, this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
|
||||
this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
@Override
|
||||
protected boolean supportCapacity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int availableUpgrades() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
if (Platform.isServer()) {
|
||||
this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE));
|
||||
this.setReadWriteMode(
|
||||
(AccessRestriction) this.getUpgradeable().getConfigManager().getSetting(Settings.ACCESS));
|
||||
this.setStorageFilter(
|
||||
(StorageFilter) this.getUpgradeable().getConfigManager().getSetting(Settings.STORAGE_FILTER));
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.setFuzzyMode( (FuzzyMode) this.getUpgradeable().getConfigManager().getSetting( Settings.FUZZY_MODE ) );
|
||||
this.setReadWriteMode( (AccessRestriction) this.getUpgradeable().getConfigManager().getSetting( Settings.ACCESS ) );
|
||||
this.setStorageFilter( (StorageFilter) this.getUpgradeable().getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
|
||||
}
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled( final int idx )
|
||||
{
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
return upgrades > idx;
|
||||
}
|
||||
|
||||
return upgrades > idx;
|
||||
}
|
||||
public void clear() {
|
||||
ItemHandlerUtil.clear(this.getUpgradeable().getInventoryByName("config"));
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
ItemHandlerUtil.clear( this.getUpgradeable().getInventoryByName( "config" ) );
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
public void partition() {
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName("config");
|
||||
|
||||
public void partition()
|
||||
{
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
|
||||
final IMEInventory<IAEItemStack> cellInv = this.storageBus.getInternalHandler();
|
||||
|
||||
final IMEInventory<IAEItemStack> cellInv = this.storageBus.getInternalHandler();
|
||||
Iterator<IAEItemStack> i = new NullIterator<>();
|
||||
if (cellInv != null) {
|
||||
final IItemList<IAEItemStack> list = cellInv.getAvailableItems(
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
|
||||
i = list.iterator();
|
||||
}
|
||||
|
||||
Iterator<IAEItemStack> i = new NullIterator<>();
|
||||
if( cellInv != null )
|
||||
{
|
||||
final IItemList<IAEItemStack> list = cellInv
|
||||
.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
|
||||
i = list.iterator();
|
||||
}
|
||||
for (int x = 0; x < inv.getSlots(); x++) {
|
||||
if (i.hasNext() && this.isSlotEnabled((x / 9) - 2)) {
|
||||
// TODO: check if ok
|
||||
final ItemStack g = i.next().asItemStackRepresentation();
|
||||
ItemHandlerUtil.setStackInSlot(inv, x, g);
|
||||
} else {
|
||||
ItemHandlerUtil.setStackInSlot(inv, x, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
for( int x = 0; x < inv.getSlots(); x++ )
|
||||
{
|
||||
if( i.hasNext() && this.isSlotEnabled( ( x / 9 ) - 2 ) )
|
||||
{
|
||||
// TODO: check if ok
|
||||
final ItemStack g = i.next().asItemStackRepresentation();
|
||||
ItemHandlerUtil.setStackInSlot( inv, x, g );
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.EMPTY );
|
||||
}
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
public AccessRestriction getReadWriteMode() {
|
||||
return this.rwMode;
|
||||
}
|
||||
|
||||
public AccessRestriction getReadWriteMode()
|
||||
{
|
||||
return this.rwMode;
|
||||
}
|
||||
private void setReadWriteMode(final AccessRestriction rwMode) {
|
||||
this.rwMode = rwMode;
|
||||
}
|
||||
|
||||
private void setReadWriteMode( final AccessRestriction rwMode )
|
||||
{
|
||||
this.rwMode = rwMode;
|
||||
}
|
||||
public StorageFilter getStorageFilter() {
|
||||
return this.storageFilter;
|
||||
}
|
||||
|
||||
public StorageFilter getStorageFilter()
|
||||
{
|
||||
return this.storageFilter;
|
||||
}
|
||||
|
||||
private void setStorageFilter( final StorageFilter storageFilter )
|
||||
{
|
||||
this.storageFilter = storageFilter;
|
||||
}
|
||||
private void setStorageFilter(final StorageFilter storageFilter) {
|
||||
this.storageFilter = storageFilter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -43,6 +41,7 @@ import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
@@ -54,300 +53,249 @@ import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.parts.automation.PartExportBus;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSlotHost {
|
||||
|
||||
public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSlotHost
|
||||
{
|
||||
public static ContainerType<ContainerUpgradeable> TYPE;
|
||||
|
||||
public static ContainerType<ContainerUpgradeable> TYPE;
|
||||
private static final ContainerHelper<ContainerUpgradeable, IUpgradeableHost> helper = new ContainerHelper<>(
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
private final IUpgradeableHost upgradeable;
|
||||
@GuiSync(0)
|
||||
public RedstoneMode rsMode = RedstoneMode.IGNORE;
|
||||
@GuiSync(1)
|
||||
public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL;
|
||||
@GuiSync(5)
|
||||
public YesNo cMode = YesNo.NO;
|
||||
@GuiSync(6)
|
||||
public SchedulingMode schedulingMode = SchedulingMode.DEFAULT;
|
||||
private int tbSlot;
|
||||
private NetworkToolViewer tbInventory;
|
||||
|
||||
private final IUpgradeableHost upgradeable;
|
||||
@GuiSync( 0 )
|
||||
public RedstoneMode rsMode = RedstoneMode.IGNORE;
|
||||
@GuiSync( 1 )
|
||||
public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL;
|
||||
@GuiSync( 5 )
|
||||
public YesNo cMode = YesNo.NO;
|
||||
@GuiSync( 6 )
|
||||
public SchedulingMode schedulingMode = SchedulingMode.DEFAULT;
|
||||
private int tbSlot;
|
||||
private NetworkToolViewer tbInventory;
|
||||
public ContainerUpgradeable(int id, final PlayerInventory ip, final IUpgradeableHost te) {
|
||||
this(TYPE, id, ip, te);
|
||||
}
|
||||
|
||||
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));
|
||||
this.upgradeable = 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 ) );
|
||||
this.upgradeable = te;
|
||||
World w = null;
|
||||
int xCoord = 0;
|
||||
int yCoord = 0;
|
||||
int zCoord = 0;
|
||||
|
||||
World w = null;
|
||||
int xCoord = 0;
|
||||
int yCoord = 0;
|
||||
int zCoord = 0;
|
||||
if (te instanceof TileEntity) {
|
||||
final TileEntity myTile = (TileEntity) te;
|
||||
w = myTile.getWorld();
|
||||
xCoord = myTile.getPos().getX();
|
||||
yCoord = myTile.getPos().getY();
|
||||
zCoord = myTile.getPos().getZ();
|
||||
}
|
||||
|
||||
if( te instanceof TileEntity )
|
||||
{
|
||||
final TileEntity myTile = (TileEntity) te;
|
||||
w = myTile.getWorld();
|
||||
xCoord = myTile.getPos().getX();
|
||||
yCoord = myTile.getPos().getY();
|
||||
zCoord = myTile.getPos().getZ();
|
||||
}
|
||||
if (te instanceof IPart) {
|
||||
final TileEntity mk = te.getTile();
|
||||
w = mk.getWorld();
|
||||
xCoord = mk.getPos().getX();
|
||||
yCoord = mk.getPos().getY();
|
||||
zCoord = mk.getPos().getZ();
|
||||
}
|
||||
|
||||
if( te instanceof IPart )
|
||||
{
|
||||
final TileEntity mk = te.getTile();
|
||||
w = mk.getWorld();
|
||||
xCoord = mk.getPos().getX();
|
||||
yCoord = mk.getPos().getY();
|
||||
zCoord = mk.getPos().getZ();
|
||||
}
|
||||
final IInventory pi = this.getPlayerInv();
|
||||
for (int x = 0; x < pi.getSizeInventory(); x++) {
|
||||
final ItemStack pii = pi.getStackInSlot(x);
|
||||
if (!pii.isEmpty() && pii.getItem() instanceof ToolNetworkTool) {
|
||||
this.lockPlayerInventorySlot(x);
|
||||
this.tbSlot = x;
|
||||
this.tbInventory = (NetworkToolViewer) ((IGuiItem) pii.getItem()).getGuiObject(pii, x, w,
|
||||
new BlockPos(xCoord, yCoord, zCoord));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final IInventory pi = this.getPlayerInv();
|
||||
for( int x = 0; x < pi.getSizeInventory(); x++ )
|
||||
{
|
||||
final ItemStack pii = pi.getStackInSlot( x );
|
||||
if( !pii.isEmpty() && pii.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
this.lockPlayerInventorySlot( x );
|
||||
this.tbSlot = x;
|
||||
this.tbInventory = (NetworkToolViewer) ( (IGuiItem) pii.getItem() ).getGuiObject( pii, x, w, new BlockPos( xCoord, yCoord, zCoord ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.hasToolbox()) {
|
||||
for (int v = 0; v < 3; v++) {
|
||||
for (int u = 0; u < 3; u++) {
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES,
|
||||
this.tbInventory.getInternalInventory(), u + v * 3, 186 + u * 18,
|
||||
this.getHeight() - 82 + v * 18, this.getPlayerInventory())).setPlayerSide());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.hasToolbox() )
|
||||
{
|
||||
for( int v = 0; v < 3; v++ )
|
||||
{
|
||||
for( int u = 0; u < 3; u++ )
|
||||
{
|
||||
this.addSlot( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, this.tbInventory
|
||||
.getInternalInventory(), u + v * 3, 186 + u * 18, this.getHeight() - 82 + v * 18, this.getPlayerInventory() ) ).setPlayerSide() );
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setupConfig();
|
||||
|
||||
this.setupConfig();
|
||||
this.bindPlayerInventory(ip, 0, this.getHeight() - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
this.bindPlayerInventory( ip, 0, this.getHeight() - /* height of player inventory */82 );
|
||||
}
|
||||
public boolean hasToolbox() {
|
||||
return this.tbInventory != null;
|
||||
}
|
||||
|
||||
public boolean hasToolbox()
|
||||
{
|
||||
return this.tbInventory != null;
|
||||
}
|
||||
protected int getHeight() {
|
||||
return 184;
|
||||
}
|
||||
|
||||
protected int getHeight()
|
||||
{
|
||||
return 184;
|
||||
}
|
||||
protected void setupConfig() {
|
||||
this.setupUpgrades();
|
||||
|
||||
protected void setupConfig()
|
||||
{
|
||||
this.setupUpgrades();
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName("config");
|
||||
final int y = 40;
|
||||
final int x = 80;
|
||||
this.addSlot(new SlotFakeTypeOnly(inv, 0, x, y));
|
||||
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
|
||||
final int y = 40;
|
||||
final int x = 80;
|
||||
this.addSlot( new SlotFakeTypeOnly( inv, 0, x, y ) );
|
||||
if (this.supportCapacity()) {
|
||||
this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 1, x, y, -1, 0, 1));
|
||||
this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 2, x, y, 1, 0, 1));
|
||||
this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 3, x, y, 0, -1, 1));
|
||||
this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 4, x, y, 0, 1, 1));
|
||||
|
||||
if( this.supportCapacity() )
|
||||
{
|
||||
this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) );
|
||||
this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 2, x, y, 1, 0, 1 ) );
|
||||
this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 3, x, y, 0, -1, 1 ) );
|
||||
this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 4, x, y, 0, 1, 1 ) );
|
||||
this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 5, x, y, -1, -1, 2));
|
||||
this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 6, x, y, 1, -1, 2));
|
||||
this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 7, x, y, -1, 1, 2));
|
||||
this.addSlot(new OptionalSlotFakeTypeOnly(inv, this, 8, x, y, 1, 1, 2));
|
||||
}
|
||||
}
|
||||
|
||||
this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 5, x, y, -1, -1, 2 ) );
|
||||
this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 6, x, y, 1, -1, 2 ) );
|
||||
this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 7, x, y, -1, 1, 2 ) );
|
||||
this.addSlot( new OptionalSlotFakeTypeOnly( inv, this, 8, x, y, 1, 1, 2 ) );
|
||||
}
|
||||
}
|
||||
protected void setupUpgrades() {
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName("upgrades");
|
||||
if (this.availableUpgrades() > 0) {
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8,
|
||||
this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
if (this.availableUpgrades() > 1) {
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187,
|
||||
8 + 18, this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
if (this.availableUpgrades() > 2) {
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187,
|
||||
8 + 18 * 2, this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
if (this.availableUpgrades() > 3) {
|
||||
this.addSlot((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187,
|
||||
8 + 18 * 3, this.getPlayerInventory())).setNotDraggable());
|
||||
}
|
||||
}
|
||||
|
||||
protected void setupUpgrades()
|
||||
{
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
|
||||
if( this.availableUpgrades() > 0 )
|
||||
{
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
if( this.availableUpgrades() > 1 )
|
||||
{
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
if( this.availableUpgrades() > 2 )
|
||||
{
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
if( this.availableUpgrades() > 3 )
|
||||
{
|
||||
this.addSlot(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getPlayerInventory() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
}
|
||||
protected boolean supportCapacity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public int availableUpgrades() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
if (Platform.isServer()) {
|
||||
final IConfigManager cm = this.getUpgradeable().getConfigManager();
|
||||
this.loadSettingsFromHost(cm);
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
final IConfigManager cm = this.getUpgradeable().getConfigManager();
|
||||
this.loadSettingsFromHost( cm );
|
||||
}
|
||||
this.checkToolbox();
|
||||
|
||||
this.checkToolbox();
|
||||
for (final Object o : this.inventorySlots) {
|
||||
if (o instanceof OptionalSlotFake) {
|
||||
final OptionalSlotFake fs = (OptionalSlotFake) o;
|
||||
if (!fs.isSlotEnabled() && !fs.getDisplayStack().isEmpty()) {
|
||||
fs.clearStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( final Object o : this.inventorySlots )
|
||||
{
|
||||
if( o instanceof OptionalSlotFake )
|
||||
{
|
||||
final OptionalSlotFake fs = (OptionalSlotFake) o;
|
||||
if( !fs.isSlotEnabled() && !fs.getDisplayStack().isEmpty() )
|
||||
{
|
||||
fs.clearStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
protected void loadSettingsFromHost(final IConfigManager cm) {
|
||||
this.setFuzzyMode((FuzzyMode) cm.getSetting(Settings.FUZZY_MODE));
|
||||
this.setRedStoneMode((RedstoneMode) cm.getSetting(Settings.REDSTONE_CONTROLLED));
|
||||
if (this.getUpgradeable() instanceof PartExportBus) {
|
||||
this.setCraftingMode((YesNo) cm.getSetting(Settings.CRAFT_ONLY));
|
||||
this.setSchedulingMode((SchedulingMode) cm.getSetting(Settings.SCHEDULING_MODE));
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadSettingsFromHost( final IConfigManager cm )
|
||||
{
|
||||
this.setFuzzyMode( (FuzzyMode) cm.getSetting( Settings.FUZZY_MODE ) );
|
||||
this.setRedStoneMode( (RedstoneMode) cm.getSetting( Settings.REDSTONE_CONTROLLED ) );
|
||||
if( this.getUpgradeable() instanceof PartExportBus )
|
||||
{
|
||||
this.setCraftingMode( (YesNo) cm.getSetting( Settings.CRAFT_ONLY ) );
|
||||
this.setSchedulingMode( (SchedulingMode) cm.getSetting( Settings.SCHEDULING_MODE ) );
|
||||
}
|
||||
}
|
||||
protected void checkToolbox() {
|
||||
if (this.hasToolbox()) {
|
||||
final ItemStack currentItem = this.getPlayerInv().getStackInSlot(this.tbSlot);
|
||||
|
||||
protected void checkToolbox()
|
||||
{
|
||||
if( this.hasToolbox() )
|
||||
{
|
||||
final ItemStack currentItem = this.getPlayerInv().getStackInSlot( this.tbSlot );
|
||||
if (currentItem != this.tbInventory.getItemStack()) {
|
||||
if (!currentItem.isEmpty()) {
|
||||
if (ItemStack.areItemsEqual(this.tbInventory.getItemStack(), currentItem)) {
|
||||
this.getPlayerInv().setInventorySlotContents(this.tbSlot, this.tbInventory.getItemStack());
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( currentItem != this.tbInventory.getItemStack() )
|
||||
{
|
||||
if( !currentItem.isEmpty() )
|
||||
{
|
||||
if( ItemStack.areItemsEqual( this.tbInventory.getItemStack(), currentItem ) )
|
||||
{
|
||||
this.getPlayerInv().setInventorySlotContents( this.tbSlot, this.tbInventory.getItemStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected void standardDetectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
protected void standardDetectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled( final int idx )
|
||||
{
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
if (idx == 1 && upgrades > 0) {
|
||||
return true;
|
||||
}
|
||||
if (idx == 2 && upgrades > 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if( idx == 1 && upgrades > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( idx == 2 && upgrades > 1 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public FuzzyMode getFuzzyMode() {
|
||||
return this.fzMode;
|
||||
}
|
||||
|
||||
public FuzzyMode getFuzzyMode()
|
||||
{
|
||||
return this.fzMode;
|
||||
}
|
||||
public void setFuzzyMode(final FuzzyMode fzMode) {
|
||||
this.fzMode = fzMode;
|
||||
}
|
||||
|
||||
public void setFuzzyMode( final FuzzyMode fzMode )
|
||||
{
|
||||
this.fzMode = fzMode;
|
||||
}
|
||||
public YesNo getCraftingMode() {
|
||||
return this.cMode;
|
||||
}
|
||||
|
||||
public YesNo getCraftingMode()
|
||||
{
|
||||
return this.cMode;
|
||||
}
|
||||
public void setCraftingMode(final YesNo cMode) {
|
||||
this.cMode = cMode;
|
||||
}
|
||||
|
||||
public void setCraftingMode( final YesNo cMode )
|
||||
{
|
||||
this.cMode = cMode;
|
||||
}
|
||||
public RedstoneMode getRedStoneMode() {
|
||||
return this.rsMode;
|
||||
}
|
||||
|
||||
public RedstoneMode getRedStoneMode()
|
||||
{
|
||||
return this.rsMode;
|
||||
}
|
||||
public void setRedStoneMode(final RedstoneMode rsMode) {
|
||||
this.rsMode = rsMode;
|
||||
}
|
||||
|
||||
public void setRedStoneMode( final RedstoneMode rsMode )
|
||||
{
|
||||
this.rsMode = rsMode;
|
||||
}
|
||||
public SchedulingMode getSchedulingMode() {
|
||||
return this.schedulingMode;
|
||||
}
|
||||
|
||||
public SchedulingMode getSchedulingMode()
|
||||
{
|
||||
return this.schedulingMode;
|
||||
}
|
||||
private void setSchedulingMode(final SchedulingMode schedulingMode) {
|
||||
this.schedulingMode = schedulingMode;
|
||||
}
|
||||
|
||||
private void setSchedulingMode( final SchedulingMode schedulingMode )
|
||||
{
|
||||
this.schedulingMode = schedulingMode;
|
||||
}
|
||||
|
||||
protected IUpgradeableHost getUpgradeable()
|
||||
{
|
||||
return this.upgradeable;
|
||||
}
|
||||
protected IUpgradeableHost getUpgradeable() {
|
||||
return this.upgradeable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,82 +18,73 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.interfaces.IProgressProvider;
|
||||
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 class ContainerVibrationChamber extends AEBaseContainer implements IProgressProvider
|
||||
{
|
||||
public static ContainerType<ContainerVibrationChamber> TYPE;
|
||||
|
||||
public static ContainerType<ContainerVibrationChamber> TYPE;
|
||||
private static final ContainerHelper<ContainerVibrationChamber, TileVibrationChamber> helper = new ContainerHelper<>(
|
||||
ContainerVibrationChamber::new, TileVibrationChamber.class);
|
||||
|
||||
private static final ContainerHelper<ContainerVibrationChamber, TileVibrationChamber> helper
|
||||
= new ContainerHelper<>(ContainerVibrationChamber::new, TileVibrationChamber.class);
|
||||
public static ContainerVibrationChamber fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
private final TileVibrationChamber vibrationChamber;
|
||||
@GuiSync( 0 )
|
||||
public int burnSpeed = 0;
|
||||
@GuiSync( 1 )
|
||||
public int remainingBurnTime = 0;
|
||||
public ContainerVibrationChamber(int id, final PlayerInventory ip, final TileVibrationChamber vibrationChamber) {
|
||||
super(TYPE, id, ip, vibrationChamber, null);
|
||||
this.vibrationChamber = vibrationChamber;
|
||||
|
||||
public ContainerVibrationChamber(int id, final PlayerInventory ip, final TileVibrationChamber vibrationChamber )
|
||||
{
|
||||
super( TYPE, id, ip, vibrationChamber, null );
|
||||
this.vibrationChamber = vibrationChamber;
|
||||
this.addSlot(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.FUEL,
|
||||
vibrationChamber.getInternalInventory(), 0, 80, 37, this.getPlayerInventory()));
|
||||
|
||||
this.addSlot( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.FUEL, vibrationChamber.getInternalInventory(), 0, 80, 37, this
|
||||
.getPlayerInventory() ) );
|
||||
this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isServer()) {
|
||||
this.remainingBurnTime = this.vibrationChamber.getMaxBurnTime() <= 0 ? 0
|
||||
: (int) (100.0 * this.vibrationChamber.getBurnTime() / this.vibrationChamber.getMaxBurnTime());
|
||||
this.burnSpeed = this.remainingBurnTime <= 0 ? 0 : this.vibrationChamber.getBurnSpeed();
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.remainingBurnTime = this.vibrationChamber
|
||||
.getMaxBurnTime() <= 0 ? 0 : (int) ( 100.0 * this.vibrationChamber.getBurnTime() / this.vibrationChamber.getMaxBurnTime() );
|
||||
this.burnSpeed = this.remainingBurnTime <= 0 ? 0 : this.vibrationChamber.getBurnSpeed();
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
@Override
|
||||
public int getCurrentProgress() {
|
||||
return this.burnSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentProgress()
|
||||
{
|
||||
return this.burnSpeed;
|
||||
}
|
||||
public int getRemainingBurnTime() {
|
||||
return this.remainingBurnTime;
|
||||
}
|
||||
|
||||
public int getRemainingBurnTime()
|
||||
{
|
||||
return this.remainingBurnTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxProgress()
|
||||
{
|
||||
return TileVibrationChamber.MAX_BURN_SPEED;
|
||||
}
|
||||
@Override
|
||||
public int getMaxProgress() {
|
||||
return TileVibrationChamber.MAX_BURN_SPEED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,82 +18,73 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
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;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.implementations.ContainerHelper;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
|
||||
public class ContainerWireless extends AEBaseContainer
|
||||
{
|
||||
public class ContainerWireless extends AEBaseContainer {
|
||||
|
||||
public static ContainerType<ContainerWireless> TYPE;
|
||||
public static ContainerType<ContainerWireless> TYPE;
|
||||
|
||||
private static final ContainerHelper<ContainerWireless, TileWireless> helper
|
||||
= new ContainerHelper<>(ContainerWireless::new, TileWireless.class, SecurityPermissions.BUILD);
|
||||
private static final ContainerHelper<ContainerWireless, TileWireless> helper = new ContainerHelper<>(
|
||||
ContainerWireless::new, TileWireless.class, SecurityPermissions.BUILD);
|
||||
|
||||
public static ContainerWireless fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) {
|
||||
return helper.fromNetwork(windowId, inv, buf);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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;
|
||||
private final SlotRestrictedInput boosterSlot;
|
||||
@GuiSync(1)
|
||||
public long range = 0;
|
||||
@GuiSync(2)
|
||||
public long drain = 0;
|
||||
|
||||
public ContainerWireless(int id, final PlayerInventory ip, final TileWireless te )
|
||||
{
|
||||
super( TYPE, id, ip, te, null );
|
||||
public ContainerWireless(int id, final PlayerInventory ip, final TileWireless te) {
|
||||
super(TYPE, id, ip, te, null);
|
||||
|
||||
this.addSlot( this.boosterSlot = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.RANGE_BOOSTER, te
|
||||
.getInternalInventory(), 0, 80, 47, this.getPlayerInventory() ) );
|
||||
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 );
|
||||
}
|
||||
this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
final int boosters = this.boosterSlot.getStack().isEmpty() ? 0 : this.boosterSlot.getStack().getCount();
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
final int boosters = this.boosterSlot.getStack().isEmpty() ? 0 : this.boosterSlot.getStack().getCount();
|
||||
|
||||
this.setRange( (long) ( 10 * AEConfig.instance().wireless_getMaxRange( boosters ) ) );
|
||||
this.setDrain( (long) ( 100 * AEConfig.instance().wireless_getPowerDrain( boosters ) ) );
|
||||
this.setRange((long) (10 * AEConfig.instance().wireless_getMaxRange(boosters)));
|
||||
this.setDrain((long) (100 * AEConfig.instance().wireless_getPowerDrain(boosters)));
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
public long getRange()
|
||||
{
|
||||
return this.range;
|
||||
}
|
||||
public long getRange() {
|
||||
return this.range;
|
||||
}
|
||||
|
||||
private void setRange( final long range )
|
||||
{
|
||||
this.range = range;
|
||||
}
|
||||
private void setRange(final long range) {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public long getDrain()
|
||||
{
|
||||
return this.drain;
|
||||
}
|
||||
public long getDrain() {
|
||||
return this.drain;
|
||||
}
|
||||
|
||||
private void setDrain( final long drain )
|
||||
{
|
||||
this.drain = drain;
|
||||
}
|
||||
private void setDrain(final long drain) {
|
||||
this.drain = drain;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,60 +18,52 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.core.AEConfig;
|
||||
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 class ContainerWirelessTerm extends ContainerMEPortableCell
|
||||
{
|
||||
public static ContainerType<ContainerWirelessTerm> TYPE;
|
||||
|
||||
public static ContainerType<ContainerWirelessTerm> TYPE;
|
||||
private static final ContainerHelper<ContainerWirelessTerm, WirelessTerminalGuiObject> helper = new ContainerHelper<>(
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean open(PlayerEntity player, ContainerLocator locator) {
|
||||
return helper.open(player, locator);
|
||||
}
|
||||
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
|
||||
|
||||
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
|
||||
public ContainerWirelessTerm(int id, final PlayerInventory ip, final WirelessTerminalGuiObject gui) {
|
||||
super(TYPE, id, ip, gui);
|
||||
this.wirelessTerminalGUIObject = gui;
|
||||
}
|
||||
|
||||
public ContainerWirelessTerm(int id, final PlayerInventory ip, final WirelessTerminalGuiObject gui )
|
||||
{
|
||||
super( TYPE, id, ip, gui );
|
||||
this.wirelessTerminalGUIObject = gui;
|
||||
}
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
|
||||
if (Platform.isServer() && this.isValidContainer()) {
|
||||
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
|
||||
}
|
||||
|
||||
if( !this.wirelessTerminalGUIObject.rangeCheck() )
|
||||
{
|
||||
if( Platform.isServer() && this.isValidContainer() )
|
||||
{
|
||||
this.getPlayerInv().player.sendMessage( PlayerMessages.OutOfRange.get() );
|
||||
}
|
||||
|
||||
this.setValidContainer( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setPowerMultiplier( AEConfig.instance().wireless_getDrainRate( this.wirelessTerminalGUIObject.getRange() ) );
|
||||
}
|
||||
}
|
||||
this.setValidContainer(false);
|
||||
} else {
|
||||
this.setPowerMultiplier(
|
||||
AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,57 +18,48 @@
|
||||
|
||||
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;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
|
||||
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
||||
{
|
||||
private final ITextComponent myName;
|
||||
private final ICraftingCPU cpu;
|
||||
private final long size;
|
||||
private final int processors;
|
||||
public class CraftingCPURecord implements Comparable<CraftingCPURecord> {
|
||||
private final ITextComponent myName;
|
||||
private final ICraftingCPU cpu;
|
||||
private final long size;
|
||||
private final int processors;
|
||||
|
||||
public CraftingCPURecord( final long size, final int coProcessors, final ICraftingCPU server )
|
||||
{
|
||||
this.size = size;
|
||||
this.processors = coProcessors;
|
||||
this.cpu = server;
|
||||
this.myName = server.getName();
|
||||
}
|
||||
public CraftingCPURecord(final long size, final int coProcessors, final ICraftingCPU server) {
|
||||
this.size = size;
|
||||
this.processors = coProcessors;
|
||||
this.cpu = server;
|
||||
this.myName = server.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( @Nonnull final CraftingCPURecord o )
|
||||
{
|
||||
final int a = Long.compare( o.getProcessors(), this.getProcessors() );
|
||||
if( a != 0 )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
return Long.compare( o.getSize(), this.getSize() );
|
||||
}
|
||||
@Override
|
||||
public int compareTo(@Nonnull final CraftingCPURecord o) {
|
||||
final int a = Long.compare(o.getProcessors(), this.getProcessors());
|
||||
if (a != 0) {
|
||||
return a;
|
||||
}
|
||||
return Long.compare(o.getSize(), this.getSize());
|
||||
}
|
||||
|
||||
ICraftingCPU getCpu()
|
||||
{
|
||||
return this.cpu;
|
||||
}
|
||||
ICraftingCPU getCpu() {
|
||||
return this.cpu;
|
||||
}
|
||||
|
||||
ITextComponent getName()
|
||||
{
|
||||
return this.myName;
|
||||
}
|
||||
ITextComponent getName() {
|
||||
return this.myName;
|
||||
}
|
||||
|
||||
int getProcessors()
|
||||
{
|
||||
return this.processors;
|
||||
}
|
||||
int getProcessors() {
|
||||
return this.processors;
|
||||
}
|
||||
|
||||
long getSize()
|
||||
{
|
||||
return this.size;
|
||||
}
|
||||
long getSize() {
|
||||
return this.size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,35 @@
|
||||
/*
|
||||
* 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.interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Any item providing a GUI and depending on an exact inventory slot.
|
||||
*
|
||||
* This interface is likely a volatile one until a general GUI refactoring occurred.
|
||||
* Use it with care and expect changes.
|
||||
*
|
||||
*/
|
||||
public interface IInventorySlotAware
|
||||
{
|
||||
/**
|
||||
* This is needed to select the correct slot index.
|
||||
*
|
||||
* @return the inventory index of this portable cell.
|
||||
*/
|
||||
int getInventorySlot();
|
||||
}
|
||||
/*
|
||||
* 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.interfaces;
|
||||
|
||||
/**
|
||||
* Any item providing a GUI and depending on an exact inventory slot.
|
||||
*
|
||||
* This interface is likely a volatile one until a general GUI refactoring
|
||||
* occurred. Use it with care and expect changes.
|
||||
*
|
||||
*/
|
||||
public interface IInventorySlotAware {
|
||||
/**
|
||||
* This is needed to select the correct slot index.
|
||||
*
|
||||
* @return the inventory index of this portable cell.
|
||||
*/
|
||||
int getInventorySlot();
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
/*
|
||||
* 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.interfaces;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface provides the data for anything simulating a progress.
|
||||
*
|
||||
* Its main use is in combination with the {@link appeng.client.gui.widgets.GuiProgressBar}, which ensures to scale it to a percentage of 0 to
|
||||
* 100.
|
||||
*/
|
||||
public interface IProgressProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* The current value of the progress. It should cover a range from 0 to the max progress
|
||||
*
|
||||
* @return An int representing the current progress
|
||||
*/
|
||||
int getCurrentProgress();
|
||||
|
||||
/**
|
||||
* The max value the progress.
|
||||
*
|
||||
* It is not limited to a value of 100 and can be scaled to fit the current needs. For example scaled down to
|
||||
* decrease or scaled up to increase the precision.
|
||||
*
|
||||
* @return An int representing the max progress
|
||||
*/
|
||||
int getMaxProgress();
|
||||
}
|
||||
/*
|
||||
* 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.interfaces;
|
||||
|
||||
/**
|
||||
* This interface provides the data for anything simulating a progress.
|
||||
*
|
||||
* Its main use is in combination with the
|
||||
* {@link appeng.client.gui.widgets.GuiProgressBar}, which ensures to scale it
|
||||
* to a percentage of 0 to 100.
|
||||
*/
|
||||
public interface IProgressProvider {
|
||||
|
||||
/**
|
||||
* The current value of the progress. It should cover a range from 0 to the max
|
||||
* progress
|
||||
*
|
||||
* @return An int representing the current progress
|
||||
*/
|
||||
int getCurrentProgress();
|
||||
|
||||
/**
|
||||
* The max value the progress.
|
||||
*
|
||||
* It is not limited to a value of 100 and can be scaled to fit the current
|
||||
* needs. For example scaled down to decrease or scaled up to increase the
|
||||
* precision.
|
||||
*
|
||||
* @return An int representing the max progress
|
||||
*/
|
||||
int getMaxProgress();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -30,177 +29,169 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
|
||||
public class AppEngCraftingSlot extends AppEngSlot {
|
||||
|
||||
public class AppEngCraftingSlot extends AppEngSlot
|
||||
{
|
||||
/**
|
||||
* The craft matrix inventory linked to this result slot.
|
||||
*/
|
||||
private final IItemHandler craftMatrix;
|
||||
|
||||
/**
|
||||
* The craft matrix inventory linked to this result slot.
|
||||
*/
|
||||
private final IItemHandler craftMatrix;
|
||||
/**
|
||||
* The player that is using the GUI where this slot resides.
|
||||
*/
|
||||
private final PlayerEntity thePlayer;
|
||||
|
||||
/**
|
||||
* The player that is using the GUI where this slot resides.
|
||||
*/
|
||||
private final PlayerEntity thePlayer;
|
||||
/**
|
||||
* The number of items that have been crafted so far. Gets passed to
|
||||
* ItemStack.onCrafting before being reset.
|
||||
*/
|
||||
private int amountCrafted;
|
||||
|
||||
/**
|
||||
* The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset.
|
||||
*/
|
||||
private int amountCrafted;
|
||||
public AppEngCraftingSlot(final PlayerEntity par1PlayerEntity, final IItemHandler par2IInventory,
|
||||
final IItemHandler par3IInventory, final int par4, final int par5, final int par6) {
|
||||
super(par3IInventory, par4, par5, par6);
|
||||
this.thePlayer = par1PlayerEntity;
|
||||
this.craftMatrix = par2IInventory;
|
||||
}
|
||||
|
||||
public AppEngCraftingSlot( final PlayerEntity par1PlayerEntity, final IItemHandler par2IInventory, final IItemHandler par3IInventory, final int par4, final int par5, final int par6 )
|
||||
{
|
||||
super( par3IInventory, par4, par5, par6 );
|
||||
this.thePlayer = par1PlayerEntity;
|
||||
this.craftMatrix = par2IInventory;
|
||||
}
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the
|
||||
* armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not
|
||||
* ore and wood. Typically increases an internal count then calls
|
||||
* onCrafting(item).
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting(final ItemStack par1ItemStack, final int par2) {
|
||||
this.amountCrafted += par2;
|
||||
this.onCrafting(par1ItemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
|
||||
* internal count then calls onCrafting(item).
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting( final ItemStack par1ItemStack, final int par2 )
|
||||
{
|
||||
this.amountCrafted += par2;
|
||||
this.onCrafting( par1ItemStack );
|
||||
}
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not
|
||||
* ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting(final ItemStack par1ItemStack) {
|
||||
par1ItemStack.onCrafting(this.thePlayer.world, this.thePlayer, this.amountCrafted);
|
||||
this.amountCrafted = 0;
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting( final ItemStack par1ItemStack )
|
||||
{
|
||||
par1ItemStack.onCrafting( this.thePlayer.world, this.thePlayer, this.amountCrafted );
|
||||
this.amountCrafted = 0;
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.CRAFTING_TABLE )
|
||||
// )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_WORK_BENCH, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemPickaxe )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_PICKAXE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.FURNACE ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_FURNACE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemHoe )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_HOE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Items.BREAD )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.MAKE_BREAD, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Items.CAKE )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BAKE_CAKE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemPickaxe && ( (ItemTool)
|
||||
// par1ItemStack.getItem()
|
||||
// ).getToolMaterial() != Item.ToolMaterial.WOOD )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_BETTER_PICKAXE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemSword )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_SWORD, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.ENCHANTING_TABLE
|
||||
// ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.ENCHANTMENTS, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.BOOKSHELF ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BOOKCASE, 1 );
|
||||
// }
|
||||
}
|
||||
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.CRAFTING_TABLE ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_WORK_BENCH, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemPickaxe )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_PICKAXE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.FURNACE ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_FURNACE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemHoe )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_HOE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Items.BREAD )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.MAKE_BREAD, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Items.CAKE )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BAKE_CAKE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemPickaxe && ( (ItemTool) par1ItemStack.getItem()
|
||||
// ).getToolMaterial() != Item.ToolMaterial.WOOD )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_BETTER_PICKAXE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemSword )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_SWORD, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.ENCHANTING_TABLE ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.ENCHANTMENTS, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.BOOKSHELF ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BOOKCASE, 1 );
|
||||
// }
|
||||
}
|
||||
@Override
|
||||
public ItemStack onTake(final PlayerEntity playerIn, final ItemStack stack) {
|
||||
BasicEventHooks.firePlayerCraftingEvent(playerIn, stack, new WrapperInvItemHandler(this.craftMatrix));
|
||||
this.onCrafting(stack);
|
||||
net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
|
||||
final CraftingInventory ic = new CraftingInventory(this.getContainer(), 3, 3);
|
||||
|
||||
@Override
|
||||
public ItemStack onTake( final PlayerEntity playerIn, final ItemStack stack )
|
||||
{
|
||||
BasicEventHooks.firePlayerCraftingEvent( playerIn, stack, new WrapperInvItemHandler( this.craftMatrix ) );
|
||||
this.onCrafting( stack );
|
||||
net.minecraftforge.common.ForgeHooks.setCraftingPlayer( playerIn );
|
||||
final CraftingInventory ic = new CraftingInventory( this.getContainer(), 3, 3 );
|
||||
for (int x = 0; x < this.craftMatrix.getSlots(); x++) {
|
||||
ic.setInventorySlotContents(x, this.craftMatrix.getStackInSlot(x));
|
||||
}
|
||||
|
||||
for( int x = 0; x < this.craftMatrix.getSlots(); x++ )
|
||||
{
|
||||
ic.setInventorySlotContents( x, this.craftMatrix.getStackInSlot( x ) );
|
||||
}
|
||||
final NonNullList<ItemStack> aitemstack = this.getRemainingItems(ic, playerIn.world);
|
||||
|
||||
final NonNullList<ItemStack> aitemstack = this.getRemainingItems( ic, playerIn.world );
|
||||
ItemHandlerUtil.copy(ic, this.craftMatrix, false);
|
||||
|
||||
ItemHandlerUtil.copy( ic, this.craftMatrix, false );
|
||||
net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);
|
||||
|
||||
net.minecraftforge.common.ForgeHooks.setCraftingPlayer( null );
|
||||
for (int i = 0; i < aitemstack.size(); ++i) {
|
||||
final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
|
||||
final ItemStack itemstack2 = aitemstack.get(i);
|
||||
|
||||
for( int i = 0; i < aitemstack.size(); ++i )
|
||||
{
|
||||
final ItemStack itemstack1 = this.craftMatrix.getStackInSlot( i );
|
||||
final ItemStack itemstack2 = aitemstack.get( i );
|
||||
if (!itemstack1.isEmpty()) {
|
||||
this.craftMatrix.extractItem(i, 1, false);
|
||||
}
|
||||
|
||||
if( !itemstack1.isEmpty() )
|
||||
{
|
||||
this.craftMatrix.extractItem( i, 1, false );
|
||||
}
|
||||
if (!itemstack2.isEmpty()) {
|
||||
if (this.craftMatrix.getStackInSlot(i).isEmpty()) {
|
||||
ItemHandlerUtil.setStackInSlot(this.craftMatrix, i, itemstack2);
|
||||
} else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) {
|
||||
this.thePlayer.dropItem(itemstack2, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !itemstack2.isEmpty() )
|
||||
{
|
||||
if( this.craftMatrix.getStackInSlot( i ).isEmpty() )
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( this.craftMatrix, i, itemstack2 );
|
||||
}
|
||||
else if( !this.thePlayer.inventory.addItemStackToInventory( itemstack2 ) )
|
||||
{
|
||||
this.thePlayer.dropItem( itemstack2, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
/**
|
||||
* Decrease the size of the stack in slot (first int arg) by the amount of the
|
||||
* second int arg. Returns the new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
if (this.getHasStack()) {
|
||||
this.amountCrafted += Math.min(par1, this.getStack().getCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
|
||||
* stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
if( this.getHasStack() )
|
||||
{
|
||||
this.amountCrafted += Math.min( par1, this.getStack().getCount() );
|
||||
}
|
||||
return super.decrStackSize(par1);
|
||||
}
|
||||
|
||||
return super.decrStackSize( par1 );
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
protected NonNullList<ItemStack> getRemainingItems( CraftingInventory ic, World world )
|
||||
{
|
||||
// FIXME return CraftingManager.getRemainingItems( ic, world );
|
||||
return null;
|
||||
}
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui
|
||||
// refactoring.
|
||||
protected NonNullList<ItemStack> getRemainingItems(CraftingInventory ic, World world) {
|
||||
// FIXME return CraftingManager.getRemainingItems( ic, world );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -33,257 +32,211 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
|
||||
public class AppEngSlot extends Slot {
|
||||
private static IInventory emptyInventory = new Inventory(0);
|
||||
private final IItemHandler itemHandler;
|
||||
private final int index;
|
||||
|
||||
public class AppEngSlot extends Slot
|
||||
{
|
||||
private static IInventory emptyInventory = new Inventory(0);
|
||||
private final IItemHandler itemHandler;
|
||||
private final int index;
|
||||
private final int defX;
|
||||
private final int defY;
|
||||
private boolean isDraggable = true;
|
||||
private boolean isPlayerSide = false;
|
||||
private AEBaseContainer myContainer = null;
|
||||
private int IIcon = -1;
|
||||
private hasCalculatedValidness isValid;
|
||||
private boolean isDisplay = false;
|
||||
|
||||
private final int defX;
|
||||
private final int defY;
|
||||
private boolean isDraggable = true;
|
||||
private boolean isPlayerSide = false;
|
||||
private AEBaseContainer myContainer = null;
|
||||
private int IIcon = -1;
|
||||
private hasCalculatedValidness isValid;
|
||||
private boolean isDisplay = false;
|
||||
public AppEngSlot(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(emptyInventory, idx, x, y);
|
||||
this.itemHandler = inv;
|
||||
this.index = idx;
|
||||
|
||||
public AppEngSlot( final IItemHandler inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( emptyInventory, idx, x, y );
|
||||
this.itemHandler = inv;
|
||||
this.index = idx;
|
||||
this.defX = x;
|
||||
this.defY = y;
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
}
|
||||
|
||||
this.defX = x;
|
||||
this.defY = y;
|
||||
this.setIsValid( hasCalculatedValidness.NotAvailable );
|
||||
}
|
||||
public Slot setNotDraggable() {
|
||||
this.setDraggable(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Slot setNotDraggable()
|
||||
{
|
||||
this.setDraggable( false );
|
||||
return this;
|
||||
}
|
||||
public Slot setPlayerSide() {
|
||||
this.isPlayerSide = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Slot setPlayerSide()
|
||||
{
|
||||
this.isPlayerSide = true;
|
||||
return this;
|
||||
}
|
||||
public String getTooltip() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getTooltip()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public void clearStack() {
|
||||
ItemHandlerUtil.setStackInSlot(this.itemHandler, this.index, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public void clearStack()
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, ItemStack.EMPTY );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(@Nonnull final ItemStack par1ItemStack) {
|
||||
if (this.isSlotEnabled()) {
|
||||
return this.itemHandler.isItemValid(this.index, par1ItemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( @Nonnull final ItemStack par1ItemStack )
|
||||
{
|
||||
if( this.isSlotEnabled() )
|
||||
{
|
||||
return this.itemHandler.isItemValid( this.index, par1ItemStack );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack() {
|
||||
if (!this.isSlotEnabled()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( !this.isSlotEnabled() )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (this.itemHandler.getSlots() <= this.getSlotIndex()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( this.itemHandler.getSlots() <= this.getSlotIndex() )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (this.isDisplay()) {
|
||||
this.setDisplay(false);
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
|
||||
if( this.isDisplay() )
|
||||
{
|
||||
this.setDisplay( false );
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
return this.itemHandler.getStackInSlot(this.index);
|
||||
}
|
||||
|
||||
return this.itemHandler.getStackInSlot( this.index );
|
||||
}
|
||||
@Override
|
||||
public void putStack(final ItemStack stack) {
|
||||
if (this.isSlotEnabled()) {
|
||||
ItemHandlerUtil.setStackInSlot(this.itemHandler, this.index, stack);
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack stack )
|
||||
{
|
||||
if( this.isSlotEnabled() )
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, stack );
|
||||
if (this.getContainer() != null) {
|
||||
this.getContainer().onSlotChange(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.getContainer() != null )
|
||||
{
|
||||
this.getContainer().onSlotChange( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
public IItemHandler getItemHandler() {
|
||||
return this.itemHandler;
|
||||
}
|
||||
|
||||
public IItemHandler getItemHandler()
|
||||
{
|
||||
return this.itemHandler;
|
||||
}
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
this.setIsValid( hasCalculatedValidness.NotAvailable );
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return this.itemHandler.getSlotLimit(this.index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return this.itemHandler.getSlotLimit( this.index );
|
||||
}
|
||||
@Override
|
||||
public int getItemStackLimit(@Nonnull ItemStack stack) {
|
||||
return Math.min(this.getSlotStackLimit(), stack.getMaxStackSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemStackLimit( @Nonnull ItemStack stack )
|
||||
{
|
||||
return Math.min( this.getSlotStackLimit(), stack.getMaxStackSize() );
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
if (this.isSlotEnabled()) {
|
||||
return !this.itemHandler.extractItem(this.index, 1, true).isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
if( this.isSlotEnabled() )
|
||||
{
|
||||
return !this.itemHandler.extractItem( this.index, 1, true ).isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack decrStackSize(int amount) {
|
||||
return this.itemHandler.extractItem(this.index, amount, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack decrStackSize( int amount )
|
||||
{
|
||||
return this.itemHandler.extractItem( this.index, amount, false );
|
||||
}
|
||||
@Override
|
||||
public boolean isSameInventory(Slot other) {
|
||||
return other instanceof AppEngSlot && ((AppEngSlot) other).itemHandler == this.itemHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameInventory( Slot other )
|
||||
{
|
||||
return other instanceof AppEngSlot && ( (AppEngSlot) other ).itemHandler == this.itemHandler;
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public boolean isEnabled() {
|
||||
return this.isSlotEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return this.isSlotEnabled();
|
||||
}
|
||||
public boolean isSlotEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public ItemStack getDisplayStack() {
|
||||
return this.itemHandler.getStackInSlot(this.index);
|
||||
}
|
||||
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
return this.itemHandler.getStackInSlot( this.index );
|
||||
}
|
||||
public float getOpacityOfIcon() {
|
||||
return 0.4f;
|
||||
}
|
||||
|
||||
public float getOpacityOfIcon()
|
||||
{
|
||||
return 0.4f;
|
||||
}
|
||||
public boolean renderIconWithItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderIconWithItem()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public int getIcon() {
|
||||
return this.getIIcon();
|
||||
}
|
||||
|
||||
public int getIcon()
|
||||
{
|
||||
return this.getIIcon();
|
||||
}
|
||||
public boolean isPlayerSide() {
|
||||
return this.isPlayerSide;
|
||||
}
|
||||
|
||||
public boolean isPlayerSide()
|
||||
{
|
||||
return this.isPlayerSide;
|
||||
}
|
||||
public boolean shouldDisplay() {
|
||||
return this.isSlotEnabled();
|
||||
}
|
||||
|
||||
public boolean shouldDisplay()
|
||||
{
|
||||
return this.isSlotEnabled();
|
||||
}
|
||||
public int getX() {
|
||||
return this.defX;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return this.defX;
|
||||
}
|
||||
public int getY() {
|
||||
return this.defY;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return this.defY;
|
||||
}
|
||||
private int getIIcon() {
|
||||
return this.IIcon;
|
||||
}
|
||||
|
||||
private int getIIcon()
|
||||
{
|
||||
return this.IIcon;
|
||||
}
|
||||
public void setIIcon(final int iIcon) {
|
||||
this.IIcon = iIcon;
|
||||
}
|
||||
|
||||
public void setIIcon( final int iIcon )
|
||||
{
|
||||
this.IIcon = iIcon;
|
||||
}
|
||||
private boolean isDisplay() {
|
||||
return this.isDisplay;
|
||||
}
|
||||
|
||||
private boolean isDisplay()
|
||||
{
|
||||
return this.isDisplay;
|
||||
}
|
||||
public void setDisplay(final boolean isDisplay) {
|
||||
this.isDisplay = isDisplay;
|
||||
}
|
||||
|
||||
public void setDisplay( final boolean isDisplay )
|
||||
{
|
||||
this.isDisplay = isDisplay;
|
||||
}
|
||||
public boolean isDraggable() {
|
||||
return this.isDraggable;
|
||||
}
|
||||
|
||||
public boolean isDraggable()
|
||||
{
|
||||
return this.isDraggable;
|
||||
}
|
||||
private void setDraggable(final boolean isDraggable) {
|
||||
this.isDraggable = isDraggable;
|
||||
}
|
||||
|
||||
private void setDraggable( final boolean isDraggable )
|
||||
{
|
||||
this.isDraggable = isDraggable;
|
||||
}
|
||||
void setPlayerSide(final boolean isPlayerSide) {
|
||||
this.isPlayerSide = isPlayerSide;
|
||||
}
|
||||
|
||||
void setPlayerSide( final boolean isPlayerSide )
|
||||
{
|
||||
this.isPlayerSide = isPlayerSide;
|
||||
}
|
||||
public hasCalculatedValidness getIsValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
public hasCalculatedValidness getIsValid()
|
||||
{
|
||||
return this.isValid;
|
||||
}
|
||||
public void setIsValid(final hasCalculatedValidness isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
public void setIsValid( final hasCalculatedValidness isValid )
|
||||
{
|
||||
this.isValid = isValid;
|
||||
}
|
||||
protected AEBaseContainer getContainer() {
|
||||
return this.myContainer;
|
||||
}
|
||||
|
||||
protected AEBaseContainer getContainer()
|
||||
{
|
||||
return this.myContainer;
|
||||
}
|
||||
public void setContainer(final AEBaseContainer myContainer) {
|
||||
this.myContainer = myContainer;
|
||||
}
|
||||
|
||||
public void setContainer( final AEBaseContainer myContainer )
|
||||
{
|
||||
this.myContainer = myContainer;
|
||||
}
|
||||
|
||||
public enum hasCalculatedValidness
|
||||
{
|
||||
NotAvailable, Valid, Invalid
|
||||
}
|
||||
public enum hasCalculatedValidness {
|
||||
NotAvailable, Valid, Invalid
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,17 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 2/05/2018
|
||||
* @since rv6 2/05/2018
|
||||
*/
|
||||
public interface IOptionalSlot
|
||||
{
|
||||
default boolean isRenderDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public interface IOptionalSlot {
|
||||
default boolean isRenderDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int getSourceX();
|
||||
int getSourceX();
|
||||
|
||||
int getSourceY();
|
||||
int getSourceY();
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
public interface IOptionalSlotHost {
|
||||
|
||||
public interface IOptionalSlotHost
|
||||
{
|
||||
|
||||
boolean isSlotEnabled( int idx );
|
||||
boolean isSlotEnabled(int idx);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -26,72 +25,60 @@ import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
// FIXME seems unused
|
||||
public class NullSlot extends Slot
|
||||
{
|
||||
public class NullSlot extends Slot {
|
||||
|
||||
public NullSlot()
|
||||
{
|
||||
super( null, 0, 0, 0 );
|
||||
}
|
||||
public NullSlot() {
|
||||
super(null, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange( final ItemStack par1ItemStack, final ItemStack par2ItemStack )
|
||||
{
|
||||
@Override
|
||||
public void onSlotChange(final ItemStack par1ItemStack, final ItemStack par2ItemStack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onTake( final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack )
|
||||
{
|
||||
return par2ItemStack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack onTake(final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack) {
|
||||
return par2ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack() {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack par1ItemStack )
|
||||
{
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotIndex()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getSlotIndex() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,77 +18,65 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class OptionalSlotFake extends SlotFake implements IOptionalSlot {
|
||||
|
||||
public class OptionalSlotFake extends SlotFake implements IOptionalSlot
|
||||
{
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
private boolean renderDisabled = true;
|
||||
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
private boolean renderDisabled = true;
|
||||
public OptionalSlotFake(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x,
|
||||
final int y, final int offX, final int offY, final int groupNum) {
|
||||
super(inv, idx, x + offX * 18, y + offY * 18);
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
|
||||
public OptionalSlotFake( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
|
||||
{
|
||||
super( inv, idx, x + offX * 18, y + offY * 18 );
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack() {
|
||||
if (!this.isSlotEnabled()) {
|
||||
if (!this.getDisplayStack().isEmpty()) {
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( !this.isSlotEnabled() )
|
||||
{
|
||||
if( !this.getDisplayStack().isEmpty() )
|
||||
{
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
return super.getStack();
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.host == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
@Override
|
||||
public boolean isRenderDisabled() {
|
||||
return this.renderDisabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRenderDisabled()
|
||||
{
|
||||
return this.renderDisabled;
|
||||
}
|
||||
public void setRenderDisabled(final boolean renderDisabled) {
|
||||
this.renderDisabled = renderDisabled;
|
||||
}
|
||||
|
||||
public void setRenderDisabled( final boolean renderDisabled )
|
||||
{
|
||||
this.renderDisabled = renderDisabled;
|
||||
}
|
||||
@Override
|
||||
public int getSourceX() {
|
||||
return this.srcX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceX()
|
||||
{
|
||||
return this.srcX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceY()
|
||||
{
|
||||
return this.srcY;
|
||||
}
|
||||
@Override
|
||||
public int getSourceY() {
|
||||
return this.srcY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,35 +18,27 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class OptionalSlotFakeTypeOnly extends OptionalSlotFake {
|
||||
|
||||
public class OptionalSlotFakeTypeOnly extends OptionalSlotFake
|
||||
{
|
||||
public OptionalSlotFakeTypeOnly(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx,
|
||||
final int x, final int y, final int offX, final int offY, final int groupNum) {
|
||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
||||
}
|
||||
|
||||
public OptionalSlotFakeTypeOnly( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
|
||||
{
|
||||
super( inv, containerBus, idx, x, y, offX, offY, groupNum );
|
||||
}
|
||||
@Override
|
||||
public void putStack(ItemStack is) {
|
||||
if (!is.isEmpty()) {
|
||||
is = is.copy();
|
||||
if (is.getCount() > 1) {
|
||||
is.setCount(1);
|
||||
} else if (is.getCount() < -1) {
|
||||
is.setCount(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
is = is.copy();
|
||||
if( is.getCount() > 1 )
|
||||
{
|
||||
is.setCount( 1 );
|
||||
}
|
||||
else if( is.getCount() < -1 )
|
||||
{
|
||||
is.setCount( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
super.putStack( is );
|
||||
}
|
||||
super.putStack(is);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,43 +18,36 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class OptionalSlotNormal extends AppEngSlot implements IOptionalSlot {
|
||||
|
||||
public class OptionalSlotNormal extends AppEngSlot implements IOptionalSlot
|
||||
{
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
public OptionalSlotNormal(final IItemHandler inv, final IOptionalSlotHost containerBus, final int slot,
|
||||
final int xPos, final int yPos, final int groupNum) {
|
||||
super(inv, slot, xPos, yPos);
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
|
||||
public OptionalSlotNormal( final IItemHandler inv, final IOptionalSlotHost containerBus, final int slot, final int xPos, final int yPos, final int groupNum )
|
||||
{
|
||||
super( inv, slot, xPos, yPos );
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.host == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
@Override
|
||||
public int getSourceX() {
|
||||
return this.xPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceX()
|
||||
{
|
||||
return this.xPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceY()
|
||||
{
|
||||
return this.yPos;
|
||||
}
|
||||
@Override
|
||||
public int getSourceY() {
|
||||
return this.yPos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,32 +18,27 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class OptionalSlotRestrictedInput extends SlotRestrictedInput {
|
||||
|
||||
public class OptionalSlotRestrictedInput extends SlotRestrictedInput
|
||||
{
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
public OptionalSlotRestrictedInput(final PlacableItemType valid, final IItemHandler i, final IOptionalSlotHost host,
|
||||
final int slotIndex, final int x, final int y, final int grpNum, final PlayerInventory invPlayer) {
|
||||
super(valid, i, slotIndex, x, y, invPlayer);
|
||||
this.groupNum = grpNum;
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public OptionalSlotRestrictedInput( final PlacableItemType valid, final IItemHandler i, final IOptionalSlotHost host, final int slotIndex, final int x, final int y, final int grpNum, final PlayerInventory invPlayer )
|
||||
{
|
||||
super( valid, i, slotIndex, x, y, invPlayer );
|
||||
this.groupNum = grpNum;
|
||||
this.host = host;
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.host == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -26,44 +25,38 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
|
||||
public class SlotCraftingMatrix extends AppEngSlot {
|
||||
private final AEBaseContainer c;
|
||||
private final IInventory wrappedInventory;
|
||||
|
||||
public class SlotCraftingMatrix extends AppEngSlot
|
||||
{
|
||||
private final AEBaseContainer c;
|
||||
private final IInventory wrappedInventory;
|
||||
public SlotCraftingMatrix(final AEBaseContainer c, final IItemHandler par1iInventory, final int par2,
|
||||
final int par3, final int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.c = c;
|
||||
this.wrappedInventory = new WrapperInvItemHandler(par1iInventory);
|
||||
}
|
||||
|
||||
public SlotCraftingMatrix( final AEBaseContainer c, final IItemHandler par1iInventory, final int par2, final int par3, final int par4 )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
this.c = c;
|
||||
this.wrappedInventory = new WrapperInvItemHandler( par1iInventory );
|
||||
}
|
||||
@Override
|
||||
public void clearStack() {
|
||||
super.clearStack();
|
||||
this.c.onCraftMatrixChanged(this.wrappedInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearStack()
|
||||
{
|
||||
super.clearStack();
|
||||
this.c.onCraftMatrixChanged( this.wrappedInventory );
|
||||
}
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {
|
||||
super.putStack(par1ItemStack);
|
||||
this.c.onCraftMatrixChanged(this.wrappedInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack par1ItemStack )
|
||||
{
|
||||
super.putStack( par1ItemStack );
|
||||
this.c.onCraftMatrixChanged( this.wrappedInventory );
|
||||
}
|
||||
@Override
|
||||
public boolean isPlayerSide() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerSide()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
final ItemStack is = super.decrStackSize( par1 );
|
||||
this.c.onCraftMatrixChanged( this.wrappedInventory );
|
||||
return is;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
final ItemStack is = super.decrStackSize(par1);
|
||||
this.c.onCraftMatrixChanged(this.wrappedInventory);
|
||||
return is;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -56,277 +55,239 @@ import appeng.util.inv.WrapperCursorItemHandler;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
|
||||
public class SlotCraftingTerm extends AppEngCraftingSlot
|
||||
{
|
||||
private final IItemHandler craftInv;
|
||||
private final IItemHandler pattern;
|
||||
|
||||
private final IItemHandler craftInv;
|
||||
private final IItemHandler pattern;
|
||||
private final IActionSource mySrc;
|
||||
private final IEnergySource energySrc;
|
||||
private final IStorageMonitorable storage;
|
||||
private final IContainerCraftingPacket container;
|
||||
|
||||
private final IActionSource mySrc;
|
||||
private final IEnergySource energySrc;
|
||||
private final IStorageMonitorable storage;
|
||||
private final IContainerCraftingPacket container;
|
||||
public SlotCraftingTerm(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc,
|
||||
final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix,
|
||||
final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp) {
|
||||
super(player, cMatrix, output, 0, x, y);
|
||||
this.energySrc = energySrc;
|
||||
this.storage = storage;
|
||||
this.mySrc = mySrc;
|
||||
this.pattern = cMatrix;
|
||||
this.craftInv = secondMatrix;
|
||||
this.container = ccp;
|
||||
}
|
||||
|
||||
public SlotCraftingTerm( final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp )
|
||||
{
|
||||
super( player, cMatrix, output, 0, x, y );
|
||||
this.energySrc = energySrc;
|
||||
this.storage = storage;
|
||||
this.mySrc = mySrc;
|
||||
this.pattern = cMatrix;
|
||||
this.craftInv = secondMatrix;
|
||||
this.container = ccp;
|
||||
}
|
||||
public IItemHandler getCraftingMatrix() {
|
||||
return this.craftInv;
|
||||
}
|
||||
|
||||
public IItemHandler getCraftingMatrix()
|
||||
{
|
||||
return this.craftInv;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ItemStack onTake(final PlayerEntity p, final ItemStack is) {
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onTake( final PlayerEntity p, final ItemStack is )
|
||||
{
|
||||
return is;
|
||||
}
|
||||
public void doClick(final InventoryAction action, final PlayerEntity who) {
|
||||
if (this.getStack().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void doClick( final InventoryAction action, final PlayerEntity who )
|
||||
{
|
||||
if( this.getStack().isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IMEMonitor<IAEItemStack> inv = this.storage
|
||||
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
final int howManyPerCraft = this.getStack().getCount();
|
||||
int maxTimesToCraft = 0;
|
||||
|
||||
final IMEMonitor<IAEItemStack> inv = this.storage.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final int howManyPerCraft = this.getStack().getCount();
|
||||
int maxTimesToCraft = 0;
|
||||
InventoryAdaptor ia = null;
|
||||
if (action == InventoryAction.CRAFT_SHIFT) // craft into player inventory...
|
||||
{
|
||||
ia = InventoryAdaptor.getAdaptor(who);
|
||||
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft);
|
||||
} else if (action == InventoryAction.CRAFT_STACK) // craft into hand, full stack
|
||||
{
|
||||
ia = new AdaptorItemHandler(new WrapperCursorItemHandler(who.inventory));
|
||||
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft);
|
||||
} else
|
||||
// pick up what was crafted...
|
||||
{
|
||||
ia = new AdaptorItemHandler(new WrapperCursorItemHandler(who.inventory));
|
||||
maxTimesToCraft = 1;
|
||||
}
|
||||
|
||||
InventoryAdaptor ia = null;
|
||||
if( action == InventoryAction.CRAFT_SHIFT ) // craft into player inventory...
|
||||
{
|
||||
ia = InventoryAdaptor.getAdaptor( who );
|
||||
maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft );
|
||||
}
|
||||
else if( action == InventoryAction.CRAFT_STACK ) // craft into hand, full stack
|
||||
{
|
||||
ia = new AdaptorItemHandler( new WrapperCursorItemHandler( who.inventory ) );
|
||||
maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft );
|
||||
}
|
||||
else
|
||||
// pick up what was crafted...
|
||||
{
|
||||
ia = new AdaptorItemHandler( new WrapperCursorItemHandler( who.inventory ) );
|
||||
maxTimesToCraft = 1;
|
||||
}
|
||||
maxTimesToCraft = this.capCraftingAttempts(maxTimesToCraft);
|
||||
|
||||
maxTimesToCraft = this.capCraftingAttempts( maxTimesToCraft );
|
||||
if (ia == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ia == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final ItemStack rs = this.getStack().copy();
|
||||
if (rs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemStack rs = this.getStack().copy();
|
||||
if( rs.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int x = 0; x < maxTimesToCraft; x++) {
|
||||
if (ia.simulateAdd(rs).isEmpty()) {
|
||||
final IItemList<IAEItemStack> all = inv.getStorageList();
|
||||
final ItemStack extra = ia.addItems(this.craftItem(who, rs, inv, all));
|
||||
if (!extra.isEmpty()) {
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
drops.add(extra);
|
||||
Platform.spawnDrops(who.world,
|
||||
new BlockPos((int) who.getPosX(), (int) who.getPosY(), (int) who.getPosZ()), drops);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( int x = 0; x < maxTimesToCraft; x++ )
|
||||
{
|
||||
if( ia.simulateAdd( rs ).isEmpty() )
|
||||
{
|
||||
final IItemList<IAEItemStack> all = inv.getStorageList();
|
||||
final ItemStack extra = ia.addItems( this.craftItem( who, rs, inv, all ) );
|
||||
if( !extra.isEmpty() )
|
||||
{
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
drops.add( extra );
|
||||
Platform.spawnDrops( who.world, new BlockPos( (int) who.getPosX(), (int) who.getPosY(), (int) who.getPosZ() ), drops );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui
|
||||
// refactoring.
|
||||
protected IRecipe<CraftingInventory> findRecipe(CraftingInventory ic, World world) {
|
||||
if (this.container instanceof ContainerCraftingTerm) {
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
protected IRecipe<CraftingInventory> findRecipe( CraftingInventory ic, World world )
|
||||
{
|
||||
if( this.container instanceof ContainerCraftingTerm )
|
||||
{
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
|
||||
if (recipe != null && recipe.matches(ic, world)) {
|
||||
return containerTerminal.getCurrentRecipe();
|
||||
}
|
||||
}
|
||||
|
||||
if( recipe != null && recipe.matches( ic, world ) )
|
||||
{
|
||||
return containerTerminal.getCurrentRecipe();
|
||||
}
|
||||
}
|
||||
return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null);
|
||||
}
|
||||
|
||||
return world.getRecipeManager().getRecipe( IRecipeType.CRAFTING, ic, world ).orElse(null);
|
||||
}
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui
|
||||
// refactoring.
|
||||
@Override
|
||||
protected NonNullList<ItemStack> getRemainingItems(CraftingInventory ic, World world) {
|
||||
if (this.container instanceof ContainerCraftingTerm) {
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
@Override
|
||||
protected NonNullList<ItemStack> getRemainingItems( CraftingInventory ic, World world )
|
||||
{
|
||||
if( this.container instanceof ContainerCraftingTerm )
|
||||
{
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
|
||||
if (recipe != null && recipe.matches(ic, world)) {
|
||||
return containerTerminal.getCurrentRecipe().getRemainingItems(ic);
|
||||
}
|
||||
}
|
||||
|
||||
if( recipe != null && recipe.matches( ic, world ) )
|
||||
{
|
||||
return containerTerminal.getCurrentRecipe().getRemainingItems( ic );
|
||||
}
|
||||
}
|
||||
return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).map(r -> r.getRemainingItems(ic))
|
||||
.orElse(NonNullList.create());
|
||||
}
|
||||
|
||||
return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world)
|
||||
.map(r -> r.getRemainingItems(ic))
|
||||
.orElse(NonNullList.create());
|
||||
}
|
||||
private int capCraftingAttempts(final int maxTimesToCraft) {
|
||||
return maxTimesToCraft;
|
||||
}
|
||||
|
||||
private int capCraftingAttempts( final int maxTimesToCraft )
|
||||
{
|
||||
return maxTimesToCraft;
|
||||
}
|
||||
private ItemStack craftItem(final PlayerEntity p, final ItemStack request, final IMEMonitor<IAEItemStack> inv,
|
||||
final IItemList all) {
|
||||
// update crafting matrix...
|
||||
ItemStack is = this.getStack();
|
||||
|
||||
private ItemStack craftItem( final PlayerEntity p, final ItemStack request, final IMEMonitor<IAEItemStack> inv, final IItemList all )
|
||||
{
|
||||
// update crafting matrix...
|
||||
ItemStack is = this.getStack();
|
||||
if (!is.isEmpty() && ItemStack.areItemsEqual(request, is)) {
|
||||
final ItemStack[] set = new ItemStack[this.getPattern().getSlots()];
|
||||
// Safeguard for empty slots in the inventory for now
|
||||
Arrays.fill(set, ItemStack.EMPTY);
|
||||
|
||||
if( !is.isEmpty() && ItemStack.areItemsEqual( request, is ) )
|
||||
{
|
||||
final ItemStack[] set = new ItemStack[this.getPattern().getSlots()];
|
||||
// Safeguard for empty slots in the inventory for now
|
||||
Arrays.fill( set, ItemStack.EMPTY );
|
||||
// add one of each item to the items on the board...
|
||||
if (Platform.isServer()) {
|
||||
final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3);
|
||||
for (int x = 0; x < 9; x++) {
|
||||
ic.setInventorySlotContents(x, this.getPattern().getStackInSlot(x));
|
||||
}
|
||||
|
||||
// add one of each item to the items on the board...
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
final CraftingInventory ic = new CraftingInventory( new ContainerNull(), 3, 3 );
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
ic.setInventorySlotContents( x, this.getPattern().getStackInSlot( x ) );
|
||||
}
|
||||
final IRecipe<CraftingInventory> r = this.findRecipe(ic, p.world);
|
||||
|
||||
final IRecipe<CraftingInventory> r = this.findRecipe( ic, p.world );
|
||||
if (r == null) {
|
||||
final Item target = request.getItem();
|
||||
if (target.isDamageable() && target.isRepairable(request)) {
|
||||
boolean isBad = false;
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++) {
|
||||
final ItemStack pis = ic.getStackInSlot(x);
|
||||
if (pis.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (pis.getItem() != target) {
|
||||
isBad = true;
|
||||
}
|
||||
}
|
||||
if (!isBad) {
|
||||
super.onTake(p, is);
|
||||
// actually necessary to cleanup this case...
|
||||
p.openContainer.onCraftMatrixChanged(new WrapperInvItemHandler(this.craftInv));
|
||||
return request;
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( r == null )
|
||||
{
|
||||
final Item target = request.getItem();
|
||||
if( target.isDamageable() && target.isRepairable(request) )
|
||||
{
|
||||
boolean isBad = false;
|
||||
for( int x = 0; x < ic.getSizeInventory(); x++ )
|
||||
{
|
||||
final ItemStack pis = ic.getStackInSlot( x );
|
||||
if( pis.isEmpty() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( pis.getItem() != target )
|
||||
{
|
||||
isBad = true;
|
||||
}
|
||||
}
|
||||
if( !isBad )
|
||||
{
|
||||
super.onTake( p, is );
|
||||
// actually necessary to cleanup this case...
|
||||
p.openContainer.onCraftMatrixChanged( new WrapperInvItemHandler( this.craftInv ) );
|
||||
return request;
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
is = r.getCraftingResult(ic);
|
||||
|
||||
is = r.getCraftingResult( ic );
|
||||
if (inv != null) {
|
||||
for (int x = 0; x < this.getPattern().getSlots(); x++) {
|
||||
if (!this.getPattern().getStackInSlot(x).isEmpty()) {
|
||||
set[x] = Platform.extractItemsByRecipe(this.energySrc, this.mySrc, inv, p.world, r, is, ic,
|
||||
this.getPattern().getStackInSlot(x), x, all, Actionable.MODULATE,
|
||||
ItemViewCell.createFilter(this.container.getViewCells()));
|
||||
ic.setInventorySlotContents(x, set[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( inv != null )
|
||||
{
|
||||
for( int x = 0; x < this.getPattern().getSlots(); x++ )
|
||||
{
|
||||
if( !this.getPattern().getStackInSlot( x ).isEmpty() )
|
||||
{
|
||||
set[x] = Platform.extractItemsByRecipe( this.energySrc, this.mySrc, inv, p.world, r, is, ic, this.getPattern().getStackInSlot( x ),
|
||||
x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.container.getViewCells() ) );
|
||||
ic.setInventorySlotContents( x, set[x] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.preCraft(p, inv, set, is)) {
|
||||
this.makeItem(p, is);
|
||||
|
||||
if( this.preCraft( p, inv, set, is ) )
|
||||
{
|
||||
this.makeItem( p, is );
|
||||
this.postCraft(p, inv, set, is);
|
||||
}
|
||||
|
||||
this.postCraft( p, inv, set, is );
|
||||
}
|
||||
p.openContainer.onCraftMatrixChanged(new WrapperInvItemHandler(this.craftInv));
|
||||
|
||||
p.openContainer.onCraftMatrixChanged( new WrapperInvItemHandler( this.craftInv ) );
|
||||
return is;
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
private boolean preCraft(final PlayerEntity p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set,
|
||||
final ItemStack result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean preCraft( final PlayerEntity p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set, final ItemStack result )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
private void makeItem(final PlayerEntity p, final ItemStack is) {
|
||||
super.onTake(p, is);
|
||||
}
|
||||
|
||||
private void makeItem( final PlayerEntity p, final ItemStack is )
|
||||
{
|
||||
super.onTake( p, is );
|
||||
}
|
||||
private void postCraft(final PlayerEntity p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set,
|
||||
final ItemStack result) {
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
|
||||
private void postCraft( final PlayerEntity p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set, final ItemStack result )
|
||||
{
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
// add one of each item to the items on the board...
|
||||
if (Platform.isServer()) {
|
||||
// set new items onto the crafting table...
|
||||
for (int x = 0; x < this.craftInv.getSlots(); x++) {
|
||||
if (this.craftInv.getStackInSlot(x).isEmpty()) {
|
||||
ItemHandlerUtil.setStackInSlot(this.craftInv, x, set[x]);
|
||||
} else if (!set[x].isEmpty()) {
|
||||
// eek! put it back!
|
||||
final IAEItemStack fail = inv.injectItems(AEItemStack.fromItemStack(set[x]), Actionable.MODULATE,
|
||||
this.mySrc);
|
||||
if (fail != null) {
|
||||
drops.add(fail.createItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add one of each item to the items on the board...
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// set new items onto the crafting table...
|
||||
for( int x = 0; x < this.craftInv.getSlots(); x++ )
|
||||
{
|
||||
if( this.craftInv.getStackInSlot( x ).isEmpty() )
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( this.craftInv, x, set[x] );
|
||||
}
|
||||
else if( !set[x].isEmpty() )
|
||||
{
|
||||
// eek! put it back!
|
||||
final IAEItemStack fail = inv.injectItems( AEItemStack.fromItemStack( set[x] ), Actionable.MODULATE, this.mySrc );
|
||||
if( fail != null )
|
||||
{
|
||||
drops.add( fail.createItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (drops.size() > 0) {
|
||||
Platform.spawnDrops(p.world, new BlockPos((int) p.getPosX(), (int) p.getPosY(), (int) p.getPosZ()), drops);
|
||||
}
|
||||
}
|
||||
|
||||
if( drops.size() > 0 )
|
||||
{
|
||||
Platform.spawnDrops( p.world, new BlockPos( (int) p.getPosX(), (int) p.getPosY(), (int) p.getPosZ() ), drops );
|
||||
}
|
||||
}
|
||||
|
||||
IItemHandler getPattern()
|
||||
{
|
||||
return this.pattern;
|
||||
}
|
||||
IItemHandler getPattern() {
|
||||
return this.pattern;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,29 +18,23 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotDisabled extends AppEngSlot {
|
||||
|
||||
public class SlotDisabled extends AppEngSlot
|
||||
{
|
||||
public SlotDisabled(final IItemHandler par1iInventory, final int slotIndex, final int x, final int y) {
|
||||
super(par1iInventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
public SlotDisabled( final IItemHandler par1iInventory, final int slotIndex, final int x, final int y )
|
||||
{
|
||||
super( par1iInventory, slotIndex, x, y );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,52 +18,42 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotFake extends AppEngSlot {
|
||||
|
||||
public class SlotFake extends AppEngSlot
|
||||
{
|
||||
public SlotFake(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
public SlotFake( final IItemHandler inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
@Override
|
||||
public ItemStack onTake(final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack) {
|
||||
return par2ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onTake( final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack )
|
||||
{
|
||||
return par2ItemStack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void putStack(ItemStack is) {
|
||||
if (!is.isEmpty()) {
|
||||
is = is.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
is = is.copy();
|
||||
}
|
||||
super.putStack(is);
|
||||
}
|
||||
|
||||
super.putStack( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,37 +18,29 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotFakeBlacklist extends SlotFakeTypeOnly {
|
||||
|
||||
public class SlotFakeBlacklist extends SlotFakeTypeOnly
|
||||
{
|
||||
public SlotFakeBlacklist(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
public SlotFakeBlacklist( final IItemHandler inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
@Override
|
||||
public float getOpacityOfIcon() {
|
||||
return 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getOpacityOfIcon()
|
||||
{
|
||||
return 0.8f;
|
||||
}
|
||||
@Override
|
||||
public boolean renderIconWithItem() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderIconWithItem()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIcon()
|
||||
{
|
||||
if( this.getHasStack() )
|
||||
{
|
||||
return this.getStack().getCount() > 0 ? 16 + 14 : 14;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@Override
|
||||
public int getIcon() {
|
||||
if (this.getHasStack()) {
|
||||
return this.getStack().getCount() > 0 ? 16 + 14 : 14;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotFakeCraftingMatrix extends SlotFake {
|
||||
|
||||
public class SlotFakeCraftingMatrix extends SlotFake
|
||||
{
|
||||
|
||||
public SlotFakeCraftingMatrix( final IItemHandler inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
public SlotFakeCraftingMatrix(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,35 +18,26 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotFakeTypeOnly extends SlotFake {
|
||||
|
||||
public class SlotFakeTypeOnly extends SlotFake
|
||||
{
|
||||
public SlotFakeTypeOnly(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
public SlotFakeTypeOnly( final IItemHandler inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
@Override
|
||||
public void putStack(ItemStack is) {
|
||||
if (!is.isEmpty()) {
|
||||
is = is.copy();
|
||||
if (is.getCount() > 1) {
|
||||
is.setCount(1);
|
||||
} else if (is.getCount() < -1) {
|
||||
is.setCount(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
is = is.copy();
|
||||
if( is.getCount() > 1 )
|
||||
{
|
||||
is.setCount( 1 );
|
||||
}
|
||||
else if( is.getCount() < -1 )
|
||||
{
|
||||
is.setCount( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
super.putStack( is );
|
||||
}
|
||||
super.putStack(is);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,52 +18,42 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotInaccessible extends AppEngSlot {
|
||||
|
||||
public class SlotInaccessible extends AppEngSlot
|
||||
{
|
||||
private ItemStack dspStack = ItemStack.EMPTY;
|
||||
|
||||
private ItemStack dspStack = ItemStack.EMPTY;
|
||||
public SlotInaccessible(final IItemHandler i, final int slotIdx, final int x, final int y) {
|
||||
super(i, slotIdx, x, y);
|
||||
}
|
||||
|
||||
public SlotInaccessible( final IItemHandler i, final int slotIdx, final int x, final int y )
|
||||
{
|
||||
super( i, slotIdx, x, y );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack i )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
super.onSlotChanged();
|
||||
this.dspStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
super.onSlotChanged();
|
||||
this.dspStack = ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
if( this.dspStack.isEmpty() )
|
||||
{
|
||||
final ItemStack dsp = super.getDisplayStack();
|
||||
if( !dsp.isEmpty() )
|
||||
{
|
||||
this.dspStack = dsp.copy();
|
||||
}
|
||||
}
|
||||
return this.dspStack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
if (this.dspStack.isEmpty()) {
|
||||
final ItemStack dsp = super.getDisplayStack();
|
||||
if (!dsp.isEmpty()) {
|
||||
this.dspStack = dsp.copy();
|
||||
}
|
||||
}
|
||||
return this.dspStack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotInaccessibleHD extends SlotInaccessible {
|
||||
|
||||
public class SlotInaccessibleHD extends SlotInaccessible
|
||||
{
|
||||
|
||||
public SlotInaccessibleHD( final IItemHandler i, final int slotIdx, final int x, final int y )
|
||||
{
|
||||
super( i, slotIdx, x, y );
|
||||
}
|
||||
public SlotInaccessibleHD(final IItemHandler i, final int slotIdx, final int x, final int y) {
|
||||
super(i, slotIdx, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,27 +18,22 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.container.implementations.ContainerMAC;
|
||||
|
||||
public class SlotMACPattern extends AppEngSlot {
|
||||
|
||||
public class SlotMACPattern extends AppEngSlot
|
||||
{
|
||||
private final ContainerMAC mac;
|
||||
|
||||
private final ContainerMAC mac;
|
||||
public SlotMACPattern(final ContainerMAC mac, final IItemHandler i, final int slotIdx, final int x, final int y) {
|
||||
super(i, slotIdx, x, y);
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public SlotMACPattern( final ContainerMAC mac, final IItemHandler i, final int slotIdx, final int x, final int y )
|
||||
{
|
||||
super( i, slotIdx, x, y );
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack i )
|
||||
{
|
||||
return this.mac.isValidItemForSlot( this.getSlotIndex(), i );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
return this.mac.isValidItemForSlot(this.getSlotIndex(), i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotNormal extends AppEngSlot {
|
||||
|
||||
public class SlotNormal extends AppEngSlot
|
||||
{
|
||||
|
||||
public SlotNormal( final IItemHandler inv, final int slot, final int xPos, final int yPos )
|
||||
{
|
||||
super( inv, slot, xPos, yPos );
|
||||
}
|
||||
public SlotNormal(final IItemHandler inv, final int slot, final int xPos, final int yPos) {
|
||||
super(inv, slot, xPos, yPos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,23 +18,18 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotOutput extends AppEngSlot {
|
||||
|
||||
public class SlotOutput extends AppEngSlot
|
||||
{
|
||||
public SlotOutput(final IItemHandler a, final int b, final int c, final int d, final int i) {
|
||||
super(a, b, c, d);
|
||||
this.setIIcon(i);
|
||||
}
|
||||
|
||||
public SlotOutput( final IItemHandler a, final int b, final int c, final int d, final int i )
|
||||
{
|
||||
super( a, b, c, d );
|
||||
this.setIIcon( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack i )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,27 +18,22 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotPatternOutputs extends OptionalSlotFake {
|
||||
|
||||
public class SlotPatternOutputs extends OptionalSlotFake
|
||||
{
|
||||
public SlotPatternOutputs(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x,
|
||||
final int y, final int offX, final int offY, final int groupNum) {
|
||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
||||
}
|
||||
|
||||
public SlotPatternOutputs( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
|
||||
{
|
||||
super( inv, containerBus, idx, x, y, offX, offY, groupNum );
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDisplay()
|
||||
{
|
||||
return super.isSlotEnabled();
|
||||
}
|
||||
@Override
|
||||
public boolean shouldDisplay() {
|
||||
return super.isSlotEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -34,49 +33,44 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
|
||||
public class SlotPatternTerm extends SlotCraftingTerm {
|
||||
|
||||
public class SlotPatternTerm extends SlotCraftingTerm
|
||||
{
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
public SlotPatternTerm(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc,
|
||||
final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix,
|
||||
final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber,
|
||||
final IContainerCraftingPacket c) {
|
||||
super(player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c);
|
||||
|
||||
public SlotPatternTerm( final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, final IContainerCraftingPacket c )
|
||||
{
|
||||
super( player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c );
|
||||
this.host = h;
|
||||
this.groupNum = groupNumber;
|
||||
}
|
||||
|
||||
this.host = h;
|
||||
this.groupNum = groupNumber;
|
||||
}
|
||||
public AppEngPacket getRequest(final boolean shift) {
|
||||
return new PacketPatternSlot(this.getPattern(),
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(this.getStack()),
|
||||
shift);
|
||||
}
|
||||
|
||||
public AppEngPacket getRequest( final boolean shift )
|
||||
{
|
||||
return new PacketPatternSlot( this
|
||||
.getPattern(), AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( this.getStack() ), shift );
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
if (!this.isSlotEnabled()) {
|
||||
if (!this.getDisplayStack().isEmpty()) {
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( !this.isSlotEnabled() )
|
||||
{
|
||||
if( !this.getDisplayStack().isEmpty() )
|
||||
{
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
return super.getStack();
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.host == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,12 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotPlayerHotBar extends AppEngSlot {
|
||||
|
||||
public class SlotPlayerHotBar extends AppEngSlot
|
||||
{
|
||||
|
||||
public SlotPlayerHotBar( final IItemHandler par1iInventory, final int par2, final int par3, final int par4 )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
this.setPlayerSide( true );
|
||||
}
|
||||
public SlotPlayerHotBar(final IItemHandler par1iInventory, final int par2, final int par3, final int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.setPlayerSide(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,19 +18,15 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
|
||||
// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
|
||||
|
||||
public class SlotPlayerInv extends AppEngSlot
|
||||
{
|
||||
public class SlotPlayerInv extends AppEngSlot {
|
||||
|
||||
public SlotPlayerInv( final IItemHandler par1iInventory, final int idx, final int x, final int y )
|
||||
{
|
||||
super( par1iInventory, idx, x, y );
|
||||
public SlotPlayerInv(final IItemHandler par1iInventory, final int idx, final int x, final int y) {
|
||||
super(par1iInventory, idx, x, y);
|
||||
|
||||
this.setPlayerSide( true );
|
||||
}
|
||||
this.setPlayerSide(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.recipes.handlers.GrinderRecipes;
|
||||
import appeng.tile.misc.InscriberRecipes;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -43,281 +39,243 @@ import appeng.api.implementations.items.IStorageComponent;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.recipes.handlers.GrinderRecipes;
|
||||
import appeng.tile.misc.InscriberRecipes;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv0
|
||||
*/
|
||||
public class SlotRestrictedInput extends AppEngSlot
|
||||
{
|
||||
public class SlotRestrictedInput extends AppEngSlot {
|
||||
|
||||
private final PlacableItemType which;
|
||||
private final PlayerInventory p;
|
||||
private boolean allowEdit = true;
|
||||
private int stackLimit = -1;
|
||||
private final PlacableItemType which;
|
||||
private final PlayerInventory p;
|
||||
private boolean allowEdit = true;
|
||||
private int stackLimit = -1;
|
||||
|
||||
public SlotRestrictedInput( final PlacableItemType valid, final IItemHandler i, final int slotIndex, final int x, final int y, final PlayerInventory p )
|
||||
{
|
||||
super( i, slotIndex, x, y );
|
||||
this.which = valid;
|
||||
this.setIIcon( valid.IIcon );
|
||||
this.p = p;
|
||||
}
|
||||
public SlotRestrictedInput(final PlacableItemType valid, final IItemHandler i, final int slotIndex, final int x,
|
||||
final int y, final PlayerInventory p) {
|
||||
super(i, slotIndex, x, y);
|
||||
this.which = valid;
|
||||
this.setIIcon(valid.IIcon);
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
if( this.stackLimit != -1 )
|
||||
{
|
||||
return this.stackLimit;
|
||||
}
|
||||
return super.getSlotStackLimit();
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
if (this.stackLimit != -1) {
|
||||
return this.stackLimit;
|
||||
}
|
||||
return super.getSlotStackLimit();
|
||||
}
|
||||
|
||||
public boolean isValid( final ItemStack is, final World theWorld )
|
||||
{
|
||||
if( this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT )
|
||||
{
|
||||
final ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem ? ( (ICraftingPatternItem) is.getItem() ).getPatternForItem( is,
|
||||
theWorld ) : null;
|
||||
return ap != null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean isValid(final ItemStack is, final World theWorld) {
|
||||
if (this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT) {
|
||||
final ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem
|
||||
? ((ICraftingPatternItem) is.getItem()).getPatternForItem(is, theWorld)
|
||||
: null;
|
||||
return ap != null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Slot setStackLimit(final int i )
|
||||
{
|
||||
this.stackLimit = i;
|
||||
return this;
|
||||
}
|
||||
public Slot setStackLimit(final int i) {
|
||||
this.stackLimit = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack i )
|
||||
{
|
||||
if( !this.getContainer().isValidForSlot( this, i ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
if (!this.getContainer().isValidForSlot(this, i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( i.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (i.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( i.getItem() == Items.AIR )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (i.getItem() == Items.AIR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !super.isItemValid( i ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!super.isItemValid(i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !this.isAllowEdit() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!this.isAllowEdit()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IMaterials materials = definitions.materials();
|
||||
final IItems items = definitions.items();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IMaterials materials = definitions.materials();
|
||||
final IItems items = definitions.items();
|
||||
|
||||
switch( this.which )
|
||||
{
|
||||
case ENCODED_CRAFTING_PATTERN:
|
||||
if( i.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
final ICraftingPatternItem b = (ICraftingPatternItem) i.getItem();
|
||||
final ICraftingPatternDetails de = b.getPatternForItem( i, this.p.player.world );
|
||||
if( de != null )
|
||||
{
|
||||
return de.isCraftable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
case VALID_ENCODED_PATTERN_W_OUTPUT:
|
||||
case ENCODED_PATTERN_W_OUTPUT:
|
||||
case ENCODED_PATTERN:
|
||||
{
|
||||
if( i.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ?
|
||||
// ((ICraftingPatternItem)
|
||||
// i.getItem()).getPatternForItem( i ) : null;
|
||||
return false;// pattern != null;
|
||||
}
|
||||
case BLANK_PATTERN:
|
||||
return materials.blankPattern().isSameAs( i );
|
||||
switch (this.which) {
|
||||
case ENCODED_CRAFTING_PATTERN:
|
||||
if (i.getItem() instanceof ICraftingPatternItem) {
|
||||
final ICraftingPatternItem b = (ICraftingPatternItem) i.getItem();
|
||||
final ICraftingPatternDetails de = b.getPatternForItem(i, this.p.player.world);
|
||||
if (de != null) {
|
||||
return de.isCraftable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
case VALID_ENCODED_PATTERN_W_OUTPUT:
|
||||
case ENCODED_PATTERN_W_OUTPUT:
|
||||
case ENCODED_PATTERN: {
|
||||
if (i.getItem() instanceof ICraftingPatternItem) {
|
||||
return true;
|
||||
}
|
||||
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem
|
||||
// ?
|
||||
// ((ICraftingPatternItem)
|
||||
// i.getItem()).getPatternForItem( i ) : null;
|
||||
return false;// pattern != null;
|
||||
}
|
||||
case BLANK_PATTERN:
|
||||
return materials.blankPattern().isSameAs(i);
|
||||
|
||||
case PATTERN:
|
||||
case PATTERN:
|
||||
|
||||
if( i.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (i.getItem() instanceof ICraftingPatternItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return materials.blankPattern().isSameAs( i );
|
||||
return materials.blankPattern().isSameAs(i);
|
||||
|
||||
case INSCRIBER_PLATE:
|
||||
if( materials.namePress().isSameAs( i ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
case INSCRIBER_PLATE:
|
||||
if (materials.namePress().isSameAs(i)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return InscriberRecipes.isValidOptionalIngredient(p.player.world, i);
|
||||
return InscriberRecipes.isValidOptionalIngredient(p.player.world, i);
|
||||
|
||||
case INSCRIBER_INPUT:
|
||||
return true;/*
|
||||
* for (ItemStack is : Inscribe.inputs) if ( Platform.isSameItemPrecise( is, i ) ) return
|
||||
* true;
|
||||
* return false;
|
||||
*/
|
||||
case INSCRIBER_INPUT:
|
||||
return true;/*
|
||||
* for (ItemStack is : Inscribe.inputs) if ( Platform.isSameItemPrecise( is, i )
|
||||
* ) return true; return false;
|
||||
*/
|
||||
|
||||
case METAL_INGOTS:
|
||||
case METAL_INGOTS:
|
||||
|
||||
return isMetalIngot( i );
|
||||
return isMetalIngot(i);
|
||||
|
||||
case VIEW_CELL:
|
||||
return items.viewCell().isSameAs( i );
|
||||
case ORE:
|
||||
return GrinderRecipes.isValidIngredient(p.player.world, i);
|
||||
case FUEL:
|
||||
return ForgeHooks.getBurnTime( i ) > 0;
|
||||
case POWERED_TOOL:
|
||||
return Platform.isChargeable( i );
|
||||
case QE_SINGULARITY:
|
||||
return materials.qESingularity().isSameAs( i );
|
||||
case VIEW_CELL:
|
||||
return items.viewCell().isSameAs(i);
|
||||
case ORE:
|
||||
return GrinderRecipes.isValidIngredient(p.player.world, i);
|
||||
case FUEL:
|
||||
return ForgeHooks.getBurnTime(i) > 0;
|
||||
case POWERED_TOOL:
|
||||
return Platform.isChargeable(i);
|
||||
case QE_SINGULARITY:
|
||||
return materials.qESingularity().isSameAs(i);
|
||||
|
||||
case RANGE_BOOSTER:
|
||||
return materials.wirelessBooster().isSameAs( i );
|
||||
case RANGE_BOOSTER:
|
||||
return materials.wirelessBooster().isSameAs(i);
|
||||
|
||||
case SPATIAL_STORAGE_CELLS:
|
||||
return i.getItem() instanceof ISpatialStorageCell && ( (ISpatialStorageCell) i.getItem() ).isSpatialStorage( i );
|
||||
case STORAGE_CELLS:
|
||||
return AEApi.instance().registries().cell().isCellHandled( i );
|
||||
case WORKBENCH_CELL:
|
||||
return i.getItem() instanceof ICellWorkbenchItem && ( (ICellWorkbenchItem) i.getItem() ).isEditable( i );
|
||||
case STORAGE_COMPONENT:
|
||||
return i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i );
|
||||
case TRASH:
|
||||
if( AEApi.instance().registries().cell().isCellHandled( i ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
case SPATIAL_STORAGE_CELLS:
|
||||
return i.getItem() instanceof ISpatialStorageCell
|
||||
&& ((ISpatialStorageCell) i.getItem()).isSpatialStorage(i);
|
||||
case STORAGE_CELLS:
|
||||
return AEApi.instance().registries().cell().isCellHandled(i);
|
||||
case WORKBENCH_CELL:
|
||||
return i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable(i);
|
||||
case STORAGE_COMPONENT:
|
||||
return i.getItem() instanceof IStorageComponent
|
||||
&& ((IStorageComponent) i.getItem()).isStorageComponent(i);
|
||||
case TRASH:
|
||||
if (AEApi.instance().registries().cell().isCellHandled(i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !( i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i ) );
|
||||
case ENCODABLE_ITEM:
|
||||
return i.getItem() instanceof INetworkEncodable || AEApi.instance().registries().wireless().isWirelessTerminal( i );
|
||||
case BIOMETRIC_CARD:
|
||||
return i.getItem() instanceof IBiometricCard;
|
||||
case UPGRADES:
|
||||
return i.getItem() instanceof IUpgradeModule && ( (IUpgradeModule) i.getItem() ).getType( i ) != null;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return !(i.getItem() instanceof IStorageComponent
|
||||
&& ((IStorageComponent) i.getItem()).isStorageComponent(i));
|
||||
case ENCODABLE_ITEM:
|
||||
return i.getItem() instanceof INetworkEncodable
|
||||
|| AEApi.instance().registries().wireless().isWirelessTerminal(i);
|
||||
case BIOMETRIC_CARD:
|
||||
return i.getItem() instanceof IBiometricCard;
|
||||
case UPGRADES:
|
||||
return i.getItem() instanceof IUpgradeModule && ((IUpgradeModule) i.getItem()).getType(i) != null;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return this.isAllowEdit();
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return this.isAllowEdit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
if( Platform.isClient() && ( this.which == PlacableItemType.ENCODED_PATTERN ) )
|
||||
{
|
||||
final ItemStack is = super.getStack();
|
||||
if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern)
|
||||
{
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
final ItemStack out = iep.getOutput( is );
|
||||
if( !out.isEmpty() )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
if (Platform.isClient() && (this.which == PlacableItemType.ENCODED_PATTERN)) {
|
||||
final ItemStack is = super.getStack();
|
||||
if (!is.isEmpty() && is.getItem() instanceof ItemEncodedPattern) {
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
final ItemStack out = iep.getOutput(is);
|
||||
if (!out.isEmpty()) {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
public static boolean isMetalIngot( final ItemStack i )
|
||||
{
|
||||
if( Platform.itemComparisons().isSameItem( i, new ItemStack( Items.IRON_INGOT ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public static boolean isMetalIngot(final ItemStack i) {
|
||||
if (Platform.itemComparisons().isSameItem(i, new ItemStack(Items.IRON_INGOT))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for( final String name : new String[] { "Copper", "Tin", "Obsidian", "Iron", "Lead", "Bronze", "Brass", "Nickel", "Aluminium" } )
|
||||
{
|
||||
// FIXME for( final ItemStack ingot : OreDictionary.getOres( "ingot" + name ) )
|
||||
// FIXME {
|
||||
// FIXME if( Platform.itemComparisons().isSameItem( i, ingot ) )
|
||||
// FIXME {
|
||||
// FIXME return true;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
}
|
||||
for (final String name : new String[] { "Copper", "Tin", "Obsidian", "Iron", "Lead", "Bronze", "Brass",
|
||||
"Nickel", "Aluminium" }) {
|
||||
// FIXME for( final ItemStack ingot : OreDictionary.getOres( "ingot" + name ) )
|
||||
// FIXME {
|
||||
// FIXME if( Platform.itemComparisons().isSameItem( i, ingot ) )
|
||||
// FIXME {
|
||||
// FIXME return true;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isAllowEdit()
|
||||
{
|
||||
return this.allowEdit;
|
||||
}
|
||||
private boolean isAllowEdit() {
|
||||
return this.allowEdit;
|
||||
}
|
||||
|
||||
public void setAllowEdit( final boolean allowEdit )
|
||||
{
|
||||
this.allowEdit = allowEdit;
|
||||
}
|
||||
public void setAllowEdit(final boolean allowEdit) {
|
||||
this.allowEdit = allowEdit;
|
||||
}
|
||||
|
||||
public enum PlacableItemType
|
||||
{
|
||||
STORAGE_CELLS( 15 ),
|
||||
ORE( 16 + 15 ),
|
||||
STORAGE_COMPONENT( 3 * 16 + 15 ),
|
||||
public enum PlacableItemType {
|
||||
STORAGE_CELLS(15), ORE(16 + 15), STORAGE_COMPONENT(3 * 16 + 15),
|
||||
|
||||
ENCODABLE_ITEM( 4 * 16 + 15 ),
|
||||
TRASH( 5 * 16 + 15 ),
|
||||
VALID_ENCODED_PATTERN_W_OUTPUT( 7 * 16 + 15 ),
|
||||
ENCODED_PATTERN_W_OUTPUT( 7 * 16 + 15 ),
|
||||
ENCODABLE_ITEM(4 * 16 + 15), TRASH(5 * 16 + 15), VALID_ENCODED_PATTERN_W_OUTPUT(7 * 16 + 15),
|
||||
ENCODED_PATTERN_W_OUTPUT(7 * 16 + 15),
|
||||
|
||||
ENCODED_CRAFTING_PATTERN( 7 * 16 + 15 ),
|
||||
ENCODED_PATTERN( 7 * 16 + 15 ),
|
||||
PATTERN( 8 * 16 + 15 ),
|
||||
BLANK_PATTERN( 8 * 16 + 15 ),
|
||||
POWERED_TOOL( 9 * 16 + 15 ),
|
||||
ENCODED_CRAFTING_PATTERN(7 * 16 + 15), ENCODED_PATTERN(7 * 16 + 15), PATTERN(8 * 16 + 15),
|
||||
BLANK_PATTERN(8 * 16 + 15), POWERED_TOOL(9 * 16 + 15),
|
||||
|
||||
RANGE_BOOSTER( 6 * 16 + 15 ),
|
||||
QE_SINGULARITY( 10 * 16 + 15 ),
|
||||
SPATIAL_STORAGE_CELLS( 11 * 16 + 15 ),
|
||||
RANGE_BOOSTER(6 * 16 + 15), QE_SINGULARITY(10 * 16 + 15), SPATIAL_STORAGE_CELLS(11 * 16 + 15),
|
||||
|
||||
FUEL( 12 * 16 + 15 ),
|
||||
UPGRADES( 13 * 16 + 15 ),
|
||||
WORKBENCH_CELL( 15 ),
|
||||
BIOMETRIC_CARD( 14 * 16 + 15 ),
|
||||
VIEW_CELL( 4 * 16 + 14 ),
|
||||
FUEL(12 * 16 + 15), UPGRADES(13 * 16 + 15), WORKBENCH_CELL(15), BIOMETRIC_CARD(14 * 16 + 15),
|
||||
VIEW_CELL(4 * 16 + 14),
|
||||
|
||||
INSCRIBER_PLATE( 2 * 16 + 14 ),
|
||||
INSCRIBER_INPUT( 3 * 16 + 14 ),
|
||||
METAL_INGOTS( 3 * 16 + 14 );
|
||||
INSCRIBER_PLATE(2 * 16 + 14), INSCRIBER_INPUT(3 * 16 + 14), METAL_INGOTS(3 * 16 + 14);
|
||||
|
||||
public final int IIcon;
|
||||
public final int IIcon;
|
||||
|
||||
PlacableItemType( final int o )
|
||||
{
|
||||
this.IIcon = o;
|
||||
}
|
||||
}
|
||||
PlacableItemType(final int o) {
|
||||
this.IIcon = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user