Skip to content

Commit

Permalink
Merge pull request #141 from Thorfusion/CME-Fixes
Browse files Browse the repository at this point in the history
Fixes CMEs
  • Loading branch information
maggi373 authored Oct 15, 2023
2 parents e900821 + f4c036a commit 3eb98a1
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ public void removeInvalidTransmitters()
{
logger.info("Dealing with " + invalidTransmitters.size() + " invalid Transmitters");
}

for(IGridTransmitter invalid : invalidTransmitters)

HashSet<IGridTransmitter> orphanTransmitterCopy = new HashSet<>(invalidTransmitters);
for(IGridTransmitter invalid : orphanTransmitterCopy)
{
if(!(invalid.isOrphan() && invalid.isValid()))
{
Expand All @@ -132,8 +133,9 @@ public void assignOrphans()
{
logger.info("Dealing with " + orphanTransmitters.size() + " orphan Transmitters");
}

for(IGridTransmitter orphanTransmitter : orphanTransmitters.values())

HashMap<Coord4D, IGridTransmitter> orphanTransmitterCopy = new HashMap<Coord4D, IGridTransmitter>(orphanTransmitters);
for(IGridTransmitter orphanTransmitter : orphanTransmitterCopy.values())
{
DynamicNetwork network = getNetworkFromOrphan(orphanTransmitter);

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/mekanism/client/ClientTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;

import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.*;

import static mekanism.client.sound.SoundHandler.Channel.*;

Expand Down Expand Up @@ -155,7 +152,8 @@ else if(shouldReset)

if(client.enablePlayerSounds)
{
for(String username : Mekanism.jetpackOn)
Set<String> jetpackPlayers = new HashSet<String>(Mekanism.jetpackOn);
for(String username : jetpackPlayers)
{
EntityPlayer player = mc.theWorld.getPlayerEntityByName(username);

Expand All @@ -170,7 +168,8 @@ else if(shouldReset)
}
}

for(String username : Mekanism.gasmaskOn)
Set<String> gasmaskPlayers = new HashSet<String>(Mekanism.gasmaskOn);
for(String username : gasmaskPlayers)
{
EntityPlayer player = mc.theWorld.getPlayerEntityByName(username);

Expand All @@ -185,7 +184,8 @@ else if(shouldReset)
}
}

for(EntityPlayer player : (List<EntityPlayer>)mc.theWorld.playerEntities)
List<EntityPlayer> worldPlayers = new ArrayList<>((List<EntityPlayer>)mc.theWorld.playerEntities);
for(EntityPlayer player : worldPlayers)
{
if(hasFlamethrower(player))
{
Expand Down
84 changes: 37 additions & 47 deletions src/main/java/mekanism/client/render/RenderTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

import java.util.List;
import java.util.Random;
import java.util.*;

@SideOnly(Side.CLIENT)
public class RenderTickHandler
Expand Down Expand Up @@ -106,19 +105,17 @@ else if(stack.getItem() instanceof ItemScubaTank)

synchronized(Mekanism.jetpackOn)
{
for(String s : Mekanism.jetpackOn)
{
Set<String> jetpackPlayers = new HashSet<String>(Mekanism.jetpackOn);
for (String s : jetpackPlayers) {
EntityPlayer p = mc.theWorld.getPlayerEntityByName(s);

if(p == null)
{
if (p == null) {
continue;
}

Pos3D playerPos = new Pos3D(p);

if(p != mc.thePlayer)
{
if (p != mc.thePlayer) {
playerPos.translate(0, 1.7, 0);
}

Expand Down Expand Up @@ -173,7 +170,9 @@ else if(stack.getItem() instanceof ItemScubaTank)
{
if(world.getWorldTime() % 4 == 0)
{
for(String s : Mekanism.gasmaskOn)
Set<String> gasmaskPlayers = new HashSet<String>(Mekanism.gasmaskOn);

for(String s : gasmaskPlayers)
{
EntityPlayer p = mc.theWorld.getPlayerEntityByName(s);

Expand Down Expand Up @@ -201,50 +200,42 @@ else if(stack.getItem() instanceof ItemScubaTank)
}
}

if(world.getWorldTime() % 4 == 0)
{
for(EntityPlayer p : (List<EntityPlayer>)world.playerEntities)
{
if(!Mekanism.flamethrowerActive.contains(p.getCommandSenderName()) && !p.isSwingInProgress && p.getCurrentEquippedItem() != null && p.getCurrentEquippedItem().getItem() instanceof ItemFlamethrower)
{
if(((ItemFlamethrower)p.getCurrentEquippedItem().getItem()).getGas(p.getCurrentEquippedItem()) != null)
{
if(world.getWorldTime() % 4 == 0) {
List<EntityPlayer> flamethrowerPlayers = new ArrayList<>((List<EntityPlayer>) world.playerEntities);
for (EntityPlayer p : flamethrowerPlayers) {
if (!Mekanism.flamethrowerActive.contains(p.getCommandSenderName()) && !p.isSwingInProgress && p.getCurrentEquippedItem() != null && p.getCurrentEquippedItem().getItem() instanceof ItemFlamethrower) {
if (((ItemFlamethrower) p.getCurrentEquippedItem().getItem()).getGas(p.getCurrentEquippedItem()) != null) {
Pos3D playerPos = new Pos3D(p);
Pos3D flameVec = new Pos3D();

if(p.isSneaking())
{

if (p.isSneaking()) {
flameVec.yPos -= 0.35F;
flameVec.zPos -= 0.15F;
}

Pos3D flameMotion = new Pos3D(p.motionX, p.onGround ? 0 : p.motionY, p.motionZ);

if(player == p && mc.gameSettings.thirdPersonView == 0)
{

if (player == p && mc.gameSettings.thirdPersonView == 0) {
flameVec = new Pos3D(0.8, 0.8, 0.8);

flameVec.multiply(new Pos3D(p.getLook(90)));
flameVec.rotateYaw(15);
}
else {
} else {
flameVec.xPos -= 0.45F;

if(player == p)
{

if (player == p) {
flameVec.yPos -= 0.5F;
}
else {
} else {
flameVec.yPos += 1F;
}

flameVec.zPos += 1.05F;

flameVec.rotateYaw(p.renderYawOffset);
}

Pos3D mergedVec = playerPos.clone().translate(flameVec);

spawnAndSetParticle("flame", world, mergedVec.xPos, mergedVec.yPos, mergedVec.zPos, flameMotion.xPos, flameMotion.yPos, flameMotion.zPos);
}
}
Expand All @@ -258,17 +249,16 @@ public void spawnAndSetParticle(String s, World world, double x, double y, doubl
{
EntityFX fx = null;

if(s.equals("flame"))
{
fx = new EntityJetpackFlameFX(world, x, y, z, velX, velY, velZ);
}
else if(s.equals("smoke"))
{
fx = new EntityJetpackSmokeFX(world, x, y, z, velX, velY, velZ);
}
else if(s.equals("bubble"))
{
fx = new EntityScubaBubbleFX(world, x, y, z, velX, velY, velZ);
switch (s) {
case "flame":
fx = new EntityJetpackFlameFX(world, x, y, z, velX, velY, velZ);
break;
case "smoke":
fx = new EntityJetpackSmokeFX(world, x, y, z, velX, velY, velZ);
break;
case "bubble":
fx = new EntityScubaBubbleFX(world, x, y, z, velX, velY, velZ);
break;
}

mc.effectRenderer.addEffect(fx);
Expand Down
33 changes: 8 additions & 25 deletions src/main/java/mekanism/common/Mekanism.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
package mekanism.common;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.*;

import cpw.mods.fml.common.event.*;
import mekanism.api.Coord4D;
Expand Down Expand Up @@ -92,6 +85,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.WorldChunkManager;
import net.minecraftforge.common.ForgeChunkManager;
Expand Down Expand Up @@ -1628,24 +1622,13 @@ public synchronized void onChunkLoad(ChunkEvent.Load event)
{
if(event.getChunk() != null && !event.world.isRemote)
{
//Map copy = (Map)((HashMap)event.getChunk().chunkTileEntityMap).clone();
HashMap<ChunkPosition, TileEntity> chunkData = new HashMap<ChunkPosition, TileEntity>(event.getChunk().chunkTileEntityMap);

for(Iterator iter = /*copy*/event.getChunk().chunkTileEntityMap.values().iterator(); iter.hasNext();)
{
Object obj = iter.next();

if(obj instanceof TileEntity)
{
TileEntity tileEntity = (TileEntity)obj;

if(tileEntity instanceof TileEntityElectricBlock && MekanismUtils.useIC2())
{
((TileEntityElectricBlock)tileEntity).register();
}
else if(tileEntity instanceof IChunkLoadHandler)
{
((IChunkLoadHandler)tileEntity).onChunkLoad();
}
for (TileEntity tileEntity : chunkData.values()) {
if (tileEntity instanceof TileEntityElectricBlock && MekanismUtils.useIC2()) {
((TileEntityElectricBlock) tileEntity).register();
} else if (tileEntity instanceof IChunkLoadHandler) {
((IChunkLoadHandler) tileEntity).onChunkLoad();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ else if(isFrame(Coord4D.get(tile).translate(x, y, z), origX+xmin, origX+xmax, or

if(isViableNode(coord.xCoord, coord.yCoord, coord.zCoord))
{
if(!iteratedNodes.contains(tileEntity))
if(tileEntity != null && !iteratedNodes.contains(tileEntity))
{
loopThrough(tileEntity);
}
Expand Down

0 comments on commit 3eb98a1

Please sign in to comment.