下面列出了怎么用net.minecraftforge.common.ForgeChunkManager.Type的API类实例代码及写法,或者点击链接到github查看源代码。
public BaseVehicleEntity(World worldIn) {
super(worldIn);
storage = new ShipStorage(getOffset(), worldIn);
Ticket tic = ForgeChunkManager.requestTicket(CommunityMod.INSTANCE,
DimensionManager.getWorld(StorageDimReg.storageDimensionType.getId()), Type.NORMAL);
loadTicket = tic;
}
public boolean markAsChunkLoader(String chunkloadingPlayer, EntityMinecart cart){
Ticket ticket = ForgeChunkManager.requestPlayerTicket(Signals.instance, chunkloadingPlayer, cart.world, Type.ENTITY);
if(ticket != null) {
ticket.bindEntity(cart);
add(ticket);
return true;
} else {
return false;
}
}
@Override
public void onLoad() {
if(ticket == null) {
ticket = ForgeChunkManager.requestTicket(AdvancedRocketry.instance, this.world, Type.NORMAL);
if(ticket != null)
ForgeChunkManager.forceChunk(ticket, new ChunkPos(getPos().getX() / 16 - (getPos().getX() < 0 ? 1 : 0), getPos().getZ() / 16 - (getPos().getZ() < 0 ? 1 : 0)));
}
}
/**
* Checks to see if the situation for firing the laser exists... and changes the state accordingly
*/
public void checkCanRun() {
//Laser requires lense, redstone power, not be jammed, and be in orbit and energy to function
if(world.isBlockIndirectlyGettingPowered(getPos()) == 0 || !isAllowedToRun()) {
if(laserSat.isAlive()) {
laserSat.deactivateLaser();
}
setRunning(false);
} else if(!laserSat.isAlive() && !finished && !laserSat.getJammed() && world.isBlockIndirectlyGettingPowered(getPos()) > 0 && canMachineSeeEarth()) {
//Laser will be on at this point
int orbitDimId = ((WorldProviderSpace)this.world.provider).getDimensionProperties(getPos()).getParentPlanet();
if(orbitDimId == SpaceObjectManager.WARPDIMID)
return;
WorldServer orbitWorld = DimensionManager.getWorld(orbitDimId);
if(orbitWorld == null) {
DimensionManager.initDimension(orbitDimId);
orbitWorld = DimensionManager.getWorld(orbitDimId);
if(orbitWorld == null)
return;
}
if(ticket == null) {
ticket = ForgeChunkManager.requestTicket(AdvancedRocketry.instance, this.world, Type.NORMAL);
if(ticket != null)
ForgeChunkManager.forceChunk(ticket, new ChunkPos(getPos().getX() / 16 - (getPos().getX() < 0 ? 1 : 0), getPos().getZ() / 16 - (getPos().getZ() < 0 ? 1 : 0)));
}
setRunning(laserSat.activateLaser(orbitWorld, laserX, laserZ));
}
if(!this.world.isRemote)
PacketHandler.sendToNearby(new PacketMachine(this, (byte)12), 128, pos, this.world.provider.getDimension());
}
/**
* creates the laser and begins mining. This can
* fail if the chunk cannot be force loaded
* @param world world to spawn the laser into
* @param x x coord
* @param z z coord
* @return whether creating the laser is successful
*/
public boolean activateLaser(World world, int x, int z) {
ticketLaser = ForgeChunkManager.requestTicket(AdvancedRocketry.instance, world, Type.NORMAL);
if(ticketLaser != null) {
ForgeChunkManager.forceChunk(ticketLaser, new ChunkPos(x >> 4, z >> 4));
int y = 64;
if(world.getChunkFromChunkCoords(x >> 4, z >> 4).isLoaded()) {
int current = 0;
for(int i = 0; i < 9; i++) {
current = world.getTopSolidOrLiquidBlock(new BlockPos(x + (i % 3) - 1, 0xFF, z + (i / 3) - 1)).getY();
if(current > y)
y = current;
}
if(y < 1)
y = 255;
}
else
y = 255;
laser = new EntityLaserNode(world, x, y, z);
laser.forceSpawn = true;
world.spawnEntity(laser);
return true;
}
return false;
}
@Override
public Ticket createTicket(int dimension) {
return ForgeChunkManager.requestPlayerTicket(ChickenChunks.instance, username, DimensionManager.getWorld(dimension), Type.NORMAL);
}
@Override
protected Ticket createTicket(int dimension) {
return ForgeChunkManager.requestTicket(mod, DimensionManager.getWorld(dimension), Type.NORMAL);
}