Java Code Examples for net.minecraft.server.MinecraftServer#worldServerForDimension()
The following examples show how to use
net.minecraft.server.MinecraftServer#worldServerForDimension() .
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: DebugCommand.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] params) { EntityPlayerMP player; try { player = getCommandSenderAsPlayer(sender); } catch (PlayerNotFoundException e) { return; } WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension()); if(params.length == 1 && params[0].equalsIgnoreCase("report")) { int xM =player.getPosition().getX() >> 12; int zM =player.getPosition().getZ() >> 12; String out = "World Seed: [" + world.getSeed() + "] | IslandMap: [" +xM + "," + zM + "] | PlayerPos: [" + player.getPosition().toString() + "]"; StringSelection selection = new StringSelection(out); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); if(clipboard != null) clipboard.setContents(selection, selection); } }
Example 2
Source File: Entity.java From TickDynamic with MIT License | 4 votes |
/** * Teleports the entity to another dimension. Params: Dimension number to teleport to */ public void travelToDimension(int p_71027_1_) { if (!this.worldObj.isRemote && !this.isDead) { this.worldObj.theProfiler.startSection("changeDimension"); MinecraftServer minecraftserver = MinecraftServer.getServer(); int j = this.dimension; WorldServer worldserver = minecraftserver.worldServerForDimension(j); WorldServer worldserver1 = minecraftserver.worldServerForDimension(p_71027_1_); this.dimension = p_71027_1_; if (j == 1 && p_71027_1_ == 1) { worldserver1 = minecraftserver.worldServerForDimension(0); this.dimension = 0; } this.worldObj.removeEntity(this); this.isDead = false; this.worldObj.theProfiler.startSection("reposition"); minecraftserver.getConfigurationManager().transferEntityToWorld(this, j, worldserver, worldserver1); this.worldObj.theProfiler.endStartSection("reloading"); Entity entity = EntityList.createEntityByName(EntityList.getEntityString(this), worldserver1); if (entity != null) { entity.copyDataFrom(this, true); if (j == 1 && p_71027_1_ == 1) { ChunkCoordinates chunkcoordinates = worldserver1.getSpawnPoint(); chunkcoordinates.posY = this.worldObj.getTopSolidOrLiquidBlock(chunkcoordinates.posX, chunkcoordinates.posZ); entity.setLocationAndAngles((double)chunkcoordinates.posX, (double)chunkcoordinates.posY, (double)chunkcoordinates.posZ, entity.rotationYaw, entity.rotationPitch); } worldserver1.spawnEntityInWorld(entity); } this.isDead = true; this.worldObj.theProfiler.endSection(); worldserver.resetUpdateEntityTick(); worldserver1.resetUpdateEntityTick(); this.worldObj.theProfiler.endSection(); } }
Example 3
Source File: TeleportInIslandCommand.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] params) { EntityPlayerMP player = null; try { player = getCommandSenderAsPlayer(sender); } catch (PlayerNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension()); if(!player.isCreative()) return; if(params.length == 3) { int x = (int)Math.floor(player.posX); int y = (int)Math.floor(player.posY); int z = (int)Math.floor(player.posZ); int mX = x >> 12; int mZ = z >> 12; int inX = Integer.parseInt(params[0]); int inY = Integer.parseInt(params[1]); int inZ = Integer.parseInt(params[2]); Point p = new Point(x, z); if(params[0].contains("+") || params[0].contains("-")) x += inX; else x = mX*4096+inX; if(params[1].contains("+") || params[1].contains("-")) y += inY; else y = inY; if(params[2].contains("+") || params[2].contains("-")) z += inZ; else z = mZ*4096+inZ; player.setPositionAndUpdate(x, y, z); } }
Example 4
Source File: RegenChunkCommand.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] params) { EntityPlayerMP player; try { player = getCommandSenderAsPlayer(sender); } catch (PlayerNotFoundException e) { return; } if(!player.isCreative()) return; WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension()); if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 1) { int radius = Integer.parseInt(params[0]); for(int i = -radius; i <= radius; i++) { for(int k = -radius; k <= radius; k++) { int x = (((int)player.posX+i*16) >> 4); int z = (((int)player.posZ+k*16) >> 4); ChunkProviderServer cps = world.getChunkProvider(); Chunk c = cps.chunkGenerator.provideChunk(x, z); Chunk old = world.getChunkProvider().provideChunk(x, z); old.setStorageArrays(c.getBlockStorageArray()); c.setTerrainPopulated(false); c.onChunkLoad(); c.setChunkModified(); c.checkLight(); cps.chunkGenerator.populate(c.xPosition, c.zPosition); net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider()); c.setChunkModified(); player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff)); } } /*for(int i = -radius; i <= radius; i++) { for(int k = -radius; k <= radius; k++) { int x = (((int)player.posX+i*16) >> 4); int z = (((int)player.posZ+k*16) >> 4); ChunkProviderServer cps = world.getChunkProvider(); Chunk c = cps.chunkGenerator.provideChunk(x, z); Chunk old = world.getChunkProvider().provideChunk(x, z); old.populateChunk(cps, cps.chunkGenerator); if (c.isTerrainPopulated()) { if (cps.chunkGenerator.generateStructures(c, c.xPosition, c.zPosition)) { c.setChunkModified(); } } else { c.checkLight(); cps.chunkGenerator.populate(c.xPosition, c.zPosition); net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider()); c.setChunkModified(); } player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff)); } }*/ } else if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 2 && params[1].equalsIgnoreCase("hex")) { execute(server, sender, new String[] {params[0]}); IslandMap map = Core.getMapForWorld(world, player.getPosition()); HexGenRegistry.generate(Core.getMapForWorld(world, player.getPosition()), map.getClosestCenter(player.getPosition()), world); } }