2014-01-05 09:44:31 +01:00
|
|
|
package appeng.parts.misc;
|
|
|
|
|
2014-05-09 06:10:12 +02:00
|
|
|
import java.util.EnumSet;
|
2014-04-28 06:50:50 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2014-01-05 09:44:31 +01:00
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.inventory.ISidedInventory;
|
2014-05-09 06:10:12 +02:00
|
|
|
import net.minecraft.inventory.InventoryCrafting;
|
2014-01-05 09:44:31 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-06-11 07:14:37 +02:00
|
|
|
import net.minecraft.util.IIcon;
|
2014-01-05 09:44:31 +01:00
|
|
|
import net.minecraft.util.Vec3;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-07-06 08:48:21 +02:00
|
|
|
import appeng.api.config.Actionable;
|
2014-07-05 03:59:50 +02:00
|
|
|
import appeng.api.config.Upgrades;
|
2014-01-23 20:02:48 +01:00
|
|
|
import appeng.api.implementations.tiles.ISegmentedInventory;
|
|
|
|
import appeng.api.implementations.tiles.ITileStorageMonitorable;
|
2014-01-05 09:44:31 +01:00
|
|
|
import appeng.api.networking.IGridNode;
|
2014-07-06 08:48:21 +02:00
|
|
|
import appeng.api.networking.crafting.ICraftingLink;
|
2014-05-09 06:10:12 +02:00
|
|
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
|
|
|
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
2014-06-23 07:08:38 +02:00
|
|
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
|
|
|
import appeng.api.networking.events.MENetworkEventSubscribe;
|
|
|
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
2014-04-18 05:33:48 +02:00
|
|
|
import appeng.api.networking.security.BaseActionSource;
|
2014-01-05 09:44:31 +01:00
|
|
|
import appeng.api.networking.ticking.IGridTickable;
|
|
|
|
import appeng.api.networking.ticking.TickRateModulation;
|
|
|
|
import appeng.api.networking.ticking.TickingRequest;
|
|
|
|
import appeng.api.parts.IPartCollsionHelper;
|
|
|
|
import appeng.api.parts.IPartRenderHelper;
|
|
|
|
import appeng.api.storage.IMEMonitor;
|
|
|
|
import appeng.api.storage.IStorageMonitorable;
|
|
|
|
import appeng.api.storage.data.IAEFluidStack;
|
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
2014-05-01 07:41:19 +02:00
|
|
|
import appeng.api.util.IConfigManager;
|
2014-01-05 09:44:31 +01:00
|
|
|
import appeng.client.texture.CableBusTextures;
|
|
|
|
import appeng.core.sync.GuiBridge;
|
|
|
|
import appeng.helpers.DualityInterface;
|
|
|
|
import appeng.helpers.IInterfaceHost;
|
2014-07-18 05:38:57 +02:00
|
|
|
import appeng.helpers.IPriorityHost;
|
2014-01-05 09:44:31 +01:00
|
|
|
import appeng.parts.PartBasicState;
|
|
|
|
import appeng.tile.inventory.IAEAppEngInventory;
|
|
|
|
import appeng.tile.inventory.InvOperation;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
import appeng.util.inv.IInventoryDestination;
|
2014-07-06 08:48:21 +02:00
|
|
|
|
|
|
|
import com.google.common.collect.ImmutableSet;
|
|
|
|
|
2014-02-07 06:51:19 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2014-01-05 09:44:31 +01:00
|
|
|
|
|
|
|
public class PartInterface extends PartBasicState implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IInterfaceHost,
|
2014-07-18 05:38:57 +02:00
|
|
|
ISidedInventory, IAEAppEngInventory, ITileStorageMonitorable, IPriorityHost
|
2014-01-05 09:44:31 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
DualityInterface duality = new DualityInterface( proxy, this );
|
|
|
|
|
|
|
|
public PartInterface(ItemStack is) {
|
|
|
|
super( PartInterface.class, is );
|
|
|
|
}
|
2014-07-18 05:38:57 +02:00
|
|
|
|
2014-07-15 19:02:26 +02:00
|
|
|
@Override
|
|
|
|
public void addToWorld()
|
|
|
|
{
|
|
|
|
super.addToWorld();
|
|
|
|
duality.initalize();
|
|
|
|
}
|
2014-07-18 05:38:57 +02:00
|
|
|
|
2014-06-23 07:08:38 +02:00
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void stateChange(MENetworkChannelsChanged c)
|
|
|
|
{
|
|
|
|
duality.notifyNeightbors();
|
|
|
|
}
|
|
|
|
|
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void stateChange(MENetworkPowerStatusChange c)
|
|
|
|
{
|
|
|
|
duality.notifyNeightbors();
|
|
|
|
}
|
|
|
|
|
2014-01-05 09:44:31 +01:00
|
|
|
@Override
|
|
|
|
public void gridChanged()
|
|
|
|
{
|
|
|
|
duality.gridChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeToNBT(NBTTagCompound data)
|
|
|
|
{
|
|
|
|
super.writeToNBT( data );
|
|
|
|
duality.writeToNBT( data );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void readFromNBT(NBTTagCompound data)
|
|
|
|
{
|
|
|
|
super.readFromNBT( data );
|
|
|
|
duality.readFromNBT( data );
|
|
|
|
}
|
|
|
|
|
2014-04-28 06:50:50 +02:00
|
|
|
@Override
|
|
|
|
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
|
|
|
{
|
2014-06-23 06:51:20 +02:00
|
|
|
duality.addDrops( drops );
|
2014-04-28 06:50:50 +02:00
|
|
|
}
|
|
|
|
|
2014-01-05 09:44:31 +01:00
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2014-01-05 09:44:31 +01:00
|
|
|
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
|
|
|
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
|
|
|
|
|
|
|
rh.setBounds( 3, 3, 15, 13, 13, 16 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
|
|
|
|
rh.setBounds( 2, 2, 14, 14, 14, 15 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
|
|
|
|
rh.setBounds( 5, 5, 12, 11, 11, 14 );
|
|
|
|
rh.renderInventoryBox( renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2014-01-05 09:44:31 +01:00
|
|
|
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
2014-02-15 07:30:06 +01:00
|
|
|
renderCache = rh.useSimpliedRendering( x, y, z, this, renderCache );
|
2014-01-05 09:44:31 +01:00
|
|
|
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
|
|
|
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
|
|
|
|
|
|
|
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
|
|
|
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
|
|
|
|
|
|
|
rh.setBounds( 5, 5, 12, 11, 11, 13 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
|
|
|
CableBusTextures.PartMonitorBack.getIcon(), is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
|
|
|
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
|
|
|
|
|
|
|
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
|
|
|
rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
renderLights( x, y, z, rh, renderer );
|
|
|
|
}
|
|
|
|
|
2014-06-11 07:14:37 +02:00
|
|
|
@Override
|
|
|
|
public IIcon getBreakingTexture()
|
|
|
|
{
|
|
|
|
return is.getIconIndex();
|
|
|
|
}
|
|
|
|
|
2014-01-05 09:44:31 +01:00
|
|
|
@Override
|
|
|
|
public void getBoxes(IPartCollsionHelper bch)
|
|
|
|
{
|
2014-04-11 05:54:28 +02:00
|
|
|
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
|
|
|
bch.addBox( 5, 5, 12, 11, 11, 14 );
|
2014-01-05 09:44:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int cableConnectionRenderTo()
|
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TileEntity getTileEntity()
|
|
|
|
{
|
|
|
|
return (TileEntity) super.getHost().getTile();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canInsert(ItemStack stack)
|
|
|
|
{
|
|
|
|
return duality.canInsert( stack );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IMEMonitor<IAEItemStack> getItemInventory()
|
|
|
|
{
|
|
|
|
return duality.getItemInventory();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IMEMonitor<IAEFluidStack> getFluidInventory()
|
|
|
|
{
|
|
|
|
return duality.getFluidInventory();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TickingRequest getTickingRequest(IGridNode node)
|
|
|
|
{
|
|
|
|
return duality.getTickingRequest( node );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
|
|
|
{
|
|
|
|
return duality.tickingRequest( node, TicksSinceLastCall );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getSizeInventory()
|
|
|
|
{
|
|
|
|
return duality.getStorage().getSizeInventory();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getStackInSlot(int i)
|
|
|
|
{
|
|
|
|
return duality.getStorage().getStackInSlot( i );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack decrStackSize(int i, int j)
|
|
|
|
{
|
|
|
|
return duality.getStorage().decrStackSize( i, j );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getStackInSlotOnClosing(int i)
|
|
|
|
{
|
|
|
|
return duality.getStorage().getStackInSlotOnClosing( i );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setInventorySlotContents(int i, ItemStack itemstack)
|
|
|
|
{
|
|
|
|
duality.getStorage().setInventorySlotContents( i, itemstack );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public String getInventoryName()
|
2014-01-05 09:44:31 +01:00
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
return duality.getStorage().getInventoryName();
|
2014-01-05 09:44:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public boolean hasCustomInventoryName()
|
2014-01-05 09:44:31 +01:00
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
return duality.getStorage().hasCustomInventoryName();
|
2014-01-05 09:44:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getInventoryStackLimit()
|
|
|
|
{
|
|
|
|
return duality.getStorage().getInventoryStackLimit();
|
|
|
|
}
|
|
|
|
|
2014-05-01 07:41:19 +02:00
|
|
|
@Override
|
|
|
|
public IConfigManager getConfigManager()
|
|
|
|
{
|
|
|
|
return duality.getConfigManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IInventory getInventoryByName(String name)
|
|
|
|
{
|
|
|
|
return duality.getInventoryByName( name );
|
|
|
|
}
|
|
|
|
|
2014-01-05 09:44:31 +01:00
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public void markDirty()
|
2014-01-05 09:44:31 +01:00
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
duality.getStorage().markDirty();
|
2014-01-05 09:44:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
|
|
|
{
|
|
|
|
return duality.getStorage().isUseableByPlayer( entityplayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public void openInventory()
|
2014-01-05 09:44:31 +01:00
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
duality.getStorage().openInventory();
|
2014-01-05 09:44:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public void closeInventory()
|
2014-01-05 09:44:31 +01:00
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
duality.getStorage().closeInventory();
|
2014-01-05 09:44:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
|
|
|
{
|
|
|
|
return duality.getStorage().isItemValidForSlot( i, itemstack );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int[] getAccessibleSlotsFromSide(int s)
|
|
|
|
{
|
|
|
|
return duality.getAccessibleSlotsFromSide( s );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canInsertItem(int i, ItemStack itemstack, int j)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canExtractItem(int i, ItemStack itemstack, int j)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
|
|
|
{
|
|
|
|
duality.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public DualityInterface getInterfaceDuality()
|
|
|
|
{
|
|
|
|
return duality;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-20 06:18:49 +01:00
|
|
|
public boolean onPartActivate(EntityPlayer p, Vec3 pos)
|
2014-01-05 09:44:31 +01:00
|
|
|
{
|
|
|
|
if ( p.isSneaking() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( Platform.isServer() )
|
|
|
|
Platform.openGUI( p, getTileEntity(), side, GuiBridge.GUI_INTERFACE );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-04-18 05:33:48 +02:00
|
|
|
public IStorageMonitorable getMonitorable(ForgeDirection side, BaseActionSource src)
|
2014-01-05 09:44:31 +01:00
|
|
|
{
|
2014-04-18 05:33:48 +02:00
|
|
|
return duality.getMonitorable( side, src, this );
|
2014-01-05 09:44:31 +01:00
|
|
|
}
|
2014-05-09 06:10:12 +02:00
|
|
|
|
|
|
|
@Override
|
2014-06-19 08:28:45 +02:00
|
|
|
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table)
|
2014-05-09 06:10:12 +02:00
|
|
|
{
|
2014-06-19 08:28:45 +02:00
|
|
|
return duality.pushPattern( patternDetails, table );
|
2014-05-09 06:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void provideCrafting(ICraftingProviderHelper craftingTracker)
|
|
|
|
{
|
|
|
|
duality.provideCrafting( craftingTracker );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EnumSet<ForgeDirection> getTargets()
|
|
|
|
{
|
|
|
|
return EnumSet.of( side );
|
|
|
|
}
|
|
|
|
|
2014-06-19 08:28:45 +02:00
|
|
|
@Override
|
|
|
|
public boolean isBusy()
|
|
|
|
{
|
|
|
|
return duality.isBusy();
|
|
|
|
}
|
|
|
|
|
2014-07-05 03:59:50 +02:00
|
|
|
@Override
|
|
|
|
public int getInstalledUpgrades(Upgrades u)
|
|
|
|
{
|
|
|
|
return duality.getInstalledUpgrades( u );
|
|
|
|
}
|
|
|
|
|
2014-07-06 08:48:21 +02:00
|
|
|
@Override
|
|
|
|
public ImmutableSet<ICraftingLink> getRequestedJobs()
|
|
|
|
{
|
|
|
|
return duality.getRequestedJobs();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IAEItemStack injectCratedItems(ICraftingLink link, IAEItemStack items, Actionable mode)
|
|
|
|
{
|
|
|
|
return duality.injectCratedItems( link, items, mode );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void jobStateChange(ICraftingLink link)
|
|
|
|
{
|
|
|
|
duality.jobStateChange( link );
|
|
|
|
}
|
|
|
|
|
2014-07-18 05:38:57 +02:00
|
|
|
@Override
|
|
|
|
public int getPriority()
|
|
|
|
{
|
|
|
|
return duality.getPriority();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setPriority(int newValue)
|
|
|
|
{
|
|
|
|
duality.setPriority( newValue );
|
|
|
|
}
|
|
|
|
|
2014-01-05 09:44:31 +01:00
|
|
|
}
|