diff --git a/build.gradle b/build.gradle index eb20b9a..148d077 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { apply plugin: 'net.minecraftforge.gradle.forge' -version = "1.12.2-0.1.0" +version = "1.12.2-0.1.1" group = "com.charles445.simpledifficulty" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "SimpleDifficulty" diff --git a/modupdatechecker.json b/modupdatechecker.json index 6bcdf0b..c72a9be 100644 --- a/modupdatechecker.json +++ b/modupdatechecker.json @@ -1,12 +1,11 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/simpledifficulty/files", "promos": { - "1.12.2-latest": "0.1.2", - "1.12.2-recommended": "0.1.2" + "1.12.2-latest": "0.1.1", + "1.12.2-recommended": "0.1.1" }, "1.12.2": { - "0.1.2": "Dummy update to test out the update checker", - "0.1.1": "Update Checker, Mod Compatibility, Configurable mod water temperatures", + "0.1.1": "Update Checker, Mod Compatibility, Thermometer HUD, Configurable mod water temperatures", "0.1.0": "Initial Release" } } \ No newline at end of file diff --git a/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java b/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java index f877692..747e666 100644 --- a/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java +++ b/src/main/java/com/charles445/simpledifficulty/SimpleDifficulty.java @@ -21,14 +21,15 @@ modid = SimpleDifficulty.MODID, name = SimpleDifficulty.NAME, version = SimpleDifficulty.VERSION, - acceptedMinecraftVersions = "[1.12]" + acceptedMinecraftVersions = "[1.12]", + updateJSON = "https://raw.githubusercontent.com/Charles445/SimpleDifficulty/master/modupdatechecker.json" ) public class SimpleDifficulty { public static final String MODID = "simpledifficulty"; public static final String NAME = "SimpleDifficulty"; - public static final String VERSION = "0.1.0"; + public static final String VERSION = "0.1.1"; @Mod.Instance(SimpleDifficulty.MODID) public static SimpleDifficulty instance; diff --git a/src/main/java/com/charles445/simpledifficulty/api/config/ClientOptions.java b/src/main/java/com/charles445/simpledifficulty/api/config/ClientOptions.java index fa96c76..c75087a 100644 --- a/src/main/java/com/charles445/simpledifficulty/api/config/ClientOptions.java +++ b/src/main/java/com/charles445/simpledifficulty/api/config/ClientOptions.java @@ -5,7 +5,8 @@ public enum ClientOptions implements IConfigOption /*Boolean*/ DEBUG ("debug"), /*Boolean*/ DRAW_THIRST_SATURATION ("drawThirstSaturation"), /*Boolean*/ ENABLE_THERMOMETER ("enableThermometer"), - /*Boolean*/ ALTERNATE_TEMP ("alternateTemp"); + /*Boolean*/ ALTERNATE_TEMP ("alternateTemp"), + /*BOOLEAN*/ HUD_THERMOMETER ("hudThermometer"); String name; diff --git a/src/main/java/com/charles445/simpledifficulty/client/gui/TemperatureGui.java b/src/main/java/com/charles445/simpledifficulty/client/gui/TemperatureGui.java index b3d6c23..bf1f3f6 100644 --- a/src/main/java/com/charles445/simpledifficulty/client/gui/TemperatureGui.java +++ b/src/main/java/com/charles445/simpledifficulty/client/gui/TemperatureGui.java @@ -1,8 +1,11 @@ package com.charles445.simpledifficulty.client.gui; +import java.util.HashMap; +import java.util.Map; import java.util.Random; import com.charles445.simpledifficulty.api.SDCapabilities; +import com.charles445.simpledifficulty.api.SDItems; import com.charles445.simpledifficulty.api.config.ClientConfig; import com.charles445.simpledifficulty.api.config.ClientOptions; import com.charles445.simpledifficulty.api.config.QuickConfig; @@ -11,13 +14,18 @@ import com.charles445.simpledifficulty.api.temperature.TemperatureUtil; import com.charles445.simpledifficulty.debug.DebugUtil; import com.charles445.simpledifficulty.util.RenderUtil; +import com.charles445.simpledifficulty.util.WorldUtil; +import ibxm.Player; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -30,7 +38,6 @@ public class TemperatureGui private int updateCounter = 0; private final Random rand = new Random(); public static final ResourceLocation ICONS = new ResourceLocation("simpledifficulty:textures/gui/icons.png"); - //Position on the icons sheet private static final int texturepos_X = 0; private static final int texturepos_Y = 32; @@ -48,6 +55,13 @@ public class TemperatureGui private static final int texturepos_Y_alt_BG = 96; private int alternateTemperature = 0; + private int worldThermometerTemperature = 0; + private boolean hasThermometer = false; + private static final int texturepos_X_therm = 0; + private static final int texturepos_Y_therm = 192; + private static final int thermometer_per_row = 8; + private static final int textureWidthTherm = 16; + private static final int textureHeightTherm = 16; @SubscribeEvent public void onPreRenderGameOverlay(RenderGameOverlayEvent.Pre event) @@ -75,6 +89,8 @@ private void renderTemperatureIcon(int width, int height, int temperature) { GlStateManager.enableBlend(); + // --- + TemperatureEnum tempEnum = TemperatureUtil.getTemperatureEnum(temperature); int bgXOffset = textureWidth * tempEnum.ordinal(); @@ -231,6 +247,20 @@ else if(tempEnum == TemperatureEnum.BURNING) RenderUtil.drawTexturedModalRect(x, y, texturepos_X + ovrXOffset, texturepos_Y + ovrYOffset, textureWidth, textureHeight); } + //Thermometer + + if(hasThermometer && ClientConfig.instance.getBoolean(ClientOptions.HUD_THERMOMETER) && ClientConfig.instance.getBoolean(ClientOptions.ENABLE_THERMOMETER)) + { + int therm_position = worldThermometerTemperature - TemperatureEnum.FREEZING.getLowerBound(); + + int therm_x = (therm_position % thermometer_per_row)*textureWidthTherm + texturepos_X_therm; + int therm_y = (therm_position / thermometer_per_row)*textureHeightTherm + texturepos_Y_therm; + + + //TODO configure where this thing draws + + RenderUtil.drawTexturedModalRect(x, y - 18, therm_x, therm_y, textureWidthTherm, textureHeightTherm); + } // - - - @@ -262,10 +292,27 @@ public void onClientTick(TickEvent.ClientTickEvent event) } //} - if(updateCounter % 15 == 12 && QuickConfig.isTemperatureEnabled() && ClientConfig.instance.getBoolean(ClientOptions.ALTERNATE_TEMP)) + if(updateCounter % 15 == 12 && QuickConfig.isTemperatureEnabled()) { if(minecraftInstance.player != null) - alternateTemperature = TemperatureUtil.clampTemperature(TemperatureUtil.getPlayerTargetTemperature(minecraftInstance.player)); + { + EntityPlayer player = minecraftInstance.player; + World world = player.getEntityWorld(); + + if(ClientConfig.instance.getBoolean(ClientOptions.ALTERNATE_TEMP)) + { + alternateTemperature = TemperatureUtil.clampTemperature(TemperatureUtil.getPlayerTargetTemperature(player)); + } + + if(ClientConfig.instance.getBoolean(ClientOptions.HUD_THERMOMETER) && ClientConfig.instance.getBoolean(ClientOptions.ENABLE_THERMOMETER)) + { + + worldThermometerTemperature = TemperatureUtil.clampTemperature((int)WorldUtil.calculateClientWorldEntityTemperature(world, player)); + + //TODO Verify this is how you're supposed to check for items in player inventory + hasThermometer = player.inventory.hasItemStack(new ItemStack(SDItems.thermometer)); + } + } } } } diff --git a/src/main/java/com/charles445/simpledifficulty/compat/JsonCompatDefaults.java b/src/main/java/com/charles445/simpledifficulty/compat/JsonCompatDefaults.java new file mode 100644 index 0000000..aef7e0e --- /dev/null +++ b/src/main/java/com/charles445/simpledifficulty/compat/JsonCompatDefaults.java @@ -0,0 +1,64 @@ +package com.charles445.simpledifficulty.compat; + +import static com.charles445.simpledifficulty.config.JsonConfig.armorTemperatures; +import static com.charles445.simpledifficulty.config.JsonConfig.blockTemperatures; +import static com.charles445.simpledifficulty.config.JsonConfig.fluidTemperatures; + +import com.charles445.simpledifficulty.config.json.JsonPropertyTemperature; +import com.charles445.simpledifficulty.config.json.JsonTemperature; +import com.charles445.simpledifficulty.config.json.PropertyValue; + +public class JsonCompatDefaults +{ + public static JsonCompatDefaults instance = new JsonCompatDefaults(); + //Default mod support for JSON + + public void populate() + { + populateBiomesOPlenty(); + populateLycanitesMobs(); + populateSimpleCampfire(); + } + + //Biomes O' Plenty + private void populateBiomesOPlenty() + { + fluidTemperatures.put("hot_spring_water", temperature(3.0f)); + } + + //Lycanites Mobs + private void populateLycanitesMobs() + { + blockTemperatures.put("lycanitesmobs:purelava", propTemp(15.0f)); + + //TODO considering adding the ooze to actually chill the surrounding area + //That could be fun + } + + //Simple Camp Fire + private void populateSimpleCampfire() + { + blockTemperatures.put("campfire:campfire", propTemp(7.0f)); + } + + + + //Utility + + private JsonTemperature temperature(float temp) + { + return new JsonTemperature(temp); + } + + private JsonPropertyTemperature propTemp(float temp) + { + return new JsonPropertyTemperature(temp); + } + + private JsonPropertyTemperature propTemp(float temp, PropertyValue... props) + { + return new JsonPropertyTemperature(temp, props); + } + + +} diff --git a/src/main/java/com/charles445/simpledifficulty/config/JsonConfig.java b/src/main/java/com/charles445/simpledifficulty/config/JsonConfig.java index 6080cb0..6791a49 100644 --- a/src/main/java/com/charles445/simpledifficulty/config/JsonConfig.java +++ b/src/main/java/com/charles445/simpledifficulty/config/JsonConfig.java @@ -13,9 +13,10 @@ import com.charles445.simpledifficulty.SimpleDifficulty; import com.charles445.simpledifficulty.api.SDBlocks; import com.charles445.simpledifficulty.api.SDItems; +import com.charles445.simpledifficulty.compat.JsonCompatDefaults; import com.charles445.simpledifficulty.config.json.PropertyValue; -import com.charles445.simpledifficulty.config.json.ArmorTemperature; -import com.charles445.simpledifficulty.config.json.BlockTemperature; +import com.charles445.simpledifficulty.config.json.JsonTemperature; +import com.charles445.simpledifficulty.config.json.JsonPropertyTemperature; import com.charles445.simpledifficulty.config.json.MaterialTemperature; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -31,49 +32,55 @@ public class JsonConfig //TODO this whole thing isn't good //TODO now that I get how this stuff works, sort of, make it better - public static Map armorTemperatures = new HashMap(); - public static Map blockTemperatures = new HashMap(); + //TODO a way for mods to set defaults for themselves via the API + + + + public static Map armorTemperatures = new HashMap(); + + public static Map blockTemperatures = new HashMap(); + + public static Map fluidTemperatures = new HashMap(); //TODO customizable materials? Probably not public static MaterialTemperature materialTemperature = new MaterialTemperature(); public static void init(File jsonDirectory) { - armorTemperatures.put(SDItems.wool_helmet.getRegistryName().toString(), new ArmorTemperature(2.0f)); - armorTemperatures.put(SDItems.wool_chestplate.getRegistryName().toString(), new ArmorTemperature(2.0f)); - armorTemperatures.put(SDItems.wool_leggings.getRegistryName().toString(), new ArmorTemperature(2.0f)); - armorTemperatures.put(SDItems.wool_boots.getRegistryName().toString(), new ArmorTemperature(2.0f)); + //Setup default JSON - armorTemperatures.put(SDItems.ice_helmet.getRegistryName().toString(), new ArmorTemperature(-2.0f)); - armorTemperatures.put(SDItems.ice_chestplate.getRegistryName().toString(), new ArmorTemperature(-2.0f)); - armorTemperatures.put(SDItems.ice_leggings.getRegistryName().toString(), new ArmorTemperature(-2.0f)); - armorTemperatures.put(SDItems.ice_boots.getRegistryName().toString(), new ArmorTemperature(-2.0f)); + armorTemperatures.put(SDItems.wool_helmet.getRegistryName().toString(), new JsonTemperature(2.0f)); + armorTemperatures.put(SDItems.wool_chestplate.getRegistryName().toString(), new JsonTemperature(2.0f)); + armorTemperatures.put(SDItems.wool_leggings.getRegistryName().toString(), new JsonTemperature(2.0f)); + armorTemperatures.put(SDItems.wool_boots.getRegistryName().toString(), new JsonTemperature(2.0f)); + armorTemperatures.put(SDItems.ice_helmet.getRegistryName().toString(), new JsonTemperature(-2.0f)); + armorTemperatures.put(SDItems.ice_chestplate.getRegistryName().toString(), new JsonTemperature(-2.0f)); + armorTemperatures.put(SDItems.ice_leggings.getRegistryName().toString(), new JsonTemperature(-2.0f)); + armorTemperatures.put(SDItems.ice_boots.getRegistryName().toString(), new JsonTemperature(-2.0f)); - armorTemperatures = processJson("armorTemperatures.json", armorTemperatures, new TypeToken>(){}.getType(), jsonDirectory); + blockTemperatures.put(SDBlocks.campfire.getRegistryName().toString(), new JsonPropertyTemperature(7.0f, new PropertyValue("burning","true"))); + blockTemperatures.put(Blocks.LIT_FURNACE.getRegistryName().toString(), new JsonPropertyTemperature(3.0f)); + blockTemperatures.put(Blocks.LAVA.getRegistryName().toString(), new JsonPropertyTemperature(15.0f)); + blockTemperatures.put(Blocks.FLOWING_LAVA.getRegistryName().toString(), new JsonPropertyTemperature(15.0f)); + blockTemperatures.put(Blocks.MAGMA.getRegistryName().toString(), new JsonPropertyTemperature(12.5f)); - //blockTemperatures.put(Blocks.LIT_FURNACE.getRegistryName().toString(), - // new BlockTemperature(3.0f, new BlockProperty("burning","true"))); - - blockTemperatures.put(SDBlocks.campfire.getRegistryName().toString(), new BlockTemperature(7.0f, new PropertyValue("burning","true"))); - blockTemperatures.put(Blocks.LIT_FURNACE.getRegistryName().toString(), new BlockTemperature(3.0f)); - blockTemperatures.put(Blocks.LAVA.getRegistryName().toString(), new BlockTemperature(15.0f)); - blockTemperatures.put(Blocks.FLOWING_LAVA.getRegistryName().toString(), new BlockTemperature(15.0f)); - blockTemperatures.put(Blocks.MAGMA.getRegistryName().toString(), new BlockTemperature(12.5f)); + //materialTemperature is not a Map - blockTemperatures = processJson("blockTemperatures.json", blockTemperatures, new TypeToken>(){}.getType(), jsonDirectory); + //Mod Compatibility - materialTemperature = processJson("materialTemperature.json", materialTemperature, new TypeToken(){}.getType(), jsonDirectory); + JsonCompatDefaults.instance.populate(); - /* - for(Map.Entry entry : blockTemperatures.entrySet()) - { - SimpleDifficulty.logger.debug(entry.getKey()); - SimpleDifficulty.logger.debug(entry.getValue().temperature); - SimpleDifficulty.logger.debug(entry.getValue().properties.size()); - } - */ + //TODO consider how fluidTemperatures should actually be stored. is Fluid name a reliable way to get their name? + + + //Process JSON + + armorTemperatures = processJson("armorTemperatures.json", armorTemperatures, new TypeToken>(){}.getType(), jsonDirectory); + blockTemperatures = processJson("blockTemperatures.json", blockTemperatures, new TypeToken>(){}.getType(), jsonDirectory); + fluidTemperatures = processJson("fluidTemperatures.json", fluidTemperatures, new TypeToken>(){}.getType(), jsonDirectory); + materialTemperature = processJson("materialTemperature.json", materialTemperature, new TypeToken(){}.getType(), jsonDirectory); } public static T processJson(String jsonFileName, final T container, Type type, File jsonDirectory) diff --git a/src/main/java/com/charles445/simpledifficulty/config/ModConfig.java b/src/main/java/com/charles445/simpledifficulty/config/ModConfig.java index c0c9189..d457be3 100644 --- a/src/main/java/com/charles445/simpledifficulty/config/ModConfig.java +++ b/src/main/java/com/charles445/simpledifficulty/config/ModConfig.java @@ -247,6 +247,10 @@ public static class SDCFGClientConfig @Config.Name("EnableThermometer") public boolean enableThermometer = true; + @Config.Comment("Whether thermometers in your inventory will display on your HUD") + @Config.Name("HUDThermometer") + public boolean hudThermometer = true; + @Config.Comment("Client config debug") @Config.Name("ClientConfigDebug") public boolean clientdebug = false; @@ -299,6 +303,7 @@ public static void sendLocalClientConfigToAPI() ClientConfig.instance.put(ClientOptions.DRAW_THIRST_SATURATION, client.drawThirstSaturation); ClientConfig.instance.put(ClientOptions.ENABLE_THERMOMETER, client.enableThermometer); ClientConfig.instance.put(ClientOptions.ALTERNATE_TEMP, client.alternateTemp); + ClientConfig.instance.put(ClientOptions.HUD_THERMOMETER, client.hudThermometer); ClientConfig.instance.put(ClientOptions.DEBUG, client.clientdebug); } diff --git a/src/main/java/com/charles445/simpledifficulty/config/json/BlockTemperature.java b/src/main/java/com/charles445/simpledifficulty/config/json/JsonPropertyTemperature.java similarity index 90% rename from src/main/java/com/charles445/simpledifficulty/config/json/BlockTemperature.java rename to src/main/java/com/charles445/simpledifficulty/config/json/JsonPropertyTemperature.java index a1bdb2c..4e2aa1b 100644 --- a/src/main/java/com/charles445/simpledifficulty/config/json/BlockTemperature.java +++ b/src/main/java/com/charles445/simpledifficulty/config/json/JsonPropertyTemperature.java @@ -8,7 +8,7 @@ import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; -public class BlockTemperature +public class JsonPropertyTemperature { @SerializedName("properties") public Map properties; @@ -16,7 +16,7 @@ public class BlockTemperature @SerializedName("temperature") public float temperature; - public BlockTemperature(float temperature, PropertyValue ... props) + public JsonPropertyTemperature(float temperature, PropertyValue ... props) { this.temperature = temperature; this.properties = new HashMap(); diff --git a/src/main/java/com/charles445/simpledifficulty/config/json/ArmorTemperature.java b/src/main/java/com/charles445/simpledifficulty/config/json/JsonTemperature.java similarity index 73% rename from src/main/java/com/charles445/simpledifficulty/config/json/ArmorTemperature.java rename to src/main/java/com/charles445/simpledifficulty/config/json/JsonTemperature.java index bf88c40..831d803 100644 --- a/src/main/java/com/charles445/simpledifficulty/config/json/ArmorTemperature.java +++ b/src/main/java/com/charles445/simpledifficulty/config/json/JsonTemperature.java @@ -2,13 +2,13 @@ import com.google.gson.annotations.SerializedName; -public class ArmorTemperature +public class JsonTemperature { @SerializedName("temperature") public float temperature; - public ArmorTemperature(float temperature) + public JsonTemperature(float temperature) { this.temperature = temperature; } -} +} \ No newline at end of file diff --git a/src/main/java/com/charles445/simpledifficulty/item/ItemThermometer.java b/src/main/java/com/charles445/simpledifficulty/item/ItemThermometer.java index 93724d2..f20aa99 100644 --- a/src/main/java/com/charles445/simpledifficulty/item/ItemThermometer.java +++ b/src/main/java/com/charles445/simpledifficulty/item/ItemThermometer.java @@ -18,6 +18,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -273,12 +274,9 @@ else if(age==null || temp == null) @SideOnly(Side.CLIENT) private float calculateTemperature(World world, Entity entity) { - float newDestTemperature = TemperatureUtil.clampTemperature(TemperatureUtil.getWorldTemperature(world, WorldUtil.getSidedBlockPos(world,entity))); - float tempRange = (float)(TemperatureEnum.BURNING.getUpperBound() - TemperatureEnum.FREEZING.getLowerBound() + 1); - - return newDestTemperature / tempRange; + int tempRange = TemperatureEnum.BURNING.getUpperBound() - TemperatureEnum.FREEZING.getLowerBound() + 1; + return (float)WorldUtil.calculateClientWorldEntityTemperature(world, entity) / (float)tempRange; } - }); } } diff --git a/src/main/java/com/charles445/simpledifficulty/temperature/ModifierArmor.java b/src/main/java/com/charles445/simpledifficulty/temperature/ModifierArmor.java index 7f644af..101478e 100644 --- a/src/main/java/com/charles445/simpledifficulty/temperature/ModifierArmor.java +++ b/src/main/java/com/charles445/simpledifficulty/temperature/ModifierArmor.java @@ -4,7 +4,7 @@ import com.charles445.simpledifficulty.api.temperature.TemperatureUtil; import com.charles445.simpledifficulty.config.JsonConfig; import com.charles445.simpledifficulty.config.ModConfig; -import com.charles445.simpledifficulty.config.json.ArmorTemperature; +import com.charles445.simpledifficulty.config.json.JsonTemperature; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; @@ -49,7 +49,7 @@ else if(EnchantmentHelper.getEnchantmentLevel(SDEnchantments.heating, stack) > 0 } //ArmorTemperature - ArmorTemperature armorInfo = JsonConfig.armorTemperatures.get(stack.getItem().getRegistryName().toString()); + JsonTemperature armorInfo = JsonConfig.armorTemperatures.get(stack.getItem().getRegistryName().toString()); if(armorInfo!=null) { sum += armorInfo.temperature; diff --git a/src/main/java/com/charles445/simpledifficulty/temperature/ModifierBlock.java b/src/main/java/com/charles445/simpledifficulty/temperature/ModifierBlock.java index 5623837..8128237 100644 --- a/src/main/java/com/charles445/simpledifficulty/temperature/ModifierBlock.java +++ b/src/main/java/com/charles445/simpledifficulty/temperature/ModifierBlock.java @@ -1,7 +1,7 @@ package com.charles445.simpledifficulty.temperature; import com.charles445.simpledifficulty.config.JsonConfig; -import com.charles445.simpledifficulty.config.json.BlockTemperature; +import com.charles445.simpledifficulty.config.json.JsonPropertyTemperature; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -35,7 +35,7 @@ public float getWorldInfluence(World world, BlockPos pos) final IBlockState blockstate = world.getBlockState(blockpos); final Block block = blockstate.getBlock(); - BlockTemperature tempInfo = JsonConfig.blockTemperatures.get(block.getRegistryName().toString()); + JsonPropertyTemperature tempInfo = JsonConfig.blockTemperatures.get(block.getRegistryName().toString()); if(tempInfo!=null) { float blockTemp = tempInfo.temperature; diff --git a/src/main/java/com/charles445/simpledifficulty/temperature/ModifierWet.java b/src/main/java/com/charles445/simpledifficulty/temperature/ModifierWet.java index 6f2deee..6034699 100644 --- a/src/main/java/com/charles445/simpledifficulty/temperature/ModifierWet.java +++ b/src/main/java/com/charles445/simpledifficulty/temperature/ModifierWet.java @@ -1,11 +1,18 @@ package com.charles445.simpledifficulty.temperature; +import com.charles445.simpledifficulty.config.JsonConfig; import com.charles445.simpledifficulty.config.ModConfig; +import com.charles445.simpledifficulty.config.json.JsonPropertyTemperature; +import com.charles445.simpledifficulty.config.json.JsonTemperature; +import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.IFluidBlock; public class ModifierWet extends ModifierBase { @@ -33,9 +40,42 @@ public float getWorldInfluence(World world, BlockPos pos) //Optifine + Serene Seasons = misleading particle effects //Nothing I can do about that... - if(world.getBlockState(pos).getMaterial()==Material.WATER || world.isRainingAt(pos)) + + //TODO some Material.WATER liquids may not be "cold" + //Like Biomes O' Plenty's Hot Spring Water + + IBlockState state = world.getBlockState(pos); + Block block = state.getBlock(); + + if(block instanceof IFluidBlock) + { + //Modded fluid + Fluid fluid = ((IFluidBlock)block).getFluid(); + if(fluid != null) + { + JsonTemperature tempInfo = JsonConfig.fluidTemperatures.get(fluid.getName()); + if(tempInfo!=null) + { + //Overridden mod fluid + return tempInfo.temperature; + } + } + } + + //Vanilla fluid, or modded fluid with no override, or no fluid at all + + if(state.getMaterial() == Material.WATER) + { + return ModConfig.server.temperature.wetValue; + } + else if(world.isRainingAt(pos)) + { + //Rain return ModConfig.server.temperature.wetValue; + } else + { return 0.0f; + } } } diff --git a/src/main/java/com/charles445/simpledifficulty/util/WorldUtil.java b/src/main/java/com/charles445/simpledifficulty/util/WorldUtil.java index 6e7b7aa..79b0a68 100644 --- a/src/main/java/com/charles445/simpledifficulty/util/WorldUtil.java +++ b/src/main/java/com/charles445/simpledifficulty/util/WorldUtil.java @@ -1,5 +1,7 @@ package com.charles445.simpledifficulty.util; +import com.charles445.simpledifficulty.api.temperature.TemperatureEnum; +import com.charles445.simpledifficulty.api.temperature.TemperatureUtil; import com.charles445.simpledifficulty.debug.DebugUtil; import net.minecraft.entity.Entity; @@ -44,4 +46,9 @@ else if(entity instanceof EntityItemFrame) return entity.getPosition(); } } + + public static int calculateClientWorldEntityTemperature(World world, Entity entity) + { + return TemperatureUtil.clampTemperature(TemperatureUtil.getWorldTemperature(world, WorldUtil.getSidedBlockPos(world,entity))); + } } diff --git a/src/main/resources/assets/simpledifficulty/textures/gui/icons.png b/src/main/resources/assets/simpledifficulty/textures/gui/icons.png index c933f8b..078170c 100644 Binary files a/src/main/resources/assets/simpledifficulty/textures/gui/icons.png and b/src/main/resources/assets/simpledifficulty/textures/gui/icons.png differ