Closes #12 Added visual lock state to monitors

Some general refactoring of every monitor including panels and terminals.
Disabled glPushAttrib and glPopAttrib for StorageMonitor as this can be a
performance issue.

Conflicts:
	src/main/java/appeng/parts/AEBasePart.java
	src/main/java/appeng/parts/reporting/PartConversionMonitor.java
	src/main/java/appeng/parts/reporting/PartDarkMonitor.java
	src/main/java/appeng/parts/reporting/PartMonitor.java
	src/main/java/appeng/parts/reporting/PartPatternTerminal.java
	src/main/java/appeng/parts/reporting/PartSemiDarkMonitor.java
	src/main/java/appeng/parts/reporting/PartStorageMonitor.java
	src/main/java/appeng/parts/reporting/PartTerminal.java
This commit is contained in:
yueh 2015-05-27 16:54:04 +02:00 committed by thatsIch
parent 07a4a8505b
commit ed47a23156
26 changed files with 1524 additions and 1124 deletions

View File

@ -44,7 +44,7 @@ import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.container.implementations.ContainerInterfaceTerminal;
import appeng.core.localization.GuiText;
import appeng.parts.reporting.PartMonitor;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.util.Platform;
import com.google.common.collect.HashMultimap;
@ -68,7 +68,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
private boolean refreshList = false;
private MEGuiTextField searchField;
public GuiInterfaceTerminal( InventoryPlayer inventoryPlayer, PartMonitor te )
public GuiInterfaceTerminal( InventoryPlayer inventoryPlayer, PartInterfaceTerminal te )
{
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
this.myScrollBar = new GuiScrollbar();

View File

@ -62,6 +62,7 @@ import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.parts.reporting.AbstractPartTerminal;
import appeng.parts.reporting.PartTerminal;
import appeng.tile.misc.TileSecurity;
import appeng.util.IConfigManagerHost;
@ -139,7 +140,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
{
this.myName = GuiText.Chest;
}
else if( te instanceof PartTerminal )
else if( te instanceof AbstractPartTerminal )
{
this.myName = GuiText.Terminal;
}

View File

@ -47,13 +47,13 @@ public enum CableBusTextures
PartPatternTerm_Bright( "PartPatternTerm_Bright" ), PartPatternTerm_Colored( "PartPatternTerm_Colored" ), PartPatternTerm_Dark( "PartPatternTerm_Dark" ),
PartConversionMonitor_Bright( "PartConversionMonitor_Bright" ), PartConversionMonitor_Colored( "PartConversionMonitor_Colored" ), PartConversionMonitor_Dark( "PartConversionMonitor_Dark" ),
PartConversionMonitor_Bright( "PartConversionMonitor_Bright" ), PartConversionMonitor_Colored( "PartConversionMonitor_Colored" ), PartConversionMonitor_Dark( "PartConversionMonitor_Dark" ), PartConversionMonitor_Dark_Locked( "PartConversionMonitor_Dark_Locked" ),
PartInterfaceTerm_Bright( "PartInterfaceTerm_Bright" ), PartInterfaceTerm_Colored( "PartInterfaceTerm_Colored" ), PartInterfaceTerm_Dark( "PartInterfaceTerm_Dark" ),
PartCraftingTerm_Bright( "PartCraftingTerm_Bright" ), PartCraftingTerm_Colored( "PartCraftingTerm_Colored" ), PartCraftingTerm_Dark( "PartCraftingTerm_Dark" ), //
PartStorageMonitor_Bright( "PartStorageMonitor_Bright" ), PartStorageMonitor_Colored( "PartStorageMonitor_Colored" ), PartStorageMonitor_Dark( "PartStorageMonitor_Dark" ),
PartStorageMonitor_Bright( "PartStorageMonitor_Bright" ), PartStorageMonitor_Colored( "PartStorageMonitor_Colored" ), PartStorageMonitor_Dark( "PartStorageMonitor_Dark" ), PartStorageMonitor_Colored_Locked( "PartStorageMonitor_Colored_Locked" ),
PartTerminal_Bright( "PartTerminal_Bright" ), PartTerminal_Colored( "PartTerminal_Colored" ), PartTerminal_Dark( "PartTerminal_Dark" ),

View File

@ -43,7 +43,7 @@ import appeng.helpers.IInterfaceHost;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.parts.misc.PartInterface;
import appeng.parts.reporting.PartMonitor;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.misc.TileInterface;
import appeng.util.InventoryAdaptor;
@ -66,7 +66,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
IGrid grid;
NBTTagCompound data = new NBTTagCompound();
public ContainerInterfaceTerminal( InventoryPlayer ip, PartMonitor anchor )
public ContainerInterfaceTerminal( InventoryPlayer ip, PartInterfaceTerminal anchor )
{
super( ip, anchor );
@ -418,7 +418,6 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
}
}
static class PatternInvSlot extends WrapperInvSlot
{

View File

@ -97,7 +97,8 @@ import appeng.parts.automation.PartFormationPlane;
import appeng.parts.automation.PartLevelEmitter;
import appeng.parts.misc.PartStorageBus;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartMonitor;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.parts.reporting.PartPanel;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.tile.crafting.TileCraftingTile;
import appeng.tile.crafting.TileMolecularAssembler;
@ -186,7 +187,7 @@ public enum GuiBridge implements IGuiHandler
GUI_CRAFTING_CONFIRM( ContainerCraftConfirm.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT ),
GUI_INTERFACE_TERMINAL( ContainerInterfaceTerminal.class, PartMonitor.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
GUI_INTERFACE_TERMINAL( ContainerInterfaceTerminal.class, PartInterfaceTerminal.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
GUI_CRAFTING_STATUS( ContainerCraftingStatus.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT );

View File

@ -51,11 +51,11 @@ import appeng.parts.p2p.PartP2PRedstone;
import appeng.parts.p2p.PartP2PTunnelME;
import appeng.parts.reporting.PartConversionMonitor;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartDarkMonitor;
import appeng.parts.reporting.PartDarkPanel;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.parts.reporting.PartMonitor;
import appeng.parts.reporting.PartPanel;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartSemiDarkMonitor;
import appeng.parts.reporting.PartSemiDarkPanel;
import appeng.parts.reporting.PartStorageMonitor;
import appeng.parts.reporting.PartTerminal;
@ -108,11 +108,11 @@ public enum PartType
QuartzFiber( 140, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartQuartzFiber.class ),
Monitor( 160, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartMonitor.class ),
Monitor( 160, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartPanel.class ),
SemiDarkMonitor( 180, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartSemiDarkMonitor.class ),
SemiDarkMonitor( 180, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartSemiDarkPanel.class ),
DarkMonitor( 200, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartDarkMonitor.class ),
DarkMonitor( 200, EnumSet.of( AEFeature.Core ), EnumSet.noneOf( IntegrationType.class ), PartDarkPanel.class ),
StorageBus( 220, EnumSet.of( AEFeature.StorageBus ), EnumSet.noneOf( IntegrationType.class ), PartStorageBus.class ),

View File

@ -19,14 +19,16 @@
package appeng.parts;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.entity.Entity;
@ -83,6 +85,8 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
public AEBasePart( ItemStack is )
{
Preconditions.checkNotNull( is );
this.is = is;
this.proxy = new AENetworkProxy( this, "part", is, this instanceof PartCable );
this.proxy.setValidSides( EnumSet.noneOf( EnumFacing.class ) );
@ -137,7 +141,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
public int getInstalledUpgrades( Upgrades u )
{
return 0;
} @Override
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, IRenderHelper renderer )
{
@ -188,7 +194,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
{
return this.is.getDisplayName();
}
@Override
@SideOnly( Side.CLIENT )
public void renderStatic( BlockPos pos, IPartRenderHelper rh, IRenderHelper renderer )
@ -208,10 +214,6 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
crashreportcategory.addCrashSection( "Part Side", this.side );
}
@Override
@SideOnly( Side.CLIENT )
public void renderDynamic( double x, double y, double z, IPartRenderHelper rh, IRenderHelper renderer )
@ -369,7 +371,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
/**
* depending on the from, different settings will be accepted, don't call this with null
*
* @param from source of settings
* @param from source of settings
* @param compound compound of source
*/
public void uploadSettings( SettingsFrom from, NBTTagCompound compound )

View File

@ -0,0 +1,151 @@
/*
* 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.parts.reporting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.parts.IPartRenderHelper;
import appeng.client.render.IRenderHelper;
import appeng.client.texture.CableBusTextures;
import appeng.client.texture.IAESprite;
/**
* A more sophisticated part overlapping all 3 textures.
*
* Subclass this if you need want a new part and need all 3 textures.
* For more concrete implementations, the direct abstract subclasses might be a better alternative.
*
* @author AlgorithmX2
* @author yueh
* @version rv3
* @since rv3
*/
public abstract class AbstractPartDisplay extends AbstractPartReporting
{
public AbstractPartDisplay( ItemStack is )
{
super( is, true );
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, IRenderHelper renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );
final IAESprite sideTexture = CableBusTextures.PartMonitorSides.getIcon();
final IAESprite backTexture = CableBusTextures.PartMonitorBack.getIcon();
rh.setTexture( sideTexture, sideTexture, backTexture, renderer.getIcon( this.is ), sideTexture, sideTexture );
rh.renderInventoryBox( renderer );
rh.setInvColor( this.getColor().whiteVariant );
rh.renderInventoryFace( this.getFrontBright().getIcon(), EnumFacing.SOUTH, renderer );
rh.setInvColor( this.getColor().mediumVariant );
rh.renderInventoryFace( this.getFrontDark().getIcon(), EnumFacing.SOUTH, renderer );
rh.setInvColor( this.getColor().blackVariant );
rh.renderInventoryFace( this.getFrontColored().getIcon(), EnumFacing.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderInventoryBox( renderer );
}
@Override
@SideOnly( Side.CLIENT )
public void renderStatic( BlockPos pos, IPartRenderHelper rh, IRenderHelper renderer )
{
final IAESprite sideTexture = CableBusTextures.PartMonitorSides.getIcon();
final IAESprite backTexture = CableBusTextures.PartMonitorBack.getIcon();
rh.setTexture( sideTexture, sideTexture, backTexture, renderer.getIcon( this.is ), sideTexture, sideTexture );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( pos, renderer );
if( this.getLightLevel() > 0 )
{
final int l = 13;
renderer.setBrightness( l << 20 | l << 4 );
}
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this.getSpin();
renderer.setColorOpaque_I( this.getColor().whiteVariant );
rh.renderFace( pos, this.getFrontBright().getIcon(), EnumFacing.SOUTH, renderer );
renderer.setColorOpaque_I( this.getColor().mediumVariant );
rh.renderFace( pos, this.getFrontDark().getIcon(), EnumFacing.SOUTH, renderer );
renderer.setColorOpaque_I( this.getColor().blackVariant );
rh.renderFace( pos, this.getFrontColored().getIcon(), EnumFacing.SOUTH, renderer );
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
final IAESprite sideStatusTexture = CableBusTextures.PartMonitorSidesStatus.getIcon();
rh.setTexture( sideStatusTexture, sideStatusTexture, backTexture, renderer.getIcon( this.is ), sideStatusTexture, sideStatusTexture );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( pos, renderer );
final boolean hasChan = ( this.getClientFlags() & ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG ) ) == ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG );
final boolean hasPower = ( this.getClientFlags() & PartPanel.POWERED_FLAG ) == PartPanel.POWERED_FLAG;
if( hasChan )
{
final int l = 14;
renderer.setBrightness( l << 20 | l << 4 );
renderer.setColorOpaque_I( this.getColor().blackVariant );
}
else if( hasPower )
{
final int l = 9;
renderer.setBrightness( l << 20 | l << 4 );
renderer.setColorOpaque_I( this.getColor().whiteVariant );
}
else
{
renderer.setBrightness( 0 );
renderer.setColorOpaque_I( 0x000000 );
}
final IAESprite sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon();
rh.renderFace( pos, sideStatusLightTexture, EnumFacing.EAST, renderer );
rh.renderFace( pos, sideStatusLightTexture, EnumFacing.WEST, renderer );
rh.renderFace( pos, sideStatusLightTexture, EnumFacing.UP, renderer );
rh.renderFace( pos, sideStatusLightTexture, EnumFacing.DOWN, renderer );
}
@Override
public boolean isLightSource()
{
return false;
}
}

View File

@ -0,0 +1,430 @@
/*
* 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.parts.reporting;
import java.io.IOException;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import io.netty.buffer.ByteBuf;
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.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
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.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
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.api.util.AEPartLocation;
import appeng.client.ClientHelper;
import appeng.client.render.IRenderHelper;
import appeng.core.AELog;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException;
import appeng.util.IWideReadableNumberConverter;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import appeng.util.item.AEItemStack;
/**
* A basic subclass for any item monitor like display with an item icon and an amount.
*
* It can also be used to extract items from somewhere and spawned into the world.
*
* @author AlgorithmX2
* @author thatsIch
* @author yueh
* @version rv3
* @since rv3
*/
public abstract class AbstractPartMonitor extends AbstractPartDisplay implements IPartStorageMonitor, IStackWatcherHost
{
private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE;
private IAEItemStack configuredItem;
private boolean isLocked;
private IStackWatcher myWatcher;
@SideOnly( Side.CLIENT )
private boolean updateList;
@SideOnly( Side.CLIENT )
private Integer dspList;
@Reflected
public AbstractPartMonitor( ItemStack is )
{
super( is );
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.isLocked = data.getBoolean( "isLocked" );
final NBTTagCompound myItem = data.getCompoundTag( "configuredItem" );
this.configuredItem = AEItemStack.loadItemStackFromNBT( myItem );
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
data.setBoolean( "isLocked", this.isLocked );
final NBTTagCompound myItem = new NBTTagCompound();
if( this.configuredItem != null )
{
this.configuredItem.writeToNBT( myItem );
}
data.setTag( "configuredItem", myItem );
}
@Override
public void writeToStream( ByteBuf data ) throws IOException
{
super.writeToStream( data );
data.writeBoolean( this.isLocked );
data.writeBoolean( this.configuredItem != null );
if( this.configuredItem != null )
{
this.configuredItem.writeToPacket( data );
}
}
@Override
public boolean readFromStream( ByteBuf data ) throws IOException
{
boolean needRedraw = super.readFromStream( data );
final boolean isLocked = data.readBoolean();
needRedraw = this.isLocked != isLocked;
this.isLocked = isLocked;
final boolean val = data.readBoolean();
if( val )
{
this.configuredItem = AEItemStack.loadItemStackFromPacket( data );
}
else
{
this.configuredItem = null;
}
this.updateList = true;
return needRedraw;
}
@Override
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
if( Platform.isClient() )
{
return true;
}
if( !this.proxy.isActive() )
{
return false;
}
if( !Platform.hasPermissions( this.getLocation(), player ) )
{
return false;
}
final TileEntity te = this.tile;
final ItemStack eq = player.getCurrentEquippedItem();
if( Platform.isWrench( player, eq, te.getPos() ) )
{
this.isLocked = !this.isLocked;
player.addChatMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() );
this.getHost().markForUpdate();
}
else if( !this.isLocked )
{
this.configuredItem = AEItemStack.create( eq );
this.configureWatchers();
this.getHost().markForUpdate();
}
else
{
this.extractItem( player );
}
return true;
}
// update the system...
public void configureWatchers()
{
if( this.myWatcher != null )
{
this.myWatcher.clear();
}
try
{
if( this.configuredItem != null )
{
if( this.myWatcher != null )
{
this.myWatcher.add( this.configuredItem );
}
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
}
}
catch( final GridAccessException e )
{
// >.>
}
}
protected void extractItem( EntityPlayer player )
{
}
private void updateReportingValue( IMEMonitor<IAEItemStack> itemInventory )
{
if( this.configuredItem != null )
{
final IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem );
if( result == null )
{
this.configuredItem.setStackSize( 0 );
}
else
{
this.configuredItem.setStackSize( result.getStackSize() );
}
}
}
@Override
@SideOnly( Side.CLIENT )
protected void finalize() throws Throwable
{
super.finalize();
if( this.dspList != null )
{
GLAllocation.deleteDisplayLists( this.dspList );
}
}
@Override
@SideOnly( Side.CLIENT )
public void renderDynamic( double x, double y, double z, IPartRenderHelper rh, IRenderHelper renderer )
{
if( this.dspList == null )
{
this.dspList = GLAllocation.generateDisplayLists( 1 );
}
final Tessellator tess = Tessellator.getInstance();
final WorldRenderer wr = tess.getWorldRenderer();
if( ( this.getClientFlags() & ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG ) ) != ( PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG ) )
{
return;
}
final IAEItemStack ais = (IAEItemStack) this.getDisplayed();
if( ais != null )
{
GL11.glPushMatrix();
GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 );
if( this.updateList )
{
this.updateList = false;
GL11.glNewList( this.dspList, GL11.GL_COMPILE_AND_EXECUTE );
this.tesrRenderScreen( wr, ais );
GL11.glEndList();
}
else
{
GL11.glCallList( this.dspList );
}
GL11.glPopMatrix();
}
}
@Override
public boolean requireDynamicRender()
{
return true;
}
@Override
public IAEStack<?> getDisplayed()
{
return this.configuredItem;
}
private void tesrRenderScreen( WorldRenderer wr, IAEItemStack ais )
{
// GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
final AEPartLocation d = this.side;
GL11.glTranslated( d.xOffset * 0.77, d.yOffset * 0.77, d.zOffset * 0.77 );
if( d == AEPartLocation.UP )
{
GL11.glScalef( 1.0f, -1.0f, 1.0f );
GL11.glRotatef( 90.0f, 1.0f, 0.0f, 0.0f );
GL11.glRotatef( this.getSpin() * 90.0F, 0, 0, 1 );
}
if( d == AEPartLocation.DOWN )
{
GL11.glScalef( 1.0f, -1.0f, 1.0f );
GL11.glRotatef( -90.0f, 1.0f, 0.0f, 0.0f );
GL11.glRotatef( this.getSpin() * -90.0F, 0, 0, 1 );
}
if( d == AEPartLocation.EAST )
{
GL11.glScalef( -1.0f, -1.0f, -1.0f );
GL11.glRotatef( -90.0f, 0.0f, 1.0f, 0.0f );
}
if( d == AEPartLocation.WEST )
{
GL11.glScalef( -1.0f, -1.0f, -1.0f );
GL11.glRotatef( 90.0f, 0.0f, 1.0f, 0.0f );
}
if( d == AEPartLocation.NORTH )
{
GL11.glScalef( -1.0f, -1.0f, -1.0f );
}
if( d == AEPartLocation.SOUTH )
{
GL11.glScalef( -1.0f, -1.0f, -1.0f );
GL11.glRotatef( 180.0f, 0.0f, 1.0f, 0.0f );
}
GL11.glPushMatrix();
try
{
final ItemStack sis = ais.getItemStack();
sis.stackSize = 1;
final int br = 16 << 20 | 16 << 4;
final int var11 = br % 65536;
final 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();
wr.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
ClientHelper.proxy.doRenderItem( sis, this.tile.getWorld() );
}
catch( final 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 );
final long stackSize = ais.getStackSize();
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize );
final FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
final int width = fr.getStringWidth( renderedStackSize );
GL11.glTranslatef( -0.5f * width, 0.0f, -1.0f );
fr.drawString( renderedStackSize, 0, 0, 0 );
// GL11.glPopAttrib();
}
@Override
public boolean isLocked()
{
return this.isLocked;
}
@Override
public void updateWatcher( IStackWatcher newWatcher )
{
this.myWatcher = newWatcher;
this.configureWatchers();
}
@Override
public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan )
{
if( this.configuredItem != null )
{
if( fullStack == null )
{
this.configuredItem.setStackSize( 0 );
}
else
{
this.configuredItem.setStackSize( fullStack.getStackSize() );
}
this.getHost().markForUpdate();
}
}
@Override
public boolean showNetworkInfo( MovingObjectPosition where )
{
return false;
}
}

View File

@ -0,0 +1,132 @@
/*
* 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.parts.reporting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.util.AEColor;
import appeng.client.render.IRenderHelper;
import appeng.client.texture.CableBusTextures;
import appeng.client.texture.IAESprite;
/**
* A very simple part for emitting light.
*
* Opposed to the other subclass of {@link AbstractPartReporting}, it will only use the bright front texture.
*
* @author AlgorithmX2
* @author yueh
* @version rv3
* @since rv3
*/
public abstract class AbstractPartPanel extends AbstractPartReporting
{
private static final CableBusTextures FRONT_BRIGHT_ICON = CableBusTextures.PartMonitor_Bright;
private static final CableBusTextures FRONT_DARK_ICON = CableBusTextures.PartMonitor_Colored;
private static final CableBusTextures FRONT_COLORED_ICON = CableBusTextures.PartMonitor_Colored;
public AbstractPartPanel( ItemStack is )
{
super( is, false );
}
@Override
public CableBusTextures getFrontBright()
{
return FRONT_BRIGHT_ICON;
}
@Override
public CableBusTextures getFrontColored()
{
return FRONT_COLORED_ICON;
}
@Override
public CableBusTextures getFrontDark()
{
return FRONT_DARK_ICON;
}
@Override
public boolean isLightSource()
{
return true;
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, IRenderHelper renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );
final IAESprite sideTexture = CableBusTextures.PartMonitorSides.getIcon();
final IAESprite backTexture = CableBusTextures.PartMonitorBack.getIcon();
rh.setTexture( sideTexture, sideTexture, backTexture, renderer.getIcon( this.is ), sideTexture, sideTexture );
rh.renderInventoryBox( renderer );
rh.setInvColor( this.getBrightnessColor() );
rh.renderInventoryFace( this.getFrontBright().getIcon(), EnumFacing.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderInventoryBox( renderer );
}
@Override
@SideOnly( Side.CLIENT )
public void renderStatic( BlockPos pos, IPartRenderHelper rh, IRenderHelper renderer )
{
final IAESprite sideTexture = CableBusTextures.PartMonitorSides.getIcon();
final IAESprite backTexture = CableBusTextures.PartMonitorBack.getIcon();
rh.setTexture( sideTexture, sideTexture, backTexture, renderer.getIcon( this.is ), sideTexture, sideTexture );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( pos, renderer );
if( this.getLightLevel() > 0 )
{
final int l = 13;
renderer.setBrightness( l << 20 | l << 4 );
}
renderer.setColorOpaque_I( this.getBrightnessColor() );
rh.renderFace( pos, this.getFrontBright().getIcon(), EnumFacing.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( pos, renderer );
}
/**
* How bright the color the panel should appear. Usually it depends on a {@link AEColor} variant.
* This does not affect the actual light level of the part.
*
* @return the brightness to be used.
*/
abstract protected int getBrightnessColor();
}

View File

@ -0,0 +1,329 @@
/*
* 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.parts.reporting;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
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 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.util.AEPartLocation;
import appeng.client.texture.CableBusTextures;
import appeng.me.GridAccessException;
import appeng.parts.AEBasePart;
import appeng.util.Platform;
/**
* The most basic class for any part reporting information, like terminals or monitors. This can also include basic
* panels which just provide light.
*
* It deals with the most basic functionalities like network data, grid registration or the rotation of the actual part.
*
* The direct abstract subclasses are usually a better entry point for adding new concrete ones.
* But this might be an ideal starting point to completely new type, which does not resemble any existing one.
*
* @author AlgorithmX2
* @author yueh
* @version rv3
* @since rv3
*/
public abstract class AbstractPartReporting extends AEBasePart implements IPartMonitor, IPowerChannelState
{
protected static final int POWERED_FLAG = 4;
protected static final int CHANNEL_FLAG = 16;
private static final int BOOTING_FLAG = 8;
private byte spin = 0; // 0-3
private int clientFlags = 0; // sent as byte.
private float opacity = -1;
public AbstractPartReporting( ItemStack is )
{
this( is, false );
}
protected AbstractPartReporting( ItemStack is, boolean requireChannel )
{
super( is );
if( requireChannel )
{
this.proxy.setFlags( GridFlags.REQUIRE_CHANNEL );
this.proxy.setIdlePowerUsage( 1.0 / 2.0 );
}
else
{
this.proxy.setIdlePowerUsage( 1.0 / 16.0 ); // lights drain a little bit.
}
}
@MENetworkEventSubscribe
public final void bootingRender( MENetworkBootingStatusChange c )
{
if( !this.isLightSource() )
{
this.getHost().markForUpdate();
}
}
@MENetworkEventSubscribe
public final void powerRender( MENetworkPowerStatusChange c )
{
this.getHost().markForUpdate();
}
@Override
public final void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 2, 2, 14, 14, 14, 16 );
bch.addBox( 4, 4, 13, 12, 12, 14 );
}
@Override
public void onNeighborChanged()
{
this.opacity = -1;
this.getHost().markForUpdate();
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
if( data.hasKey( "opacity" ) )
{
this.opacity = data.getFloat( "opacity" );
}
this.spin = data.getByte( "spin" );
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
data.setFloat( "opacity", this.opacity );
data.setByte( "spin", this.getSpin() );
}
@Override
public void writeToStream( ByteBuf data ) throws IOException
{
super.writeToStream( data );
this.clientFlags = this.getSpin() & 3;
try
{
if( this.proxy.getEnergy().isNetworkPowered() )
{
this.clientFlags = this.getClientFlags() | AbstractPartReporting.POWERED_FLAG;
}
if( this.proxy.getPath().isNetworkBooting() )
{
this.clientFlags = this.getClientFlags() | AbstractPartReporting.BOOTING_FLAG;
}
if( this.proxy.getNode().meetsChannelRequirements() )
{
this.clientFlags = this.getClientFlags() | AbstractPartReporting.CHANNEL_FLAG;
}
}
catch( final GridAccessException e )
{
// um.. nothing.
}
data.writeByte( (byte) this.getClientFlags() );
}
@Override
public boolean readFromStream( ByteBuf data ) throws IOException
{
super.readFromStream( data );
final int oldFlags = this.getClientFlags();
this.clientFlags = data.readByte();
this.spin = (byte) ( this.getClientFlags() & 3 );
if( this.getClientFlags() == oldFlags )
{
return false;
}
return true;
}
@Override
public final int getLightLevel()
{
return this.blockLight( this.isPowered() ? ( this.isLightSource() ? 15 : 9 ) : 0 );
}
@Override
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
final TileEntity te = this.getTile();
if( !player.isSneaking() && Platform.isWrench( player, player.inventory.getCurrentItem(), te.getPos() ) )
{
if( Platform.isServer() )
{
if( this.getSpin() > 3 )
{
this.spin = 0;
}
switch( this.getSpin() )
{
case 0:
this.spin = 1;
break;
case 1:
this.spin = 3;
break;
case 2:
this.spin = 0;
break;
case 3:
this.spin = 2;
break;
}
this.host.markForUpdate();
this.saveChanges();
}
return true;
}
else
{
return super.onPartActivate( player, pos );
}
}
@Override
public final void onPlacement( EntityPlayer player, ItemStack held, AEPartLocation side )
{
super.onPlacement( player, held, side );
final byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 );
if( side == AEPartLocation.UP )
{
this.spin = rotation;
}
else if( side == AEPartLocation.DOWN )
{
this.spin = rotation;
}
}
private final int blockLight( int emit )
{
if( this.opacity < 0 )
{
final TileEntity te = this.getTile();
this.opacity = 255 - te.getWorld().getBlockLightOpacity( te.getPos().offset( side.getFacing() ) );
}
return (int) ( emit * ( this.opacity / 255.0f ) );
}
@Override
public final boolean isPowered()
{
try
{
if( Platform.isServer() )
{
return this.proxy.getEnergy().isNetworkPowered();
}
else
{
return( ( this.getClientFlags() & PartPanel.POWERED_FLAG ) == PartPanel.POWERED_FLAG );
}
}
catch( final GridAccessException e )
{
return false;
}
}
@Override
public final boolean isActive()
{
if( !this.isLightSource() )
{
return( ( this.getClientFlags() & ( PartPanel.CHANNEL_FLAG | PartPanel.POWERED_FLAG ) ) == ( PartPanel.CHANNEL_FLAG | PartPanel.POWERED_FLAG ) );
}
else
{
return this.isPowered();
}
}
public final int getClientFlags()
{
return this.clientFlags;
}
public final byte getSpin()
{
return this.spin;
}
/**
* The texture used for the bright front layer.
*
* The final texture can overlap any of the the texture in no particular order.
*/
public abstract CableBusTextures getFrontBright();
/**
* The texture used for the colored (medium) front layer.
*
* The final texture can overlap any of the the texture in no particular order.
*/
public abstract CableBusTextures getFrontColored();
/**
* The texture used for the dark front layer.
*
* The final texture can overlap any of the the texture in no particular order.
*/
public abstract CableBusTextures getFrontDark();
/**
* Should the part emit light. This actually only affects the light level, light source use a level of 15 and non
* light source 9.
*/
public abstract boolean isLightSource();
}

View File

@ -0,0 +1,182 @@
/*
* 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.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.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.IConfigManager;
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;
/**
* Anything resembling an network terminal with view cells can reuse this.
*
* Note this applies only to terminals like the ME Terminal. It does not apply for more specialized terminals like the
* Interface Terminal.
*
* @author AlgorithmX2
* @author yueh
* @version rv3
* @since rv3
*/
public abstract class AbstractPartTerminal extends AbstractPartDisplay implements ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory
{
private final IConfigManager cm = new ConfigManager( this );
private final AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 );
public AbstractPartTerminal( ItemStack is )
{
super( is );
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
}
@Override
public void getDrops( List<ItemStack> drops, boolean wrenched )
{
super.getDrops( drops, wrenched );
for( final ItemStack is : this.viewCell )
{
if( is != null )
{
drops.add( is );
}
}
}
@Override
public IConfigManager getConfigManager()
{
return this.cm;
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.cm.readFromNBT( data );
this.viewCell.readFromNBT( data, "viewCell" );
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
this.cm.writeToNBT( data );
this.viewCell.writeToNBT( data, "viewCell" );
}
@Override
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
if( !super.onPartActivate( player, pos ) )
{
if( !player.isSneaking() )
{
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.side, this.getGui( player ) );
return true;
}
}
return false;
}
public GuiBridge getGui( EntityPlayer player )
{
return GuiBridge.GUI_ME;
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory()
{
try
{
return this.proxy.getStorage().getItemInventory();
}
catch( final GridAccessException e )
{
// err nope?
}
return null;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory()
{
try
{
return this.proxy.getStorage().getFluidInventory();
}
catch( final GridAccessException e )
{
// err nope?
}
return null;
}
@Override
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
}
@Override
public IInventory getViewCellStorage()
{
return this.viewCell;
}
@Override
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
{
this.host.markForSave();
}
}

View File

@ -39,17 +39,17 @@ import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public class PartConversionMonitor extends PartStorageMonitor
public class PartConversionMonitor extends AbstractPartMonitor
{
private static final CableBusTextures FRONT_BRIGHT_ICON = CableBusTextures.PartConversionMonitor_Bright;
private static final CableBusTextures FRONT_DARK_ICON = CableBusTextures.PartConversionMonitor_Dark;
private static final CableBusTextures FRONT_DARK_ICON_LOCKED = CableBusTextures.PartConversionMonitor_Dark_Locked;
private static final CableBusTextures FRONT_COLORED_ICON = CableBusTextures.PartConversionMonitor_Colored;
@Reflected
public PartConversionMonitor( ItemStack is )
{
super( is );
this.frontBright = CableBusTextures.PartConversionMonitor_Bright;
this.frontColored = CableBusTextures.PartConversionMonitor_Colored;
this.frontDark = CableBusTextures.PartConversionMonitor_Dark;
// frontSolid = CableBusTextures.PartConversionMonitor_Solid;
}
@Override
@ -88,31 +88,31 @@ public class PartConversionMonitor extends PartStorageMonitor
return false;
}
IEnergySource energy = this.proxy.getEnergy();
IMEMonitor<IAEItemStack> cell = this.proxy.getStorage().getItemInventory();
IAEItemStack input = AEItemStack.create( item );
final IEnergySource energy = this.proxy.getEnergy();
final IMEMonitor<IAEItemStack> cell = this.proxy.getStorage().getItemInventory();
final IAEItemStack input = AEItemStack.create( item );
if( ModeB )
{
for( int x = 0; x < player.inventory.getSizeInventory(); x++ )
{
ItemStack targetStack = player.inventory.getStackInSlot( x );
final ItemStack targetStack = player.inventory.getStackInSlot( x );
if( input.equals( targetStack ) )
{
IAEItemStack insertItem = input.copy();
final IAEItemStack insertItem = input.copy();
insertItem.setStackSize( targetStack.stackSize );
IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, insertItem, new PlayerSource( player, this ) );
final 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 ) );
final 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 )
catch( final GridAccessException e )
{
// :P
}
@ -123,7 +123,7 @@ public class PartConversionMonitor extends PartStorageMonitor
@Override
protected void extractItem( EntityPlayer player )
{
IAEItemStack input = (IAEItemStack) this.getDisplayed();
final IAEItemStack input = (IAEItemStack) this.getDisplayed();
if( input != null )
{
try
@ -133,22 +133,22 @@ public class PartConversionMonitor extends PartStorageMonitor
return;
}
IEnergySource energy = this.proxy.getEnergy();
IMEMonitor<IAEItemStack> cell = this.proxy.getStorage().getItemInventory();
final IEnergySource energy = this.proxy.getEnergy();
final IMEMonitor<IAEItemStack> cell = this.proxy.getStorage().getItemInventory();
ItemStack is = input.getItemStack();
final ItemStack is = input.getItemStack();
input.setStackSize( is.getMaxStackSize() );
IAEItemStack retrieved = Platform.poweredExtraction( energy, cell, input, new PlayerSource( player, this ) );
final IAEItemStack retrieved = Platform.poweredExtraction( energy, cell, input, new PlayerSource( player, this ) );
if( retrieved != null )
{
ItemStack newItems = retrieved.getItemStack();
InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player, EnumFacing.UP );
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player, EnumFacing.UP );
newItems = adaptor.addItems( newItems );
if( newItems != null )
{
TileEntity te = this.tile;
List<ItemStack> list = Collections.singletonList( newItems );
final TileEntity te = this.tile;
final List<ItemStack> list = Collections.singletonList( newItems );
Platform.spawnDrops( player.worldObj, te.getPos().offset( side.getFacing() ), list );
}
@ -158,10 +158,28 @@ public class PartConversionMonitor extends PartStorageMonitor
}
}
}
catch( GridAccessException e )
catch( final GridAccessException e )
{
// :P
}
}
}
@Override
public CableBusTextures getFrontBright()
{
return FRONT_BRIGHT_ICON;
}
@Override
public CableBusTextures getFrontColored()
{
return FRONT_COLORED_ICON;
}
@Override
public CableBusTextures getFrontDark()
{
return this.isLocked() ? FRONT_DARK_ICON_LOCKED : FRONT_DARK_ICON;
}
}

View File

@ -29,22 +29,20 @@ import appeng.client.texture.CableBusTextures;
import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
public class PartCraftingTerminal extends PartTerminal
public class PartCraftingTerminal extends AbstractPartTerminal
{
private static final CableBusTextures FRONT_BRIGHT_ICON = CableBusTextures.PartCraftingTerm_Bright;
private static final CableBusTextures FRONT_DARK_ICON = CableBusTextures.PartCraftingTerm_Dark;
private static final CableBusTextures FRONT_COLORED_ICON = CableBusTextures.PartCraftingTerm_Colored;
private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 );
@Reflected
public PartCraftingTerminal( ItemStack is )
{
super( is );
this.frontBright = CableBusTextures.PartCraftingTerm_Bright;
this.frontColored = CableBusTextures.PartCraftingTerm_Colored;
this.frontDark = CableBusTextures.PartCraftingTerm_Dark;
// frontSolid = CableBusTextures.PartCraftingTerm_Solid;
}
@Override
@ -52,7 +50,7 @@ public class PartCraftingTerminal extends PartTerminal
{
super.getDrops( drops, wrenched );
for( ItemStack is : this.craftingGrid )
for( final ItemStack is : this.craftingGrid )
{
if( is != null )
{
@ -95,12 +93,6 @@ public class PartCraftingTerminal extends PartTerminal
return GuiBridge.GUI_ME;
}
@Override
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
{
this.host.markForSave();
}
@Override
public IInventory getInventoryByName( String name )
{
@ -110,4 +102,22 @@ public class PartCraftingTerminal extends PartTerminal
}
return super.getInventoryByName( name );
}
@Override
public CableBusTextures getFrontBright()
{
return FRONT_BRIGHT_ICON;
}
@Override
public CableBusTextures getFrontColored()
{
return FRONT_COLORED_ICON;
}
@Override
public CableBusTextures getFrontDark()
{
return FRONT_DARK_ICON;
}
}

View File

@ -1,77 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.parts.reporting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.parts.IPartRenderHelper;
import appeng.client.render.IRenderHelper;
import appeng.client.texture.CableBusTextures;
public class PartDarkMonitor extends PartMonitor
{
public PartDarkMonitor( ItemStack is )
{
super( is, false );
this.notLightSource = false;
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, IRenderHelper renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), renderer.getIcon( is ), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.renderInventoryBox( renderer );
rh.setInvColor( this.getColor().mediumVariant );
rh.renderInventoryFace( this.frontBright.getIcon(), EnumFacing.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderInventoryBox( renderer );
}
@Override
@SideOnly( Side.CLIENT )
public void renderStatic( BlockPos pos, IPartRenderHelper rh, IRenderHelper renderer )
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), renderer.getIcon( is ), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( pos, renderer );
if( this.getLightLevel() > 0 )
{
int l = 13;
renderer.setBrightness( l << 20 | l << 4 );
}
renderer.setColorOpaque_I( this.getColor().mediumVariant );
rh.renderFace( pos, this.frontBright.getIcon(), EnumFacing.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( pos, renderer );
}
}

View File

@ -0,0 +1,41 @@
/*
* 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.parts.reporting;
import net.minecraft.item.ItemStack;
import appeng.helpers.Reflected;
public class PartDarkPanel extends AbstractPartPanel
{
@Reflected
public PartDarkPanel( ItemStack is )
{
super( is );
}
@Override
protected int getBrightnessColor()
{
return this.getColor().mediumVariant;
}
}

View File

@ -27,15 +27,15 @@ import appeng.core.sync.GuiBridge;
import appeng.util.Platform;
public class PartInterfaceTerminal extends PartMonitor
public class PartInterfaceTerminal extends AbstractPartDisplay
{
private static final CableBusTextures FRONT_BRIGHT_ICON = CableBusTextures.PartInterfaceTerm_Bright;
private static final CableBusTextures FRONT_DARK_ICON = CableBusTextures.PartInterfaceTerm_Dark;
private static final CableBusTextures FRONT_COLORED_ICON = CableBusTextures.PartInterfaceTerm_Colored;
public PartInterfaceTerminal( ItemStack is )
{
super( is, true );
this.frontBright = CableBusTextures.PartInterfaceTerm_Bright;
this.frontColored = CableBusTextures.PartInterfaceTerm_Colored;
this.frontDark = CableBusTextures.PartInterfaceTerm_Dark;
super( is );
}
@Override
@ -58,4 +58,22 @@ public class PartInterfaceTerminal extends PartMonitor
return false;
}
@Override
public CableBusTextures getFrontBright()
{
return FRONT_BRIGHT_ICON;
}
@Override
public CableBusTextures getFrontColored()
{
return FRONT_COLORED_ICON;
}
@Override
public CableBusTextures getFrontDark()
{
return FRONT_DARK_ICON;
}
}

View File

@ -1,374 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.parts.reporting;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
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.api.util.AEPartLocation;
import appeng.client.render.IRenderHelper;
import appeng.client.texture.CableBusTextures;
import appeng.me.GridAccessException;
import appeng.parts.AEBasePart;
import appeng.util.Platform;
public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChannelState
{
protected static final int POWERED_FLAG = 4;
protected static final int CHANNEL_FLAG = 16;
private static final int BOOTING_FLAG = 8;
// 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 );
byte spin = 0; // 0-3
int clientFlags = 0; // sent as byte.
float opacity = -1;
public PartMonitor( ItemStack is )
{
this( is, false );
}
protected PartMonitor( ItemStack is, boolean requireChannel )
{
super( is );
if( requireChannel )
{
this.proxy.setFlags( GridFlags.REQUIRE_CHANNEL );
this.proxy.setIdlePowerUsage( 1.0 / 2.0 );
}
else
{
this.proxy.setIdlePowerUsage( 1.0 / 16.0 ); // lights drain a little bit.
}
}
@MENetworkEventSubscribe
public void bootingRender( MENetworkBootingStatusChange c )
{
if( this.notLightSource )
{
this.getHost().markForUpdate();
}
}
@MENetworkEventSubscribe
public void powerRender( MENetworkPowerStatusChange c )
{
this.getHost().markForUpdate();
}
@Override
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 2, 2, 14, 14, 14, 16 );
bch.addBox( 4, 4, 13, 12, 12, 14 );
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, IRenderHelper renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), renderer.getIcon( is ), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.renderInventoryBox( renderer );
rh.setInvColor( this.getColor().whiteVariant );
rh.renderInventoryFace( this.frontBright.getIcon(), EnumFacing.SOUTH, renderer );
rh.setInvColor( this.getColor().mediumVariant );
rh.renderInventoryFace( this.frontDark.getIcon(), EnumFacing.SOUTH, renderer );
rh.setInvColor( this.getColor().blackVariant );
rh.renderInventoryFace( this.frontColored.getIcon(), EnumFacing.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderInventoryBox( renderer );
}
@Override
@SideOnly( Side.CLIENT )
public void renderStatic( BlockPos pos, IPartRenderHelper rh, IRenderHelper renderer )
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), renderer.getIcon( is ), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( pos, renderer );
if( this.getLightLevel() > 0 )
{
int l = 13;
renderer.setBrightness( l << 20 | l << 4 );
}
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this.spin;
renderer.setColorOpaque_I( this.getColor().whiteVariant );
rh.renderFace( pos, this.frontBright.getIcon(), EnumFacing.SOUTH, renderer );
renderer.setColorOpaque_I( this.getColor().mediumVariant );
rh.renderFace( pos, this.frontDark.getIcon(), EnumFacing.SOUTH, renderer );
renderer.setColorOpaque_I( this.getColor().blackVariant );
rh.renderFace( pos, this.frontColored.getIcon(), EnumFacing.SOUTH, renderer );
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
if( this.notLightSource )
{
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), renderer.getIcon( is ), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
}
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( pos, renderer );
if( this.notLightSource )
{
boolean hasChan = ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG );
boolean hasPower = ( this.clientFlags & this.POWERED_FLAG ) == this.POWERED_FLAG;
if( hasChan )
{
int l = 14;
renderer.setBrightness( l << 20 | l << 4 );
renderer.setColorOpaque_I( this.getColor().blackVariant );
}
else if( hasPower )
{
int l = 9;
renderer.setBrightness( l << 20 | l << 4 );
renderer.setColorOpaque_I( this.getColor().whiteVariant );
}
else
{
renderer.setBrightness( 0 );
renderer.setColorOpaque_I( 0x000000 );
}
rh.renderFace( pos, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), EnumFacing.EAST, renderer );
rh.renderFace( pos, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), EnumFacing.WEST, renderer );
rh.renderFace( pos, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), EnumFacing.UP, renderer );
rh.renderFace( pos, CableBusTextures.PartMonitorSidesStatusLights.getIcon(), EnumFacing.DOWN, renderer );
}
}
@Override
public void onNeighborChanged()
{
this.opacity = -1;
this.getHost().markForUpdate();
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
if( data.hasKey( "opacity" ) )
{
this.opacity = data.getFloat( "opacity" );
}
this.spin = data.getByte( "spin" );
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
data.setFloat( "opacity", this.opacity );
data.setByte( "spin", this.spin );
}
@Override
public void writeToStream( ByteBuf data ) throws IOException
{
super.writeToStream( data );
this.clientFlags = this.spin & 3;
try
{
if( this.proxy.getEnergy().isNetworkPowered() )
{
this.clientFlags |= this.POWERED_FLAG;
}
if( this.proxy.getPath().isNetworkBooting() )
{
this.clientFlags |= this.BOOTING_FLAG;
}
if( this.proxy.getNode().meetsChannelRequirements() )
{
this.clientFlags |= this.CHANNEL_FLAG;
}
}
catch( GridAccessException e )
{
// um.. nothing.
}
data.writeByte( (byte) this.clientFlags );
}
@Override
public boolean readFromStream( ByteBuf data ) throws IOException
{
super.readFromStream( data );
int oldFlags = this.clientFlags;
this.clientFlags = data.readByte();
this.spin = (byte) ( this.clientFlags & 3 );
if( this.clientFlags == oldFlags )
{
return false;
}
return true;
}
@Override
public int getLightLevel()
{
return this.blockLight( this.isPowered() ? ( this.notLightSource ? 9 : 15 ) : 0 );
}
@Override
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
TileEntity te = this.getTile();
if( !player.isSneaking() && Platform.isWrench( player, player.inventory.getCurrentItem(), te.getPos() ) )
{
if( Platform.isServer() )
{
if( this.spin > 3 )
{
this.spin = 0;
}
switch( this.spin )
{
case 0:
this.spin = 1;
break;
case 1:
this.spin = 3;
break;
case 2:
this.spin = 0;
break;
case 3:
this.spin = 2;
break;
}
this.host.markForUpdate();
this.saveChanges();
}
return true;
}
else
{
return super.onPartActivate( player, pos );
}
}
@Override
public void onPlacement( EntityPlayer player, ItemStack held, AEPartLocation side )
{
super.onPlacement( player, held, side );
byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 );
if( side == AEPartLocation.UP )
{
this.spin = rotation;
}
else if( side == AEPartLocation.DOWN )
{
this.spin = rotation;
}
}
private int blockLight( int emit )
{
if( this.opacity < 0 )
{
TileEntity te = this.getTile();
this.opacity = 255 - te.getWorld().getBlockLightOpacity( te.getPos().offset( side.getFacing() ) );
}
return (int) ( emit * ( this.opacity / 255.0f ) );
}
@Override
public boolean isPowered()
{
try
{
if( Platform.isServer() )
{
return this.proxy.getEnergy().isNetworkPowered();
}
else
{
return ( ( this.clientFlags & this.POWERED_FLAG ) == this.POWERED_FLAG );
}
}
catch( GridAccessException e )
{
return false;
}
}
@Override
public boolean isActive()
{
if( this.notLightSource )
{
return ( ( this.clientFlags & ( this.CHANNEL_FLAG | this.POWERED_FLAG ) ) == ( this.CHANNEL_FLAG | this.POWERED_FLAG ) );
}
else
{
return this.isPowered();
}
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.parts.reporting;
import net.minecraft.item.ItemStack;
import appeng.helpers.Reflected;
public class PartPanel extends AbstractPartPanel
{
@Reflected
public PartPanel( ItemStack is )
{
super( is );
}
@Override
protected int getBrightnessColor()
{
return this.getColor().whiteVariant;
}
}

View File

@ -35,8 +35,12 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
public class PartPatternTerminal extends PartTerminal
public class PartPatternTerminal extends AbstractPartTerminal
{
private static final CableBusTextures FRONT_BRIGHT_ICON = CableBusTextures.PartPatternTerm_Bright;
private static final CableBusTextures FRONT_DARK_ICON = CableBusTextures.PartPatternTerm_Dark;
private static final CableBusTextures FRONT_COLORED_ICON = CableBusTextures.PartPatternTerm_Colored;
private final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 );
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 3 );
private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
@ -47,16 +51,12 @@ public class PartPatternTerminal extends PartTerminal
public PartPatternTerminal( ItemStack is )
{
super( is );
this.frontBright = CableBusTextures.PartPatternTerm_Bright;
this.frontColored = CableBusTextures.PartPatternTerm_Colored;
this.frontDark = CableBusTextures.PartPatternTerm_Dark;
}
@Override
public void getDrops( List<ItemStack> drops, boolean wrenched )
{
for( ItemStack is : this.pattern )
for( final ItemStack is : this.pattern )
{
if( is != null )
{
@ -110,24 +110,24 @@ public class PartPatternTerminal extends PartTerminal
{
if( inv == this.pattern && slot == 1 )
{
ItemStack is = this.pattern.getStackInSlot( 1 );
final ItemStack is = this.pattern.getStackInSlot( 1 );
if( is != null && is.getItem() instanceof ICraftingPatternItem )
{
ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorld() );
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorld() );
if( details != null )
{
this.setCraftingRecipe( details.isCraftable() );
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
IAEItemStack item = details.getInputs()[x];
final IAEItemStack item = details.getInputs()[x];
this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
IAEItemStack item = details.getOutputs()[x];
final IAEItemStack item = details.getOutputs()[x];
this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
}
@ -147,7 +147,7 @@ public class PartPatternTerminal extends PartTerminal
{
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
ItemStack is = this.crafting.getStackInSlot( x );
final ItemStack is = this.crafting.getStackInSlot( x );
if( is != null )
{
is.stackSize = 1;
@ -187,4 +187,22 @@ public class PartPatternTerminal extends PartTerminal
return super.getInventoryByName( name );
}
@Override
public CableBusTextures getFrontBright()
{
return FRONT_BRIGHT_ICON;
}
@Override
public CableBusTextures getFrontColored()
{
return FRONT_COLORED_ICON;
}
@Override
public CableBusTextures getFrontDark()
{
return FRONT_DARK_ICON;
}
}

View File

@ -1,82 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.parts.reporting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.parts.IPartRenderHelper;
import appeng.client.render.IRenderHelper;
import appeng.client.texture.CableBusTextures;
public class PartSemiDarkMonitor extends PartMonitor
{
public PartSemiDarkMonitor( ItemStack is )
{
super( is, false );
this.notLightSource = false;
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( IPartRenderHelper rh, IRenderHelper renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), renderer.getIcon(is), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.renderInventoryBox( renderer );
int light = this.getColor().whiteVariant;
int dark = this.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( this.frontBright.getIcon(), EnumFacing.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderInventoryBox( renderer );
}
@Override
@SideOnly( Side.CLIENT )
public void renderStatic( BlockPos pos, IPartRenderHelper rh, IRenderHelper renderer )
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), renderer.getIcon(is), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( pos, renderer );
if( this.getLightLevel() > 0 )
{
int l = 13;
renderer.setBrightness( l << 20 | l << 4 );
}
int light = this.getColor().whiteVariant;
int dark = this.getColor().mediumVariant;
renderer.setColorOpaque( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2, ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2, ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 );
rh.renderFace( pos, this.frontBright.getIcon(), EnumFacing.SOUTH, renderer );
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( pos, renderer );
}
}

View File

@ -0,0 +1,43 @@
/*
* 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.parts.reporting;
import net.minecraft.item.ItemStack;
import appeng.helpers.Reflected;
public class PartSemiDarkPanel extends AbstractPartPanel
{
@Reflected
public PartSemiDarkPanel( ItemStack is )
{
super( is );
}
@Override
protected int getBrightnessColor()
{
final int light = this.getColor().whiteVariant;
final int dark = this.getColor().mediumVariant;
return ( ( ( ( ( light >> 16 ) & 0xff ) + ( ( dark >> 16 ) & 0xff ) ) / 2 ) << 16 ) | ( ( ( ( ( light >> 8 ) & 0xff ) + ( ( dark >> 8 ) & 0xff ) ) / 2 ) << 8 ) | ( ( ( ( light ) & 0xff ) + ( ( dark ) & 0xff ) ) / 2 );
}
}

View File

@ -19,50 +19,10 @@
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.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
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.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
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.api.util.AEPartLocation;
import appeng.client.ClientHelper;
import appeng.client.render.IRenderHelper;
import appeng.client.texture.CableBusTextures;
import appeng.core.AELog;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException;
import appeng.util.IWideReadableNumberConverter;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import appeng.util.item.AEItemStack;
/**
@ -71,360 +31,34 @@ import appeng.util.item.AEItemStack;
* @version rv2
* @since rv0
*/
public class PartStorageMonitor extends PartMonitor implements IPartStorageMonitor, IStackWatcherHost
public class PartStorageMonitor extends AbstractPartMonitor
{
private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE;
IAEItemStack configuredItem;
boolean isLocked;
IStackWatcher myWatcher;
@SideOnly( Side.CLIENT )
private boolean updateList;
@SideOnly( Side.CLIENT )
private Integer dspList;
private static final CableBusTextures FRONT_BRIGHT_ICON = CableBusTextures.PartStorageMonitor_Bright;
private static final CableBusTextures FRONT_DARK_ICON = CableBusTextures.PartStorageMonitor_Dark;
private static final CableBusTextures FRONT_COLORED_ICON = CableBusTextures.PartStorageMonitor_Colored;
private static final CableBusTextures FRONT_COLORED_ICON_LOCKED = CableBusTextures.PartStorageMonitor_Colored_Locked;
@Reflected
public PartStorageMonitor( ItemStack is )
{
super( is, true );
this.frontBright = CableBusTextures.PartStorageMonitor_Bright;
this.frontColored = CableBusTextures.PartStorageMonitor_Colored;
this.frontDark = CableBusTextures.PartStorageMonitor_Dark;
// frontSolid = CableBusTextures.PartStorageMonitor_Solid;
super( is );
}
@Override
public void readFromNBT( NBTTagCompound data )
public CableBusTextures getFrontBright()
{
super.readFromNBT( data );
this.isLocked = data.getBoolean( "isLocked" );
NBTTagCompound myItem = data.getCompoundTag( "configuredItem" );
this.configuredItem = AEItemStack.loadItemStackFromNBT( myItem );
return FRONT_BRIGHT_ICON;
}
@Override
public void writeToNBT( NBTTagCompound data )
public CableBusTextures getFrontColored()
{
super.writeToNBT( data );
data.setBoolean( "isLocked", this.isLocked );
NBTTagCompound myItem = new NBTTagCompound();
if( this.configuredItem != null )
{
this.configuredItem.writeToNBT( myItem );
}
data.setTag( "configuredItem", myItem );
return this.isLocked() ? FRONT_COLORED_ICON_LOCKED : FRONT_COLORED_ICON;
}
@Override
public void writeToStream( ByteBuf data ) throws IOException
public CableBusTextures getFrontDark()
{
super.writeToStream( data );
data.writeByte( this.spin );
data.writeBoolean( this.isLocked );
data.writeBoolean( this.configuredItem != null );
if( this.configuredItem != null )
{
this.configuredItem.writeToPacket( data );
}
}
@Override
public boolean readFromStream( ByteBuf data ) throws IOException
{
boolean stuff = super.readFromStream( data );
this.spin = data.readByte();
this.isLocked = data.readBoolean();
boolean val = data.readBoolean();
if( val )
{
this.configuredItem = AEItemStack.loadItemStackFromPacket( data );
}
else
{
this.configuredItem = null;
}
this.updateList = true;
return stuff;
}
@Override
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
if( Platform.isClient() )
{
return true;
}
if( !this.proxy.isActive() )
{
return false;
}
if( !Platform.hasPermissions( this.getLocation(), player ) )
{
return false;
}
TileEntity te = this.tile;
ItemStack eq = player.getCurrentEquippedItem();
if( Platform.isWrench( player, eq, te.getPos() ) )
{
this.isLocked = !this.isLocked;
player.addChatMessage( ( this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked ).get() );
this.getHost().markForUpdate();
}
else if( !this.isLocked )
{
this.configuredItem = AEItemStack.create( eq );
this.configureWatchers();
this.getHost().markForUpdate();
}
else
{
this.extractItem( player );
}
return true;
}
// update the system...
public void configureWatchers()
{
if( this.myWatcher != null )
{
this.myWatcher.clear();
}
try
{
if( this.configuredItem != null )
{
if( this.myWatcher != null )
{
this.myWatcher.add( this.configuredItem );
}
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
}
}
catch( GridAccessException e )
{
// >.>
}
}
protected void extractItem( EntityPlayer player )
{
}
private void updateReportingValue( IMEMonitor<IAEItemStack> itemInventory )
{
if( this.configuredItem != null )
{
IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem );
if( result == null )
{
this.configuredItem.setStackSize( 0 );
}
else
{
this.configuredItem.setStackSize( result.getStackSize() );
}
}
}
@Override
@SideOnly( Side.CLIENT )
protected void finalize() throws Throwable
{
super.finalize();
if( this.dspList != null )
{
GLAllocation.deleteDisplayLists( this.dspList );
}
}
@Override
@SideOnly( Side.CLIENT )
public void renderDynamic( double x, double y, double z, IPartRenderHelper rh, IRenderHelper renderer )
{
if( this.dspList == null )
{
this.dspList = GLAllocation.generateDisplayLists( 1 );
}
Tessellator tess = Tessellator.getInstance();
WorldRenderer wr = tess.getWorldRenderer();
if( ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) != ( this.POWERED_FLAG | this.CHANNEL_FLAG ) )
{
return;
}
IAEItemStack ais = (IAEItemStack) this.getDisplayed();
if( ais != null )
{
GL11.glPushMatrix();
GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 );
if( this.updateList )
{
this.updateList = false;
GL11.glNewList( this.dspList, GL11.GL_COMPILE_AND_EXECUTE );
wr.startDrawingQuads();
this.tesrRenderScreen( wr, ais );
tess.draw();
GL11.glEndList();
}
else
{
GL11.glCallList( this.dspList );
}
GL11.glPopMatrix();
}
}
@Override
public boolean requireDynamicRender()
{
return true;
}
@Override
public IAEStack getDisplayed()
{
return this.configuredItem;
}
private void tesrRenderScreen( WorldRenderer wr, IAEItemStack ais )
{
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
AEPartLocation d = this.side;
GL11.glTranslated( d.xOffset * 0.77, d.yOffset * 0.77, d.zOffset * 0.77 );
if( d == AEPartLocation.UP )
{
GL11.glScalef( 1.0f, -1.0f, 1.0f );
GL11.glRotatef( 90.0f, 1.0f, 0.0f, 0.0f );
GL11.glRotatef( this.spin * 90.0F, 0, 0, 1 );
}
if( d == AEPartLocation.DOWN )
{
GL11.glScalef( 1.0f, -1.0f, 1.0f );
GL11.glRotatef( -90.0f, 1.0f, 0.0f, 0.0f );
GL11.glRotatef( this.spin * -90.0F, 0, 0, 1 );
}
if( d == AEPartLocation.EAST )
{
GL11.glScalef( -1.0f, -1.0f, -1.0f );
GL11.glRotatef( -90.0f, 0.0f, 1.0f, 0.0f );
}
if( d == AEPartLocation.WEST )
{
GL11.glScalef( -1.0f, -1.0f, -1.0f );
GL11.glRotatef( 90.0f, 0.0f, 1.0f, 0.0f );
}
if( d == AEPartLocation.NORTH )
{
GL11.glScalef( -1.0f, -1.0f, -1.0f );
}
if( d == AEPartLocation.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();
wr.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
ClientHelper.proxy.doRenderItem( sis, this.tile.getWorld() );
}
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 );
final long stackSize = ais.getStackSize();
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize );
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
int width = fr.getStringWidth( renderedStackSize );
GL11.glTranslatef( -0.5f * width, 0.0f, -1.0f );
fr.drawString( renderedStackSize, 0, 0, 0 );
GL11.glPopAttrib();
}
@Override
public boolean isLocked()
{
return this.isLocked;
}
@Override
public void updateWatcher( IStackWatcher newWatcher )
{
this.myWatcher = newWatcher;
this.configureWatchers();
}
@Override
public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan )
{
if( this.configuredItem != null )
{
if( fullStack == null )
{
this.configuredItem.setStackSize( 0 );
}
else
{
this.configuredItem.setStackSize( fullStack.getStackSize() );
}
this.getHost().markForUpdate();
}
}
@Override
public boolean showNetworkInfo( MovingObjectPosition where )
{
return false;
return FRONT_DARK_ICON;
}
}

View File

@ -19,156 +19,38 @@
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
public class PartTerminal extends AbstractPartTerminal
{
final IConfigManager cm = new ConfigManager( this );
final AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 );
public PartTerminal( ItemStack is )
{
super( is, true );
super( is );
}
this.frontBright = CableBusTextures.PartTerminal_Bright;
this.frontColored = CableBusTextures.PartTerminal_Colored;
this.frontDark = CableBusTextures.PartTerminal_Dark;
// frontSolid = CableBusTextures.PartTerminal_Solid;
private static final CableBusTextures FRONT_BRIGHT_ICON = CableBusTextures.PartTerminal_Bright;
private static final CableBusTextures FRONT_DARK_ICON = CableBusTextures.PartTerminal_Dark;
private static final CableBusTextures FRONT_COLORED_ICON = CableBusTextures.PartTerminal_Colored;
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
@Override
public CableBusTextures getFrontBright()
{
return FRONT_BRIGHT_ICON;
}
@Override
public void getDrops( List<ItemStack> drops, boolean wrenched )
public CableBusTextures getFrontColored()
{
super.getDrops( drops, wrenched );
for( ItemStack is : this.viewCell )
{
if( is != null )
{
drops.add( is );
}
}
return FRONT_COLORED_ICON;
}
@Override
public IConfigManager getConfigManager()
public CableBusTextures getFrontDark()
{
return this.cm;
}
@Override
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.cm.readFromNBT( data );
this.viewCell.readFromNBT( data, "viewCell" );
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
this.cm.writeToNBT( data );
this.viewCell.writeToNBT( data, "viewCell" );
}
@Override
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
{
if( !super.onPartActivate( player, pos ) )
{
if( !player.isSneaking() )
{
if( Platform.isClient() )
{
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.side, this.getGui( player ) );
return true;
}
}
return false;
}
public GuiBridge getGui( EntityPlayer player )
{
return GuiBridge.GUI_ME;
}
@Override
public IMEMonitor getItemInventory()
{
try
{
return this.proxy.getStorage().getItemInventory();
}
catch( GridAccessException e )
{
// err nope?
}
return null;
}
@Override
public IMEMonitor getFluidInventory()
{
try
{
return this.proxy.getStorage().getFluidInventory();
}
catch( GridAccessException e )
{
// err nope?
}
return null;
}
@Override
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
}
@Override
public IInventory getViewCellStorage()
{
return this.viewCell;
}
@Override
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
{
this.host.markForSave();
return FRONT_DARK_ICON;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B