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

The following examples show how to use net.minecraftforge.common.DimensionManager#initDimension() . 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: TileSpaceLaser.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
/**
 * 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());
}
 
Example 2
Source File: CraftServer.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public World createWorld(WorldCreator creator) {
    Validate.notNull(creator, "Creator may not be null");

    String name = creator.name();
    ChunkGenerator generator = creator.generator();
    File folder = new File(getWorldContainer(), name);
    World world = getWorld(name);
    WorldType type = WorldType.parseWorldType(creator.type().getName());
    boolean generateStructures = creator.generateStructures();

    if ((folder.exists()) && (!folder.isDirectory())) {
        throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
    }

    if (world != null) {
        return world;
    }

    boolean hardcore = false;

    WorldSettings worldSettings = new WorldSettings(creator.seed(), WorldSettings.getGameTypeById(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
    WorldServer internal = DimensionManager.initDimension(creator, worldSettings);

    pluginManager.callEvent(new WorldInitEvent(internal.getWorld()));
    System.out.println("Preparing start region for level " + (console.worldServerList.size() - 1) + " (Seed: " + internal.getSeed() + ")");

    if (internal.getWorld().getKeepSpawnInMemory()) {
        short short1 = 196;
        long i = System.currentTimeMillis();
        for (int j = -short1; j <= short1; j += 16) {
            for (int k = -short1; k <= short1; k += 16) {
                long l = System.currentTimeMillis();

                if (l < i) {
                    i = l;
                }

                if (l > i + 1000L) {
                    int i1 = (short1 * 2 + 1) * (short1 * 2 + 1);
                    int j1 = (j + short1) * (short1 * 2 + 1) + k + 1;

                    System.out.println("Preparing spawn area for " + name + ", " + (j1 * 100 / i1) + "%");
                    i = l;
                }

                BlockPos chunkcoordinates = internal.getSpawnPoint();
                internal.getChunkProvider().loadChunk(chunkcoordinates.getX() + j >> 4, chunkcoordinates.getZ() + k >> 4);
            }
        }
    }
    pluginManager.callEvent(new WorldLoadEvent(internal.getWorld()));
    return internal.getWorld();
}
 
Example 3
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public World createWorld(WorldCreator creator) {
    Validate.notNull(creator, "Creator may not be null");

    String name = creator.name();
    ChunkGenerator generator = creator.generator();
    File folder = new File(getWorldContainer(), name);
    World world = getWorld(name);
    net.minecraft.world.WorldType type = net.minecraft.world.WorldType.parseWorldType(creator.type().getName());
    boolean generateStructures = creator.generateStructures();

    if ((folder.exists()) && (!folder.isDirectory())) {
        throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
    }

    if (world != null) {
        return world;
    }

    boolean hardcore = false;
    WorldSettings worldSettings = new WorldSettings(creator.seed(), net.minecraft.world.WorldSettings.GameType.getByID(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
    net.minecraft.world.WorldServer worldserver = DimensionManager.initDimension(creator, worldSettings);

    pluginManager.callEvent(new WorldInitEvent(worldserver.getWorld()));
    net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = true;
    System.out.print("Preparing start region for level " + (console.worlds.size() - 1) + " (Dimension: " + worldserver.provider.dimensionId + ", Seed: " + worldserver.getSeed() + ")"); // Cauldron - log dimension

    if (worldserver.getWorld().getKeepSpawnInMemory()) {
        short short1 = 196;
        long i = System.currentTimeMillis();
        for (int j = -short1; j <= short1; j += 16) {
            for (int k = -short1; k <= short1; k += 16) {
                long l = System.currentTimeMillis();

                if (l < i) {
                    i = l;
                }

                if (l > i + 1000L) {
                    int i1 = (short1 * 2 + 1) * (short1 * 2 + 1);
                    int j1 = (j + short1) * (short1 * 2 + 1) + k + 1;

                    System.out.println("Preparing spawn area for " + worldserver.getWorld().getName() + ", " + (j1 * 100 / i1) + "%");
                    i = l;
                }

                net.minecraft.util.ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
                worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + j >> 4, chunkcoordinates.posZ + k >> 4);
            }
        }
    }
    pluginManager.callEvent(new WorldLoadEvent(worldserver.getWorld()));
    net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = false;
    return worldserver.getWorld();
}