2013-12-22 07:49:55 +01:00
|
|
|
package mekanism.common.network;
|
|
|
|
|
2014-08-01 01:58:12 +02:00
|
|
|
import mekanism.api.MekanismConfig.general;
|
|
|
|
import mekanism.api.MekanismConfig.usage;
|
2014-08-01 02:55:01 +02:00
|
|
|
import mekanism.api.util.EnergyUtils.EnergyType;
|
2013-12-22 07:49:55 +01:00
|
|
|
import mekanism.common.Mekanism;
|
2014-08-10 04:20:49 +02:00
|
|
|
import mekanism.common.base.IModule;
|
2014-06-11 11:57:49 +02:00
|
|
|
import mekanism.common.network.PacketConfigSync.ConfigSyncMessage;
|
2014-09-03 20:00:03 +02:00
|
|
|
|
2014-06-11 11:57:49 +02:00
|
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
|
|
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
2013-12-22 07:49:55 +01:00
|
|
|
|
2014-09-03 20:00:03 +02:00
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
|
2014-06-11 11:57:49 +02:00
|
|
|
public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMessage>
|
2013-12-22 07:49:55 +01:00
|
|
|
{
|
2014-06-02 17:33:19 +02:00
|
|
|
@Override
|
2014-06-11 11:57:49 +02:00
|
|
|
public IMessage onMessage(ConfigSyncMessage message, MessageContext context)
|
2014-03-08 02:00:25 +01:00
|
|
|
{
|
2014-06-11 11:57:49 +02:00
|
|
|
return null;
|
2013-12-22 07:49:55 +01:00
|
|
|
}
|
2014-06-11 11:57:49 +02:00
|
|
|
|
|
|
|
public static class ConfigSyncMessage implements IMessage
|
2014-04-20 22:15:44 +02:00
|
|
|
{
|
2014-06-11 11:57:49 +02:00
|
|
|
public ConfigSyncMessage() {}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void toBytes(ByteBuf dataStream)
|
2014-06-02 17:33:19 +02:00
|
|
|
{
|
2014-08-01 01:58:12 +02:00
|
|
|
dataStream.writeBoolean(general.updateNotifications);
|
|
|
|
dataStream.writeBoolean(general.controlCircuitOreDict);
|
|
|
|
dataStream.writeBoolean(general.logPackets);
|
|
|
|
dataStream.writeBoolean(general.dynamicTankEasterEgg);
|
|
|
|
dataStream.writeBoolean(general.voiceServerEnabled);
|
|
|
|
dataStream.writeBoolean(general.cardboardSpawners);
|
|
|
|
dataStream.writeBoolean(general.creativeOverrideElectricChest);
|
|
|
|
dataStream.writeBoolean(general.spawnBabySkeletons);
|
|
|
|
dataStream.writeInt(general.obsidianTNTDelay);
|
|
|
|
dataStream.writeInt(general.obsidianTNTBlastRadius);
|
|
|
|
dataStream.writeInt(general.UPDATE_DELAY);
|
|
|
|
dataStream.writeDouble(general.FROM_IC2);
|
|
|
|
dataStream.writeDouble(general.TO_IC2);
|
|
|
|
dataStream.writeDouble(general.FROM_BC);
|
|
|
|
dataStream.writeDouble(general.TO_BC);
|
|
|
|
dataStream.writeDouble(general.FROM_H2);
|
|
|
|
dataStream.writeDouble(general.ENERGY_PER_REDSTONE);
|
|
|
|
dataStream.writeInt(general.VOICE_PORT);
|
|
|
|
dataStream.writeInt(general.maxUpgradeMultiplier);
|
|
|
|
dataStream.writeInt(general.activeType.ordinal());
|
2014-06-11 11:57:49 +02:00
|
|
|
|
2014-08-01 01:58:12 +02:00
|
|
|
dataStream.writeDouble(usage.enrichmentChamberUsage);
|
|
|
|
dataStream.writeDouble(usage.osmiumCompressorUsage);
|
|
|
|
dataStream.writeDouble(usage.combinerUsage);
|
|
|
|
dataStream.writeDouble(usage.crusherUsage);
|
|
|
|
dataStream.writeDouble(usage.factoryUsage);
|
|
|
|
dataStream.writeDouble(usage.metallurgicInfuserUsage);
|
|
|
|
dataStream.writeDouble(usage.purificationChamberUsage);
|
|
|
|
dataStream.writeDouble(usage.energizedSmelterUsage);
|
|
|
|
dataStream.writeDouble(usage.digitalMinerUsage);
|
|
|
|
dataStream.writeDouble(usage.electricPumpUsage);
|
|
|
|
dataStream.writeDouble(usage.rotaryCondensentratorUsage);
|
|
|
|
dataStream.writeDouble(usage.oxidationChamberUsage);
|
|
|
|
dataStream.writeDouble(usage.chemicalInfuserUsage);
|
|
|
|
dataStream.writeDouble(usage.chemicalInjectionChamberUsage);
|
|
|
|
dataStream.writeDouble(usage.precisionSawmillUsage);
|
|
|
|
dataStream.writeDouble(usage.chemicalDissolutionChamberUsage);
|
|
|
|
dataStream.writeDouble(usage.chemicalWasherUsage);
|
|
|
|
dataStream.writeDouble(usage.chemicalCrystallizerUsage);
|
|
|
|
dataStream.writeDouble(usage.seismicVibratorUsage);
|
|
|
|
dataStream.writeDouble(usage.fluidicPlenisherUsage);
|
2014-06-11 11:57:49 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
for(IModule module : Mekanism.modulesLoaded)
|
|
|
|
{
|
|
|
|
module.writeConfig(dataStream);
|
|
|
|
}
|
|
|
|
} catch(Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void fromBytes(ByteBuf dataStream)
|
|
|
|
{
|
2014-08-01 01:58:12 +02:00
|
|
|
general.updateNotifications = dataStream.readBoolean();
|
|
|
|
general.controlCircuitOreDict = dataStream.readBoolean();
|
|
|
|
general.logPackets = dataStream.readBoolean();
|
|
|
|
general.dynamicTankEasterEgg = dataStream.readBoolean();
|
|
|
|
general.voiceServerEnabled = dataStream.readBoolean();
|
|
|
|
general.cardboardSpawners = dataStream.readBoolean();
|
|
|
|
general.creativeOverrideElectricChest = dataStream.readBoolean();
|
|
|
|
general.spawnBabySkeletons = dataStream.readBoolean();
|
|
|
|
general.obsidianTNTDelay = dataStream.readInt();
|
|
|
|
general.obsidianTNTBlastRadius = dataStream.readInt();
|
|
|
|
general.UPDATE_DELAY = dataStream.readInt();
|
|
|
|
general.FROM_IC2 = dataStream.readDouble();
|
|
|
|
general.TO_IC2 = dataStream.readDouble();
|
|
|
|
general.FROM_BC = dataStream.readDouble();
|
|
|
|
general.TO_BC = dataStream.readDouble();
|
|
|
|
general.FROM_H2 = dataStream.readDouble();
|
|
|
|
general.ENERGY_PER_REDSTONE = dataStream.readDouble();
|
|
|
|
general.VOICE_PORT = dataStream.readInt();
|
|
|
|
general.maxUpgradeMultiplier = dataStream.readInt();
|
|
|
|
general.activeType = EnergyType.values()[dataStream.readInt()];
|
2014-06-11 11:57:49 +02:00
|
|
|
|
2014-08-01 01:58:12 +02:00
|
|
|
general.TO_TE = general.TO_BC*10;
|
|
|
|
general.FROM_TE = general.FROM_BC/10;
|
2014-06-11 11:57:49 +02:00
|
|
|
|
2014-08-01 01:58:12 +02:00
|
|
|
usage.enrichmentChamberUsage = dataStream.readDouble();
|
|
|
|
usage.osmiumCompressorUsage = dataStream.readDouble();
|
|
|
|
usage.combinerUsage = dataStream.readDouble();
|
|
|
|
usage.crusherUsage = dataStream.readDouble();
|
|
|
|
usage.factoryUsage = dataStream.readDouble();
|
|
|
|
usage.metallurgicInfuserUsage = dataStream.readDouble();
|
|
|
|
usage.purificationChamberUsage = dataStream.readDouble();
|
|
|
|
usage.energizedSmelterUsage = dataStream.readDouble();
|
|
|
|
usage.digitalMinerUsage = dataStream.readDouble();
|
|
|
|
usage.electricPumpUsage = dataStream.readDouble();
|
|
|
|
usage.rotaryCondensentratorUsage = dataStream.readDouble();
|
|
|
|
usage.oxidationChamberUsage = dataStream.readDouble();
|
|
|
|
usage.chemicalInfuserUsage = dataStream.readDouble();
|
|
|
|
usage.chemicalInjectionChamberUsage = dataStream.readDouble();
|
|
|
|
usage.precisionSawmillUsage = dataStream.readDouble();
|
|
|
|
usage.chemicalDissolutionChamberUsage = dataStream.readDouble();
|
|
|
|
usage.chemicalWasherUsage = dataStream.readDouble();
|
|
|
|
usage.chemicalCrystallizerUsage = dataStream.readDouble();
|
|
|
|
usage.seismicVibratorUsage = dataStream.readDouble();
|
|
|
|
usage.fluidicPlenisherUsage = dataStream.readDouble();
|
2014-06-11 11:57:49 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
for(IModule module : Mekanism.modulesLoaded)
|
|
|
|
{
|
|
|
|
module.readConfig(dataStream);
|
|
|
|
}
|
|
|
|
} catch(Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
Mekanism.proxy.onConfigSync();
|
2014-06-02 17:33:19 +02:00
|
|
|
}
|
2014-04-20 22:15:44 +02:00
|
|
|
}
|
2013-12-22 07:49:55 +01:00
|
|
|
}
|