2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* 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>.
|
|
|
|
*/
|
|
|
|
|
2014-09-17 06:26:25 +02:00
|
|
|
package appeng.container.implementations;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-09-17 06:26:25 +02:00
|
|
|
import appeng.api.AEApi;
|
2017-04-12 16:10:13 +02:00
|
|
|
import appeng.api.config.*;
|
2014-09-17 06:26:25 +02:00
|
|
|
import appeng.api.implementations.guiobjects.IPortableCell;
|
|
|
|
import appeng.api.implementations.tiles.IMEChest;
|
|
|
|
import appeng.api.implementations.tiles.IViewCellStorage;
|
|
|
|
import appeng.api.networking.IGrid;
|
|
|
|
import appeng.api.networking.IGridHost;
|
|
|
|
import appeng.api.networking.IGridNode;
|
|
|
|
import appeng.api.networking.energy.IEnergyGrid;
|
2015-05-09 00:00:52 +02:00
|
|
|
import appeng.api.networking.energy.IEnergySource;
|
2014-09-17 06:26:25 +02:00
|
|
|
import appeng.api.networking.security.BaseActionSource;
|
|
|
|
import appeng.api.networking.storage.IBaseMonitor;
|
|
|
|
import appeng.api.parts.IPart;
|
|
|
|
import appeng.api.storage.IMEMonitor;
|
|
|
|
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
|
|
|
import appeng.api.storage.ITerminalHost;
|
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
|
|
|
import appeng.api.storage.data.IItemList;
|
|
|
|
import appeng.api.util.IConfigManager;
|
2014-09-20 22:20:00 +02:00
|
|
|
import appeng.api.util.IConfigurableObject;
|
2014-09-17 06:26:25 +02:00
|
|
|
import appeng.container.AEBaseContainer;
|
|
|
|
import appeng.container.guisync.GuiSync;
|
|
|
|
import appeng.container.slot.SlotRestrictedInput;
|
|
|
|
import appeng.core.AELog;
|
|
|
|
import appeng.core.sync.network.NetworkHandler;
|
|
|
|
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
|
|
|
import appeng.core.sync.packets.PacketValueConfig;
|
|
|
|
import appeng.me.helpers.ChannelPowerSrc;
|
2021-03-28 18:20:02 +02:00
|
|
|
import appeng.tile.legacy.TileTerminal;
|
2014-09-17 06:26:25 +02:00
|
|
|
import appeng.util.ConfigManager;
|
|
|
|
import appeng.util.IConfigManagerHost;
|
|
|
|
import appeng.util.Platform;
|
2017-04-12 16:10:13 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
import net.minecraft.inventory.ICrafting;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.nio.BufferOverflowException;
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-09-20 22:20:00 +02:00
|
|
|
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack>
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
|
|
|
|
private final IMEMonitor<IAEItemStack> monitor;
|
|
|
|
private final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
|
|
|
|
private final IConfigManager clientCM;
|
2015-04-03 08:54:31 +02:00
|
|
|
private final ITerminalHost host;
|
|
|
|
@GuiSync( 99 )
|
2014-09-17 06:26:25 +02:00
|
|
|
public boolean canAccessViewCells = false;
|
2015-04-03 08:54:31 +02:00
|
|
|
@GuiSync( 98 )
|
2014-09-17 06:26:25 +02:00
|
|
|
public boolean hasPower = false;
|
2015-10-08 15:42:42 +02:00
|
|
|
private IConfigManagerHost gui;
|
|
|
|
private IConfigManager serverCM;
|
2014-09-17 06:26:25 +02:00
|
|
|
private IGridNode networkNode;
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public ContainerMEMonitorable( final InventoryPlayer ip, final ITerminalHost monitorable )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
this( ip, monitorable, true );
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
protected ContainerMEMonitorable( final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory )
|
2015-04-03 08:54:31 +02:00
|
|
|
{
|
2014-09-21 01:06:22 +02:00
|
|
|
super( ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null );
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.host = monitorable;
|
|
|
|
this.clientCM = new ConfigManager( this );
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
|
|
|
this.clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
|
|
|
this.clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( Platform.isServer() )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.serverCM = monitorable.getConfigManager();
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.monitor = monitorable.getItemInventory();
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.monitor != null )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.monitor.addListener( this, null );
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setCellInventory( this.monitor );
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( monitorable instanceof IPortableCell )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setPowerSource( (IEnergySource) monitorable );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
else if( monitorable instanceof IMEChest )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setPowerSource( (IEnergySource) monitorable );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
else if( monitorable instanceof IGridHost )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final IGridNode node = ( (IGridHost) monitorable ).getGridNode( ForgeDirection.UNKNOWN );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( node != null )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.networkNode = node;
|
2015-09-25 23:10:56 +02:00
|
|
|
final IGrid g = node.getGrid();
|
2015-04-03 08:54:31 +02:00
|
|
|
if( g != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setPowerSource( new ChannelPowerSrc( this.networkNode, (IEnergySource) g.getCache( IEnergyGrid.class ) ) );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setValidContainer( false );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
else
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.monitor = null;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.canAccessViewCells = false;
|
2015-04-03 08:54:31 +02:00
|
|
|
if( monitorable instanceof IViewCellStorage )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int y = 0; y < 5; y++ )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.cellView[y] = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.VIEW_CELL, ( (IViewCellStorage) monitorable ).getViewCellStorage(), y, 206, y * 18 + 8, this.getInventoryPlayer() );
|
|
|
|
this.cellView[y].setAllowEdit( this.canAccessViewCells );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.addSlotToContainer( this.cellView[y] );
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( bindInventory )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bindPlayerInventory( ip, 0, 0 );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public IGridNode getNetworkNode()
|
|
|
|
{
|
|
|
|
return this.networkNode;
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void detectAndSendChanges()
|
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( Platform.isServer() )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.monitor != this.host.getItemInventory() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setValidContainer( false );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-02-03 12:04:13 +01:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final Settings set : this.serverCM.getSettings() )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final Enum<?> sideLocal = this.serverCM.getSetting( set );
|
|
|
|
final Enum<?> sideRemote = this.clientCM.getSetting( set );
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( sideLocal != sideRemote )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.clientCM.putSetting( set, sideLocal );
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final Object crafter : this.crafters )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2014-09-29 09:23:02 +02:00
|
|
|
NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) crafter );
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
2015-09-25 23:10:56 +02:00
|
|
|
catch( final IOException e )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-11-22 15:54:29 +01:00
|
|
|
AELog.debug( e );
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !this.items.isEmpty() )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final IAEItemStack is : this.items )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final IAEItemStack send = monitorCache.findPrecise( is );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( send == null )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
|
|
|
is.setStackSize( 0 );
|
|
|
|
piu.appendItem( is );
|
|
|
|
}
|
|
|
|
else
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-17 06:26:25 +02:00
|
|
|
piu.appendItem( send );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !piu.isEmpty() )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.items.resetStatus();
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final Object c : this.crafters )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( c instanceof EntityPlayer )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-17 06:26:25 +02:00
|
|
|
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-25 23:10:56 +02:00
|
|
|
catch( final IOException e )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-11-22 15:54:29 +01:00
|
|
|
AELog.debug( e );
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.updatePowerStatus();
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
final boolean oldAccessible = this.canAccessViewCells;
|
2014-12-29 15:13:47 +01:00
|
|
|
this.canAccessViewCells = this.hasAccess( SecurityPermissions.BUILD, false );
|
2015-05-08 23:34:24 +02:00
|
|
|
if( this.canAccessViewCells != oldAccessible )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int y = 0; y < 5; y++ )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.cellView[y] != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.cellView[y].setAllowEdit( this.canAccessViewCells );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
super.detectAndSendChanges();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void updatePowerStatus()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.networkNode != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setPowered( this.networkNode.isActive() );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-10-08 15:42:42 +02:00
|
|
|
else if( this.getPowerSource() instanceof IEnergyGrid )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setPowered( ( (IEnergyGrid) this.getPowerSource() ).isNetworkPowered() );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
else
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.setPowered( this.getPowerSource().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8 );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
2015-09-25 23:10:56 +02:00
|
|
|
catch( final Throwable t )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void onUpdate( final String field, final Object oldValue, final Object newValue )
|
2015-04-03 08:54:31 +02:00
|
|
|
{
|
|
|
|
if( field.equals( "canAccessViewCells" ) )
|
|
|
|
{
|
|
|
|
for( int y = 0; y < 5; y++ )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.cellView[y] != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.cellView[y].setAllowEdit( this.canAccessViewCells );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
super.onUpdate( field, oldValue, newValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void addCraftingToCrafters( final ICrafting c )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
|
|
|
super.addCraftingToCrafters( c );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.queueInventory( c );
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
private void queueInventory( final ICrafting c )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( Platform.isServer() && c instanceof EntityPlayer && this.monitor != null )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
2015-09-25 23:10:56 +02:00
|
|
|
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final IAEItemStack send : monitorCache )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
piu.appendItem( send );
|
|
|
|
}
|
2015-09-25 23:10:56 +02:00
|
|
|
catch( final BufferOverflowException boe )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
|
|
|
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
|
|
|
|
|
|
|
|
piu = new PacketMEInventoryUpdate();
|
|
|
|
piu.appendItem( send );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
|
|
|
|
}
|
2015-09-25 23:10:56 +02:00
|
|
|
catch( final IOException e )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-11-22 15:54:29 +01:00
|
|
|
AELog.debug( e );
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void removeCraftingFromCrafters( final ICrafting c )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
super.removeCraftingFromCrafters( c );
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.crafters.isEmpty() && this.monitor != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
this.monitor.removeListener( this );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void onContainerClosed( final EntityPlayer player )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
|
|
|
super.onContainerClosed( player );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.monitor != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.monitor.removeListener( this );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public boolean isValid( final Object verificationToken )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
return true;
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final BaseActionSource source )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final IAEItemStack is : change )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.items.add( is );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public void onListUpdate()
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
for( final Object c : this.crafters )
|
2015-04-03 08:54:31 +02:00
|
|
|
{
|
|
|
|
if( c instanceof ICrafting )
|
|
|
|
{
|
2015-09-25 23:10:56 +02:00
|
|
|
final ICrafting cr = (ICrafting) c;
|
2015-04-03 08:54:31 +02:00
|
|
|
this.queueInventory( cr );
|
|
|
|
}
|
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
|
2014-09-17 06:26:25 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
if( this.getGui() != null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-10-08 15:42:42 +02:00
|
|
|
this.getGui().updateSetting( manager, settingName, newValue );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IConfigManager getConfigManager()
|
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( Platform.isServer() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.serverCM;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.clientCM;
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack[] getViewCells()
|
|
|
|
{
|
2021-03-28 18:20:02 +02:00
|
|
|
if (host instanceof TileTerminal) {
|
|
|
|
return new ItemStack[0];
|
|
|
|
}
|
2015-09-25 23:10:56 +02:00
|
|
|
final ItemStack[] list = new ItemStack[this.cellView.length];
|
2014-09-17 06:26:25 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int x = 0; x < this.cellView.length; x++ )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
list[x] = this.cellView[x].getStack();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
2015-10-08 15:42:42 +02:00
|
|
|
|
|
|
|
public SlotRestrictedInput getCellViewSlot( final int index )
|
|
|
|
{
|
|
|
|
return this.cellView[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isPowered()
|
|
|
|
{
|
|
|
|
return this.hasPower;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setPowered( final boolean isPowered )
|
|
|
|
{
|
|
|
|
this.hasPower = isPowered;
|
|
|
|
}
|
|
|
|
|
|
|
|
private IConfigManagerHost getGui()
|
|
|
|
{
|
|
|
|
return this.gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setGui( @Nonnull final IConfigManagerHost gui )
|
|
|
|
{
|
|
|
|
this.gui = gui;
|
|
|
|
}
|
2014-09-17 06:26:25 +02:00
|
|
|
}
|