Implemented a failsafe tick handler in FrequencyManager, fixed a small deactivation mishap
This commit is contained in:
parent
6801092113
commit
093d18e6fa
2 changed files with 53 additions and 0 deletions
|
@ -86,6 +86,7 @@ public class CommonWorldTickHandler
|
|||
if(!world.isRemote)
|
||||
{
|
||||
MultiblockManager.tick(world);
|
||||
FrequencyManager.tick(world);
|
||||
|
||||
if(chunkRegenMap == null)
|
||||
{
|
||||
|
|
|
@ -9,8 +9,10 @@ import java.util.Iterator;
|
|||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.tile.TileEntityTeleporter;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
@ -65,6 +67,8 @@ public class FrequencyManager
|
|||
}
|
||||
}
|
||||
|
||||
deactivate(coord);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -213,6 +217,54 @@ public class FrequencyManager
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void tick(World world)
|
||||
{
|
||||
if(!loaded)
|
||||
{
|
||||
load(world);
|
||||
}
|
||||
|
||||
for(FrequencyManager manager : managers)
|
||||
{
|
||||
manager.tickSelf(world);
|
||||
}
|
||||
}
|
||||
|
||||
public void tickSelf(World world)
|
||||
{
|
||||
for(Frequency iterFreq : frequencies)
|
||||
{
|
||||
for(Iterator<Coord4D> iter = iterFreq.activeCoords.iterator(); iter.hasNext();)
|
||||
{
|
||||
Coord4D coord = iter.next();
|
||||
|
||||
if(coord.dimensionId == world.provider.dimensionId)
|
||||
{
|
||||
if(!coord.exists(world))
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
else {
|
||||
TileEntity tile = coord.getTileEntity(world);
|
||||
|
||||
if(!(tile instanceof TileEntityTeleporter))
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
else {
|
||||
Frequency freq = ((TileEntityTeleporter)tile).frequency;
|
||||
|
||||
if(freq == null || !freq.equals(iterFreq))
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeFrequencies(ArrayList data)
|
||||
{
|
||||
data.add(frequencies.size());
|
||||
|
|
Loading…
Reference in a new issue