Make the gas mask and jetpack maps synchronized

This commit is contained in:
Ben Spiers 2015-01-10 18:17:17 +00:00
parent 89be8b4482
commit 1f9185dd01
5 changed files with 89 additions and 74 deletions

View file

@ -391,6 +391,8 @@ public class ClientTickHandler
}
if(MekanismClient.audioHandler != null)
{
synchronized(Mekanism.jetpackOn)
{
for (String username : Mekanism.jetpackOn)
{
@ -402,7 +404,10 @@ public class ClientTickHandler
}
}
}
}
synchronized(Mekanism.gasmaskOn)
{
for (String username : Mekanism.gasmaskOn)
{
if (mc.theWorld.getPlayerEntityByName(username) != null)
@ -414,6 +419,7 @@ public class ClientTickHandler
}
}
}
}
if(mc.thePlayer.getEquipmentInSlot(3) != null && mc.thePlayer.getEquipmentInSlot(3).getItem() instanceof ItemJetpack)
{

View file

@ -103,9 +103,9 @@ public class RenderTickHandler
}
}
Set<String> copy = (Set)((HashSet)Mekanism.jetpackOn).clone();
for(String s : copy)
synchronized(Mekanism.jetpackOn)
{
for(String s : Mekanism.jetpackOn)
{
EntityPlayer p = mc.theWorld.getPlayerEntityByName(s);
@ -166,6 +166,7 @@ public class RenderTickHandler
}
}
}
}
public void spawnAndSetParticle(String s, World world, double x, double y, double z, double velX, double velY, double velZ)
{

View file

@ -2,6 +2,7 @@ package mekanism.common;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -35,6 +36,7 @@ import mekanism.common.EnergyDisplay.EnergyType;
import mekanism.common.EnergyNetwork.EnergyTransferEvent;
import mekanism.common.FluidNetwork.FluidTransferEvent;
import mekanism.common.IFactory.RecipeType;
import mekanism.common.Teleporter.Code;
import mekanism.common.Tier.EnergyCubeTier;
import mekanism.common.Tier.FactoryTier;
import mekanism.common.block.BlockBasic;
@ -191,7 +193,7 @@ public class Mekanism
public static Version versionNumber = new Version(7, 1, 1);
/** Map of Teleporters */
public static Map<Teleporter.Code, ArrayList<Coord4D>> teleporters = new HashMap<Teleporter.Code, ArrayList<Coord4D>>();
public static Map<Teleporter.Code, ArrayList<Coord4D>> teleporters = new HashMap<Code, ArrayList<Coord4D>>();
/** A map containing references to all dynamic tank inventory caches. */
public static Map<Integer, DynamicTankCache> dynamicInventories = new HashMap<Integer, DynamicTankCache>();
@ -225,8 +227,8 @@ public class Mekanism
public static KeySync keyMap = new KeySync();
public static Set<String> jetpackOn = new HashSet<String>();
public static Set<String> gasmaskOn = new HashSet<String>();
public static final Set<String> jetpackOn = Collections.synchronizedSet(new HashSet<String>());
public static final Set<String> gasmaskOn = Collections.synchronizedSet(new HashSet<String>());
public static Set<Coord4D> activeVibrators = new HashSet<Coord4D>();

View file

@ -93,12 +93,15 @@ public class PacketJetpackData implements IMessageHandler<JetpackDataMessage, IM
{
dataStream.writeInt(Mekanism.jetpackOn.size());
synchronized(Mekanism.jetpackOn)
{
for (String username : Mekanism.jetpackOn)
{
PacketHandler.writeString(dataStream, username);
}
}
}
}
@Override
public void fromBytes(ByteBuf dataStream)

View file

@ -82,12 +82,15 @@ public class PacketScubaTankData implements IMessageHandler<ScubaTankDataMessage
{
dataStream.writeInt(Mekanism.gasmaskOn.size());
synchronized(Mekanism.gasmaskOn)
{
for (String name : Mekanism.gasmaskOn)
{
PacketHandler.writeString(dataStream, name);
}
}
}
}
@Override
public void fromBytes(ByteBuf dataStream)