mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Fixed Tesla crash, added chunk loading system to allow for ease of future additions
This commit is contained in:
1 parent
d629fc03b7
commit
4958c40380
6 files changed
+221
-44
No files matched your search
@@ -28,6 +28,7 @@ import mekanism.common.network.PacketEntityMove.EntityMoveMessage;
|
||||
import mekanism.common.network.PacketPortalFX.PortalFXMessage;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentChunkLoader;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -46,11 +47,9 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Type;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -73,8 +72,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
public List<Frequency> publicCache = new ArrayList<Frequency>();
|
||||
public List<Frequency> privateCache = new ArrayList<Frequency>();
|
||||
|
||||
public Ticket chunkTicket;
|
||||
|
||||
/** This teleporter's current status. */
|
||||
public byte status = 0;
|
||||
@@ -82,6 +79,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentSecurity securityComponent;
|
||||
public TileComponentChunkLoader chunkLoaderComponent;
|
||||
|
||||
public TileEntityTeleporter()
|
||||
{
|
||||
@@ -89,6 +87,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
inventory = new ItemStack[1];
|
||||
|
||||
securityComponent = new TileComponentSecurity(this);
|
||||
chunkLoaderComponent = new TileComponentChunkLoader(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,20 +102,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(chunkTicket == null)
|
||||
{
|
||||
Ticket ticket = ForgeChunkManager.requestTicket(Mekanism.instance, worldObj, Type.NORMAL);
|
||||
|
||||
if(ticket != null)
|
||||
{
|
||||
ticket.getModData().setInteger("xCoord", getPos().getX());
|
||||
ticket.getModData().setInteger("yCoord", getPos().getY());
|
||||
ticket.getModData().setInteger("zCoord", getPos().getZ());
|
||||
|
||||
forceChunks(ticket);
|
||||
}
|
||||
}
|
||||
|
||||
FrequencyManager manager = getManager(frequency);
|
||||
|
||||
if(manager != null)
|
||||
@@ -263,8 +248,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
releaseChunks();
|
||||
|
||||
if(frequency != null)
|
||||
{
|
||||
FrequencyManager manager = getManager(frequency);
|
||||
@@ -760,24 +743,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
return INFINITE_EXTENT_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceChunks(Ticket ticket)
|
||||
{
|
||||
releaseChunks();
|
||||
chunkTicket = ticket;
|
||||
|
||||
ForgeChunkManager.forceChunk(chunkTicket, new Chunk3D(Coord4D.get(this)).getPos());
|
||||
}
|
||||
|
||||
public void releaseChunks()
|
||||
{
|
||||
if(chunkTicket != null)
|
||||
{
|
||||
ForgeChunkManager.releaseTicket(chunkTicket);
|
||||
chunkTicket = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
@@ -801,4 +766,20 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
{
|
||||
return securityComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentChunkLoader getChunkLoader()
|
||||
{
|
||||
return chunkLoaderComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ChunkPos> getChunkSet()
|
||||
{
|
||||
Set<ChunkPos> ret = new HashSet<ChunkPos>();
|
||||
|
||||
ret.add(new Chunk3D(Coord4D.get(this)).getPos());
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user