/** * initializes and returns the chunk loader for the specified world provider */ public IChunkLoader getChunkLoader(WorldProvider provider) { File file1 = this.getWorldDirectory(); if (provider instanceof WorldProviderHell) { File file3 = new File(file1, "DIM-1"); file3.mkdirs(); return new AnvilChunkLoader(file3); } else if (provider instanceof WorldProviderEnd) { File file2 = new File(file1, "DIM1"); file2.mkdirs(); return new AnvilChunkLoader(file2); } else { return new AnvilChunkLoader(file1); } }
public WorldClient(NetHandlerPlayClient p_i45063_1_, WorldSettings p_i45063_2_, int p_i45063_3_, EnumDifficulty p_i45063_4_, Profiler p_i45063_5_) { super(new SaveHandlerMP(), new WorldInfo(p_i45063_2_, "MpServer"), WorldProvider.getProviderForDimension(p_i45063_3_), p_i45063_5_, true); this.sendQueue = p_i45063_1_; this.getWorldInfo().setDifficulty(p_i45063_4_); this.provider.registerWorld(this); this.setSpawnPoint(new BlockPos(8, 64, 8)); this.chunkProvider = this.createChunkProvider(); this.mapStorage = new SaveDataMemoryStorage(); this.calculateInitialSkylight(); this.calculateInitialWeather(); Reflector.postForgeBusEvent(Reflector.WorldEvent_Load_Constructor, new Object[] {this}); if (this.mc.playerController != null && this.mc.playerController.getClass() == PlayerControllerMP.class) { this.mc.playerController = new PlayerControllerOF(this.mc, p_i45063_1_); } }
public WorldServerProxy(WorldServer realWorld, WorldServer proxyWorld, String modClass) { super(proxyWorld.getMinecraftServer(), proxyWorld.getSaveHandler(), proxyWorld.getWorldInfo(), proxyWorld.provider.getDimension(), proxyWorld.profiler); // fix the dimension manager! net.minecraftforge.common.DimensionManager.setWorld(this.provider.getDimension(), proxyWorld, proxyWorld.getMinecraftServer()); m_realWorld = realWorld; m_proxyWorld = proxyWorld; m_modPrefix = Util.getClassDomainFromName(modClass); InjectionHandler.copyAllFieldsFrom(this, m_realWorld, WorldServer.class); try { InjectionHandler.writeFieldOfType( this, new WorldProviderProxyServer(m_realWorld.provider, m_proxyWorld.provider, modClass), WorldProvider.class); } catch (IllegalAccessException e) { Util.logger.logException("Unable to set WorldProviderProxyServer", e); } }
/** * initializes and returns the chunk loader for the specified world provider */ public IChunkLoader getChunkLoader(WorldProvider provider) { File file1 = this.getWorldDirectory(); if (provider instanceof WorldProviderHell) { File file3 = new File(file1, "DIM-1"); file3.mkdirs(); return new AnvilChunkLoader(file3, this.dataFixer); } else if (provider instanceof WorldProviderEnd) { File file2 = new File(file1, "DIM1"); file2.mkdirs(); return new AnvilChunkLoader(file2, this.dataFixer); } else { return new AnvilChunkLoader(file1, this.dataFixer); } }
public static WorldProvider createProviderFor(int dim) { try { if (dimensions.containsKey(dim)) { WorldProvider ret = getProviderType(dim).createDimension(); ret.setDimension(dim); return ret; } else { throw new RuntimeException(String.format("No WorldProvider bound for dimension %d", dim)); //It's going to crash anyway at this point. Might as well be informative } } catch (Exception e) { FMLCommonHandler.instance().getFMLLogger().log(Level.ERROR, String.format("An error occurred trying to create an instance of WorldProvider %d (%s)", dim, getProviderType(dim)),e); throw new RuntimeException(e); } }
/** * initializes and returns the chunk loader for the specified world provider */ public IChunkLoader getChunkLoader(WorldProvider provider) { File file1 = this.getWorldDirectory(); if (provider.getSaveFolder() != null) { File file3 = new File(file1, provider.getSaveFolder()); file3.mkdirs(); return new AnvilChunkLoader(file3, this.dataFixer); } else { return new AnvilChunkLoader(file1, this.dataFixer); } }
/** * Gets the name of the current world the player is. * Returns "single player" is the player is playing single player. */ public String getWorldID() { if (lastResponse < lastRequest) { //No WorldInfo response so just use vanilla world names WorldProvider provider = Minecraft.getMinecraft().theWorld.provider; if (provider instanceof WorldProviderEnd) return "world_the_end"; else if (provider instanceof WorldProviderHell) return "world_nether"; else return "world"; } else return worldID; }
public int getAirProducts() { WorldProvider WP = this.worldObj.provider; if (WP instanceof WorldProviderSpace) { ArrayList<IAtmosphericGas> atmos = ((WorldProviderSpace)WP).getCelestialBody().atmosphere; if (atmos.size() > 0) { if (atmos.get(0) == IAtmosphericGas.CO2) return 1; } if (atmos.size() > 1) { if (atmos.get(1) == IAtmosphericGas.CO2) return 1; } if (atmos.size() > 2) { if (atmos.get(2) == IAtmosphericGas.CO2) return 1; } return 0; } return 0; }
public int getAirProducts() { WorldProvider WP = this.worldObj.provider; if (WP instanceof WorldProviderSpace) { int result = 0; ArrayList<IAtmosphericGas> atmos = ((WorldProviderSpace)WP).getCelestialBody().atmosphere; if (atmos.size() > 0) { result = this.getIdFromName(atmos.get(0).name().toLowerCase()) + 1; } if (atmos.size() > 1) { result += 16 * (this.getIdFromName(atmos.get(1).name().toLowerCase()) + 1); } if (atmos.size() > 2) { result += 256 * (this.getIdFromName(atmos.get(2).name().toLowerCase()) + 1); } return result; } return 35; }
/*** * Now returns a boolean to indicate whether registration of the WorldProvider type was successful. * (If it failed, you should probably set the CelestialBody as unreachable.) * * @param id * @param provider * @param keepLoaded * @return <boolean> success */ public static boolean registerProvider(int id, Class<? extends WorldProvider> provider, boolean keepLoaded, int defaultID) { boolean flag = DimensionManager.registerProviderType(id, provider, keepLoaded); if (flag) { GalacticraftRegistry.worldProviderIDs.add(id); return true; } else { GalacticraftRegistry.worldProviderIDs.add(defaultID); //Adding the 0 here preserves the order, important for network compatibility between GC versions FMLLog.severe("Could not register dimension " + id + " - does it clash with another mod? Change the ID in config."); return false; } }
/** * Test whether fire can burn in this world's atmosphere (outside any oxygen bubble). * * @param provider The WorldProvider for this dimension * * @return False if fire burns normally * True if fire cannot burn in this world * */ public static boolean noAtmosphericCombustion(WorldProvider provider) { try { if (combusionTestMethod == null) { if (oxygenUtilClass == null) { oxygenUtilClass = Class.forName("micdoodle8.mods.galacticraft.core.util.OxygenUtil"); } combusionTestMethod = oxygenUtilClass.getDeclaredMethod("noAtmosphericCombustion", WorldProvider.class); } return (Boolean)combusionTestMethod.invoke(null, provider); } catch (Exception e) { e.printStackTrace(); } return false; }
public static WorldProvider getProviderForNameServer(String par1String) { String nameToFind = par1String; if (par1String.contains("$")) { final String[] twoDimensions = par1String.split("\\$"); nameToFind = twoDimensions[0]; } if (nameToFind == null) { return null; } for (Map.Entry<Integer, String> element : WorldUtil.dimNames.entrySet()) { if (nameToFind.equals(element.getValue())) { return WorldUtil.getProviderForDimensionServer(element.getKey()); } } GCLog.info("Failed to find matching world for '" + par1String + "'"); return null; }
@SideOnly(Side.CLIENT) public static WorldProvider getProviderForNameClient(String par1String) { String nameToFind = par1String; if (par1String.contains("$")) { final String[] twoDimensions = par1String.split("\\$"); nameToFind = twoDimensions[0]; } if (nameToFind == null) { return null; } for (Map.Entry<Integer, String> element : WorldUtil.dimNames.entrySet()) { if (nameToFind.equals(element.getValue())) { return WorldUtil.getProviderForDimensionClient(element.getKey()); } } GCLog.info("Failed to find matching world for '" + par1String + "'"); return null; }
public static WorldProvider createProviderFor(int dim) { try { if (dimensions.containsKey(dim)) { WorldProvider provider = providers.get(getProviderType(dim)).newInstance(); provider.setDimension(dim); return provider; } else { throw new RuntimeException(String.format("No WorldProvider bound for dimension %d", dim)); //It's going to crash anyway at this point. Might as well be informative } } catch (Exception e) { FMLCommonHandler.instance().getFMLLogger().log(Level.ERROR, String.format("An error occured trying to create an instance of WorldProvider %d (%s)", dim, providers.get(getProviderType(dim)).getSimpleName()),e); throw new RuntimeException(e); } }
/** * Hook the weather renderer for the loading world. */ @SubscribeEvent(priority = EventPriority.LOWEST) public static void onWorldLoad(@Nonnull final WorldEvent.Load e) { if (DSurround.proxy().effectiveSide() == Side.SERVER || !ModOptions.enableWeatherASM) return; // Only want to hook if the provider doesn't have special // weather handling. final WorldProvider provider = e.getWorld().provider; final String dimName = provider.getDimensionType().getName(); final IRenderHandler renderer = provider.getWeatherRenderer(); if (renderer == null) { DSurround.log().info("Setting weather renderer for dimension [%s]", dimName); provider.setWeatherRenderer(new RenderWeather()); } else { DSurround.log().info("Not hooking weather renderer for dimension [%s] (%s)", dimName, renderer.getClass()); } }
public String registerNewDimension(int dimension, String name, String suffix, boolean keepLoaded, String providerClassName, boolean override) throws CommandException { Class<? extends WorldProvider> providerClass = DimensionTypeEntry.getProviderClass(providerClassName); if (providerClass == null) { CommandJED.throwCommand("invalid.worldprovider.name", providerClassName); } DimensionConfigEntry entry = new DimensionConfigEntry(dimension); entry.setDimensionTypeEntry(new DimensionTypeEntry(dimension, name, suffix, keepLoaded, providerClass)); entry.setOverride(override); return this.registerNewDimension(dimension, entry); }
public static void transferEntityToWorld(Entity ent, WorldServer oldWorld, WorldServer newWorld) { WorldProvider pOld = oldWorld.provider; WorldProvider pNew = newWorld.provider; double moveFactor = pOld.getMovementFactor() / pNew.getMovementFactor(); double x = ent.posX * moveFactor; double z = ent.posZ * moveFactor; x = MathHelper.clamp_double(x, -29999872, 29999872); z = MathHelper.clamp_double(z, -29999872, 29999872); if (ent.isEntityAlive()) { ent.setLocationAndAngles(x, ent.posY, z, ent.rotationYaw, ent.rotationPitch); newWorld.spawnEntityInWorld(ent); newWorld.updateEntityWithOptionalForce(ent, false); } ent.setWorld(newWorld); }
/** * Changes the world that an entity is in. This allows for changing dimensions safer when * working with other mods. * * @param entity The entity to change the world of. * @param worldOld The old entity world. * @param worldNew The new entity world. */ public static void changeWorld (Entity entity, WorldServer worldOld, WorldServer worldNew) { final WorldProvider providerOld = worldOld.provider; final WorldProvider providerNew = worldNew.provider; final double moveFactor = providerOld.getMovementFactor() / providerNew.getMovementFactor(); final double x = MathHelper.clamp(entity.posX * moveFactor, -29999872, 29999872); final double z = MathHelper.clamp(entity.posZ * moveFactor, -29999872, 29999872); if (entity.isEntityAlive()) { entity.setLocationAndAngles(x, entity.posY, z, entity.rotationYaw, entity.rotationPitch); worldNew.spawnEntity(entity); worldNew.updateEntityWithOptionalForce(entity, false); } entity.setWorld(worldNew); }
private void overrideBiomeProvider(int dimension, World world) { // Don't accidentally re-wrap our own BiomeProvider... if (world.getBiomeProvider() instanceof BiomeProviderPaintedBiomes) { return; } PaintedBiomes.logger.info("Wrapping the BiomeProvider (of type {}) of dimension {} with {}", world.getBiomeProvider().getClass().getName(), dimension, BiomeProviderPaintedBiomes.class.getName()); try { // Re-initialize the ImageHandler when a world loads, to update config values etc. ImageHandler imageHandler = ImageHandler.getImageHandler(dimension).init(world.getSeed()); BiomeProvider newBiomeProvider = new BiomeProviderPaintedBiomes(world, world.getBiomeProvider(), imageHandler); ReflectionHelper.setPrivateValue(WorldProvider.class, world.provider, newBiomeProvider, "field_76578_c", "biomeProvider"); } catch (UnableToAccessFieldException e) { PaintedBiomes.logger.error("Failed to wrap the BiomeProvider of dimension " + dimension); } }
/** * Returns the chunk loader with the provided world provider */ public IChunkLoader getChunkLoader(WorldProvider par1WorldProvider) { File var2 = this.getWorldDirectory(); File var3; if (par1WorldProvider instanceof WorldProviderHell) { var3 = new File(var2, "DIM-1"); var3.mkdirs(); return new AnvilChunkLoader(var3); } else if (par1WorldProvider instanceof WorldProviderEnd) { var3 = new File(var2, "DIM1"); var3.mkdirs(); return new AnvilChunkLoader(var3); } else { return new AnvilChunkLoader(var2); } }
public static void transferEntityToWorld(Entity entity, int dimension, WorldServer oldWorld, WorldServer newWorld, Coord6D dest) { WorldProvider pOld = oldWorld.provider; WorldProvider pNew = newWorld.provider; //oldWorld.theProfiler.startSection("moving"); entity.posY = dest.y; entity.setLocationAndAngles(dest.x, dest.y, dest.z, dest.yaw, dest.pitch); if (entity.isEntityAlive()) { entity.setLocationAndAngles(dest.x, dest.y, dest.z, dest.yaw, dest.pitch); newWorld.spawnEntityInWorld(entity); newWorld.updateEntityWithOptionalForce(entity, false); } //oldWorld.theProfiler.endSection(); entity.setWorld(newWorld); }
public static WorldProvider getProviderForName(String par1String) /* */ { /* 223 */ Integer[] var1 = getArrayOfPossibleDimensions(); /* */ /* 225 */ for (Integer element : var1) /* */ { /* 227 */ if ((WorldProvider.func_76570_a(element.intValue()) != null) && (WorldProvider.func_76570_a(element.intValue()).func_80007_l() != null)) /* */ { /* 229 */ if (par1String.contains("$")) /* */ { /* 231 */ String[] twoDimensions = par1String.split("\\$"); /* */ /* 233 */ if (WorldProvider.func_76570_a(element.intValue()).func_80007_l().equals(twoDimensions[0])) /* */ { /* 235 */ return WorldProvider.func_76570_a(element.intValue()); /* */ } /* */ } /* 238 */ else if (WorldProvider.func_76570_a(element.intValue()).func_80007_l().equals(par1String)) /* */ { /* 240 */ return WorldProvider.func_76570_a(element.intValue()); /* */ } /* */ } /* */ } /* */ /* 245 */ return null; /* */ }
public static void teleportEntityToWorld(Entity entity, WorldServer oldWorld, WorldServer newWorld) { WorldProvider pOld = oldWorld.provider; WorldProvider pNew = newWorld.provider; double moveFactor = pOld.getMovementFactor() / pNew.getMovementFactor(); double x = entity.posX * moveFactor; double z = entity.posZ * moveFactor; oldWorld.theProfiler.startSection("placing"); x = MathHelper.clamp_double(x, -29999872, 29999872); z = MathHelper.clamp_double(z, -29999872, 29999872); if (entity.isEntityAlive()) { entity.setLocationAndAngles(x, entity.posY, z, entity.rotationYaw, entity.rotationPitch); newWorld.spawnEntityInWorld(entity); newWorld.updateEntityWithOptionalForce(entity, false); } oldWorld.theProfiler.endSection(); entity.setWorld(newWorld); }
public static boolean registerProviderType(int id, Class<? extends WorldProvider> provider, boolean keepLoaded) { if (providers.containsKey(id)) { return false; } // Cauldron start - register provider with bukkit and add appropriate config option String worldType = "unknown"; if (id != -1 && id != 0 && id != 1) // ignore vanilla { worldType = provider.getSimpleName().toLowerCase(); worldType = worldType.replace("worldprovider", ""); worldType = worldType.replace("provider", ""); registerBukkitEnvironment(id, worldType); } else { worldType = Environment.getEnvironment(id).name().toLowerCase(); } keepLoaded = MinecraftServer.getServer().cauldronConfig.getBoolean("world-environment-settings." + worldType + ".keep-world-loaded", keepLoaded); // Cauldron end providers.put(id, provider); classToProviders.put(provider, id); spawnSettings.put(id, keepLoaded); return true; }
public IChunkLoader getChunkLoader(WorldProvider p_75763_1_) { File file1 = this.getWorldDirectory(); // Cauldron start // To workaround the issue of Bukkit relying on every world having a seperate container // we won't be generating a DIMXX folder for chunk loaders since this name is already generated // for the world container with provider.getSaveFolder(). /* File file2; if (p_75763_1_.getSaveFolder() != null) { file2 = new File(file1, p_75763_1_.getSaveFolder()); file2.mkdirs(); return new AnvilChunkLoader(file2); } else { return new AnvilChunkLoader(file1); } */ return new AnvilChunkLoader(file1); // Cauldron end }
public IChunkLoader getChunkLoader(WorldProvider p_75763_1_) { File file1 = this.getWorldDirectory(); File file2; if (p_75763_1_.getSaveFolder() != null) { file2 = new File(file1, p_75763_1_.getSaveFolder()); file2.mkdirs(); return new AnvilChunkLoader(file2); } else { return new AnvilChunkLoader(file1); } }
/** * Returns a provider with the specified id. * @param id * @return */ public static final WorldProvider getProvider(int id) { try { return providerMap.get(id).newInstance(); } catch (IllegalAccessException | InstantiationException e) { e.printStackTrace(); if (e instanceof IllegalAccessException) { NAPILogHelper.instance.logError("If your provider has a constructor, make it public!"); } if (e instanceof InstantiationException) { NAPILogHelper.instance.logError("Please make sure your provider is NOT abstract and that your constructor does not take any args!"); } //Default to avoid nasty errors Minecraft side. return new WorldProviderSurface(); } }
@SideOnly(Side.CLIENT) public World(ISaveHandler p_i1953_1_, String p_i1953_2_, WorldProvider p_i1953_3_, WorldSettings p_i1953_4_, Profiler p_i1953_5_, ILogAgent p_i1953_6_) { this.field_72990_M = this.field_73012_v.nextInt(12000); this.field_72994_J = new int['\u8000']; this.field_73019_z = p_i1953_1_; this.field_72984_F = p_i1953_5_; this.field_72986_A = new WorldInfo(p_i1953_4_, p_i1953_2_); this.field_73011_w = p_i1953_3_; this.field_72988_C = new MapStorage(p_i1953_1_); this.field_98181_L = p_i1953_6_; VillageCollection var7 = (VillageCollection)this.field_72988_C.func_75742_a(VillageCollection.class, "villages"); if(var7 == null) { this.field_72982_D = new VillageCollection(this); this.field_72988_C.func_75745_a("villages", this.field_72982_D); } else { this.field_72982_D = var7; this.field_72982_D.func_82566_a(this); } p_i1953_3_.func_76558_a(this); this.field_73020_y = this.func_72970_h(); this.func_72966_v(); this.func_72947_a(); }
public static WorldProvider createProviderFor(int dim) { try { if (dimensions.containsKey(dim)) { WorldProvider provider = providers.get(getProviderType(dim)).newInstance(); provider.setDimension(dim); return provider; } else { throw new RuntimeException(String.format("No WorldProvider bound for dimension %d", dim)); //It's going to crash anyway at this point. Might as well be informative } } catch (Exception e) { FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE,String.format("An error occured trying to create an instance of WorldProvider %d (%s)", dim, providers.get(getProviderType(dim)).getSimpleName()),e); throw new RuntimeException(e); } }
/** * Returns the chunk loader with the provided world provider */ public IChunkLoader getChunkLoader(WorldProvider par1WorldProvider) { File file1 = this.getWorldDirectory(); File file2; if (par1WorldProvider.getSaveFolder() != null) { file2 = new File(file1, par1WorldProvider.getSaveFolder()); file2.mkdirs(); return new AnvilChunkLoader(file2); } else { return new AnvilChunkLoader(file1); } }