Skip to content

Commit

Permalink
Fixes CMEs
Browse files Browse the repository at this point in the history
Fixes Client CME with jetpack
Fixes Server CME with chunks
  • Loading branch information
DrParadox7 committed Sep 17, 2023
1 parent e900821 commit 335c668
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 46 deletions.
41 changes: 20 additions & 21 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 @@ -203,7 +202,8 @@ else if(stack.getItem() instanceof ItemScubaTank)

if(world.getWorldTime() % 4 == 0)
{
for(EntityPlayer p : (List<EntityPlayer>)world.playerEntities)
List<EntityPlayer> flamethrowerPlayers = (List<EntityPlayer>)world.playerEntities;
for(EntityPlayer p : flamethrowerPlayers)
{
if(!Mekanism.flamethrowerActive.contains(p.getCommandSenderName()) && !p.isSwingInProgress && p.getCurrentEquippedItem() != null && p.getCurrentEquippedItem().getItem() instanceof ItemFlamethrower)
{
Expand Down Expand Up @@ -258,17 +258,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

0 comments on commit 335c668

Please sign in to comment.