Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class PartConversionMonitor extends PartStorageMonitor
|
||||
{
|
||||
|
||||
public PartConversionMonitor(ItemStack is) {
|
||||
super( PartConversionMonitor.class, is );
|
||||
frontBright = CableBusTextures.PartConvMonitor_Bright;
|
||||
frontColored = CableBusTextures.PartConvMonitor_Colored;
|
||||
frontDark = CableBusTextures.PartConvMonitor_Dark;
|
||||
// frontSolid = CableBusTextures.PartConvMonitor_Solid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartShiftActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
if ( !proxy.isActive() )
|
||||
return false;
|
||||
|
||||
if ( !Platform.hasPermissions( getLocation(), player ) )
|
||||
return false;
|
||||
|
||||
boolean ModeB = false;
|
||||
|
||||
ItemStack item = player.getCurrentEquippedItem();
|
||||
if ( item == null && getDisplayed() != null )
|
||||
{
|
||||
ModeB = true;
|
||||
item = ((IAEItemStack) getDisplayed()).getItemStack();
|
||||
}
|
||||
|
||||
if ( item != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !proxy.isActive() )
|
||||
return false;
|
||||
|
||||
IEnergySource energy = proxy.getEnergy();
|
||||
IMEMonitor<IAEItemStack> cell = proxy.getStorage().getItemInventory();
|
||||
IAEItemStack input = AEItemStack.create( item );
|
||||
|
||||
if ( ModeB )
|
||||
{
|
||||
for (int x = 0; x < player.inventory.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack targetStack = player.inventory.getStackInSlot( x );
|
||||
if ( input.equals( targetStack ) )
|
||||
{
|
||||
IAEItemStack insertItem = input.copy();
|
||||
insertItem.setStackSize( targetStack.stackSize );
|
||||
IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, insertItem, new PlayerSource( player, this ) );
|
||||
player.inventory.setInventorySlotContents( x, failedToInsert == null ? null : failedToInsert.getItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
|
||||
player.inventory.setInventorySlotContents( player.inventory.currentItem, failedToInsert == null ? null : failedToInsert.getItemStack() );
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void extractItem(EntityPlayer player)
|
||||
{
|
||||
IAEItemStack input = (IAEItemStack) getDisplayed();
|
||||
if ( input != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !proxy.isActive() )
|
||||
return;
|
||||
|
||||
IEnergySource energy = proxy.getEnergy();
|
||||
IMEMonitor<IAEItemStack> cell = proxy.getStorage().getItemInventory();
|
||||
|
||||
ItemStack is = input.getItemStack();
|
||||
input.setStackSize( is.getMaxStackSize() );
|
||||
|
||||
IAEItemStack retrieved = Platform.poweredExtraction( energy, cell, input, new PlayerSource( player, this ) );
|
||||
if ( retrieved != null )
|
||||
{
|
||||
ItemStack newItems = retrieved.getItemStack();
|
||||
InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
|
||||
newItems = adaptor.addItems( newItems );
|
||||
if ( newItems != null )
|
||||
{
|
||||
TileEntity te = tile;
|
||||
List<ItemStack> list = Arrays.asList( new ItemStack[] { newItems } );
|
||||
Platform.spawnDrops( player.worldObj, te.xCoord + side.offsetX, te.yCoord + side.offsetY, te.zCoord + side.offsetZ, list );
|
||||
}
|
||||
|
||||
if ( player.openContainer != null )
|
||||
player.openContainer.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
public class PartCraftingTerminal extends PartTerminal implements IAEAppEngInventory
|
||||
{
|
||||
|
||||
AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 );
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
craftingGrid.writeToNBT( data, "craftingGrid" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
craftingGrid.readFromNBT( data, "craftingGrid" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
||||
{
|
||||
super.getDrops(drops, wrenched);
|
||||
|
||||
for (ItemStack is : craftingGrid)
|
||||
if ( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
|
||||
public PartCraftingTerminal(ItemStack is) {
|
||||
super( PartCraftingTerminal.class, is );
|
||||
frontBright = CableBusTextures.PartCraftingTerm_Bright;
|
||||
frontColored = CableBusTextures.PartCraftingTerm_Colored;
|
||||
frontDark = CableBusTextures.PartCraftingTerm_Dark;
|
||||
// frontSolid = CableBusTextures.PartCraftingTerm_Solid;
|
||||
}
|
||||
|
||||
public GuiBridge getGui()
|
||||
{
|
||||
return GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
{
|
||||
host.markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
{
|
||||
if ( name.equals( "crafting" ) )
|
||||
return craftingGrid;
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartDarkMonitor extends PartMonitor
|
||||
{
|
||||
|
||||
public PartDarkMonitor(ItemStack is) {
|
||||
super( PartDarkMonitor.class, is, false );
|
||||
notLightSource = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setInvColor( getColor().mediumVariant );
|
||||
rh.renderInventoryFace( frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 14 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(int x, int y, int z, 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( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( getLightLevel() > 0 )
|
||||
{
|
||||
int l = 13;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
}
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getColor().mediumVariant );
|
||||
rh.renderFace( x, y, z, frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PartInterfaceTerminal extends PartMonitor
|
||||
{
|
||||
|
||||
public PartInterfaceTerminal(ItemStack is) {
|
||||
super( PartInterfaceTerminal.class, is, true );
|
||||
frontBright = CableBusTextures.PartInterfaceTerm_Bright;
|
||||
frontColored = CableBusTextures.PartInterfaceTerm_Colored;
|
||||
frontDark = CableBusTextures.PartInterfaceTerm_Dark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
if ( !super.onPartActivate( player, pos ) )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, getHost().getTile(), side, GuiBridge.GUI_INTERFACE_TERMINAL );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.implementations.parts.IPartMonitor;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChannelState
|
||||
{
|
||||
|
||||
// CableBusTextures frontSolid = CableBusTextures.PartMonitor_Solid;
|
||||
CableBusTextures frontDark = CableBusTextures.PartMonitor_Colored;
|
||||
CableBusTextures frontBright = CableBusTextures.PartMonitor_Bright;
|
||||
CableBusTextures frontColored = CableBusTextures.PartMonitor_Colored;
|
||||
|
||||
boolean notLightSource = !this.getClass().equals( PartMonitor.class );
|
||||
|
||||
final int POWERED_FLAG = 4;
|
||||
final int BOOTING_FLAG = 8;
|
||||
final int CHANNEL_FLAG = 16;
|
||||
|
||||
byte spin = 0; // 0-3
|
||||
int clientFlags = 0; // sent as byte.
|
||||
float opacity = -1;
|
||||
|
||||
@Override
|
||||
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side)
|
||||
{
|
||||
super.onPlacement( player, held, side );
|
||||
|
||||
byte rotation = (byte) (MathHelper.floor_double( (double) ((player.rotationYaw * 4F) / 360F) + 2.5D ) & 3);
|
||||
if ( side == ForgeDirection.UP )
|
||||
spin = rotation;
|
||||
else if ( side == ForgeDirection.DOWN )
|
||||
spin = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setFloat( "opacity", opacity );
|
||||
data.setByte( "spin", (byte) spin );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if ( data.hasKey( "opacity" ) )
|
||||
opacity = data.getFloat( "opacity" );
|
||||
spin = data.getByte( "spin" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
TileEntity te = getTile();
|
||||
|
||||
if ( !player.isSneaking() && Platform.isWrench( player, player.inventory.getCurrentItem(), te.xCoord, te.yCoord, te.zCoord ) )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
if ( spin > 3 )
|
||||
spin = 0;
|
||||
|
||||
switch (spin)
|
||||
{
|
||||
case 0:
|
||||
spin = 1;
|
||||
break;
|
||||
case 1:
|
||||
spin = 3;
|
||||
break;
|
||||
case 2:
|
||||
spin = 0;
|
||||
break;
|
||||
case 3:
|
||||
spin = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
this.host.markForUpdate();
|
||||
this.saveChanges();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return super.onPartActivate( player, pos );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootingRender(MENetworkBootingStatusChange c)
|
||||
{
|
||||
if ( notLightSource )
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
opacity = -1;
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
{
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
clientFlags = spin & 3;
|
||||
;
|
||||
|
||||
try
|
||||
{
|
||||
if ( proxy.getEnergy().isNetworkPowered() )
|
||||
clientFlags = clientFlags | POWERED_FLAG;
|
||||
|
||||
if ( proxy.getPath().isNetworkBooting() )
|
||||
clientFlags = clientFlags | BOOTING_FLAG;
|
||||
|
||||
if ( proxy.getNode().meetsChannelRequirements() )
|
||||
clientFlags = clientFlags | CHANNEL_FLAG;
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// um.. nothing.
|
||||
}
|
||||
|
||||
data.writeByte( (byte) clientFlags );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
super.readFromStream( data );
|
||||
int oldFlags = clientFlags;
|
||||
clientFlags = data.readByte();
|
||||
spin = (byte) (clientFlags & 3);
|
||||
if ( clientFlags == oldFlags )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightLevel()
|
||||
{
|
||||
return blockLight( isPowered() ? (notLightSource ? 9 : 15) : 0 );
|
||||
}
|
||||
|
||||
private int blockLight(int emit)
|
||||
{
|
||||
if ( opacity < 0 )
|
||||
{
|
||||
TileEntity te = this.getTile();
|
||||
opacity = 255 - te.getWorldObj().getBlockLightOpacity( te.xCoord + side.offsetX, te.yCoord + side.offsetY, te.zCoord + side.offsetZ );
|
||||
}
|
||||
|
||||
return (int) (emit * (opacity / 255.0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowered()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
return proxy.getEnergy().isNetworkPowered();
|
||||
else
|
||||
return ((clientFlags & POWERED_FLAG) == POWERED_FLAG);
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public PartMonitor(ItemStack is) {
|
||||
this( PartMonitor.class, is, false );
|
||||
}
|
||||
|
||||
protected PartMonitor(Class c, ItemStack is, boolean requireChannel) {
|
||||
super( c, is );
|
||||
|
||||
if ( requireChannel )
|
||||
{
|
||||
proxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
proxy.setIdlePowerUsage( 1.0 / 2.0 );
|
||||
}
|
||||
else
|
||||
proxy.setIdlePowerUsage( 1.0 / 16.0 ); // lights drain a little bit.
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setInvColor( getColor().whiteVariant );
|
||||
rh.renderInventoryFace( frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setInvColor( getColor().mediumVariant );
|
||||
rh.renderInventoryFace( frontDark.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setInvColor( getColor().blackVariant );
|
||||
rh.renderInventoryFace( frontColored.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 14 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
renderCache = rh.useSimplifiedRendering( x, y, z, this, renderCache );
|
||||
|
||||
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 );
|
||||
|
||||
if ( getLightLevel() > 0 )
|
||||
{
|
||||
int l = 13;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
}
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this.spin;
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getColor().whiteVariant );
|
||||
rh.renderFace( x, y, z, frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getColor().mediumVariant );
|
||||
rh.renderFace( x, y, z, frontDark.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
Tessellator.instance.setColorOpaque_I( getColor().blackVariant );
|
||||
rh.renderFace( x, y, z, frontColored.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
|
||||
if ( notLightSource )
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorBack.getIcon(), is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
}
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( notLightSource )
|
||||
{
|
||||
boolean hasChan = (clientFlags & (POWERED_FLAG | CHANNEL_FLAG)) == (POWERED_FLAG | CHANNEL_FLAG);
|
||||
boolean hasPower = (clientFlags & POWERED_FLAG) == POWERED_FLAG;
|
||||
|
||||
if ( hasChan )
|
||||
{
|
||||
int l = 14;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
Tessellator.instance.setColorOpaque_I( getColor().blackVariant );
|
||||
}
|
||||
else if ( hasPower )
|
||||
{
|
||||
int l = 9;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
Tessellator.instance.setColorOpaque_I( getColor().whiteVariant );
|
||||
}
|
||||
else
|
||||
{
|
||||
Tessellator.instance.setBrightness( 0 );
|
||||
Tessellator.instance.setColorOpaque_I( 0x000000 );
|
||||
}
|
||||
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.EAST, renderer );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.WEST, renderer );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.UP, renderer );
|
||||
rh.renderFace( x, y, z, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), ForgeDirection.DOWN, renderer );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(IPartCollisionHelper bch)
|
||||
{
|
||||
bch.addBox( 2, 2, 14, 14, 14, 16 );
|
||||
bch.addBox( 4, 4, 13, 12, 12, 14 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
if ( notLightSource )
|
||||
return ((clientFlags & (CHANNEL_FLAG | POWERED_FLAG)) == (CHANNEL_FLAG | POWERED_FLAG));
|
||||
else
|
||||
return isPowered();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
public class PartPatternTerminal extends PartTerminal implements IAEAppEngInventory
|
||||
{
|
||||
|
||||
AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 );
|
||||
AppEngInternalInventory output = new AppEngInternalInventory( this, 3 );
|
||||
AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
|
||||
|
||||
private boolean craftingMode = true;
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setBoolean( "craftingMode", isCraftingRecipe() );
|
||||
pattern.writeToNBT( data, "pattern" );
|
||||
output.writeToNBT( data, "outputList" );
|
||||
crafting.writeToNBT( data, "craftingGrid" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
setCraftingRecipe( data.getBoolean( "craftingMode" ) );
|
||||
pattern.readFromNBT( data, "pattern" );
|
||||
output.readFromNBT( data, "outputList" );
|
||||
crafting.readFromNBT( data, "craftingGrid" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
||||
{
|
||||
for (ItemStack is : pattern)
|
||||
if ( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
|
||||
public PartPatternTerminal(ItemStack is) {
|
||||
super( PartPatternTerminal.class, is );
|
||||
frontBright = CableBusTextures.PartPatternTerm_Bright;
|
||||
frontColored = CableBusTextures.PartPatternTerm_Colored;
|
||||
frontDark = CableBusTextures.PartPatternTerm_Dark;
|
||||
}
|
||||
|
||||
public GuiBridge getGui()
|
||||
{
|
||||
return GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
{
|
||||
if ( name.equals( "crafting" ) )
|
||||
return crafting;
|
||||
|
||||
if ( name.equals( "output" ) )
|
||||
return output;
|
||||
|
||||
if ( name.equals( "pattern" ) )
|
||||
return pattern;
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
{
|
||||
if ( inv == pattern && slot == 1 )
|
||||
{
|
||||
ItemStack is = pattern.getStackInSlot( 1 );
|
||||
if ( is != null && is.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
|
||||
ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
|
||||
if ( details != null )
|
||||
{
|
||||
setCraftingRecipe( details.isCraftable() );
|
||||
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < details.getInputs().length; x++)
|
||||
{
|
||||
IAEItemStack aeis = details.getInputs()[x];
|
||||
crafting.setInventorySlotContents( x, aeis == null ? null : aeis.getItemStack() );
|
||||
}
|
||||
|
||||
for (int x = 0; x < output.getSizeInventory() && x < details.getOutputs().length; x++)
|
||||
{
|
||||
IAEItemStack aeis = details.getOutputs()[x];
|
||||
output.setInventorySlotContents( x, aeis == null ? null : aeis.getItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( inv == crafting )
|
||||
{
|
||||
fixCraftingRecipes();
|
||||
}
|
||||
|
||||
host.markForSave();
|
||||
}
|
||||
|
||||
public boolean isCraftingRecipe()
|
||||
{
|
||||
return craftingMode;
|
||||
}
|
||||
|
||||
public void setCraftingRecipe(boolean craftingMode)
|
||||
{
|
||||
this.craftingMode = craftingMode;
|
||||
fixCraftingRecipes();
|
||||
}
|
||||
|
||||
private void fixCraftingRecipes()
|
||||
{
|
||||
if ( isCraftingRecipe() )
|
||||
{
|
||||
for (int x = 0; x < crafting.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack is = crafting.getStackInSlot( x );
|
||||
if ( is != null )
|
||||
is.stackSize = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartSemiDarkMonitor extends PartMonitor
|
||||
{
|
||||
|
||||
public PartSemiDarkMonitor(ItemStack is) {
|
||||
super( PartSemiDarkMonitor.class, is,false );
|
||||
notLightSource = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(),
|
||||
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
int light = getColor().whiteVariant;
|
||||
int dark = getColor().mediumVariant;
|
||||
rh.setInvColor( (((((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2) << 16) | (((((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2) << 8)
|
||||
| ((((light) & 0xff) + ((dark) & 0xff)) / 2) );
|
||||
rh.renderInventoryFace( frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 14 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(int x, int y, int z, 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( 2, 2, 14, 14, 14, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
if ( getLightLevel() > 0 )
|
||||
{
|
||||
int l = 13;
|
||||
Tessellator.instance.setBrightness( l << 20 | l << 4 );
|
||||
}
|
||||
|
||||
int light = getColor().whiteVariant;
|
||||
int dark = getColor().mediumVariant;
|
||||
Tessellator.instance.setColorOpaque( (((light >> 16) & 0xff) + ((dark >> 16) & 0xff)) / 2, (((light >> 8) & 0xff) + ((dark >> 8) & 0xff)) / 2,
|
||||
(((light) & 0xff) + ((dark) & 0xff)) / 2 );
|
||||
rh.renderFace( x, y, z, frontBright.getIcon(), ForgeDirection.SOUTH, renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 13, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import appeng.api.implementations.parts.IPartStorageMonitor;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.storage.IStackWatcher;
|
||||
import appeng.api.networking.storage.IStackWatcherHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartStorageMonitor extends PartMonitor implements IPartStorageMonitor, IStackWatcherHost
|
||||
{
|
||||
|
||||
IAEItemStack configuredItem;
|
||||
boolean isLocked;
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
|
||||
data.setBoolean( "isLocked", isLocked );
|
||||
|
||||
NBTTagCompound myItem = new NBTTagCompound();
|
||||
if ( configuredItem != null )
|
||||
configuredItem.writeToNBT( myItem );
|
||||
|
||||
data.setTag( "configuredItem", myItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
|
||||
isLocked = data.getBoolean( "isLocked" );
|
||||
|
||||
NBTTagCompound myItem = data.getCompoundTag( "configuredItem" );
|
||||
configuredItem = AEItemStack.loadItemStackFromNBT( myItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
|
||||
data.writeByte( spin );
|
||||
data.writeBoolean( isLocked );
|
||||
data.writeBoolean( configuredItem != null ? true : false );
|
||||
if ( configuredItem != null )
|
||||
configuredItem.writeToPacket( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
boolean stuff = super.readFromStream( data );
|
||||
|
||||
spin = data.readByte();
|
||||
isLocked = data.readBoolean();
|
||||
boolean val = data.readBoolean();
|
||||
if ( val )
|
||||
configuredItem = AEItemStack.loadItemStackFromPacket( data );
|
||||
else
|
||||
configuredItem = null;
|
||||
|
||||
updateList = true;
|
||||
|
||||
return stuff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
if ( !proxy.isActive() )
|
||||
return false;
|
||||
|
||||
if ( !Platform.hasPermissions( getLocation(), player ) )
|
||||
return false;
|
||||
|
||||
TileEntity te = this.tile;
|
||||
ItemStack eq = player.getCurrentEquippedItem();
|
||||
if ( Platform.isWrench( player, eq, te.xCoord, te.yCoord, te.zCoord ) )
|
||||
{
|
||||
isLocked = !isLocked;
|
||||
player.addChatMessage( (isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked).get() );
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
else if ( !isLocked )
|
||||
{
|
||||
configuredItem = AEItemStack.create( eq );
|
||||
configureWatchers();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
else
|
||||
extractItem( player );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void extractItem(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected PartStorageMonitor(Class myClass, ItemStack is) {
|
||||
super( myClass, is, true );
|
||||
}
|
||||
|
||||
public PartStorageMonitor(ItemStack is) {
|
||||
super( PartStorageMonitor.class, is, true );
|
||||
frontBright = CableBusTextures.PartStorageMonitor_Bright;
|
||||
frontColored = CableBusTextures.PartStorageMonitor_Colored;
|
||||
frontDark = CableBusTextures.PartStorageMonitor_Dark;
|
||||
// frontSolid = CableBusTextures.PartStorageMonitor_Solid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireDynamicRender()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private boolean updateList;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Integer dspList;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
super.finalize();
|
||||
if ( dspList != null )
|
||||
GLAllocation.deleteDisplayLists( dspList );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer)
|
||||
{
|
||||
if ( dspList == null )
|
||||
dspList = GLAllocation.generateDisplayLists( 1 );
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
if ( Platform.isDrawing( tess ) )
|
||||
return;
|
||||
|
||||
if ( (clientFlags & (POWERED_FLAG | CHANNEL_FLAG)) != (POWERED_FLAG | CHANNEL_FLAG) )
|
||||
return;
|
||||
|
||||
IAEItemStack ais = (IAEItemStack) getDisplayed();
|
||||
if ( ais != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 );
|
||||
|
||||
if ( updateList )
|
||||
{
|
||||
updateList = false;
|
||||
GL11.glNewList( dspList, GL11.GL_COMPILE_AND_EXECUTE );
|
||||
tesrRenderScreen( tess, ais );
|
||||
GL11.glEndList();
|
||||
}
|
||||
else
|
||||
GL11.glCallList( dspList );
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private void tesrRenderScreen(Tessellator tess, IAEItemStack ais)
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
ForgeDirection d = side;
|
||||
GL11.glTranslated( d.offsetX * 0.77, d.offsetY * 0.77, d.offsetZ * 0.77 );
|
||||
|
||||
if ( d == ForgeDirection.UP )
|
||||
{
|
||||
GL11.glScalef( 1.0f, -1.0f, 1.0f );
|
||||
GL11.glRotatef( 90.0f, 1.0f, 0.0f, 0.0f );
|
||||
GL11.glRotatef( (float) spin * 90.0F, 0, 0, 1 );
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.DOWN )
|
||||
{
|
||||
GL11.glScalef( 1.0f, -1.0f, 1.0f );
|
||||
GL11.glRotatef( -90.0f, 1.0f, 0.0f, 0.0f );
|
||||
GL11.glRotatef( (float) spin * -90.0F, 0, 0, 1 );
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.EAST )
|
||||
{
|
||||
GL11.glScalef( -1.0f, -1.0f, -1.0f );
|
||||
GL11.glRotatef( -90.0f, 0.0f, 1.0f, 0.0f );
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.WEST )
|
||||
{
|
||||
GL11.glScalef( -1.0f, -1.0f, -1.0f );
|
||||
GL11.glRotatef( 90.0f, 0.0f, 1.0f, 0.0f );
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.NORTH )
|
||||
{
|
||||
GL11.glScalef( -1.0f, -1.0f, -1.0f );
|
||||
}
|
||||
|
||||
if ( d == ForgeDirection.SOUTH )
|
||||
{
|
||||
GL11.glScalef( -1.0f, -1.0f, -1.0f );
|
||||
GL11.glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
try
|
||||
{
|
||||
ItemStack sis = ais.getItemStack();
|
||||
sis.stackSize = 1;
|
||||
|
||||
int br = 16 << 20 | 16 << 4;
|
||||
int var11 = br % 65536;
|
||||
int var12 = br / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11 * 0.8F, var12 * 0.8F );
|
||||
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
|
||||
// RenderHelper.enableGUIStandardItemLighting();
|
||||
tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
|
||||
|
||||
ClientHelper.proxy.doRenderItem( sis, this.tile.getWorldObj() );
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glTranslatef( 0.0f, 0.14f, -0.24f );
|
||||
GL11.glScalef( 1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f );
|
||||
|
||||
long qty = ais.getStackSize();
|
||||
if ( qty > 999999999999L )
|
||||
qty = 999999999999L;
|
||||
|
||||
String msg = Long.toString( qty );
|
||||
if ( qty > 1000000000 )
|
||||
msg = Long.toString( qty / 1000000000 ) + "B";
|
||||
else if ( qty > 1000000 )
|
||||
msg = Long.toString( qty / 1000000 ) + "M";
|
||||
else if ( qty > 9999 )
|
||||
msg = Long.toString( qty / 1000 ) + "K";
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
int width = fr.getStringWidth( msg );
|
||||
GL11.glTranslatef( -0.5f * width, 0.0f, -1.0f );
|
||||
fr.drawString( msg, 0, 0, 0 );
|
||||
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack getDisplayed()
|
||||
{
|
||||
return configuredItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocked()
|
||||
{
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
IStackWatcher myWatcher;
|
||||
|
||||
@Override
|
||||
public void updateWatcher(IStackWatcher newWatcher)
|
||||
{
|
||||
myWatcher = newWatcher;
|
||||
configureWatchers();
|
||||
}
|
||||
|
||||
// update the system...
|
||||
public void configureWatchers()
|
||||
{
|
||||
if ( myWatcher != null )
|
||||
myWatcher.clear();
|
||||
|
||||
try
|
||||
{
|
||||
if ( configuredItem != null )
|
||||
{
|
||||
if ( myWatcher != null )
|
||||
myWatcher.add( configuredItem );
|
||||
|
||||
updateReportingValue( proxy.getStorage().getItemInventory() );
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// >.>
|
||||
}
|
||||
}
|
||||
|
||||
private void updateReportingValue(IMEMonitor<IAEItemStack> itemInventory)
|
||||
{
|
||||
if ( configuredItem != null )
|
||||
{
|
||||
IAEItemStack result = itemInventory.getStorageList().findPrecise( configuredItem );
|
||||
if ( result == null )
|
||||
configuredItem.setStackSize( 0 );
|
||||
else
|
||||
configuredItem.setStackSize( result.getStackSize() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan)
|
||||
{
|
||||
if ( configuredItem != null )
|
||||
{
|
||||
if ( fullStack == null )
|
||||
configuredItem.setStackSize( 0 );
|
||||
else
|
||||
configuredItem.setStackSize( fullStack.getStackSize() );
|
||||
|
||||
getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showNetworkInfo(MovingObjectPosition where)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package appeng.parts.reporting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory
|
||||
{
|
||||
|
||||
IConfigManager cm = new ConfigManager( this );
|
||||
AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 );
|
||||
|
||||
public PartTerminal(Class clz, ItemStack is) {
|
||||
super( clz, is, true );
|
||||
|
||||
cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(List<ItemStack> drops, boolean wrenched)
|
||||
{
|
||||
super.getDrops( drops, wrenched );
|
||||
|
||||
for (ItemStack is : viewCell)
|
||||
if ( is != null )
|
||||
drops.add( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
cm.readFromNBT( data );
|
||||
viewCell.readFromNBT( data, "viewCell" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
cm.writeToNBT( data );
|
||||
viewCell.writeToNBT( data, "viewCell" );
|
||||
}
|
||||
|
||||
public PartTerminal(ItemStack is) {
|
||||
super( PartTerminal.class, is, true );
|
||||
frontBright = CableBusTextures.PartTerminal_Bright;
|
||||
frontColored = CableBusTextures.PartTerminal_Colored;
|
||||
frontDark = CableBusTextures.PartTerminal_Dark;
|
||||
// frontSolid = CableBusTextures.PartTerminal_Solid;
|
||||
|
||||
cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
}
|
||||
|
||||
public GuiBridge getGui()
|
||||
{
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
||||
{
|
||||
if ( !super.onPartActivate( player, pos ) )
|
||||
{
|
||||
if ( !player.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( player, getHost().getTile(), side, getGui() );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor getFluidInventory()
|
||||
{
|
||||
try
|
||||
{
|
||||
return proxy.getStorage().getFluidInventory();
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// err nope?
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor getItemInventory()
|
||||
{
|
||||
try
|
||||
{
|
||||
return proxy.getStorage().getItemInventory();
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// err nope?
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return cm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage()
|
||||
{
|
||||
return viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
{
|
||||
host.markForSave();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user