Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved API and minor StormObject changes #174

Open
wants to merge 1 commit into
base: 1.12.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/weather2/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand All @@ -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});
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/weather2/api/EnvVars.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package weather2.api;

public class EnvVars {
public static float environmentTemperature;
public static float environmentHumidity;
}
40 changes: 0 additions & 40 deletions src/main/java/weather2/api/WeatherData.java

This file was deleted.

74 changes: 74 additions & 0 deletions src/main/java/weather2/api/WeatherInterface.java
Original file line number Diff line number Diff line change
@@ -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<WeatherObject> 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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/weather2/weathersystem/storm/StormObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -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)."
}
}