Sync server configs with client

This commit is contained in:
Aidan C. Brady 2013-12-22 01:49:55 -05:00
parent ced44e97fc
commit 90985663bb
14 changed files with 163 additions and 26 deletions

View file

@ -4,7 +4,10 @@ import mekanism.common.Mekanism;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import cpw.mods.fml.common.IPlayerTracker;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ClientPlayerTracker implements IPlayerTracker
{
@Override
@ -31,6 +34,10 @@ public class ClientPlayerTracker implements IPlayerTracker
Mekanism.jetpackOn.clear();
Mekanism.gasmaskOn.clear();
Mekanism.proxy.loadConfiguration();
System.out.println("[Mekanism] Reloaded config.");
}
}

View file

@ -6,6 +6,10 @@ import net.minecraft.client.model.ModelRenderer;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelGasMask extends ModelBase
{
ModelRenderer helmetfeed;

View file

@ -6,6 +6,10 @@ import net.minecraft.client.model.ModelRenderer;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelJetpack extends ModelBase
{
ModelRenderer Packtop;

View file

@ -2,8 +2,10 @@ package mekanism.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelScubaTank extends ModelBase
{
ModelRenderer tankL;

View file

@ -14,6 +14,10 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelCustomArmor extends ModelBiped
{
public static ModelCustomArmor INSTANCE = new ModelCustomArmor();

View file

@ -56,7 +56,10 @@ import codechicken.lib.render.TextureUtils.IIconRegister;
import codechicken.lib.render.UV;
import codechicken.lib.vec.Translation;
import codechicken.lib.vec.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderPartTransmitter implements IIconRegister
{
public static RenderPartTransmitter INSTANCE;

View file

@ -1,5 +1,6 @@
package mekanism.common;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketConfigSync;
import mekanism.common.network.PacketJetpackData;
import mekanism.common.network.PacketJetpackData.JetpackPacket;
import mekanism.common.network.PacketScubaTankData;
@ -14,8 +15,11 @@ public class CommonPlayerTracker implements IPlayerTracker
{
if(!player.worldObj.isRemote)
{
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketJetpackData().setParams(JetpackPacket.FULL), player.worldObj.provider.dimensionId);
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketScubaTankData().setParams(ScubaTankPacket.FULL), player.worldObj.provider.dimensionId);
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketConfigSync().setParams(), player);
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketJetpackData().setParams(JetpackPacket.FULL), player);
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketScubaTankData().setParams(ScubaTankPacket.FULL), player);
System.out.println("[Mekanism] Sent config to '" + player.username + ".'");
}
}
@ -23,12 +27,7 @@ public class CommonPlayerTracker implements IPlayerTracker
public void onPlayerLogout(EntityPlayer player)
{
Mekanism.jetpackOn.remove(player);
if(!player.worldObj.isRemote)
{
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketJetpackData().setParams(JetpackPacket.FULL), player.worldObj.provider.dimensionId);
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketScubaTankData().setParams(ScubaTankPacket.FULL), player.worldObj.provider.dimensionId);
}
Mekanism.gasmaskOn.remove(player);
}
@Override
@ -38,8 +37,8 @@ public class CommonPlayerTracker implements IPlayerTracker
if(!player.worldObj.isRemote)
{
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketJetpackData().setParams(JetpackPacket.FULL), player.worldObj.provider.dimensionId);
PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketScubaTankData().setParams(ScubaTankPacket.FULL), player.worldObj.provider.dimensionId);
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketJetpackData().setParams(JetpackPacket.FULL), player);
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketScubaTankData().setParams(ScubaTankPacket.FULL), player);
}
}

View file

@ -70,6 +70,7 @@ import mekanism.common.item.ItemScubaTank;
import mekanism.common.item.ItemWalkieTalkie;
import mekanism.common.multipart.ItemPartTransmitter;
import mekanism.common.multipart.MultipartMekanism;
import mekanism.common.network.PacketConfigSync;
import mekanism.common.network.PacketConfigurationUpdate;
import mekanism.common.network.PacketConfiguratorState;
import mekanism.common.network.PacketDataRequest;
@ -1302,6 +1303,7 @@ public class Mekanism
PacketHandler.registerPacket(PacketJetpackData.class);
PacketHandler.registerPacket(PacketKey.class);
PacketHandler.registerPacket(PacketScubaTankData.class);
PacketHandler.registerPacket(PacketConfigSync.class);
//Donators
donators.add("mrgreaper");

View file

@ -7,7 +7,6 @@ import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.PartTransmitterIcons;
import mekanism.client.render.RenderPartTransmitter;
import mekanism.common.HashList;
import mekanism.common.ILogisticalTransporter;
@ -48,7 +47,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class PartLogisticalTransporter extends PartSidedPipe implements ILogisticalTransporter, IPipeTile
{
public static PartTransmitterIcons transporterIcons;
public static TransmitterIcons transporterIcons;
public static final int SPEED = 5;
@ -80,7 +79,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
public static void registerIcons(IconRegister register)
{
transporterIcons = new PartTransmitterIcons(3, 2);
transporterIcons = new TransmitterIcons(3, 2);
transporterIcons.registerCenterIcons(register, new String[] {"LogisticalTransporter", "RestrictiveTransporter", "DiversionTransporter"});
transporterIcons.registerSideIcons(register, new String[] {"LogisticalTransporterSide", "RestrictiveTransporterSide"});
}

View file

@ -4,7 +4,6 @@ import java.util.Set;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.PartTransmitterIcons;
import mekanism.client.render.RenderPartTransmitter;
import mekanism.common.FluidNetwork;
import mekanism.common.util.MekanismUtils;
@ -29,7 +28,7 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
/** The fake tank used for fluid transfer calculations. */
public FluidTank dummyTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME);
public static PartTransmitterIcons pipeIcons;
public static TransmitterIcons pipeIcons;
public float currentScale;
@ -188,7 +187,7 @@ public class PartMechanicalPipe extends PartTransmitter<FluidNetwork> implements
public static void registerIcons(IconRegister register)
{
pipeIcons = new PartTransmitterIcons(2, 1);
pipeIcons = new TransmitterIcons(2, 1);
pipeIcons.registerCenterIcons(register, new String[] {"MechanicalPipe", "MechanicalPipeActive"});
pipeIcons.registerSideIcons(register, new String[] {"MechanicalPipeSide"});
}

View file

@ -8,7 +8,6 @@ import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.IGasHandler;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.PartTransmitterIcons;
import mekanism.client.render.RenderPartTransmitter;
import mekanism.common.EnergyNetwork;
import mekanism.common.FluidNetwork;
@ -24,7 +23,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class PartPressurizedTube extends PartTransmitter<GasNetwork>
{
public static PartTransmitterIcons tubeIcons;
public static TransmitterIcons tubeIcons;
public float currentScale;
@ -178,7 +177,7 @@ public class PartPressurizedTube extends PartTransmitter<GasNetwork>
public static void registerIcons(IconRegister register)
{
tubeIcons = new PartTransmitterIcons(1, 1);
tubeIcons = new TransmitterIcons(1, 1);
tubeIcons.registerCenterIcons(register, new String[] {"PressurizedTube"});
tubeIcons.registerSideIcons(register, new String[] {"TransmitterSideSmall"});
}

View file

@ -11,7 +11,6 @@ import mekanism.api.Coord4D;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.client.render.PartTransmitterIcons;
import mekanism.client.render.RenderPartTransmitter;
import mekanism.common.EnergyNetwork;
import mekanism.common.Mekanism;
@ -29,7 +28,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implements IStrictEnergyAcceptor, IEnergySink, IEnergyHandler
{
public static PartTransmitterIcons cableIcons;
public static TransmitterIcons cableIcons;
public double currentPower = 0;
@ -92,7 +91,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
public static void registerIcons(IconRegister register)
{
cableIcons = new PartTransmitterIcons(1, 1);
cableIcons = new TransmitterIcons(1, 1);
cableIcons.registerCenterIcons(register, new String[] {"UniversalCable"});
cableIcons.registerSideIcons(register, new String[] {"TransmitterSideSmall"});
}

View file

@ -1,14 +1,14 @@
package mekanism.client.render;
package mekanism.common.multipart;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
public class PartTransmitterIcons
public class TransmitterIcons
{
private Icon[] sideIcons;
private Icon[] centerIcons;
public PartTransmitterIcons(int numCentres, int numSides)
public TransmitterIcons(int numCentres, int numSides)
{
sideIcons = new Icon[numSides];
centerIcons = new Icon[numCentres];

View file

@ -0,0 +1,116 @@
package mekanism.common.network;
import java.io.DataOutputStream;
import mekanism.common.Mekanism;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.Configuration;
import com.google.common.io.ByteArrayDataInput;
public class PacketConfigSync implements IMekanismPacket
{
@Override
public String getName()
{
return "ConfigSync";
}
@Override
public IMekanismPacket setParams(Object... data)
{
return this;
}
@Override
public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception
{
Mekanism.osmiumGenerationEnabled = dataStream.readBoolean();
Mekanism.copperGenerationEnabled = dataStream.readBoolean();
Mekanism.tinGenerationEnabled = dataStream.readBoolean();
Mekanism.disableBCSteelCrafting = dataStream.readBoolean();
Mekanism.disableBCBronzeCrafting = dataStream.readBoolean();
Mekanism.updateNotifications = dataStream.readBoolean();
Mekanism.controlCircuitOreDict = dataStream.readBoolean();
Mekanism.logPackets = dataStream.readBoolean();
Mekanism.dynamicTankEasterEgg = dataStream.readBoolean();
Mekanism.allowBackCrafting = dataStream.readBoolean();
Mekanism.voiceServerEnabled = dataStream.readBoolean();
Mekanism.forceBuildcraft = dataStream.readBoolean();
Mekanism.obsidianTNTDelay = dataStream.readInt();
Mekanism.obsidianTNTBlastRadius = dataStream.readInt();
Mekanism.UPDATE_DELAY = dataStream.readInt();
Mekanism.osmiumGenerationAmount = dataStream.readInt();
Mekanism.copperGenerationAmount = dataStream.readInt();
Mekanism.tinGenerationAmount = dataStream.readInt();
Mekanism.FROM_IC2 = dataStream.readDouble();
Mekanism.TO_IC2 = dataStream.readDouble();
Mekanism.FROM_BC = dataStream.readDouble();
Mekanism.TO_BC = dataStream.readDouble();
Mekanism.ENERGY_PER_REDSTONE = dataStream.readDouble();
Mekanism.VOICE_PORT = dataStream.readInt();
Mekanism.upgradeModifier = dataStream.readInt();
Mekanism.TO_TE = Mekanism.TO_BC*10;
Mekanism.FROM_TE = Mekanism.FROM_BC/10;
Mekanism.enrichmentChamberUsage = dataStream.readDouble();
Mekanism.osmiumCompressorUsage = dataStream.readDouble();
Mekanism.combinerUsage = dataStream.readDouble();
Mekanism.crusherUsage = dataStream.readDouble();
Mekanism.factoryUsage = dataStream.readDouble();
Mekanism.metallurgicInfuserUsage = dataStream.readDouble();
Mekanism.purificationChamberUsage = dataStream.readDouble();
Mekanism.energizedSmelterUsage = dataStream.readDouble();
Mekanism.digitalMinerUsage = dataStream.readDouble();
Mekanism.rotaryCondensentratorUsage = dataStream.readDouble();
Mekanism.chemicalFormulatorUsage = dataStream.readDouble();
Mekanism.chemicalInfuserUsage = dataStream.readDouble();
System.out.println("[Mekanism] Received config from server.");
}
@Override
public void write(DataOutputStream dataStream) throws Exception
{
dataStream.writeBoolean(Mekanism.osmiumGenerationEnabled);
dataStream.writeBoolean(Mekanism.copperGenerationEnabled);
dataStream.writeBoolean(Mekanism.tinGenerationEnabled);
dataStream.writeBoolean(Mekanism.disableBCSteelCrafting);
dataStream.writeBoolean(Mekanism.disableBCBronzeCrafting);
dataStream.writeBoolean(Mekanism.updateNotifications);
dataStream.writeBoolean(Mekanism.controlCircuitOreDict);
dataStream.writeBoolean(Mekanism.logPackets);
dataStream.writeBoolean(Mekanism.dynamicTankEasterEgg);
dataStream.writeBoolean(Mekanism.allowBackCrafting);
dataStream.writeBoolean(Mekanism.voiceServerEnabled);
dataStream.writeBoolean(Mekanism.forceBuildcraft);
dataStream.writeInt(Mekanism.obsidianTNTDelay);
dataStream.writeInt(Mekanism.obsidianTNTBlastRadius);
dataStream.writeInt(Mekanism.UPDATE_DELAY);
dataStream.writeInt(Mekanism.osmiumGenerationAmount);
dataStream.writeInt(Mekanism.copperGenerationAmount);
dataStream.writeInt(Mekanism.tinGenerationAmount);
dataStream.writeDouble(Mekanism.FROM_IC2);
dataStream.writeDouble(Mekanism.TO_IC2);
dataStream.writeDouble(Mekanism.FROM_BC);
dataStream.writeDouble(Mekanism.TO_BC);
dataStream.writeDouble(Mekanism.ENERGY_PER_REDSTONE);
dataStream.writeInt(Mekanism.VOICE_PORT);
dataStream.writeInt(Mekanism.upgradeModifier);
dataStream.writeDouble(Mekanism.enrichmentChamberUsage);
dataStream.writeDouble(Mekanism.osmiumCompressorUsage);
dataStream.writeDouble(Mekanism.combinerUsage);
dataStream.writeDouble(Mekanism.crusherUsage);
dataStream.writeDouble(Mekanism.factoryUsage);
dataStream.writeDouble(Mekanism.metallurgicInfuserUsage);
dataStream.writeDouble(Mekanism.purificationChamberUsage);
dataStream.writeDouble(Mekanism.energizedSmelterUsage);
dataStream.writeDouble(Mekanism.digitalMinerUsage);
dataStream.writeDouble(Mekanism.rotaryCondensentratorUsage);
dataStream.writeDouble(Mekanism.chemicalFormulatorUsage);
dataStream.writeDouble(Mekanism.chemicalInfuserUsage);
}
}