Search in sources :

Example 1 with Ticket

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);
        }
    }
}
Also used : Ticket(net.minecraftforge.common.ForgeChunkManager.Ticket) GenericRailTransport(ebf.tim.entities.GenericRailTransport)

Example 2 with Ticket

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);
        }
    }
}
Also used : Ticket(net.minecraftforge.common.ForgeChunkManager.Ticket)

Example 3 with Ticket

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);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Ticket(net.minecraftforge.common.ForgeChunkManager.Ticket) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) TileWorldspike(mods.railcraft.common.blocks.machine.worldspike.TileWorldspike) BlockPos(net.minecraft.util.math.BlockPos) EntityCartWorldspike(mods.railcraft.common.carts.EntityCartWorldspike)

Example 4 with Ticket

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);
}
Also used : Ticket(net.minecraftforge.common.ForgeChunkManager.Ticket) ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair)

Example 5 with Ticket

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);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Ticket(net.minecraftforge.common.ForgeChunkManager.Ticket) ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

Ticket (net.minecraftforge.common.ForgeChunkManager.Ticket)9 TileEntity (net.minecraft.tileentity.TileEntity)3 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)3 EntityCartWorldspike (mods.railcraft.common.carts.EntityCartWorldspike)2 Entity (net.minecraft.entity.Entity)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 GenericRailTransport (ebf.tim.entities.GenericRailTransport)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 TileWorldspike (mods.railcraft.common.blocks.machine.worldspike.TileWorldspike)1 BlockPos (net.minecraft.util.math.BlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1