use of net.minecraftforge.common.ForgeChunkManager.Ticket in project ArsMagica2 by Mithion.
the class AMChunkLoader method requestStaticChunkLoad.
/**
* Requests a static chunk load. This is a non-moving chunk load, and will be assumed that the specified class will exist as a tile entity
*
* @param clazz the class to look for
* @param x the x coordinate of the tile entity
* @param y the y coordinate of the tile entity
* @param z the z coordinate of the tile entity
* @param world The world object of the tile entity
*/
public void requestStaticChunkLoad(Class clazz, int x, int y, int z, World world) {
Ticket ticket = requestTicket(x, y, z, world);
if (ticket == null) {
LogHelper.warn("Unable to get a ticket for chunk loading! The chunk identified by %d, %d is *not* loaded!", x, z);
return;
}
NBTTagCompound compound = ticket.getModData();
compound.setIntArray("StaticLoadCoords", new int[] { x, y, z });
compound.setString("ChunkLoadClass", clazz.getName());
ChunkCoordIntPair pair = new ChunkCoordIntPair(x >> 4, z >> 4);
ForgeChunkManager.forceChunk(ticket, pair);
}
use of net.minecraftforge.common.ForgeChunkManager.Ticket in project Railcraft by Railcraft.
the class TileWorldspike method setTicket.
public void setTicket(@Nullable Ticket t) {
boolean changed = false;
Ticket ticket = getTicket();
if (ticket != t) {
if (ticket != null) {
if (ticket.world == worldObj) {
for (ChunkPos chunk : ticket.getChunkList()) {
if (ForgeChunkManager.getPersistentChunksFor(worldObj).keys().contains(chunk))
ForgeChunkManager.unforceChunk(ticket, chunk);
}
ForgeChunkManager.releaseTicket(ticket);
}
tickets.remove(getUUID());
}
changed = true;
}
hasTicket = t != null;
if (hasTicket)
tickets.put(getUUID(), t);
if (changed)
sendUpdateToClient();
}
use of net.minecraftforge.common.ForgeChunkManager.Ticket in project Railcraft by Railcraft.
the class ChunkManager method ticketsLoaded.
@Override
public List<Ticket> ticketsLoaded(List<Ticket> tickets, World world, int maxTicketCount) {
// System.out.println("Callback 1");
Set<Ticket> adminTickets = new HashSet<Ticket>();
Set<Ticket> worldTickets = new HashSet<Ticket>();
Set<Ticket> cartTickets = new HashSet<Ticket>();
for (Ticket ticket : tickets) {
Entity entity = ticket.getEntity();
if (entity == null) {
int y = ticket.getModData().getInteger("yCoord");
String type = ticket.getModData().getString("type");
if (y >= 0) {
if (type.equals(WorldspikeVariant.ADMIN.getTag()))
adminTickets.add(ticket);
else if (type.equals(WorldspikeVariant.STANDARD.getTag()))
worldTickets.add(ticket);
else if (type.isEmpty())
worldTickets.add(ticket);
}
} else {
if (entity instanceof EntityCartWorldspike) {
// System.out.println("Claim Cart Ticket");
cartTickets.add(ticket);
}
}
}
List<Ticket> claimedTickets = new LinkedList<Ticket>();
claimedTickets.addAll(cartTickets);
claimedTickets.addAll(adminTickets);
claimedTickets.addAll(worldTickets);
return claimedTickets;
}
use of net.minecraftforge.common.ForgeChunkManager.Ticket in project Railcraft by Railcraft.
the class EntityCartWorldspike method requestTicket.
private boolean requestTicket() {
if (meetsTicketRequirements()) {
Ticket chunkTicket = getTicketFromForge();
//noinspection ConstantConditions
if (chunkTicket != null) {
// System.out.println("Request Ticket: " + worldObj.getClass().getSimpleName());
chunkTicket.getModData();
chunkTicket.setChunkListDepth(MAX_CHUNKS);
chunkTicket.bindEntity(this);
setChunkTicket(chunkTicket);
forceChunkLoading(chunkCoordX, chunkCoordZ);
return true;
}
}
return false;
}
Aggregations