@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { SimpleChunks.logger.info("Releasing chunkloading ticket"); TileEntity te = worldIn.getTileEntity(pos); if (te instanceof TileEntityChunkLoader) { TileEntityChunkLoader loader = (TileEntityChunkLoader) te; loader.clearTicketChunks(); ForgeChunkManager.Ticket tkt = loader.getChunkTicket(); ForgeChunkManager.releaseTicket(tkt); } super.breakBlock(worldIn, pos, state); }
@Override public void ticketsLoaded(List<ForgeChunkManager.Ticket> tickets, World world) { for (ForgeChunkManager.Ticket ticket : tickets) { BlockPos ticketPosition = NBTUtil.getPosFromTag(ticket.getModData().getCompoundTag("position")); TileEntity te = world.getTileEntity(ticketPosition); if (te instanceof TileEntityChunkLoader) { TileEntityChunkLoader loader = (TileEntityChunkLoader) te; loader.setChunkTicket(ticket); loader.forceChunks(); } else { ForgeChunkManager.releaseTicket(ticket); } } }
@Override public ListMultimap<String, ForgeChunkManager.Ticket> playerTicketsLoaded(ListMultimap<String, ForgeChunkManager.Ticket> tickets, World world) { // We don't care what order the tickets are in, but filter out the invalid ones ListMultimap<String, ForgeChunkManager.Ticket> validTickets = ArrayListMultimap.create(); for (String playerName : tickets.keySet()) { List<ForgeChunkManager.Ticket> playerTickets = new ArrayList<>(); for (ForgeChunkManager.Ticket tkt : tickets.get(playerName)) { BlockPos ticketPosition = NBTUtil.getPosFromTag(tkt.getModData().getCompoundTag("position")); TileEntity te = world.getTileEntity(ticketPosition); if (te instanceof TileEntityChunkLoader) { playerTickets.add(tkt); } } validTickets.putAll(playerName, playerTickets); } return validTickets; }
@Override protected GuiScreen buildChildScreen() { List<IConfigElement> list = new ArrayList<IConfigElement>(); list.add(new DummyCategoryElement("forgeChunkLoadingModCfg", "forge.configgui.ctgy.forgeChunkLoadingModConfig", ModOverridesEntry.class)); list.addAll((new ConfigElement(ForgeChunkManager.getDefaultsCategory())).getChildElements()); // This GuiConfig object specifies the configID of the object and as such will force-save when it is closed. The parent // GuiConfig object's propertyList will also be refreshed to reflect the changes. return new GuiConfig(this.owningScreen, list, this.owningScreen.modID, "chunkLoader", this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(ForgeChunkManager.getConfig().toString()), I18n.format("forge.configgui.ctgy.forgeChunkLoadingConfig")); }
/** * This method is called in the constructor and is used to set the childScreen field. */ @Override protected GuiScreen buildChildScreen() { List<IConfigElement> list = new ArrayList<IConfigElement>(); list.add(new DummyCategoryElement("addForgeChunkLoadingModCfg", "forge.configgui.ctgy.forgeChunkLoadingAddModConfig", AddModOverrideEntry.class)); for (ConfigCategory cc : ForgeChunkManager.getModCategories()) list.add(new ConfigElement(cc)); return new GuiConfig(this.owningScreen, list, this.owningScreen.modID, this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, this.owningScreen.title, I18n.format("forge.configgui.ctgy.forgeChunkLoadingModConfig")); }
public void nextChunk() { this.unloadChunk(); ++this.chunk_x; if (this.chunk_x << 4 >= this.max_x) { this.chunk_x = this.min_x + 1 >> 4; ++this.chunk_z; if (this.chunk_z << 4 >= this.max_z) { this.finished = true; this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, 2, 2); ForgeChunkManager.releaseTicket(this.chunkTicket); return; } } this.dy = this.chunk_y; this.loadChunk(); }
public void ticketsLoaded(final List<ForgeChunkManager.Ticket> tickets, final World world) { for (final ForgeChunkManager.Ticket ticket : tickets) { final String ticket_id = ticket.getModData().getString("id"); if (ticket_id.equals("pump")) { final int pumpX = ticket.getModData().getInteger("pumpX"); final int pumpY = ticket.getModData().getInteger("pumpY"); final int pumpZ = ticket.getModData().getInteger("pumpZ"); final TileEntityEnderThermicLavaPump tq = (TileEntityEnderThermicLavaPump)world.getTileEntity(pumpX, pumpY, pumpZ); tq.forceChunkLoading(ticket); } if (ticket_id.equals("quarry")) { final int x = ticket.getModData().getInteger("x"); final int y = ticket.getModData().getInteger("y"); final int z = ticket.getModData().getInteger("z"); final TileEntityEnderQuarry tq2 = (TileEntityEnderQuarry)world.getTileEntity(x, y, z); tq2.forceChunkLoading(ticket); } } }
public static void forceChunk(Ticket ticket, World world, int x, int y, int z, String playerName) { ChunkLoadingCallback.addToList(world, x, y, z, playerName); ChunkCoordIntPair chunkPos = new ChunkCoordIntPair(x >> 4, z >> 4); ForgeChunkManager.forceChunk(ticket, chunkPos); // // TileEntity tile = world.getTileEntity(x, y, z); // // if (tile instanceof IChunkLoader) // { // IChunkLoader chunkLoader = (IChunkLoader) tile; // int dimID = world.provider.dimensionId; // // HashSet<IChunkLoader> chunkList = loadedChunks.get(dimID); // // if (chunkList == null) // { // chunkList = new HashSet<IChunkLoader>(); // } // // ForgeChunkManager.forceChunk(ticket, chunkPos); // chunkList.add(chunkLoader); // loadedChunks.put(dimID, chunkList); // } }
public ForgeChunkManager.Ticket getPlayerTicket(final GameProfile profile) { HashMap<GameProfile, ForgeChunkManager.Ticket> gameProfileTicketHashMap = PlayerCubeChunkLoaderManager.playerTickets; if (gameProfileTicketHashMap == null) { PlayerCubeChunkLoaderManager.playerTickets = gameProfileTicketHashMap = new HashMap<GameProfile, ForgeChunkManager.Ticket>(); } ForgeChunkManager.Ticket ticket = gameProfileTicketHashMap.get(profile); if (ticket == null) { ticket = ForgeChunkManager.requestPlayerTicket(CrystalMod.instance, profile.getName(), CubeManager.getInstance().getWorld(), ForgeChunkManager.Type.NORMAL); final NBTTagCompound tag = ticket.getModData(); tag.setString("Name", profile.getName()); final UUID id = profile.getId(); if (id != null) { tag.setLong("UUIDL", id.getLeastSignificantBits()); tag.setLong("UUIDU", id.getMostSignificantBits()); } gameProfileTicketHashMap.put(profile, ticket); } return ticket; }
@Override protected GuiScreen buildChildScreen() { List<IConfigElement> list = new ArrayList<IConfigElement>(); list.add(new DummyCategoryElement("forgeChunkLoadingModCfg", "forge.configgui.ctgy.forgeChunkLoadingModConfig", ModOverridesEntry.class)); list.addAll((new ConfigElement(ForgeChunkManager.getDefaultsCategory())).getChildElements()); // This GuiConfig object specifies the configID of the object and as such will force-save when it is closed. The parent // GuiConfig object's propertyList will also be refreshed to reflect the changes. return new GuiConfig(this.owningScreen, list, this.owningScreen.modID, "chunkLoader", this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, GuiConfig.getAbridgedConfigPath(ForgeChunkManager.getConfig().toString()), I18n.func_135052_a("forge.configgui.ctgy.forgeChunkLoadingConfig")); }
/** * This method is called in the constructor and is used to set the childScreen field. */ @Override protected GuiScreen buildChildScreen() { List<IConfigElement> list = new ArrayList<IConfigElement>(); list.add(new DummyCategoryElement("addForgeChunkLoadingModCfg", "forge.configgui.ctgy.forgeChunkLoadingAddModConfig", AddModOverrideEntry.class)); for (ConfigCategory cc : ForgeChunkManager.getModCategories()) list.add(new ConfigElement(cc)); return new GuiConfig(this.owningScreen, list, this.owningScreen.modID, this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, this.owningScreen.title, I18n.func_135052_a("forge.configgui.ctgy.forgeChunkLoadingModConfig")); }
public int getChunkCount(ImmutableSetMultimap<ChunkPos, ForgeChunkManager.Ticket> tickets) { int count = 0; for(ChunkPos key : tickets.asMap().keySet()) { Collection<ForgeChunkManager.Ticket> ticketList = tickets.asMap().get(key); for(ForgeChunkManager.Ticket ticket : ticketList) { if(Reference.MOD_ID.equals(ticket.getModId())) { count++; } } } return count; }
public void disable() { if(enabled) { //FMLLog.log(Level.INFO, "Disabling chunk at: " + toString() + " for owner: " + ownerId); // Unforce chunk, release ticket unforceChunkLoading(); if(ticket != null) { ForgeChunkManager.releaseTicket(ticket); ticket = null; } enabled = false; } }
@Override public void invalidate() { if(ticket != null) { ForgeChunkManager.releaseTicket(ticket); ticket = null; } // Remove loader from world data SavedData data = SavedData.get(world); if(world.isRemote || data == null) { return; } ChunkLoaders cl = data.getChunkLoaders(); if(world.provider != null) { cl.removeLoader(new ChunkLoaderPos(ownerId.toString(), world.provider.getDimension(), getPos(), 0)); data.setChunkLoaders(cl); } super.invalidate(); }
public void unforceChunkLoading() { int size = ConfigurationHandler.chunkLoaderSize; if(size % 2 != 0 && size > 1) { size--; } int dist = size / 2; ChunkPos centerPos = new ChunkPos(pos.getX() / 16, pos.getZ() / 16); for(int x = centerPos.chunkXPos - dist; x <= centerPos.chunkXPos + dist; x++) { for (int z = centerPos.chunkZPos - dist; z <= centerPos.chunkZPos + dist; z++) { ChunkPos chunkPos = new ChunkPos(x, z); ForgeChunkManager.unforceChunk(ticket, chunkPos); FMLLog.log(Level.INFO, "Unchunkloading at chunk pos: " + chunkPos); } } }
@Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { // Config ConfigurationHandler.Init(event.getSuggestedConfigurationFile()); MinecraftForge.EVENT_BUS.register(new ConfigurationHandler()); // Login/Logout Tracking MinecraftForge.EVENT_BUS.register(new PlayerActivity()); MinecraftForge.EVENT_BUS.register(new PlayerTimeout()); // Chunk Loading ForgeChunkManager.setForcedChunkLoadingCallback(instance, new ChunkLoadingCallback()); // Blocks and Items ModBlocks.init(); ModBlocks.registerBlocks(); ModBlocks.registerRecipes(); // Keybinds proxy.registerKeys(); }
@Override public void ticketsLoaded(List<Ticket> tickets, World world) { for (ForgeChunkManager.Ticket ticket : tickets) { int xPos = ticket.getModData().getInteger("xPos"); int yPos = ticket.getModData().getInteger("yPos"); int zPos = ticket.getModData().getInteger("zPos"); BlockPos pos = new BlockPos(xPos, yPos, zPos); Block block = world.getBlockState(pos).getBlock(); if (block == ModBlocks.getBlock(ModBlocks.CHUNK_LOADER)) { ChunkLoaderTileEntity chunkLoaderTile = (ChunkLoaderTileEntity) world.getTileEntity(pos); if(chunkLoaderTile != null) { chunkLoaderTile.forceChunkLoading(ticket); } } } }
@Override public List<ForgeChunkManager.Ticket> ticketsLoaded(List<ForgeChunkManager.Ticket> tickets, World world, int maxTicketCount) { Set<ForgeChunkManager.Ticket> worldTickets = new HashSet<ForgeChunkManager.Ticket>(); Set<ForgeChunkManager.Ticket> cartTickets = new HashSet<ForgeChunkManager.Ticket>(); for (ForgeChunkManager.Ticket ticket : tickets) { Entity entity = ticket.getEntity(); if (entity == null) { int y = ticket.getModData().getInteger("yCoord"); if (y >= 0) { worldTickets.add(ticket); } } else { if (entity instanceof LocoBase) { cartTickets.add(ticket); } } } List<ForgeChunkManager.Ticket> claimedTickets = new LinkedList<ForgeChunkManager.Ticket>(); claimedTickets.addAll(cartTickets); claimedTickets.addAll(worldTickets); return claimedTickets; }
@SuppressWarnings ("unchecked") public void loadDimension(WorldServer world) { PacketCustom packet = new PacketCustom(channel, 2).compress(); int dim = CommonUtils.getDimension(world); packet.writeInt(dim); Collection<Chunk> allchunks = world.getChunkProvider().getLoadedChunks(); packet.writeInt(allchunks.size()); for (Chunk chunk : allchunks) { packet.writeInt(chunk.x); packet.writeInt(chunk.z); } Map<Ticket, Collection<ChunkPos>> tickets = ForgeChunkManager.getPersistentChunksFor(world).inverse().asMap(); packet.writeInt(tickets.size()); for (Entry<Ticket, Collection<ChunkPos>> entry : tickets.entrySet()) { writeTicketToPacket(packet, entry.getKey(), entry.getValue()); } packet.sendToPlayer(owner); }
protected void addChunk(DimChunkCoord coord) { if (heldChunks.containsKey(coord)) { return; } Stack<Ticket> freeTickets = ticketsWithSpace.computeIfAbsent(coord.dimension, k -> new Stack<>()); Ticket ticket; if (freeTickets.isEmpty()) { freeTickets.push(ticket = createTicket(coord.dimension)); } else { ticket = freeTickets.peek(); } ForgeChunkManager.forceChunk(ticket, coord.getChunkCoord()); heldChunks.put(coord, ticket); if (ticket.getChunkList().size() == ticket.getChunkListDepth() && !freeTickets.isEmpty()) { freeTickets.pop(); } }
public TicketInfo(PacketCustom packet, WorldClient world) { ID = packet.readInt(); modId = packet.readString(); if (packet.readBoolean()) { player = packet.readString(); } type = ForgeChunkManager.Type.values()[packet.readUByte()]; if (type == ForgeChunkManager.Type.ENTITY) { entity = world.getEntityByID(packet.readInt()); } int chunks = packet.readUShort(); chunkSet = new HashSet<>(chunks); for (int i = 0; i < chunks; i++) { chunkSet.add(new ChunkPos(packet.readInt(), packet.readInt())); } }
public ForgeChunkManager.Ticket register(Set<Chunk> chunkSet) { ForgeChunkManager.Ticket ticket = ForgeChunkManager.requestTicket(Hammer.instance, DeltaChunk.getServerShadowWorld(), ForgeChunkManager.Type.NORMAL); if (ticket == null) { Hammer.logSevere("Failed to acquire chunk ticket. You may need to adjust config/forgeChunkLoading.cfg"); return null; } final int maxSize = ticket.getMaxChunkListDepth(); final int size = chunkSet.size(); if (size > maxSize) { Hammer.logSevere("Registering %s chunks for loading, but ticket only has room for %s. You may need to adjust config/forgeChunkLoading.cfg", size, maxSize); } for (Chunk chunk : chunkSet) { ForgeChunkManager.forceChunk(ticket, chunk.getChunkCoordIntPair()); } return ticket; }
public void forceChunk(Ticket ticket) { if (ticket != null) { ticket.getModData().setInteger("controllerX", xCoord); ticket.getModData().setInteger("controllerY", yCoord); ticket.getModData().setInteger("controllerZ", zCoord); ArrayList<ChunkCoordIntPair> loadedChunks = new ArrayList<ChunkCoordIntPair>(); ForgeChunkManager.forceChunk(ticket, getBlockPos().getChunk()); loadedChunks.add(getBlockPos().getChunk()); for (BlockPos pos : portalFrames) { if (!loadedChunks.contains(pos.getChunk())) { ForgeChunkManager.forceChunk(ticket, pos.getChunk()); loadedChunks.add(pos.getChunk()); } } EnhancedPortals.instance.getLogger().debug("Keeping " + loadedChunks.size() + " chunks loaded at " + getWorldPos()); } else { EnhancedPortals.instance.getLogger().warn("Could not get a ChunkLoading ticket for Portal at " + getWorldPos() + " Things may not work as expected!"); } chunkLoadTicket = ticket; }
private void loadChunks(List<ChunkCoordIntPair> chunks) { // ChunkyPeripherals.infoLog("loadChunks, radius="+radiusInChunks+" mode="+mode); if(ticket==null) { /* Ticket t = ChunkLoadingCallback.starterTicketsList.remove(this);//prova a cercarlo nella lista if(t==null)//se non era nella lista {*/ ChunkyPeripherals.infoLog("creating new ticket at " + xCoord + ", "+ yCoord + ", "+ zCoord+", "+getWorldObj()); ticket = TicketManager.getNewTicket(getWorldObj()); if(ticket.isPlayerTicket()) ChunkyPeripherals.infoLog("the ticket is a player ticket: player="+ticket.getPlayerName()); ticket.getModData().setInteger("posX", xCoord); ticket.getModData().setInteger("posY", yCoord); ticket.getModData().setInteger("posZ", zCoord); // } } for(ChunkCoordIntPair chunk : chunks) { ChunkyPeripherals.infoLog("forcing chunk "+chunk); ForgeChunkManager.forceChunk(ticket, chunk); } }
@Override public void processCommand(ICommandSender icommandsender, String[] astring) { ChunkyPeripherals.logger.info("World: " + icommandsender.getEntityWorld().getWorldInfo().getWorldName()); ImmutableSetMultimap<ChunkCoordIntPair, Ticket> l = ForgeChunkManager.getPersistentChunksFor(icommandsender.getEntityWorld()); Collection<Ticket> c =l.values(); Iterator<Ticket> i = c.iterator(); int count=0; while (i.hasNext()) { Ticket t = i.next(); ChunkyPeripherals.logger.info("ticket #"+(count++)+" ="+t); ImmutableSet<ChunkCoordIntPair> sc = t.getChunkList(); ImmutableList<ChunkCoordIntPair> lc = sc.asList(); Iterator<ChunkCoordIntPair> ic = lc.iterator(); while(ic.hasNext()) { ChunkCoordIntPair ccoord = ic.next(); ChunkyPeripherals.logger.info("chunk " + ccoord.toString() + "("+ ccoord.chunkXPos*16+" ; "+ ccoord.chunkZPos*16 + ")"); } } }
private void updatePos(int x, int y, int z) { if (ticket != null) { NBTTagCompound modData = ticket.getModData(); modData.setInteger("turtleX", x); modData.setInteger("turtleY", y); modData.setInteger("turtleZ", z); int chunkX = x >> 4; int chunkZ = z >> 4; if (oldChunkX != chunkX || oldChunkZ != chunkZ) { int radius = MiscPeripherals.instance.chunkLoaderRadius; for (int cx = chunkX - radius; cx <= chunkX + radius; cx++) { for (int cz = chunkZ - radius; cz <= chunkZ + radius; cz++) { ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(cx, cz)); } } oldChunkX = chunkX; oldChunkZ = chunkZ; } } }
@Override public void ticketsLoaded(List<Ticket> tickets, World world) { for (Ticket ticket : tickets) { int x = ticket.getModData().getInteger("turtleX"); int y = ticket.getModData().getInteger("turtleY"); int z = ticket.getModData().getInteger("turtleZ"); TileEntity te = world.getBlockTileEntity(x, y, z); if (te instanceof ITurtleAccess) { ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(x >> 4, z >> 4)); PeripheralChunkLoader loader = Util.getPeripheral((ITurtleAccess)te, PeripheralChunkLoader.class); if (loader != null) loader.ticketCreated = true; } } }
@SubscribeEvent public void onEnterChunk(EntityEvent.EnteringChunk event) { if(FMLCommonHandler.instance().getEffectiveSide().isServer() && (event.entity instanceof EntityMeteorite || event.entity instanceof EntityPigzilla) && !event.entity.isDead) { ForgeChunkManager.Ticket ticket = ChunkLoadHandler.tickets.get(event.entity); if(ticket == null) { ticket = ForgeChunkManager.requestTicket(ItFellFromTheSky.instance, event.entity.worldObj, ForgeChunkManager.Type.ENTITY); if(ticket != null) { ticket.bindEntity(event.entity); ChunkLoadHandler.addTicket(event.entity, ticket); } } if(ticket != null) { if(event.oldChunkX != 0 && event.oldChunkZ != 0) { ForgeChunkManager.unforceChunk(ticket, new ChunkCoordIntPair(event.oldChunkX, event.oldChunkZ)); } ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(event.newChunkX, event.newChunkZ)); } } }
@Override public void ticketsLoaded(List<ForgeChunkManager.Ticket> tickets, World world) { for(ForgeChunkManager.Ticket ticket : tickets) { boolean saved = false; Entity ent = ticket.getEntity(); if(ent instanceof EntityMeteorite || ent instanceof EntityTransformer || ent instanceof EntityPigzilla) { if(!ent.isDead) { saved = true; addTicket(ent, ticket); } } if(!saved) { ForgeChunkManager.releaseTicket(ticket); } } }
@Mod.EventHandler public void preLoad(FMLPreInitializationEvent event) { config = ConfigHandler.createConfig(event.getSuggestedConfigurationFile(), "itfellfromthesky", "It Fell From The Sky", logger, instance); config.setCurrentCategory("gameplay", "itfellfromthesky.config.cat.gameplay.name", "itfellfromthesky.config.cat.gameplay.comment"); config.createIntBoolProperty("summonPigzillaNeedsOp", "itfellfromthesky.config.prop.summonPigzillaNeedsOp.name", "itfellfromthesky.config.prop.summonPigzillaNeedsOp.comment", true, false, false); proxy.initMod(); EventHandler handler = new EventHandler(); MinecraftForge.EVENT_BUS.register(handler); ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkLoadHandler()); ModVersionChecker.register_iChunMod(new ModVersionInfo("ItFellFromTheSky", iChunUtil.versionOfMC, version, false)); }
@Override public void registerEventHandlers() { MinecraftForge.EVENT_BUS.register(new AnvilUpdateEventHandler()); MinecraftForge.EVENT_BUS.register(new BlockEventHandler()); MinecraftForge.EVENT_BUS.register(new EntityEventHandler()); MinecraftForge.EVENT_BUS.register(new ItemPickupEventHandler()); MinecraftForge.EVENT_BUS.register(new LivingDropsEventHandler()); MinecraftForge.EVENT_BUS.register(new PlayerEventHandler()); MinecraftForge.EVENT_BUS.register(new WorldEventHandler()); MinecraftForge.EVENT_BUS.register(new TickHandler()); MinecraftForge.EVENT_BUS.register(this); ForgeChunkManager.setForcedChunkLoadingCallback(EnderUtilities.instance, new ChunkLoading()); }
@Override public void ticketsLoaded(List<Ticket> tickets, World world) { for (Ticket ticket : tickets) { //System.out.println("void ticketsLoaded(): looping tickets"); if (ticket != null) { for (ChunkPos chunk : ticket.getChunkList()) { //System.out.println("void ticketsLoaded(): forcing chunk: " + chunk + " in dimension: " + ticket.world.provider.getDimensionId()); ForgeChunkManager.forceChunk(ticket, chunk); } } } }
public boolean loadChunkForcedWithTicket(Ticket ticket, int dimension, int chunkX, int chunkZ, int unloadDelay) { if (ticket == null) { EnderUtilities.logger.warn("loadChunkForcedWithTicket(): ticket == null"); return false; } ForgeChunkManager.forceChunk(ticket, new ChunkPos(chunkX, chunkZ)); if (unloadDelay > 0) { //System.out.println("loadChunkForcedWithTicket() adding timeout: " + unloadDelay); this.addChunkTimeout(ticket, dimension, chunkX, chunkZ, unloadDelay); } return this.loadChunkWithoutForce(dimension, chunkX, chunkZ); }
private static void revalidateTicket(CoordSet chunkXZSet, Ticket currentTicket) { TicketWrapper wrapper = ticketMap.get(chunkXZSet); if (wrapper == null) { DPLogger.severe("Can't revalidate ticket! No TicketWrapper in ticketMap for chunkSet: " + chunkXZSet.toString()); return; } if (wrapper.ticket != null) { ForgeChunkManager.releaseTicket(wrapper.ticket); } wrapper.ticket = currentTicket; ForgeChunkManager.forceChunk(wrapper.ticket, new ChunkCoordIntPair(chunkXZSet.x, chunkXZSet.z)); }
private static void refreshWrapperTicket(CoordSet chunkXZSet) { TicketWrapper wrapper = ticketMap.get(chunkXZSet); // wrapper should never be null at this point. If it is, we deserve the error! if (wrapper.ticket == null) { World world = PocketRegistry.getWorldForPockets(); wrapper.ticket = ForgeChunkManager.requestTicket(DimensionalPockets.instance, world, ForgeChunkManager.Type.NORMAL); if (wrapper.ticket != null) { NBTTagCompound tag = wrapper.ticket.getModData(); chunkXZSet.writeToNBT(tag); ForgeChunkManager.forceChunk(wrapper.ticket, new ChunkCoordIntPair(chunkXZSet.x, chunkXZSet.z)); } else { DPLogger.warning("No new tickets available from the ForgeChunkManager.", ChunkLoaderHandler.class); } } }
public static void removePocketFromChunkLoader(Pocket pocket) { Utils.enforceServer(); CoordSet pocketSet = pocket.getChunkCoords(); CoordSet chunkXZSet = pocketSet.copy(); chunkXZSet.y = 0; if (!ticketMap.containsKey(chunkXZSet) && Reference.KEEP_POCKET_ROOMS_CHUNK_LOADED) { DPLogger.warning("Something tried to remove a loaded pocket from a chunk that was never loaded before..."); return; } TicketWrapper wrapper = ticketMap.get(chunkXZSet); if (wrapper.loadedRooms.remove(pocketSet)) { DPLogger.info("Removed the following pocket room from the list of loaded rooms: " + pocketSet.toString(), ChunkLoaderHandler.class); } else { DPLogger.warning("The following pocket room wanted to be removed, but was not marked as loaded: " + pocketSet.toString(), ChunkLoaderHandler.class); } if (wrapper.loadedRooms.isEmpty()) { ForgeChunkManager.releaseTicket(wrapper.ticket); wrapper.ticket = null; } }
@EventHandler public void init(FMLInitializationEvent event) { proxy.initServerSide(); proxy.initClientSide(); MinecraftForge.EVENT_BUS.register(proxy); NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy); DimensionManager.registerProviderType(Reference.DIMENSION_ID, WorldProviderPocket.class, true); DimensionManager.registerDimension(Reference.DIMENSION_ID, Reference.DIMENSION_ID); BiomeHelper.init(); if (Reference.KEEP_POCKET_ROOMS_CHUNK_LOADED) { ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkLoaderHandler()); } }
@Override public ForgeChunkManager.Ticket get(Object key) { if (key instanceof Integer) { if (super.get(key) == null) { World world = DimensionManager.getWorld((Integer) key); if (world == null) { return null; } ForgeChunkManager.Ticket ticket = ForgeChunkManager.requestTicket(MyTown.instance, world, ForgeChunkManager.Type.NORMAL); ticket.getModData().setString("townName", town.getName()); ticket.getModData().setTag("chunkCoords", new NBTTagList()); put((Integer) key, ticket); return ticket; } else { return super.get(key); } } return null; }