use of net.minecraftforge.common.ForgeChunkManager.Ticket in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class ChunkHandler method ticketsLoaded.
@Override
public void ticketsLoaded(List<Ticket> tickets, World world) {
for (Ticket ticket : tickets) {
if (!ticket.isPlayerTicket() && ticket.getEntity() instanceof GenericRailTransport) {
GenericRailTransport transport = (GenericRailTransport) ticket.getEntity();
transport.setChunkTicket(ticket);
forceChunkLoading(transport, transport.chunkCoordX, transport.chunkCoordZ);
}
}
}
use of net.minecraftforge.common.ForgeChunkManager.Ticket in project Railcraft by Railcraft.
the class TileWorldspike method requestTicket.
protected void requestTicket() {
if (meetsTicketRequirements()) {
Ticket chunkTicket = getTicketFromForge();
if (chunkTicket != null) {
setTicketData(chunkTicket);
forceChunkLoading(chunkTicket);
}
}
}
use of net.minecraftforge.common.ForgeChunkManager.Ticket in project Railcraft by Railcraft.
the class ChunkManager method ticketsLoaded.
@Override
public void ticketsLoaded(List<Ticket> tickets, World world) {
// System.out.println("Callback 2");
for (Ticket ticket : tickets) {
if (ticket.isPlayerTicket())
continue;
Entity entity = ticket.getEntity();
if (entity == null) {
int x = ticket.getModData().getInteger("xCoord");
int y = ticket.getModData().getInteger("yCoord");
int z = ticket.getModData().getInteger("zCoord");
if (y >= 0) {
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
if (tile instanceof TileWorldspike) {
TileWorldspike worldspike = (TileWorldspike) tile;
worldspike.forceChunkLoading(ticket);
printWorldspike(worldspike.getName(), x, y, z);
}
}
} else {
if (entity instanceof EntityCartWorldspike) {
EntityCartWorldspike worldspike = (EntityCartWorldspike) entity;
worldspike.setChunkTicket(ticket);
// System.out.println("Load Cart Chunks");
worldspike.forceChunkLoading(worldspike.chunkCoordX, worldspike.chunkCoordZ);
printWorldspike(worldspike.getName(), (int) entity.posX, (int) entity.posY, (int) entity.posZ);
}
}
}
}
use of net.minecraftforge.common.ForgeChunkManager.Ticket in project ArsMagica2 by Mithion.
the class AMChunkLoader method releaseStaticChunkLoad.
public void releaseStaticChunkLoad(Class clazz, int x, int y, int z, World world) {
Ticket ticket = getTicket(new TicketIdentifier(x, y, z, world.provider.dimensionId));
if (ticket == null) {
LogHelper.warn("No ticket for specified location. No chunk to unload!");
return;
}
ChunkCoordIntPair pair = new ChunkCoordIntPair(x >> 4, z >> 4);
ForgeChunkManager.unforceChunk(ticket, pair);
}
use of net.minecraftforge.common.ForgeChunkManager.Ticket in project ArsMagica2 by Mithion.
the class AMChunkLoader method ticketsLoaded.
@Override
public void ticketsLoaded(List<Ticket> tickets, World world) {
for (Ticket ticket : tickets) {
NBTTagCompound compound = ticket.getModData();
int[] coords = compound.getIntArray("StaticLoadCoords");
String clazzName = compound.getString("ChunkLoadClass");
Class clazz = null;
try {
clazz = Class.forName(clazzName);
} catch (ClassNotFoundException e) {
LogHelper.info("Cached class not found (%s) when attempting to load a chunk loading ticket. This ticket will be discarded, and the chunk may not be loaded. Block Coords: %d, %d", clazzName, coords[0], coords[2]);
ForgeChunkManager.releaseTicket(ticket);
continue;
}
TileEntity te = world.getTileEntity(coords[0], coords[1], coords[2]);
if (te != null && te.getClass().isAssignableFrom(clazz)) {
ChunkCoordIntPair pair = new ChunkCoordIntPair(coords[0] >> 4, coords[2] >> 4);
ForgeChunkManager.forceChunk(ticket, pair);
} else {
LogHelper.info("Either no tile entity was found or it did not match the cached class. This chunk loading ticket will be discarded, and the chunk may not be loaded. Block Coords: %d, %d", coords[0], coords[2]);
ForgeChunkManager.releaseTicket(ticket);
}
}
}
Aggregations