Make the gas mask and jetpack maps synchronized
This commit is contained in:
parent
89be8b4482
commit
1f9185dd01
5 changed files with 89 additions and 74 deletions
|
@ -392,24 +392,30 @@ public class ClientTickHandler
|
|||
|
||||
if(MekanismClient.audioHandler != null)
|
||||
{
|
||||
for(String username : Mekanism.jetpackOn)
|
||||
synchronized(Mekanism.jetpackOn)
|
||||
{
|
||||
if(mc.theWorld.getPlayerEntityByName(username) != null)
|
||||
for (String username : Mekanism.jetpackOn)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getFrom(mc.theWorld.getPlayerEntityByName(username)) == null)
|
||||
if (mc.theWorld.getPlayerEntityByName(username) != null)
|
||||
{
|
||||
new JetpackSound(MekanismClient.audioHandler.getIdentifier(), mc.theWorld.getPlayerEntityByName(username));
|
||||
if (MekanismClient.audioHandler.getFrom(mc.theWorld.getPlayerEntityByName(username)) == null)
|
||||
{
|
||||
new JetpackSound(MekanismClient.audioHandler.getIdentifier(), mc.theWorld.getPlayerEntityByName(username));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(String username : Mekanism.gasmaskOn)
|
||||
synchronized(Mekanism.gasmaskOn)
|
||||
{
|
||||
if(mc.theWorld.getPlayerEntityByName(username) != null)
|
||||
for (String username : Mekanism.gasmaskOn)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getFrom(mc.theWorld.getPlayerEntityByName(username)) == null)
|
||||
if (mc.theWorld.getPlayerEntityByName(username) != null)
|
||||
{
|
||||
new GasMaskSound(MekanismClient.audioHandler.getIdentifier(), mc.theWorld.getPlayerEntityByName(username));
|
||||
if (MekanismClient.audioHandler.getFrom(mc.theWorld.getPlayerEntityByName(username)) == null)
|
||||
{
|
||||
new GasMaskSound(MekanismClient.audioHandler.getIdentifier(), mc.theWorld.getPlayerEntityByName(username));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,66 +102,67 @@ public class RenderTickHandler
|
|||
font.drawStringWithShadow("Oxygen: " + scubaTank.getStored(stack), 1, y - 11, 0x404040);
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> copy = (Set)((HashSet)Mekanism.jetpackOn).clone();
|
||||
|
||||
for(String s : copy)
|
||||
|
||||
synchronized(Mekanism.jetpackOn)
|
||||
{
|
||||
EntityPlayer p = mc.theWorld.getPlayerEntityByName(s);
|
||||
|
||||
if(p == null)
|
||||
for(String s : Mekanism.jetpackOn)
|
||||
{
|
||||
continue;
|
||||
EntityPlayer p = mc.theWorld.getPlayerEntityByName(s);
|
||||
|
||||
if(p == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Pos3D playerPos = new Pos3D(p);
|
||||
|
||||
if(p != mc.thePlayer)
|
||||
{
|
||||
playerPos.translate(0, 1.7, 0);
|
||||
}
|
||||
|
||||
float random = (rand.nextFloat() - 0.5F) * 0.1F;
|
||||
|
||||
Pos3D vLeft = new Pos3D();
|
||||
vLeft.xPos -= 0.43;
|
||||
vLeft.yPos -= 0.55;
|
||||
vLeft.zPos -= 0.54;
|
||||
vLeft.rotateYaw(p.renderYawOffset);
|
||||
|
||||
Pos3D vRight = new Pos3D();
|
||||
vRight.xPos += 0.43;
|
||||
vRight.yPos -= 0.55;
|
||||
vRight.zPos -= 0.54;
|
||||
vRight.rotateYaw(p.renderYawOffset);
|
||||
|
||||
Pos3D vCenter = new Pos3D();
|
||||
vCenter.xPos = (rand.nextFloat() - 0.5F) * 0.4F;
|
||||
vCenter.yPos -= 0.86;
|
||||
vCenter.zPos -= 0.30;
|
||||
vCenter.rotateYaw(p.renderYawOffset);
|
||||
|
||||
Pos3D rLeft = vLeft.clone().scale(random);
|
||||
Pos3D rRight = vRight.clone().scale(random);
|
||||
|
||||
Pos3D mLeft = vLeft.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ));
|
||||
Pos3D mRight = vRight.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ));
|
||||
Pos3D mCenter = vCenter.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ));
|
||||
|
||||
mLeft.translate(rLeft);
|
||||
mRight.translate(rRight);
|
||||
|
||||
Pos3D v = playerPos.clone().translate(vLeft);
|
||||
spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mLeft.xPos, mLeft.yPos, mLeft.zPos);
|
||||
spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mLeft.xPos, mLeft.yPos, mLeft.zPos);
|
||||
|
||||
v = playerPos.clone().translate(vRight);
|
||||
spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mRight.xPos, mRight.yPos, mRight.zPos);
|
||||
spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mRight.xPos, mRight.yPos, mRight.zPos);
|
||||
|
||||
v = playerPos.clone().translate(vCenter);
|
||||
spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mCenter.xPos, mCenter.yPos, mCenter.zPos);
|
||||
spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mCenter.xPos, mCenter.yPos, mCenter.zPos);
|
||||
}
|
||||
|
||||
Pos3D playerPos = new Pos3D(p);
|
||||
|
||||
if(p != mc.thePlayer)
|
||||
{
|
||||
playerPos.translate(0, 1.7, 0);
|
||||
}
|
||||
|
||||
float random = (rand.nextFloat()-0.5F)*0.1F;
|
||||
|
||||
Pos3D vLeft = new Pos3D();
|
||||
vLeft.xPos -= 0.43;
|
||||
vLeft.yPos -= 0.55;
|
||||
vLeft.zPos -= 0.54;
|
||||
vLeft.rotateYaw(p.renderYawOffset);
|
||||
|
||||
Pos3D vRight = new Pos3D();
|
||||
vRight.xPos += 0.43;
|
||||
vRight.yPos -= 0.55;
|
||||
vRight.zPos -= 0.54;
|
||||
vRight.rotateYaw(p.renderYawOffset);
|
||||
|
||||
Pos3D vCenter = new Pos3D();
|
||||
vCenter.xPos = (rand.nextFloat()-0.5F)*0.4F;
|
||||
vCenter.yPos -= 0.86;
|
||||
vCenter.zPos -= 0.30;
|
||||
vCenter.rotateYaw(p.renderYawOffset);
|
||||
|
||||
Pos3D rLeft = vLeft.clone().scale(random);
|
||||
Pos3D rRight = vRight.clone().scale(random);
|
||||
|
||||
Pos3D mLeft = vLeft.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ));
|
||||
Pos3D mRight = vRight.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ));
|
||||
Pos3D mCenter = vCenter.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ));
|
||||
|
||||
mLeft.translate(rLeft);
|
||||
mRight.translate(rRight);
|
||||
|
||||
Pos3D v = playerPos.clone().translate(vLeft);
|
||||
spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mLeft.xPos, mLeft.yPos, mLeft.zPos);
|
||||
spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mLeft.xPos, mLeft.yPos, mLeft.zPos);
|
||||
|
||||
v = playerPos.clone().translate(vRight);
|
||||
spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mRight.xPos, mRight.yPos, mRight.zPos);
|
||||
spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mRight.xPos, mRight.yPos, mRight.zPos);
|
||||
|
||||
v = playerPos.clone().translate(vCenter);
|
||||
spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mCenter.xPos, mCenter.yPos, mCenter.zPos);
|
||||
spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mCenter.xPos, mCenter.yPos, mCenter.zPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>();
|
||||
|
||||
|
|
|
@ -92,10 +92,13 @@ public class PacketJetpackData implements IMessageHandler<JetpackDataMessage, IM
|
|||
else if(packetType == JetpackPacket.FULL)
|
||||
{
|
||||
dataStream.writeInt(Mekanism.jetpackOn.size());
|
||||
|
||||
for(String username : Mekanism.jetpackOn)
|
||||
|
||||
synchronized(Mekanism.jetpackOn)
|
||||
{
|
||||
PacketHandler.writeString(dataStream, username);
|
||||
for (String username : Mekanism.jetpackOn)
|
||||
{
|
||||
PacketHandler.writeString(dataStream, username);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,10 +81,13 @@ public class PacketScubaTankData implements IMessageHandler<ScubaTankDataMessage
|
|||
else if(packetType == ScubaTankPacket.FULL)
|
||||
{
|
||||
dataStream.writeInt(Mekanism.gasmaskOn.size());
|
||||
|
||||
for(String name : Mekanism.gasmaskOn)
|
||||
|
||||
synchronized(Mekanism.gasmaskOn)
|
||||
{
|
||||
PacketHandler.writeString(dataStream, name);
|
||||
for (String name : Mekanism.gasmaskOn)
|
||||
{
|
||||
PacketHandler.writeString(dataStream, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue