Nameable CPUs.

This commit is contained in:
AlgorithmX2
2014-07-15 22:26:12 -05:00
parent e64bf91789
commit e49864e295
9 changed files with 121 additions and 9 deletions
+28 -3
View File
@@ -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() );
}