net.minecraftforge.event.world.ChunkEvent Java Examples

The following examples show how to use net.minecraftforge.event.world.ChunkEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TileChunkLoadHook.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event) {
    IChunk chunk = event.getChunk();
    Map<BlockPos, TileEntity> tiles = null;
    if (chunk instanceof ChunkPrimerWrapper) {
        chunk = ((ChunkPrimerWrapper) chunk).func_217336_u();
    }
    if (chunk instanceof Chunk) {
        tiles = ((Chunk) chunk).getTileEntityMap();
    }
    if (chunk instanceof ChunkPrimer) {
        tiles = ((ChunkPrimer) chunk).getTileEntities();
    }
    if (tiles != null) {
        for (TileEntity tile : tiles.values()) {
            if (tile instanceof IChunkLoadTile) {
                ((IChunkLoadTile) tile).onChunkLoad();
            }
        }
    }
}
 
Example #2
Source File: CableTickHandler.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@SubscribeEvent
public void chunkLoadedEvent(ChunkEvent.Load event) {

	Map map = event.getChunk().getTileEntityMap();
	Iterator<Entry> iter = map.entrySet().iterator();

	try {
		while(iter.hasNext()) {
			Object obj = iter.next().getValue();

			if(obj instanceof TilePipe) {
				((TilePipe)obj).markDirty();
			}
		}
	} catch ( ConcurrentModificationException e) {
		AdvancedRocketry.logger.warn("You have been visited by the rare pepe.. I mean error of pipes not loading, this is not good, some pipe systems may not work right away.  But it's better than a corrupt world");
	}
}
 
Example #3
Source File: EpisodeEventWrapper.java    From malmo with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load cev)
{
    // Pass the event on to the active episode, if there is one:
    this.stateEpisodeLock.readLock().lock();
    if (this.stateEpisode != null && this.stateEpisode.isLive())
    {
        this.stateEpisode.onChunkLoad(cev);
    }
    this.stateEpisodeLock.readLock().unlock();
}
 
Example #4
Source File: WorldExtensionManager.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public void onChunkUnLoad(ChunkEvent.Unload event)
{
    if(event.getChunk() instanceof EmptyChunk)
        return;
    
    for(WorldExtension extension : worldMap.get(event.world))
        extension.unloadChunk(event.getChunk());
    
    if(event.world.isRemote)
        removeChunk(event.world, event.getChunk());
}
 
Example #5
Source File: LookingGlassForgeEventHandler.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onChunkUnload(ChunkEvent.Unload event) {
	if (!event.world.isRemote) return;
	Chunk chunk = event.getChunk();
	// When we unload a chunk client side, we want to make sure that any view entities clean up. Not strictly necessary, but a good practice.
	// I don't trust vanilla to unload entity references quickly/correctly/completely.
	for (int i = 0; i < chunk.entityLists.length; ++i) {
		List<Entity> list = chunk.entityLists[i];
		for (Entity entity : list) {
			if (entity instanceof EntityPortal) ((EntityPortal) entity).releaseActiveView();
		}
	}
}
 
Example #6
Source File: WorldExtensionManager.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event)
{
    if(!worldMap.containsKey(event.world))
        WorldExtensionManager.onWorldLoad(event.world);
    
    createChunkExtension(event.world, event.getChunk());
    
    for(WorldExtension extension : worldMap.get(event.world))
        extension.loadChunk(event.getChunk());
}
 
Example #7
Source File: PlayerListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
/**
 * Keep track of recently loaded chunks for the magma boss timer.
 */
@SubscribeEvent()
public void onChunkLoad(ChunkEvent.Load e) {
    if (main.getUtils().isOnSkyblock()) {
        int x = e.getChunk().xPosition;
        int z = e.getChunk().zPosition;
        IntPair coords = new IntPair(x, z);
        recentlyLoadedChunks.add(coords);
        main.getScheduler().schedule(Scheduler.CommandType.DELETE_RECENT_CHUNK, 20, x, z);
    }
}
 
Example #8
Source File: MovementScheduler.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onChunkUnload(ChunkEvent.Unload event) {

    if (event.world.isRemote)
        return;

    for (Object o : event.getChunk().chunkTileEntityMap.values()) {
        TileEntity te = (TileEntity) o;
        if (te instanceof TileMotor) {
            ((TileMotor) te).onUnload();
        }
    }
}
 
Example #9
Source File: TileChunkLoadHook.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event) {
    List<TileEntity> list = new ArrayList<TileEntity>(event.getChunk().chunkTileEntityMap.values());
    for(TileEntity t : list)
        if(t instanceof IChunkLoadTile)
            ((IChunkLoadTile)t).onChunkLoad();
}
 
Example #10
Source File: WRCoreEventHandler.java    From WirelessRedstone with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event) {
    if (event.world.isRemote)
        return;

    if (RedstoneEther.server() != null)//new world
    {
        RedstoneEther.loadServerWorld(event.world);
        RedstoneEther.server().verifyChunkTransmitters(event.world, event.getChunk().xPosition, event.getChunk().zPosition);
    }
}
 
Example #11
Source File: PlanetEventHandler.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@SubscribeEvent
public void chunkLoadEvent(ChunkEvent.Load event) {
}
 
Example #12
Source File: EventHandler.java    From mapwriter with MIT License 4 votes vote down vote up
@SubscribeEvent
public void eventChunkUnload(ChunkEvent.Unload event){
	if(event.world.isRemote){
		this.mw.onChunkUnload(event.getChunk());
	}
}
 
Example #13
Source File: EventHandler.java    From mapwriter with MIT License 4 votes vote down vote up
@SubscribeEvent
public void eventChunkLoad(ChunkEvent.Load event){
	if(event.world.isRemote){
		this.mw.onChunkLoad(event.getChunk());
	}
}
 
Example #14
Source File: MultiblockEventHandler.java    From BeefCore with MIT License 4 votes vote down vote up
@SubscribeEvent(priority = EventPriority.NORMAL)
public void onChunkLoad(ChunkEvent.Load loadEvent) {
	Chunk chunk = loadEvent.getChunk();
	World world = loadEvent.world;
	MultiblockRegistry.onChunkLoaded(world, chunk.xPosition, chunk.zPosition);
}
 
Example #15
Source File: SemiBlockManager.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onChunkUnLoad(ChunkEvent.Unload event){
    if(!event.world.isRemote) {
        chunksMarkedForRemoval.add(event.getChunk());
    }
}
 
Example #16
Source File: ChunkLoadHandler.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onChunkUnload(ChunkEvent.Unload event)
{
	if(!event.getWorld().isRemote && event.getWorld().provider.getDimension() == 0)
	{
		BlockPos chunkWorldPos = new BlockPos(event.getChunk().xPosition * 16, 0, event.getChunk().zPosition * 16);
		IslandMap map = Core.getMapForWorld(event.getWorld(), chunkWorldPos);

		Point islandPos = new Point(chunkWorldPos.getX(), chunkWorldPos.getZ()).toIslandCoord();
		AxisAlignedBB chunkAABB = new AxisAlignedBB(islandPos.getX(), 0, islandPos.getZ(), islandPos.getX()+16, 1, islandPos.getZ()+16);
		Center temp = map.getClosestCenter(islandPos);

		ArrayList<Center> genList = new ArrayList<Center>();
		genList.add(temp);
		genList.addAll(temp.neighbors);

		if(loadedCentersMap.containsKey(map.getParams().getCantorizedID()))
		{
			ArrayList<Center> loaded = loadedCentersMap.get(map.getParams().getCantorizedID());
			for(Center c : genList)
			{	
				AxisAlignedBB aabb = c.getAABB();
				boolean intersect =aabb.intersectsWith(chunkAABB);
				if(intersect && loaded.contains(c) )
				{
					loaded.remove(c);
					ArrayList<Herd> herdsToUnload = map.getIslandData().wildlifeManager.getHerdsInCenter(c);
					for(Herd h : herdsToUnload)
					{
						h.setUnloaded();
						for(VirtualAnimal animal : h.getVirtualAnimals())
						{
							if(animal.getEntity() == null)
							{
								animal.setUnloaded();
								continue;
							}
							Predicate<Entity> predicate = Predicates.<Entity>and(EntitySelectors.NOT_SPECTATING, EntitySelectors.notRiding(animal.getEntity()));
							Entity closestEntity = animal.getEntity().world.getClosestPlayer(animal.getEntity().posX, animal.getEntity().posY, animal.getEntity().posZ, 100D, predicate);
							if(closestEntity == null)
							{
								animal.getEntity().setDead();
								animal.setUnloaded();
							}
						}
					}
				}
			}
		}


	}
}
 
Example #17
Source File: Events.java    From XRay-Mod with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public static void chunkLoad( ChunkEvent.Load event )
{
	Controller.requestBlockFinder( true );
}
 
Example #18
Source File: EventHandler.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onChunkUnload(ChunkEvent.Unload event){
    if(!event.getWorld().isRemote) {
        RailNetworkManager.getInstance(event.getWorld().isRemote).onChunkUnload(event.getChunk());
    }
}
 
Example #19
Source File: StateEpisode.java    From malmo with MIT License 4 votes vote down vote up
/** Subclass should overrride this to act on chunk load events.*/
protected void onChunkLoad(ChunkEvent.Load cev) {}
 
Example #20
Source File: ChunkLogger.java    From ForgeHax with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event) {
  if (chunks != null) {
  }
}
 
Example #21
Source File: TickableWorldPipeNetEventHandler.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public static void onChunkUnload(ChunkEvent.Unload event) {
    getPipeNetsForWorld(event.getWorld()).forEach(it -> it.onChunkUnloaded(event.getChunk()));
}
 
Example #22
Source File: TickableWorldPipeNetEventHandler.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public static void onChunkLoad(ChunkEvent.Load event) {
    getPipeNetsForWorld(event.getWorld()).forEach(it -> it.onChunkLoaded(event.getChunk()));
}