Java Code Examples for net.minecraftforge.common.DimensionManager#getWorlds()

The following examples show how to use net.minecraftforge.common.DimensionManager#getWorlds() . 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: WorldConverter.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@Override
public World convert(String worldName) throws TypeConversionException {
    World[] worlds = DimensionManager.getWorlds();

    Optional<World> matchingWorld = Arrays.stream(worlds)
        .filter(world -> world.provider.getDimensionType().getName().equals(worldName))
        .findFirst();

    return matchingWorld.orElseThrow(() -> {
        String validWorlds = Arrays.stream(worlds)
            .map(world -> world.provider.getDimensionType().getName())
            .collect(Collectors.joining(", "));

        return new TypeConversionException(
            String.format("Invalid world name! Available options: %s", validWorlds));
    });
}
 
Example 2
Source File: RailNetworkManager.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
/**
 * The initial nodes used to build out the network from.
 * Signals, Station Markers, rail links. Only used when force rebuilding the network.
 * @return
 */
private Set<MCPos> getStartNodes(){
    Set<MCPos> nodes = new HashSet<>();
    for(World world : DimensionManager.getWorlds()) {
        for(TileEntity te : world.loadedTileEntityList) {
            if(te instanceof TileEntityBase) { //Any Signals TE for testing purposes
                nodes.add(new MCPos(world, te.getPos()));
                for(EnumFacing facing : EnumFacing.VALUES) {
                    BlockPos pos = te.getPos().offset(facing);
                    nodes.add(new MCPos(world, pos));
                }
            }
        }
    }
    return nodes;
}
 
Example 3
Source File: RailNetworkManager.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
private void initTrains(){
    List<EntityMinecart> carts = new ArrayList<>();

    for(World world : DimensionManager.getWorlds()) {
        for(Entity entity : world.loadedEntityList) {
            if(entity instanceof EntityMinecart) {
                carts.add((EntityMinecart)entity);
            }
        }
    }

    Set<MCTrain> trains = new NetworkObjectProvider().provideTrains(carts);
    state.setTrains(trains);
    for(MCTrain train : trains) {
        NetworkHandler.sendToAll(new PacketAddOrUpdateTrain(train));
    }
}
 
Example 4
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public String getWorldName(net.minecraft.world.World w) {
    Integer[] ids = DimensionManager.getIDs();
    WorldServer[] worlds = DimensionManager.getWorlds();
    for (int i = 0; i < ids.length; i++) {
        if (worlds[i] == w) {
            return w.getWorldInfo().getWorldName() + ";" + ids[i];
        }
    }
    return w.getWorldInfo().getWorldName() + ";" + w.provider.getDimensionId();
}
 
Example 5
Source File: FaweForge.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public String getWorldName(net.minecraft.world.World w) {
    Integer[] ids = DimensionManager.getIDs();
    WorldServer[] worlds = DimensionManager.getWorlds();
    for (int i = 0; i < ids.length; i++) {
        if (worlds[i] == w) {
            return w.getWorldInfo().getWorldName() + ";" + ids[i];
        }
    }
    return w.getWorldInfo().getWorldName() + ";" + w.provider.dimensionId;
}
 
Example 6
Source File: PlayerChunkViewerTracker.java    From ChickenChunks with MIT License 5 votes vote down vote up
public PlayerChunkViewerTracker(EntityPlayer player, PlayerChunkViewerManager manager)
{
    owner = player;
    this.manager = manager;
    
    PacketCustom packet = new PacketCustom(ChunkLoaderSPH.channel, 1);
    packet.sendToPlayer(player);
    
    for(WorldServer world : DimensionManager.getWorlds())
        loadDimension(world);
}
 
Example 7
Source File: PlayerChunkViewerManager.java    From ChickenChunks with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void updateChunkChangeMap()
{
    for(WorldServer world : DimensionManager.getWorlds())
    {
        HashSet<ChunkCoordIntPair> allChunks = new HashSet<ChunkCoordIntPair>();
        ArrayList<Chunk> loadedChunkCopy = new ArrayList<Chunk>(world.theChunkProviderServer.loadedChunks);
        for(Chunk chunk : loadedChunkCopy)
            allChunks.add(chunk.getChunkCoordIntPair());
        
        lastLoadedChunkMap.put(CommonUtils.getDimension(world), allChunks);
    }
}