public void newDay(Collection<TownBuilding> buildings) { Set<GatheringLocation> previous = new HashSet(locations); locations = new HashSet(); // Remove all previous locations for (GatheringLocation location : previous) { World world = DimensionManager.getWorld(location.dimension); if (world.getBlock(location.x, location.y, location.z) == location.block) { if (world.getBlockMetadata(location.x, location.y, location.z) == location.meta) { world.setBlockToAir(location.x, location.y, location.z); } } } // Create some new spawn spots based on where we have buildings for (TownBuilding building : buildings) { World world = DimensionManager.getWorld(building.dimension); int placed = 0; for (int i = 0; i < 64 && placed < 10; i++) { int x = building.xCoord + 32 - world.rand.nextInt(64); int y = building.yCoord + 4 - world.rand.nextInt(8); int z = building.zCoord + 32 - world.rand.nextInt(64); if (world.getBlock(x, y, z) == Blocks.grass && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z)) { ItemStack random = getRandomBlock(); Block block = Block.getBlockFromItem(random.getItem()); int meta = random.getItemDamage(); if (world.setBlock(x, y + 1, z, block, meta, 2)) { locations.add(new GatheringLocation(block, meta, building.dimension, x, y + 1, z)); placed++; } } } } }
@EventHandler() public void Init(FMLInitializationEvent Init) { loadProps(CBCMod.config); XenBlocks.init(CBCMod.config); proxy.init(); DimensionManager.registerProviderType( xenContinentDimensionID, WorldProviderXenContinent.class, true); DimensionManager.registerDimension(xenContinentDimensionID, xenContinentDimensionID); EntityRegistry.addSpawn( EntityHoundeye.class, 25, 15, 15, EnumCreatureType.monster, MainBiomes.xenHill, MainBiomes.xenPlain); EntityRegistry.addSpawn( EntityHeadcrab.class, 25, 15, 15, EnumCreatureType.monster, MainBiomes.xenHill, MainBiomes.xenPlain); EntityRegistry.addSpawn( EntityAlienSlave.class, 10, 15, 15, EnumCreatureType.monster, MainBiomes.xenHill); EntityRegistry.addSpawn( EntityBarnacle.class, 6, 15, 15, EnumCreatureType.monster, MainBiomes.xenHill, MainBiomes.xenPlain); }
/** Checking right click actions on blocks. */ public boolean checkBlockInteraction( Resident res, BlockPos bp, PlayerInteractEvent.Action action) { Block blockType = DimensionManager.getWorld(bp.getDim()).getBlock(bp.getX(), bp.getY(), bp.getZ()); for (SegmentBlock segment : segmentsBlocks) { if (segment.getCheckClass().isAssignableFrom(blockType.getClass()) && (segment.getMeta() == -1 || segment.getMeta() == DimensionManager.getWorld(bp.getDim()) .getBlockMetadata(bp.getX(), bp.getY(), bp.getZ())) && (segment.getType() == BlockType.ANY_CLICK || segment.getType() == BlockType.RIGHT_CLICK && action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || segment.getType() == BlockType.LEFT_CLICK && action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)) { int dim = bp.getDim(); int x = bp.getX(); int y = bp.getY(); int z = bp.getZ(); if (!hasPermission(res, segment, dim, x, y, z)) { if (segment.hasClientUpdate()) sendClientUpdate( segment.getClientUpdateCoords(), bp, (EntityPlayerMP) res.getPlayer(), null); return true; } } } return false; }
/** Gets the worldServer by the given dimension. */ public WorldServer worldServerForDimension(int par1) { WorldServer ret = DimensionManager.getWorld(par1); if (ret == null) { DimensionManager.initDimension(par1); ret = DimensionManager.getWorld(par1); } return ret; }
public static void LoadDim() { // generation GameRegistry.registerWorldGenerator(new DreSca(), 0); // dimension DimensionManager.registerProviderType(dimension, WorldProviderDreSca.class, false); DimensionManager.registerDimension(dimension, dimension); }
private void innerLoad() { File f = DimensionManager.getCurrentSaveRootDirectory(); conf = new HyperCubeConfig( new File( DimensionManager.getCurrentSaveRootDirectory(), "enderio/dimensionalTransceiver.cfg")); publicChannels.addAll(conf.getPublicChannels()); userChannels.putAll(conf.getUserChannels()); }
public void execute() { // Only do this on client side. for (int id : dimensions) { RFTools.log("DimensionSyncPacket: Registering id: id = " + id); if (!DimensionManager.isDimensionRegistered(id)) { DimensionManager.registerProviderType(id, GenericWorldProvider.class, false); DimensionManager.registerDimension(id, id); } } }
/** * Return the current root directory for the world save. Accesses getSaveHandler from the * overworld * * @return the root directory of the save */ public static File getCurrentSaveRootDirectory() { if (DimensionManager.getWorld(0) != null) { return ((SaveHandler) DimensionManager.getWorld(0).getSaveHandler()).getWorldDirectory(); } else if (MinecraftServer.getServer() != null) { MinecraftServer srv = MinecraftServer.getServer(); SaveHandler saveHandler = (SaveHandler) srv.getActiveAnvilConverter().getSaveLoader(srv.getFolderName(), false); return saveHandler.getWorldDirectory(); } else { return null; } }
public WorldServer getWorld() { WorldServer world = DimensionManager.getWorld(dimension); if (world == null) { DimensionManager.initDimension(dimension); world = DimensionManager.getWorld(dimension); if (world == null) { return null; // How? } } return world; }
@Override public void readFromNBT(NBTTagCompound tagCom) { TEC.idToUsername.clear(); NBTTagList idUsernameTag = tagCom.getTagList("idUsernames", 10); for (int i = 0; i < idUsernameTag.tagCount(); i++) { NBTTagCompound tag = idUsernameTag.getCompoundTagAt(i); TEC.idToUsername.put( UUID.fromString(tagCom.getString("UUID")), tagCom.getString("playerName")); } TEC.aspectBuffer.clear(); NBTTagList bufferTag = tagCom.getTagList("bufferTag", 10); for (int i = 0; i < bufferTag.tagCount(); i++) { NBTTagCompound idedBuffer = bufferTag.getCompoundTagAt(i); UUID playerID = UUID.fromString(idedBuffer.getString("playerID")); NBTTagList playersBuffer = idedBuffer.getTagList("buffer", 10); for (int j = 0; j < playersBuffer.tagCount(); j++) { NBTTagCompound bufferEntry = playersBuffer.getCompoundTagAt(j); NBTTagCompound scanTag = bufferEntry.getCompoundTag("scan"); ScanResult scan = new ScanResult( scanTag.getByte("type"), scanTag.getInteger("id"), scanTag.getInteger("meta"), EntityList.createEntityFromNBT( scanTag.getCompoundTag("entityTag"), DimensionManager.getWorld(0)), scanTag.getString("phenomena")); TEC.addAspect( playerID, scan, bufferEntry.getDouble("chance"), bufferEntry.getDouble("percent")); } } }
private void serverTick(boolean doEffects) { World entityWorld = MinecraftServer.getServer().getEntityWorld(); RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(entityWorld); if (!dimensionManager.getDimensions().isEmpty()) { DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(entityWorld); for (Map.Entry<Integer, DimensionDescriptor> entry : dimensionManager.getDimensions().entrySet()) { Integer id = entry.getKey(); // If there is an activity probe we only drain power if the dimension is loaded (a player is // there or a chunkloader) DimensionInformation information = dimensionManager.getDimensionInformation(id); WorldServer world = DimensionManager.getWorld(id); // Power handling. if (world != null || information.getProbeCounter() == 0) { handlePower(doEffects, dimensionStorage, entry, id, information); } // Special effect handling. if (world != null && !world.playerEntities.isEmpty()) { handleRandomEffects(world, information); } } dimensionStorage.save(entityWorld); } }
public static SpaceStationWorldData getMPSpaceStationData( World var0, int var1, EntityPlayer player) { final String var2 = SpaceStationWorldData.getSpaceStationID(var1); if (var0 == null) { var0 = DimensionManager.getProvider(0).worldObj; } SpaceStationWorldData var3 = (SpaceStationWorldData) var0.loadItemData(SpaceStationWorldData.class, var2); if (var3 == null) { var3 = new SpaceStationWorldData(var2); var0.setItemData(var2, var3); var3.dataCompound = new NBTTagCompound(); if (player != null) { var3.owner = player.getGameProfile().getName().replace(".", ""); } var3.spaceStationName = "Station: " + var3.owner; if (player != null) { var3.allowedPlayers.add(player.getGameProfile().getName()); } var3.markDirty(); } if (var3.getSpaceStationName().replace(" ", "").isEmpty()) { var3.setSpaceStationName("Station: " + var3.owner); var3.markDirty(); } return var3; }
/** Saves all necessary data as preparation for stopping the server. */ public void stopServer() { if (!this.worldIsBeingDeleted) { this.func_98033_al().func_98233_a("Stopping server"); if (this.getNetworkThread() != null) { this.getNetworkThread().stopListening(); } if (this.serverConfigManager != null) { this.func_98033_al().func_98233_a("Saving players"); this.serverConfigManager.saveAllPlayerData(); this.serverConfigManager.removeAllPlayers(); } this.func_98033_al().func_98233_a("Saving worlds"); this.saveAllWorlds(false); for (int i = 0; i < this.worldServers.length; ++i) { WorldServer worldserver = this.worldServers[i]; MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(worldserver)); worldserver.flush(); } WorldServer[] tmp = worldServers; for (WorldServer world : tmp) { DimensionManager.setWorld(world.provider.dimensionId, null); } if (this.usageSnooper != null && this.usageSnooper.isSnooperRunning()) { this.usageSnooper.stopSnooper(); } } }
public static void initDimension(int dim) { WorldServer overworld = getWorld(0); if (overworld == null) { throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!"); } try { DimensionManager.getProviderType(dim); } catch (Exception e) { System.err.println("Cannot Hotload Dim: " + e.getMessage()); return; // If a provider hasn't been registered then we can't hotload the dim } MinecraftServer mcServer = overworld.getMinecraftServer(); ISaveHandler savehandler = overworld.getSaveHandler(); WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo()); WorldServer world = (dim == 0 ? overworld : new WorldServerMulti( mcServer, savehandler, overworld.getWorldInfo().getWorldName(), dim, worldSettings, overworld, mcServer.theProfiler)); world.addWorldAccess(new WorldManager(mcServer, world)); MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world)); if (!mcServer.isSinglePlayer()) { world.getWorldInfo().setGameType(mcServer.getGameType()); } mcServer.func_147139_a(mcServer.func_147135_j()); }
@SubscribeEvent public void onClientPacket(ClientCustomPacketEvent event) { EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; ByteBufInputStream bbis = new ByteBufInputStream(event.packet.payload()); byte packetType; int dimension; byte packetID; try { packetType = bbis.readByte(); dimension = bbis.readInt(); World world = DimensionManager.getWorld(dimension); if (packetType == 2) { this.handleRocketJumpHackyPacket(bbis, world); } if (packetType == 3) { this.handleExplodePacket(bbis, world); } // for (int i = 0; i < 3; i++){ // player.worldObj.spawnParticle("smoke", x, y, z, -0.005D+(Math.random()*0.01D), // 0.025D, -0.005D+(Math.random()*0.01D)); // } bbis.close(); } catch (Exception e) { e.printStackTrace(); return; } }
@Override public void onSpaceDimensionChanged( World newWorld, EntityPlayerMP player, boolean ridingAutoRocket) { if (BlankPlanet.makelandingplatform) { int X = player.getPlayerCoordinates().posX; int Z = player.getPlayerCoordinates().posZ; if (newWorld.isAirBlock(X, 100, Z) && newWorld == DimensionManager.getWorld(BlankPlanet.dimensionid)) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { newWorld.setBlock(X + i, 100, Z + j, Blocks.stone); } } for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { newWorld.setBlock(X - i, 100, Z + j, Blocks.stone); } } for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { newWorld.setBlock(X + i, 100, Z - j, Blocks.stone); } } for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { newWorld.setBlock(X - i, 100, Z - j, Blocks.stone); } } } } }
@PreInit public void preInit(FMLPreInitializationEvent event) { WCConfig.preInit(event); WCMCMod.preInit(event); WCBlockIDs.init(); WCItemIDs.init(); WCRecipes.init(); WCAchievements.init(); MinecraftForge.EVENT_BUS.register(new EventSounds()); MinecraftForge.EVENT_BUS.register(new EventHookHandler()); NetworkRegistry.instance().registerGuiHandler(this, guiHandler); GameRegistry.registerPickupHandler(itemHandler); DimensionManager.registerProviderType(DIM, WorldProviderWarp.class, true); DimensionManager.registerDimension(DIM, DIM); }
@Override public void reload() { MinecraftScriptMod.getLogger().fine("Reloading Scripting Scope"); loadScope(false); loadAllScripts(_scriptsDirectory, false); loadAllScripts(new File(DimensionManager.getCurrentSaveRootDirectory(), "scripts"), true); }
@Override public void doCommand(ItemStack duplicator, EntityPlayerMP sender, String[] arguments) { try { String name = arguments.length == 2 ? arguments[1] : sender.getCommandSenderName(); File file = new File( DimensionManager.getCurrentSaveRootDirectory().getPath() + File.separator + "managers" + File.separator + name + ".nbt"); if (!file.exists()) { throw new CommandException("Couldn't access file: " + name + ".nbt"); } NBTTagCompound tagCompound = CompressedStreamTools.read(file); duplicator.setTagCompound(unstripBaseNBT(tagCompound)); CommandBase.getCommandSenderAsPlayer(sender) .addChatComponentMessage( new ChatComponentText( LocalizationHelper.translateFormatted( "stevesaddons.command.loadSuccess", name + ".nbt"))); } catch (IOException e) { throw new CommandException("stevesaddons.command.loadFailed"); } }
public TileEntity getBlockTileEntity() { WorldServer world = getWorld(); if (world == null) { DimensionManager.initDimension(dimension); world = DimensionManager.getWorld(dimension); if (world == null) { return null; // How? } } world.getChunkProvider().loadChunk(posX >> 4, posY >> 4); return world.getBlockTileEntity(posX, posY, posZ); }
public static void teleport(EntityPlayerMP player, WarpPoint point) { if (point.getWorld() == null) { DimensionManager.initDimension(point.getDimension()); if (point.getWorld() == null) { ChatOutputHandler.chatError( player, Translator.translate("Unable to teleport! Target dimension does not exist")); return; } } // Check permissions UserIdent ident = UserIdent.get(player); if (!APIRegistry.perms.checkPermission(player, TELEPORT_FROM)) throw new TranslatedCommandException("You are not allowed to teleport from here."); if (!APIRegistry.perms.checkUserPermission(ident, point.toWorldPoint(), TELEPORT_TO)) throw new TranslatedCommandException("You are not allowed to teleport to that location."); if (player.dimension != point.getDimension() && !APIRegistry.perms.checkUserPermission(ident, point.toWorldPoint(), TELEPORT_CROSSDIM)) throw new TranslatedCommandException("You are not allowed to teleport across dimensions."); // Get and check teleport cooldown int teleportCooldown = ServerUtil.parseIntDefault( APIRegistry.perms.getUserPermissionProperty(ident, TELEPORT_COOLDOWN), 0) * 1000; if (teleportCooldown > 0) { PlayerInfo pi = PlayerInfo.get(player); long cooldownDuration = (pi.getLastTeleportTime() + teleportCooldown) - System.currentTimeMillis(); if (cooldownDuration >= 0) { ChatOutputHandler.chatNotification( player, Translator.format("Cooldown still active. %d seconds to go.", cooldownDuration / 1000)); return; } } // Get and check teleport warmup int teleportWarmup = ServerUtil.parseIntDefault( APIRegistry.perms.getUserPermissionProperty(ident, TELEPORT_WARMUP), 0); if (teleportWarmup <= 0) { checkedTeleport(player, point); return; } if (!canTeleportTo(point)) { ChatOutputHandler.chatError( player, Translator.translate("Unable to teleport! Target location obstructed.")); return; } // Setup timed teleport tpInfos.put(player.getPersistentID(), new TeleportInfo(player, point, teleportWarmup * 1000)); ChatOutputHandler.chatNotification( player, Translator.format( "Teleporting. Please stand still for %s.", ChatOutputHandler.formatTimeDurationReadable(teleportWarmup, true))); }
@SideOnly(Side.CLIENT) public void addInformation( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { par3List.add( String.format( "Charge: %d / %d RF", new Object[] { Integer.valueOf(getEnergyStored(par1ItemStack)), Integer.valueOf(10000000) })); DimensionalLinkEntry[] entries = readEntries(par1ItemStack); if (entries.length != 0) { par3List.add(""); par3List.add("Bound to:"); for (DimensionalLinkEntry entry : entries) { String dimName = DimensionManager.getProvider(entry.dimID).getDimensionName(); par3List.add( String.format( "[%s] %d:%d:%d", new Object[] { dimName, Integer.valueOf(entry.x), Integer.valueOf(entry.y), Integer.valueOf(entry.z) })); } } }
public class DreSca implements IWorldGenerator { public static SparkWorld worldTypeDreSca; public static int dimension = DimensionManager.getNextFreeDimId(); // biome public static BiomeGenBase dscape = new BiomeGenDreSca(52).setBiomeName("DreamScape"); public static CreativeTabs DreScaTab = new CreativeTabs("DreScaThings") { public Item getTabIconItem() { return SparkItems.DreScaPorter; }; }; public static void LoadDim() { // generation GameRegistry.registerWorldGenerator(new DreSca(), 0); // dimension DimensionManager.registerProviderType(dimension, WorldProviderDreSca.class, false); DimensionManager.registerDimension(dimension, dimension); } public void generate( Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch (world.provider.dimensionId) { case 0: generateSurface(world, random, chunkX * 16, chunkZ * 16); break; } } public void generateSurface(World world, Random random, int blockX, int blockZ) { int RandPosX = blockX + random.nextInt(5); int RandPosY = random.nextInt(128); int RandPosZ = blockZ + random.nextInt(5); (new WorldGenCactus()).generate(world, random, RandPosX, RandPosY, RandPosZ); int RandPosX1 = blockX + random.nextInt(5); int RandPosY1 = random.nextInt(128); int RandPosZ1 = blockZ + random.nextInt(5); (new WorldGenIceSpike()).generate(world, random, RandPosX1, RandPosY1, RandPosZ1); /*for(int k = 0; k < 2; k++) { int RandPosX = blockX + random.nextInt(16); int RandPosY = random.nextInt(128); int RandPosZ = blockZ + random.nextInt(16); (new WorldGenCreeperTemple()).generate(world, random, RandPosX, RandPosY, RandPosZ); }*/ } }
@EventHandler public void init(FMLInitializationEvent event) throws Exception { packetPipeline.registerMessage( AnvilTechniquePacket.Handler.class, AnvilTechniquePacket.class, 0, Side.SERVER); packetPipeline.registerMessage( ChunkPutNbtPacket.Handler.class, ChunkPutNbtPacket.class, 1, Side.CLIENT); packetPipeline.registerMessage( ChunkRemoveNbtPacket.Handler.class, ChunkRemoveNbtPacket.class, 2, Side.CLIENT); packetPipeline.registerMessage( SoundEffectToServerPacket.Handler.class, SoundEffectToServerPacket.class, 3, Side.SERVER); packetPipeline.registerMessage( MechanicalNetworkNBTPacket.ClientHandler.class, MechanicalNetworkNBTPacket.class, 4, Side.CLIENT); packetPipeline.registerMessage( StartMeteorShowerPacket.ClientHandler.class, StartMeteorShowerPacket.class, 5, Side.CLIENT); packetPipeline.registerMessage( WorldDataPacket.ClientHandler.class, WorldDataPacket.class, 6, Side.CLIENT); packetPipeline.registerMessage( CarpentryTechniquePacket.Handler.class, CarpentryTechniquePacket.class, 7, Side.SERVER); BlocksVC.init(); ItemsVC.init(); AchievementsVC.init(); FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); proxy.registerTileEntities(); NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); System.out.println("vcraft has init."); GameRegistry.registerWorldGenerator(new WorldGenDeposits(), 4); WorldType.DEFAULT = WorldTypeVC.DEFAULT; WorldType.FLAT = WorldTypeVC.FLAT; // DimensionManager.unregisterDimension(-1); DimensionManager.unregisterDimension(0); DimensionManager.unregisterDimension(1); // DimensionManager.unregisterProviderType(-1); DimensionManager.unregisterProviderType(0); DimensionManager.unregisterProviderType(1); DimensionManager.registerProviderType(0, WorldProviderVC.class, true); DimensionManager.registerProviderType(1, WorldProviderVC.class, false); // DimensionManager.registerDimension(-1, -1); DimensionManager.registerDimension(0, 0); DimensionManager.registerDimension(1, 1); proxy.init(event); }
public World getWorld() { // Cauldron start - fixes MFR proxy worlds used with grinder/slaughterhouse if (entity.worldObj.getWorld() == null) { return DimensionManager.getWorld(0).getWorld(); } // Cauldron end return entity.worldObj.getWorld(); }
protected void loadAllWorlds( String par1Str, String par2Str, long par3, WorldType par5WorldType, String par6Str) { this.convertMapIfNeeded(par1Str); this.setUserMessage("menu.loadingLevel"); ISaveHandler isavehandler = this.anvilConverterForAnvilFile.getSaveLoader(par1Str, true); WorldInfo worldinfo = isavehandler.loadWorldInfo(); WorldSettings worldsettings; if (worldinfo == null) { worldsettings = new WorldSettings( par3, this.getGameType(), this.canStructuresSpawn(), this.isHardcore(), par5WorldType); worldsettings.func_82750_a(par6Str); } else { worldsettings = new WorldSettings(worldinfo); } if (this.enableBonusChest) { worldsettings.enableBonusChest(); } WorldServer overWorld = (isDemo() ? new DemoWorldServer(this, isavehandler, par2Str, 0, theProfiler, func_98033_al()) : new WorldServer( this, isavehandler, par2Str, 0, worldsettings, theProfiler, func_98033_al())); for (int dim : DimensionManager.getStaticDimensionIDs()) { WorldServer world = (dim == 0 ? overWorld : new WorldServerMulti( this, isavehandler, par2Str, dim, worldsettings, overWorld, theProfiler, func_98033_al())); world.addWorldAccess(new WorldManager(this, world)); if (!this.isSinglePlayer()) { world.getWorldInfo().setGameType(this.getGameType()); } this.serverConfigManager.setPlayerManager(this.worldServers); MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world)); } this.serverConfigManager.setPlayerManager(new WorldServer[] {overWorld}); this.setDifficultyForAllWorlds(this.getDifficulty()); this.initialWorldChunkLoad(); }
@Override public boolean unloadWorld(World world, boolean save) { WorldServer handle = ((CraftWorld) world).getHandle(); WorldUnloadEvent ev = new WorldUnloadEvent(world); getPluginManager().callEvent(ev); if (ev.isCancelled()) return false; // cancelled DimensionManager.unloadWorld(handle.getWorldInfo().getDimension()); worlds.remove(handle.getWorldInfo().getDimension()); return true; }
public World getWorld(int dimID) { if (worlds.containsKey(dimID)) return worlds.get(dimID); else if (!worlds.containsKey(dimID) && Arrays.asList(DimensionManager.getIDs()).contains(dimID)) { // dim there but not registered with us. WorldServer internal = DimensionManager.getWorld(dimID); int dim = internal.getWorldInfo().getDimension(); System.out.println("Registering dimension with BukkitForge: " + dim + "..." ); WorldProvider w = internal.provider; Environment env = w.isHellWorld ? Environment.NETHER : Environment.NORMAL; ChunkGenerator cg = new NormalChunkGenerator(internal);//(((WorldServer)ev.world).theChunkProviderServer); BukkitWorld bukkit = new BukkitWorld(internal, cg, env); BukkitServer.instance().worlds.put(dim, bukkit); return bukkit; } return null; }
@Override public void fromBytes(ByteBuf buf) { world = DimensionManager.getWorld(buf.readInt()); try { packet = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.SERVERBOUND, buf.readInt()); packet.readPacketData(new PacketBuffer(buf)); } catch (InstantiationException | IllegalAccessException | IOException e) { throw new DecoderException(e); } }
/** Checks if the block whitelist is still valid */ public static boolean isBlockWhitelistValid(BlockWhitelist bw) { // Delete if the town is gone if (MyTownUtils.getTownAtPosition(bw.getDim(), bw.getX() >> 4, bw.getZ() >> 4) == null) return false; if (bw.getFlagType() == FlagType.ACTIVATE && !checkActivatedBlocks( DimensionManager.getWorld(bw.getDim()).getBlock(bw.getX(), bw.getY(), bw.getZ()), DimensionManager.getWorld(bw.getDim()) .getBlockMetadata(bw.getX(), bw.getY(), bw.getZ()))) return false; if (bw.getFlagType() == FlagType.MODIFY || bw.getFlagType() == FlagType.ACTIVATE || bw.getFlagType() == FlagType.USAGE) { TileEntity te = DimensionManager.getWorld(bw.getDim()).getTileEntity(bw.getX(), bw.getY(), bw.getZ()); if (te == null) return false; return getFlagsForTile(te.getClass()).contains(bw.getFlagType()); } return true; }