diff --git a/client/gui/implementations/GuiCraftConfirm.java b/client/gui/implementations/GuiCraftConfirm.java index 4a09daa61..a80f180cf 100644 --- a/client/gui/implementations/GuiCraftConfirm.java +++ b/client/gui/implementations/GuiCraftConfirm.java @@ -110,7 +110,16 @@ public class GuiCraftConfirm extends AEBaseGui { String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic; if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() ) - btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + ccc.selectedCpu; + { + if ( ccc.myName.length() > 0 ) + { + String name = ccc.myName.substring( 0, Math.min( 20, ccc.myName.length() ) ); + btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name; + } + else + btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + ccc.selectedCpu; + } + if ( ccc.noCPU ) btnTextText = GuiText.NoCraftingCPUs.getLocal(); diff --git a/client/gui/implementations/GuiCraftingCPU.java b/client/gui/implementations/GuiCraftingCPU.java index b0d18611a..cf4241b90 100644 --- a/client/gui/implementations/GuiCraftingCPU.java +++ b/client/gui/implementations/GuiCraftingCPU.java @@ -244,7 +244,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource @Override public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { - fontRendererObj.drawString( GuiText.CraftingStatus.getLocal(), 8, 7, 4210752 ); + fontRendererObj.drawString( getGuiDisplayName( GuiText.CraftingStatus.getLocal() ), 8, 7, 4210752 ); int sectionLength = 67; diff --git a/container/AEBaseContainer.java b/container/AEBaseContainer.java index 1183dec19..eba39e96f 100644 --- a/container/AEBaseContainer.java +++ b/container/AEBaseContainer.java @@ -578,7 +578,7 @@ public abstract class AEBaseContainer extends Container { if ( syncData.containsKey( idx ) ) { - syncData.get( idx ).update( value ); + syncData.get( idx ).update( (long) value ); return; } @@ -588,13 +588,22 @@ public abstract class AEBaseContainer extends Container { if ( syncData.containsKey( idx ) ) { - syncData.get( idx ).update( value ); + syncData.get( idx ).update( (long) value ); return; } updateProgressBar( idx, (int) value ); } + public void stringSync(int idx, String value) + { + if ( syncData.containsKey( idx ) ) + { + syncData.get( idx ).update( value ); + return; + } + } + private void prepareSync() { for (Field f : getClass().getFields()) @@ -625,6 +634,12 @@ public abstract class AEBaseContainer extends Container if ( tileEntity instanceof ICustomNameObject ) name = (ICustomNameObject) tileEntity; + if ( obj instanceof ICustomNameObject ) + name = (ICustomNameObject) obj; + + if ( this instanceof ICustomNameObject ) + name = (ICustomNameObject) this; + if ( name != null ) { if ( name.hasCustomName() ) @@ -1055,4 +1070,5 @@ public abstract class AEBaseContainer extends Container { } + } diff --git a/container/guisync/SyncDat.java b/container/guisync/SyncDat.java index e3d5abc9e..d06eb3e01 100644 --- a/container/guisync/SyncDat.java +++ b/container/guisync/SyncDat.java @@ -10,6 +10,7 @@ import appeng.container.AEBaseContainer; import appeng.core.AELog; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketProgressBar; +import appeng.core.sync.packets.PacketValueConfig; public class SyncDat { @@ -59,12 +60,15 @@ public class SyncDat } } - public void update(long val) + public void update(Object val) { try { Object oldValue = field.get( source ); - updateValue( oldValue, val ); + if ( val instanceof String ) + updateString( oldValue, (String) val ); + else + updateValue( oldValue, (Long) val ); } catch (IllegalArgumentException e) { @@ -77,6 +81,22 @@ public class SyncDat } + private void updateString(Object oldValue, String val) + { + try + { + field.set( source, val ); + } + catch (IllegalArgumentException e) + { + AELog.error( e ); + } + catch (IllegalAccessException e) + { + AELog.error( e ); + } + } + private void updateValue(Object oldValue, long val) { try @@ -123,7 +143,12 @@ public class SyncDat private void send(ICrafting o, Object val) throws IOException { - if ( field.getType().isEnum() ) + if ( val instanceof String ) + { + if ( o instanceof EntityPlayerMP ) + NetworkHandler.instance.sendTo( new PacketValueConfig( "SyncDat." + channel, (String) val ), (EntityPlayerMP) o ); + } + else if ( field.getType().isEnum() ) { o.sendProgressBarUpdate( source, channel, ((Enum) val).ordinal() ); } diff --git a/container/implementations/ContainerCraftConfirm.java b/container/implementations/ContainerCraftConfirm.java index 1026f3b00..596bbd582 100644 --- a/container/implementations/ContainerCraftConfirm.java +++ b/container/implementations/ContainerCraftConfirm.java @@ -71,6 +71,9 @@ public class ContainerCraftConfirm extends AEBaseContainer @GuiSync(6) public boolean noCPU = true; + @GuiSync(7) + public String myName = ""; + protected long cpuIdx = Long.MIN_VALUE; public class CraftingCPURecord implements Comparable @@ -82,10 +85,13 @@ public class ContainerCraftConfirm extends AEBaseContainer long size; int processors; + public String myName; + CraftingCPURecord(long size, int proc, ICraftingCPU server) { this.size = size; this.processors = proc; this.cpu = server; + myName = server.getName(); } @Override @@ -115,9 +121,11 @@ public class ContainerCraftConfirm extends AEBaseContainer selectedCpu = -1; cpuBytesAvail = 0; cpuCoProcessors = 0; + myName = ""; } else if ( selectedCpu != -1 ) { + myName = cpus.get( selectedCpu ).myName; cpuBytesAvail = cpus.get( selectedCpu ).size; cpuCoProcessors = cpus.get( selectedCpu ).processors; } @@ -139,9 +147,11 @@ public class ContainerCraftConfirm extends AEBaseContainer { cpuBytesAvail = 0; cpuCoProcessors = 0; + myName = ""; } else { + myName = cpus.get( selectedCpu ).myName; cpuBytesAvail = cpus.get( selectedCpu ).size; cpuCoProcessors = cpus.get( selectedCpu ).processors; } diff --git a/container/implementations/ContainerCraftingCPU.java b/container/implementations/ContainerCraftingCPU.java index 70424ae17..9c2417e5e 100644 --- a/container/implementations/ContainerCraftingCPU.java +++ b/container/implementations/ContainerCraftingCPU.java @@ -20,15 +20,17 @@ import appeng.api.storage.data.IItemList; import appeng.container.AEBaseContainer; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketMEInventoryUpdate; +import appeng.helpers.ICustomNameObject; import appeng.me.cluster.IAECluster; import appeng.me.cluster.implementations.CraftingCPUCluster; import appeng.tile.crafting.TileCraftingTile; import appeng.util.Platform; -public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorHandlerReceiver +public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorHandlerReceiver, ICustomNameObject { CraftingCPUCluster monitor = null; + String cpuName = null; IGrid network; IItemList list = AEApi.instance().storage().createItemList(); @@ -49,6 +51,8 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH IAECluster c = ((TileCraftingTile) te).getCluster(); if ( c instanceof CraftingCPUCluster ) { + cpuName = ((CraftingCPUCluster) c).getName(); + monitor = (CraftingCPUCluster) c; if ( monitor != null ) { @@ -162,4 +166,16 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH { } + + @Override + public String getCustomName() + { + return cpuName; + } + + @Override + public boolean hasCustomName() + { + return cpuName != null && cpuName.length() > 0; + } } diff --git a/core/sync/packets/PacketValueConfig.java b/core/sync/packets/PacketValueConfig.java index eeef39d4e..fdec8a56f 100644 --- a/core/sync/packets/PacketValueConfig.java +++ b/core/sync/packets/PacketValueConfig.java @@ -186,6 +186,10 @@ public class PacketValueConfig extends AppEngPacket { ((AEBaseContainer) c).customName = Value; } + else if ( Name.startsWith( "SyncDat." ) ) + { + ((AEBaseContainer) c).stringSync( Integer.parseInt( Name.substring( 8 ) ), Value ); + } else if ( c instanceof IConfigureableObject ) { IConfigManager cm = ((IConfigureableObject) c).getConfigManager(); diff --git a/me/cluster/implementations/CraftingCPUCluster.java b/me/cluster/implementations/CraftingCPUCluster.java index b3da25ad1..d6ddc44f2 100644 --- a/me/cluster/implementations/CraftingCPUCluster.java +++ b/me/cluster/implementations/CraftingCPUCluster.java @@ -83,6 +83,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public ICraftingLink myLastLink; MachineSource machineSrc = null; + public String myName = ""; int accelerator = 0; public WorldCoord min; @@ -244,7 +245,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU te.isCoreBlock = false; te.markDirty(); - tiles.add( te ); + tiles.push( te ); if ( te.isStorage() ) { @@ -995,6 +996,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU } updateCPU(); + updateName(); } @Override @@ -1003,4 +1005,27 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU return machineSrc; } + @Override + public String getName() + { + return myName; + } + + public void updateName() + { + myName = ""; + for (TileCraftingTile te : tiles) + { + + if ( te.hasCustomName() ) + { + if ( myName.length() > 0 ) + myName += " " + te.getCustomName(); + else + myName = te.getCustomName(); + } + + } + } + } diff --git a/tile/crafting/TileCraftingTile.java b/tile/crafting/TileCraftingTile.java index 47adc0f85..ec51caac4 100644 --- a/tile/crafting/TileCraftingTile.java +++ b/tile/crafting/TileCraftingTile.java @@ -72,6 +72,13 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP calc.calculateMultiblock( worldObj, getLocation() ); } + public void setName(String name) + { + super.setName( name ); + if ( clust != null ) + clust.updateName(); + } + private class CraftingHandler extends AETileEventHandler {