From aaf4a1028569eef99072d15bdda37489d2bdaaf0 Mon Sep 17 00:00:00 2001 From: MrObsidy Date: Mon, 27 Nov 2017 21:16:09 +0100 Subject: [PATCH] Done --- src/main/java/weather2/CommonProxy.java | 4 +- src/main/java/weather2/api/EnvVars.java | 6 ++ src/main/java/weather2/api/WeatherData.java | 40 ---------- .../java/weather2/api/WeatherInterface.java | 74 +++++++++++++++++++ .../entity/particle/ParticleSandstorm.java | 1 - .../weathersystem/storm/StormObject.java | 9 ++- src/main/resources/pack.mcmeta | 7 ++ 7 files changed, 96 insertions(+), 45 deletions(-) create mode 100644 src/main/java/weather2/api/EnvVars.java delete mode 100755 src/main/java/weather2/api/WeatherData.java create mode 100644 src/main/java/weather2/api/WeatherInterface.java create mode 100644 src/main/resources/pack.mcmeta diff --git a/src/main/java/weather2/CommonProxy.java b/src/main/java/weather2/CommonProxy.java index ada3a59b..bb8271de 100755 --- a/src/main/java/weather2/CommonProxy.java +++ b/src/main/java/weather2/CommonProxy.java @@ -139,7 +139,7 @@ public void preInit() { public void postInit() { ResourceLocation group = new ResourceLocation(Weather.modID, "weather2_misc"); - + if (!ConfigMisc.Item_WeatherItemNoRecipe) GameRegistry.addShapedRecipe(new ResourceLocation(Weather.modID, weather_item), group, new ItemStack(itemWeatherRecipe, 1), new Object[] {"X X", "DID", "X X", 'D', Items.REDSTONE, 'I', Items.GOLD_INGOT, 'X', Items.IRON_INGOT}); @@ -165,7 +165,7 @@ public void postInit() { if (!ConfigMisc.Block_SandNoRecipe) GameRegistry.addShapedRecipe(new ResourceLocation(Weather.modID, "sand"), group, new ItemStack(Blocks.SAND, 1), new Object[] {"DDD", "D D", "DDD", 'D', itemSandLayer}); - if (!ConfigMisc.Item_PocketSandNoRecipe) GameRegistry.addShapedRecipe(new ResourceLocation(Weather.modID, pocket_sand), group, + if (!ConfigMisc.Item_PocketSandNoRecipe) GameRegistry.addShapedRecipe(new ResourceLocation(Weather.modID, pocket_sand), group, new ItemStack(itemPocketSand, 8), new Object[] {"DDD", "DID", "DDD", 'D', itemSandLayer, 'I', itemWeatherRecipe}); } diff --git a/src/main/java/weather2/api/EnvVars.java b/src/main/java/weather2/api/EnvVars.java new file mode 100644 index 00000000..fe84382e --- /dev/null +++ b/src/main/java/weather2/api/EnvVars.java @@ -0,0 +1,6 @@ +package weather2.api; + +public class EnvVars { + public static float environmentTemperature; + public static float environmentHumidity; +} diff --git a/src/main/java/weather2/api/WeatherData.java b/src/main/java/weather2/api/WeatherData.java deleted file mode 100755 index 08266098..00000000 --- a/src/main/java/weather2/api/WeatherData.java +++ /dev/null @@ -1,40 +0,0 @@ -package weather2.api; - -import CoroUtil.util.Vec3; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import weather2.ClientTickHandler; -import weather2.ServerTickHandler; -import weather2.weathersystem.WeatherManagerBase; - -public class WeatherData { - - /** - * Check if precipitation occurring at position. - * Use is somewhat expensive on cpu, consider caching result for frequent use - * - * @param world - * @param position - * @return - */ - public static boolean isPrecipitatingAt(World world, BlockPos position) { - WeatherManagerBase weatherManager; - if (world.isRemote) { - weatherManager = getWeatherManagerForClient(); - } else { - weatherManager = ServerTickHandler.getWeatherSystemForDim(world.provider.getDimension()); - } - if (weatherManager != null) { - return weatherManager.isPrecipitatingAt(new Vec3(position)); - } - return false; - } - - @SideOnly(Side.CLIENT) - public static WeatherManagerBase getWeatherManagerForClient() { - return ClientTickHandler.weatherManager; - } - -} diff --git a/src/main/java/weather2/api/WeatherInterface.java b/src/main/java/weather2/api/WeatherInterface.java new file mode 100644 index 00000000..377d8d57 --- /dev/null +++ b/src/main/java/weather2/api/WeatherInterface.java @@ -0,0 +1,74 @@ +package weather2.api; + +import java.util.List; + +import CoroUtil.util.CoroUtilEntity; +import CoroUtil.util.Vec3; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import weather2.ClientTickHandler; +import weather2.ServerTickHandler; +import weather2.weathersystem.WeatherManagerBase; +import weather2.weathersystem.WeatherManagerServer; +import weather2.weathersystem.storm.EnumWeatherObjectType; +import weather2.weathersystem.storm.StormObject; +import weather2.weathersystem.storm.WeatherObject; +import weather2.weathersystem.wind.WindManager; + +public class WeatherInterface { + + private String modName; + private int dimension; + + public WeatherInterface(int dim, String modName){ + this.dimension = dim; + this.modName = modName; + } + + public boolean isPrecipitating(int worldID, Vec3 pos){ + + WeatherManagerBase wm; + + if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT){ + wm = ClientTickHandler.weatherManager; + } else { + wm = ServerTickHandler.getWeatherSystemForDim(worldID); + } + + return wm.isPrecipitatingAt(pos); + } + + public List getWeatherObjects(){ + return ServerTickHandler.getWeatherSystemForDim(dimension).getStormObjects(); + } + + public WindManager getWindManager(){ + return ServerTickHandler.getWeatherSystemForDim(dimension).windMan; + } + + public void createStorm(Vec3 pos, int Stage, boolean rain, int StormType){ + StormObject so = new StormObject(ServerTickHandler.getWeatherSystemForDim(dimension)); + so.layer = 0; + so.naturallySpawned = true; + so.levelTemperature = 0.1F; + so.pos = pos; + + so.levelWater = so.levelWaterStartRaining * 2; + so.attrib_precipitation = true; + + if (!rain) { + so.initRealStorm(null, null); + } + + so.levelCurIntensityStage = Stage; + so.stormType = StormType; + } + + public void setEnvironmentTemperature(float temp){ + EnvVars.environmentTemperature = temp; + } + public void setEnvironmentHumidity(float humid){ + EnvVars.environmentHumidity = humid; + } +} diff --git a/src/main/java/weather2/client/entity/particle/ParticleSandstorm.java b/src/main/java/weather2/client/entity/particle/ParticleSandstorm.java index 88033b02..7a744e29 100755 --- a/src/main/java/weather2/client/entity/particle/ParticleSandstorm.java +++ b/src/main/java/weather2/client/entity/particle/ParticleSandstorm.java @@ -1,6 +1,5 @@ package weather2.client.entity.particle; -import com.sun.xml.internal.bind.v2.TODO; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.Entity; diff --git a/src/main/java/weather2/weathersystem/storm/StormObject.java b/src/main/java/weather2/weathersystem/storm/StormObject.java index 9898d82a..a283d81d 100644 --- a/src/main/java/weather2/weathersystem/storm/StormObject.java +++ b/src/main/java/weather2/weathersystem/storm/StormObject.java @@ -26,6 +26,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import weather2.ServerTickHandler; import weather2.Weather; +import weather2.api.EnvVars; import weather2.config.ConfigMisc; import weather2.config.ConfigSnow; import weather2.config.ConfigStorm; @@ -212,7 +213,7 @@ public void initFirstTime() { float temp = 1; if (bgb != null) { - temp = bgb.getFloatTemperature(new BlockPos(MathHelper.floor(pos.xCoord), MathHelper.floor(pos.yCoord), MathHelper.floor(pos.zCoord))); + temp = bgb.getFloatTemperature(new BlockPos(MathHelper.floor(pos.xCoord), MathHelper.floor(pos.yCoord), MathHelper.floor(pos.zCoord))) + EnvVars.environmentTemperature; } //initial setting, more apparent than gradual adjustments @@ -1005,7 +1006,7 @@ public void tickProgression() { performBuildup = true; } - if (!performBuildup && bgb != null && (isInOcean || bgb.biomeName.contains("Swamp") || bgb.biomeName.contains("Jungle") || bgb.biomeName.contains("River"))) { + if (!performBuildup && bgb != null && (isInOcean || isHumid(bgb))) { performBuildup = true; } } @@ -2381,6 +2382,10 @@ public int getUpdateRateForNetwork() { } } + private boolean isHumid(Biome bgb){ + return (bgb.getRainfall() + EnvVars.environmentHumidity) > 0.4; + } + //notes moved to bottom\\ //defaults are 0.5 diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta new file mode 100644 index 00000000..40182676 --- /dev/null +++ b/src/main/resources/pack.mcmeta @@ -0,0 +1,7 @@ +{ + "pack": { + "description": "examplemod resources", + "pack_format": 3, + "_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)." + } +}