diff --git a/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java b/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java index 9ebe406c..980ba21e 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java @@ -45,7 +45,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; @@ -67,7 +67,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(); diff --git a/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java b/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java index 0dcd3b9d..17d2a3e9 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java +++ b/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java @@ -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; } diff --git a/src/main/java/appeng/client/texture/CableBusTextures.java b/src/main/java/appeng/client/texture/CableBusTextures.java index 33961702..5212468c 100644 --- a/src/main/java/appeng/client/texture/CableBusTextures.java +++ b/src/main/java/appeng/client/texture/CableBusTextures.java @@ -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" ), diff --git a/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java b/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java index f24c561f..2852226b 100644 --- a/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java +++ b/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java @@ -44,7 +44,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; @@ -67,7 +67,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 ); @@ -419,7 +419,6 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer } } - static class PatternInvSlot extends WrapperInvSlot { diff --git a/src/main/java/appeng/core/sync/GuiBridge.java b/src/main/java/appeng/core/sync/GuiBridge.java index 3161f0ea..f4048efb 100644 --- a/src/main/java/appeng/core/sync/GuiBridge.java +++ b/src/main/java/appeng/core/sync/GuiBridge.java @@ -100,7 +100,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; @@ -187,7 +188,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 ); diff --git a/src/main/java/appeng/items/parts/PartType.java b/src/main/java/appeng/items/parts/PartType.java index 92235659..a6cd1968 100644 --- a/src/main/java/appeng/items/parts/PartType.java +++ b/src/main/java/appeng/items/parts/PartType.java @@ -54,11 +54,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; @@ -111,11 +111,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 ), diff --git a/src/main/java/appeng/parts/AEBasePart.java b/src/main/java/appeng/parts/AEBasePart.java index 9fb4bc62..d71df56d 100644 --- a/src/main/java/appeng/parts/AEBasePart.java +++ b/src/main/java/appeng/parts/AEBasePart.java @@ -25,6 +25,8 @@ 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.RenderBlocks; @@ -85,6 +87,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( ForgeDirection.class ) ); @@ -139,7 +143,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, RenderBlocks renderer ) { @@ -189,7 +195,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, public String getCustomName() { return this.is.getDisplayName(); - } @Override + } + + @Override @SideOnly( Side.CLIENT ) public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer ) { @@ -208,10 +216,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, RenderBlocks renderer ) @@ -369,7 +373,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 ) diff --git a/src/main/java/appeng/parts/reporting/AbstractPartDisplay.java b/src/main/java/appeng/parts/reporting/AbstractPartDisplay.java new file mode 100644 index 00000000..80e056af --- /dev/null +++ b/src/main/java/appeng/parts/reporting/AbstractPartDisplay.java @@ -0,0 +1,154 @@ +/* + * 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 . + */ + +package appeng.parts.reporting; + + +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import appeng.api.parts.IPartRenderHelper; +import appeng.client.texture.CableBusTextures; + + +/** + * 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, RenderBlocks renderer ) + { + rh.setBounds( 2, 2, 14, 14, 14, 16 ); + + final IIcon sideTexture = CableBusTextures.PartMonitorSides.getIcon(); + final IIcon backTexture = CableBusTextures.PartMonitorBack.getIcon(); + + rh.setTexture( sideTexture, sideTexture, backTexture, this.is.getIconIndex(), sideTexture, sideTexture ); + rh.renderInventoryBox( renderer ); + + rh.setInvColor( this.getColor().whiteVariant ); + rh.renderInventoryFace( this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer ); + + rh.setInvColor( this.getColor().mediumVariant ); + rh.renderInventoryFace( this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer ); + + rh.setInvColor( this.getColor().blackVariant ); + rh.renderInventoryFace( this.getFrontColored().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 ) + { + this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); + + final IIcon sideTexture = CableBusTextures.PartMonitorSides.getIcon(); + final IIcon backTexture = CableBusTextures.PartMonitorBack.getIcon(); + + rh.setTexture( sideTexture, sideTexture, backTexture, this.is.getIconIndex(), sideTexture, sideTexture ); + + rh.setBounds( 2, 2, 14, 14, 14, 16 ); + rh.renderBlock( x, y, z, renderer ); + + if( this.getLightLevel() > 0 ) + { + final int l = 13; + Tessellator.instance.setBrightness( l << 20 | l << 4 ); + } + + renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this.getSpin(); + + Tessellator.instance.setColorOpaque_I( this.getColor().whiteVariant ); + rh.renderFace( x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer ); + + Tessellator.instance.setColorOpaque_I( this.getColor().mediumVariant ); + rh.renderFace( x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer ); + + Tessellator.instance.setColorOpaque_I( this.getColor().blackVariant ); + rh.renderFace( x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer ); + + renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; + + final IIcon sideStatusTexture = CableBusTextures.PartMonitorSidesStatus.getIcon(); + + rh.setTexture( sideStatusTexture, sideStatusTexture, backTexture, this.is.getIconIndex(), sideStatusTexture, sideStatusTexture ); + + rh.setBounds( 4, 4, 13, 12, 12, 14 ); + rh.renderBlock( x, y, z, 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; + Tessellator.instance.setBrightness( l << 20 | l << 4 ); + Tessellator.instance.setColorOpaque_I( this.getColor().blackVariant ); + } + else if( hasPower ) + { + final int l = 9; + Tessellator.instance.setBrightness( l << 20 | l << 4 ); + Tessellator.instance.setColorOpaque_I( this.getColor().whiteVariant ); + } + else + { + Tessellator.instance.setBrightness( 0 ); + Tessellator.instance.setColorOpaque_I( 0x000000 ); + } + + final IIcon sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon(); + + rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.EAST, renderer ); + rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.WEST, renderer ); + rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.UP, renderer ); + rh.renderFace( x, y, z, sideStatusLightTexture, ForgeDirection.DOWN, renderer ); + } + + @Override + public boolean isLightSource() + { + return false; + } + +} diff --git a/src/main/java/appeng/parts/reporting/AbstractPartMonitor.java b/src/main/java/appeng/parts/reporting/AbstractPartMonitor.java new file mode 100644 index 00000000..ed4f23f6 --- /dev/null +++ b/src/main/java/appeng/parts/reporting/AbstractPartMonitor.java @@ -0,0 +1,429 @@ +/* + * 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 . + */ + +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.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 cpw.mods.fml.relauncher.Side; +import cpw.mods.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.client.ClientHelper; +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.xCoord, te.yCoord, te.zCoord ) ) + { + 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 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, RenderBlocks renderer ) + { + if( this.dspList == null ) + { + this.dspList = GLAllocation.generateDisplayLists( 1 ); + } + + final Tessellator tess = Tessellator.instance; + + 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( tess, 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( Tessellator tess, IAEItemStack ais ) + { + // GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); + + final ForgeDirection d = this.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( this.getSpin() * 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( this.getSpin() * -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 + { + 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(); + tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f ); + + ClientHelper.proxy.doRenderItem( sis, this.tile.getWorldObj() ); + } + 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().fontRenderer; + 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; + } +} diff --git a/src/main/java/appeng/parts/reporting/AbstractPartPanel.java b/src/main/java/appeng/parts/reporting/AbstractPartPanel.java new file mode 100644 index 00000000..3e70a867 --- /dev/null +++ b/src/main/java/appeng/parts/reporting/AbstractPartPanel.java @@ -0,0 +1,133 @@ +/* + * 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 . + */ + +package appeng.parts.reporting; + + +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import appeng.api.parts.IPartRenderHelper; +import appeng.api.util.AEColor; +import appeng.client.texture.CableBusTextures; + + +/** + * 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, RenderBlocks renderer ) + { + rh.setBounds( 2, 2, 14, 14, 14, 16 ); + + final IIcon sideTexture = CableBusTextures.PartMonitorSides.getIcon(); + final IIcon backTexture = CableBusTextures.PartMonitorBack.getIcon(); + + rh.setTexture( sideTexture, sideTexture, backTexture, this.is.getIconIndex(), sideTexture, sideTexture ); + rh.renderInventoryBox( renderer ); + + rh.setInvColor( this.getBrightnessColor() ); + rh.renderInventoryFace( this.getFrontBright().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 ) + { + final IIcon sideTexture = CableBusTextures.PartMonitorSides.getIcon(); + final IIcon backTexture = CableBusTextures.PartMonitorBack.getIcon(); + + rh.setTexture( sideTexture, sideTexture, backTexture, this.is.getIconIndex(), sideTexture, sideTexture ); + + rh.setBounds( 2, 2, 14, 14, 14, 16 ); + rh.renderBlock( x, y, z, renderer ); + + if( this.getLightLevel() > 0 ) + { + final int l = 13; + Tessellator.instance.setBrightness( l << 20 | l << 4 ); + } + + Tessellator.instance.setColorOpaque_I( this.getBrightnessColor() ); + rh.renderFace( x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer ); + + rh.setBounds( 4, 4, 13, 12, 12, 14 ); + rh.renderBlock( x, y, z, 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(); + +} diff --git a/src/main/java/appeng/parts/reporting/AbstractPartReporting.java b/src/main/java/appeng/parts/reporting/AbstractPartReporting.java new file mode 100644 index 00000000..b5ec5507 --- /dev/null +++ b/src/main/java/appeng/parts/reporting/AbstractPartReporting.java @@ -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 . + */ + +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 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.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.xCoord, te.yCoord, te.zCoord ) ) + { + 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, ForgeDirection side ) + { + super.onPlacement( player, held, side ); + + final byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 ); + if( side == ForgeDirection.UP ) + { + this.spin = rotation; + } + else if( side == ForgeDirection.DOWN ) + { + this.spin = rotation; + } + } + + private final int blockLight( int emit ) + { + if( this.opacity < 0 ) + { + final TileEntity te = this.getTile(); + this.opacity = 255 - te.getWorldObj().getBlockLightOpacity( te.xCoord + this.side.offsetX, te.yCoord + this.side.offsetY, te.zCoord + this.side.offsetZ ); + } + + 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(); + +} diff --git a/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java b/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java new file mode 100644 index 00000000..22c184c8 --- /dev/null +++ b/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java @@ -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 . + */ + +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 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 getItemInventory() + { + try + { + return this.proxy.getStorage().getItemInventory(); + } + catch( final GridAccessException e ) + { + // err nope? + } + return null; + } + + @Override + public IMEMonitor 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(); + } +} diff --git a/src/main/java/appeng/parts/reporting/PartConversionMonitor.java b/src/main/java/appeng/parts/reporting/PartConversionMonitor.java index 738cf63a..e0137135 100644 --- a/src/main/java/appeng/parts/reporting/PartConversionMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartConversionMonitor.java @@ -40,17 +40,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 @@ -89,31 +89,31 @@ public class PartConversionMonitor extends PartStorageMonitor return false; } - IEnergySource energy = this.proxy.getEnergy(); - IMEMonitor cell = this.proxy.getStorage().getItemInventory(); - IAEItemStack input = AEItemStack.create( item ); + final IEnergySource energy = this.proxy.getEnergy(); + final IMEMonitor 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 } @@ -124,7 +124,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 @@ -134,22 +134,22 @@ public class PartConversionMonitor extends PartStorageMonitor return; } - IEnergySource energy = this.proxy.getEnergy(); - IMEMonitor cell = this.proxy.getStorage().getItemInventory(); + final IEnergySource energy = this.proxy.getEnergy(); + final IMEMonitor 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, ForgeDirection.UNKNOWN ); + final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN ); newItems = adaptor.addItems( newItems ); if( newItems != null ) { - TileEntity te = this.tile; - List list = Collections.singletonList( newItems ); + final TileEntity te = this.tile; + final List list = Collections.singletonList( newItems ); Platform.spawnDrops( player.worldObj, te.xCoord + this.side.offsetX, te.yCoord + this.side.offsetY, te.zCoord + this.side.offsetZ, list ); } @@ -159,10 +159,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; + } } diff --git a/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java b/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java index f58ed834..9270d32a 100644 --- a/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java @@ -30,22 +30,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 @@ -53,7 +51,7 @@ public class PartCraftingTerminal extends PartTerminal { super.getDrops( drops, wrenched ); - for( ItemStack is : this.craftingGrid ) + for( final ItemStack is : this.craftingGrid ) { if( is != null ) { @@ -96,12 +94,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 ) { @@ -111,4 +103,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; + } } diff --git a/src/main/java/appeng/parts/reporting/PartDarkMonitor.java b/src/main/java/appeng/parts/reporting/PartDarkMonitor.java deleted file mode 100644 index 800e49df..00000000 --- a/src/main/java/appeng/parts/reporting/PartDarkMonitor.java +++ /dev/null @@ -1,79 +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 . - */ - -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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import appeng.api.parts.IPartRenderHelper; -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, RenderBlocks renderer ) - { - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); - rh.renderInventoryBox( renderer ); - - rh.setInvColor( this.getColor().mediumVariant ); - rh.renderInventoryFace( this.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(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); - - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.renderBlock( x, y, z, renderer ); - - if( this.getLightLevel() > 0 ) - { - int l = 13; - Tessellator.instance.setBrightness( l << 20 | l << 4 ); - } - - Tessellator.instance.setColorOpaque_I( this.getColor().mediumVariant ); - rh.renderFace( x, y, z, this.frontBright.getIcon(), ForgeDirection.SOUTH, renderer ); - - rh.setBounds( 4, 4, 13, 12, 12, 14 ); - rh.renderBlock( x, y, z, renderer ); - } -} diff --git a/src/main/java/appeng/parts/reporting/PartDarkPanel.java b/src/main/java/appeng/parts/reporting/PartDarkPanel.java new file mode 100644 index 00000000..feea7196 --- /dev/null +++ b/src/main/java/appeng/parts/reporting/PartDarkPanel.java @@ -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 . + */ + +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; + } +} diff --git a/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java b/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java index 6726c60a..6a3d9b5b 100644 --- a/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java @@ -28,15 +28,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 @@ -59,4 +59,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; + } } diff --git a/src/main/java/appeng/parts/reporting/PartMonitor.java b/src/main/java/appeng/parts/reporting/PartMonitor.java deleted file mode 100644 index cce90262..00000000 --- a/src/main/java/appeng/parts/reporting/PartMonitor.java +++ /dev/null @@ -1,377 +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 . - */ - -package appeng.parts.reporting; - - -import java.io.IOException; - -import io.netty.buffer.ByteBuf; - -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 cpw.mods.fml.relauncher.Side; -import cpw.mods.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.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, RenderBlocks renderer ) - { - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); - rh.renderInventoryBox( renderer ); - - rh.setInvColor( this.getColor().whiteVariant ); - rh.renderInventoryFace( this.frontBright.getIcon(), ForgeDirection.SOUTH, renderer ); - - rh.setInvColor( this.getColor().mediumVariant ); - rh.renderInventoryFace( this.frontDark.getIcon(), ForgeDirection.SOUTH, renderer ); - - rh.setInvColor( this.getColor().blackVariant ); - rh.renderInventoryFace( this.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 ) - { - this.renderCache = rh.useSimplifiedRendering( x, y, z, this, this.renderCache ); - - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); - - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.renderBlock( x, y, z, renderer ); - - if( this.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( this.getColor().whiteVariant ); - rh.renderFace( x, y, z, this.frontBright.getIcon(), ForgeDirection.SOUTH, renderer ); - - Tessellator.instance.setColorOpaque_I( this.getColor().mediumVariant ); - rh.renderFace( x, y, z, this.frontDark.getIcon(), ForgeDirection.SOUTH, renderer ); - - Tessellator.instance.setColorOpaque_I( this.getColor().blackVariant ); - rh.renderFace( x, y, z, this.frontColored.getIcon(), ForgeDirection.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(), this.is.getIconIndex(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() ); - } - - rh.setBounds( 4, 4, 13, 12, 12, 14 ); - rh.renderBlock( x, y, z, 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; - Tessellator.instance.setBrightness( l << 20 | l << 4 ); - Tessellator.instance.setColorOpaque_I( this.getColor().blackVariant ); - } - else if( hasPower ) - { - int l = 9; - Tessellator.instance.setBrightness( l << 20 | l << 4 ); - Tessellator.instance.setColorOpaque_I( this.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 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.xCoord, te.yCoord, te.zCoord ) ) - { - 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, ForgeDirection side ) - { - super.onPlacement( player, held, side ); - - byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 ); - if( side == ForgeDirection.UP ) - { - this.spin = rotation; - } - else if( side == ForgeDirection.DOWN ) - { - this.spin = rotation; - } - } - - private int blockLight( int emit ) - { - if( this.opacity < 0 ) - { - TileEntity te = this.getTile(); - this.opacity = 255 - te.getWorldObj().getBlockLightOpacity( te.xCoord + this.side.offsetX, te.yCoord + this.side.offsetY, te.zCoord + this.side.offsetZ ); - } - - 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(); - } - } -} diff --git a/src/main/java/appeng/parts/reporting/PartPanel.java b/src/main/java/appeng/parts/reporting/PartPanel.java new file mode 100644 index 00000000..3e0f796b --- /dev/null +++ b/src/main/java/appeng/parts/reporting/PartPanel.java @@ -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 . + */ + +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; + } + +} diff --git a/src/main/java/appeng/parts/reporting/PartPatternTerminal.java b/src/main/java/appeng/parts/reporting/PartPatternTerminal.java index a4972407..36d9827c 100644 --- a/src/main/java/appeng/parts/reporting/PartPatternTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartPatternTerminal.java @@ -36,8 +36,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 ); @@ -48,16 +52,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 drops, boolean wrenched ) { - for( ItemStack is : this.pattern ) + for( final ItemStack is : this.pattern ) { if( is != null ) { @@ -111,24 +111,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().getWorldObj() ); + final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem(); + final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() ); 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() ); } } @@ -148,7 +148,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; @@ -188,4 +188,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; + } } diff --git a/src/main/java/appeng/parts/reporting/PartSemiDarkMonitor.java b/src/main/java/appeng/parts/reporting/PartSemiDarkMonitor.java deleted file mode 100644 index b803d835..00000000 --- a/src/main/java/appeng/parts/reporting/PartSemiDarkMonitor.java +++ /dev/null @@ -1,84 +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 . - */ - -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 cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import appeng.api.parts.IPartRenderHelper; -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, RenderBlocks renderer ) - { - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - - rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.is.getIconIndex(), 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(), 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(), this.is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); - - rh.setBounds( 2, 2, 14, 14, 14, 16 ); - rh.renderBlock( x, y, z, renderer ); - - if( this.getLightLevel() > 0 ) - { - int l = 13; - Tessellator.instance.setBrightness( l << 20 | l << 4 ); - } - - int light = this.getColor().whiteVariant; - int dark = this.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, this.frontBright.getIcon(), ForgeDirection.SOUTH, renderer ); - - rh.setBounds( 4, 4, 13, 12, 12, 14 ); - rh.renderBlock( x, y, z, renderer ); - } -} diff --git a/src/main/java/appeng/parts/reporting/PartSemiDarkPanel.java b/src/main/java/appeng/parts/reporting/PartSemiDarkPanel.java new file mode 100644 index 00000000..060522a3 --- /dev/null +++ b/src/main/java/appeng/parts/reporting/PartSemiDarkPanel.java @@ -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 . + */ + +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 ); + } +} diff --git a/src/main/java/appeng/parts/reporting/PartStorageMonitor.java b/src/main/java/appeng/parts/reporting/PartStorageMonitor.java index f49a4948..50d30b80 100644 --- a/src/main/java/appeng/parts/reporting/PartStorageMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartStorageMonitor.java @@ -19,50 +19,10 @@ 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.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 cpw.mods.fml.relauncher.Side; -import cpw.mods.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.client.ClientHelper; 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,357 +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.xCoord, te.yCoord, te.zCoord ) ) - { - 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 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, RenderBlocks renderer ) - { - if( this.dspList == null ) - { - this.dspList = GLAllocation.generateDisplayLists( 1 ); - } - - Tessellator tess = Tessellator.instance; - - 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 ); - this.tesrRenderScreen( tess, 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( Tessellator tess, IAEItemStack ais ) - { - GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); - ForgeDirection d = this.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( this.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( this.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 ); - - final long stackSize = ais.getStackSize(); - final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize ); - - FontRenderer fr = Minecraft.getMinecraft().fontRenderer; - 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; } } diff --git a/src/main/java/appeng/parts/reporting/PartTerminal.java b/src/main/java/appeng/parts/reporting/PartTerminal.java index efcfdc90..e16de395 100644 --- a/src/main/java/appeng/parts/reporting/PartTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartTerminal.java @@ -19,157 +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 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; } } diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/PartConversionMonitor_Dark_Locked.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/PartConversionMonitor_Dark_Locked.png new file mode 100644 index 00000000..6fa4085e Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/PartConversionMonitor_Dark_Locked.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/PartStorageMonitor_Colored_Locked.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/PartStorageMonitor_Colored_Locked.png new file mode 100644 index 00000000..6fa4085e Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/PartStorageMonitor_Colored_Locked.png differ