From bde3c8e13e2ef64d4bf312de5b1c2aee356098a5 Mon Sep 17 00:00:00 2001 From: Hea3veN Date: Wed, 4 May 2016 17:38:48 -0300 Subject: [PATCH] * Update to java 8 --- Hea3venTweaks | 2 +- mcbuild.gradle | 4 +- .../ProxyModHardModeTweaksDayNightCycle.java | 37 ++--- .../hardmodetweaks/food/FoodValueTweaker.java | 42 +++--- .../food/ProxyModHardModeTweaksFood.java | 142 ++++++------------ .../ProxyModHardModeTweaksGameRules.java | 40 ++--- .../mobs/ProxyModHardModeTweaksMobs.java | 67 +++------ .../other/ProxyModHardModeTweaksOther.java | 46 +++--- .../sleep/ProxyModHardModeTweaksSleep.java | 46 +++--- .../world/ProxyModHardModeTweaksWorld.java | 44 ++---- 10 files changed, 176 insertions(+), 294 deletions(-) diff --git a/Hea3venTweaks b/Hea3venTweaks index c3470f8..47a09a4 160000 --- a/Hea3venTweaks +++ b/Hea3venTweaks @@ -1 +1 @@ -Subproject commit c3470f85706f2402fe35dfd5b3b01c50878ad241 +Subproject commit 47a09a4ac07a9c124229d9e73fbc723ea046c8e8 diff --git a/mcbuild.gradle b/mcbuild.gradle index 7f61d8c..f5d9809 100644 --- a/mcbuild.gradle +++ b/mcbuild.gradle @@ -37,8 +37,8 @@ version = "${version_mc}-${project_version}" group = "${project_group}" archivesBaseName = "${project_name}" -sourceCompatibility = 1.7 -targetCompatibility = 1.7 +sourceCompatibility = 1.8 +targetCompatibility = 1.8 minecraft { version = "${version_mc}-${version_forge}" + (project.hasProperty('version_forge_branch')? '-' + version_forge_branch : '') diff --git a/src/main/java/com/hea3ven/hardmodetweaks/daynightcycle/ProxyModHardModeTweaksDayNightCycle.java b/src/main/java/com/hea3ven/hardmodetweaks/daynightcycle/ProxyModHardModeTweaksDayNightCycle.java index 2ef8269..d22026e 100644 --- a/src/main/java/com/hea3ven/hardmodetweaks/daynightcycle/ProxyModHardModeTweaksDayNightCycle.java +++ b/src/main/java/com/hea3ven/hardmodetweaks/daynightcycle/ProxyModHardModeTweaksDayNightCycle.java @@ -1,8 +1,5 @@ package com.hea3ven.hardmodetweaks.daynightcycle; -import java.util.function.Consumer; - -import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property.Type; import com.hea3ven.tools.commonutils.mod.ProxyModModule; @@ -13,33 +10,23 @@ public class ProxyModHardModeTweaksDayNightCycle extends ProxyModModule { @Override public CategoryConfigManagerBuilder getConfig() { - return new CategoryConfigManagerBuilder("DayNightCycle") - .addValue("enableDayCycleTweaks", "true", Type.BOOLEAN, "Enable the day/night cycle tweaks", - new Consumer() { - @Override - public void accept(Property property) { - Hea3venTweaks.setConfig("DayNightCycle.enabled", property.getString()); - } - }, true, true) + return new CategoryConfigManagerBuilder("DayNightCycle").addValue("enableDayCycleTweaks", "true", + Type.BOOLEAN, "Enable the day/night cycle tweaks", property -> { + Hea3venTweaks.setConfig("DayNightCycle.enabled", property.getString()); + }, true, true) .addValue("cycleLengthMultiplier", "1.0", Type.DOUBLE, "Change the length of the day/night " + - "cycle, 1.0 is the same as vanilla, which is 20 minutes.", new Consumer() { - @Override - public void accept(Property property) { - Hea3venTweaks.setConfig("DayNightCycle.cycleLengthMultiplier", - Double.toString(property.getDouble())); - DayNightCycle.dayLengthMultiplier = 1.0d / property.getDouble(); - } + "cycle, 1.0 is the same as vanilla, which is 20 minutes.", property -> { + Hea3venTweaks.setConfig("DayNightCycle.cycleLengthMultiplier", + Double.toString(property.getDouble())); + DayNightCycle.dayLengthMultiplier = 1.0d / property.getDouble(); }, false, true) .addValue("dayToNightRatio", "0.5", Type.DOUBLE, "Ratio between the length of the day and " + "the length of the night, values should be between 0.0 and 1.0. A value of 0.5 " + "means day and night are the same length, a value of 0.75 means the day is longer " + - "than the night.", new Consumer() { - @Override - public void accept(Property property) { - Hea3venTweaks.setConfig("DayNightCycle.dayToNightRatio", - Float.toString((float) property.getDouble())); - DayNightCycle.dayToNightRatio = 2.0f * (float) property.getDouble(); - } + "than the night.", property -> { + Hea3venTweaks.setConfig("DayNightCycle.dayToNightRatio", + Float.toString((float) property.getDouble())); + DayNightCycle.dayToNightRatio = 2.0f * (float) property.getDouble(); }, false, true); } } diff --git a/src/main/java/com/hea3ven/hardmodetweaks/food/FoodValueTweaker.java b/src/main/java/com/hea3ven/hardmodetweaks/food/FoodValueTweaker.java index 985c2b4..8a15999 100644 --- a/src/main/java/com/hea3ven/hardmodetweaks/food/FoodValueTweaker.java +++ b/src/main/java/com/hea3ven/hardmodetweaks/food/FoodValueTweaker.java @@ -18,24 +18,30 @@ public class FoodValueTweaker { public static void modifyFoodValues() { for (FoodConfig foodCfg : foodValuesConfig) { - if (foodCfg.getName().equals("minecraft:raw_fish")) { - modifyFishFoodValue(FishType.COD, foodCfg, false); - } else if (foodCfg.getName().equals("minecraft:cooked_fish")) { - modifyFishFoodValue(FishType.COD, foodCfg, true); - } else if (foodCfg.getName().equals("minecraft:raw_salmon")) { - modifyFishFoodValue(FishType.SALMON, foodCfg, false); - } else if (foodCfg.getName().equals("minecraft:cooked_salmon")) { - modifyFishFoodValue(FishType.SALMON, foodCfg, true); - } else { - Item item = Item.getByNameOrId(foodCfg.getName()); - if (!(item instanceof ItemFood)) { - logger.warn("The item '{}' is not a food item", foodCfg.getName()); - continue; - } - ItemFood food = (ItemFood) item; - - ReflectionHelper.setPrivateValue(ItemFood.class, food, foodCfg.getValue(), 1); - ReflectionHelper.setPrivateValue(ItemFood.class, food, foodCfg.getSaturation(), 2); + switch (foodCfg.getName()) { + case "minecraft:raw_fish": + modifyFishFoodValue(FishType.COD, foodCfg, false); + break; + case "minecraft:cooked_fish": + modifyFishFoodValue(FishType.COD, foodCfg, true); + break; + case "minecraft:raw_salmon": + modifyFishFoodValue(FishType.SALMON, foodCfg, false); + break; + case "minecraft:cooked_salmon": + modifyFishFoodValue(FishType.SALMON, foodCfg, true); + break; + default: + Item item = Item.getByNameOrId(foodCfg.getName()); + if (!(item instanceof ItemFood)) { + logger.warn("The item '{}' is not a food item", foodCfg.getName()); + continue; + } + ItemFood food = (ItemFood) item; + + ReflectionHelper.setPrivateValue(ItemFood.class, food, foodCfg.getValue(), 1); + ReflectionHelper.setPrivateValue(ItemFood.class, food, foodCfg.getSaturation(), 2); + break; } } } diff --git a/src/main/java/com/hea3ven/hardmodetweaks/food/ProxyModHardModeTweaksFood.java b/src/main/java/com/hea3ven/hardmodetweaks/food/ProxyModHardModeTweaksFood.java index 07e8955..4474317 100644 --- a/src/main/java/com/hea3ven/hardmodetweaks/food/ProxyModHardModeTweaksFood.java +++ b/src/main/java/com/hea3ven/hardmodetweaks/food/ProxyModHardModeTweaksFood.java @@ -1,11 +1,8 @@ package com.hea3ven.hardmodetweaks.food; -import java.util.function.Consumer; - import com.google.common.collect.Lists; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property.Type; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @@ -25,100 +22,59 @@ public void onInitEvent(FMLInitializationEvent event) { @Override public CategoryConfigManagerBuilder getConfig() { - return new CategoryConfigManagerBuilder("Food") - .addValue("enableFoodTweaks", "true", Type.BOOLEAN, - "Enable food tweaks. The food healing stacks with the normal natural regeneration, " + - "so consider disabling the gamerule for that.", - new Consumer() { - @Override - public void accept(Property property) { - if (property.getBoolean()) { - if (foodManager == null) { - foodManager = new FoodTweaksManager(); - MinecraftForge.EVENT_BUS.register(foodManager); - } - } else { - if (foodManager != null) { - MinecraftForge.EVENT_BUS.unregister(foodManager); - foodManager = null; - } - } - } - }, true, true) - .addValue("foodValues", new String[] {"minecraft:rabbit_stew|12|12.0", - "minecraft:golden_carrot|8|14.4", - "minecraft:pumpkin_pie|8|12.0", - "minecraft:golden_apple|10|9.6", - "minecraft:mushroom_stew|8|11", - "minecraft:bread|6|11", - "minecraft:beetroot_soup|6|7.8", - "minecraft:cooked_salmon|7|6.4", - "minecraft:cooked_fish|5|7.8", - "minecraft:spider_eye|4|6.4", - "minecraft:baked_potato|5|5.2", - "minecraft:apple|4|5.2", - "minecraft:cooked_beef|3|5.2", - "minecraft:cooked_porkchop|3|5.2", - "minecraft:cooked_mutton|3|5.2", - "minecraft:cooked_chicken|3|5.2", - "minecraft:cooked_rabbit|3|5.2", - "minecraft:chorus_fruit|6|1.2", - "minecraft:cookie|4|3.2", - "minecraft:carrot|4|2.4", - "minecraft:melon|4|2.4", - "minecraft:beetroot|4|2.4", - "minecraft:potato|4|2.4", - "minecraft:rotten_flesh|4|0.8", - "minecraft:raw_salmon|2|2.4", - "minecraft:raw_fish|2|2.4", - "minecraft:rabbit|2|2.4", - "minecraft:porkchop|2|2.4", - "minecraft:beef|2|2.4", - "minecraft:mutton|2|2.4", - "minecraft:chicken|2|2.4", - "minecraft:poisonous_potato|2|0.8"}, - Type.STRING, - "Modifications to food's value and saturation." - + " Remove all entries to leave as default vanilla values.", - new Consumer() { - @Override - public void accept(Property property) { - FoodValueTweaker.foodValuesConfig = Lists.newArrayList(); - for (String foodConfigString : property.getStringList()) { - FoodConfig foodConfig = FoodConfig.parse(foodConfigString); - if (foodConfig != null) - FoodValueTweaker.foodValuesConfig.add(foodConfig); - } + return new CategoryConfigManagerBuilder("Food").addValue("enableFoodTweaks", "true", Type.BOOLEAN, + "Enable food tweaks. The food healing stacks with the normal natural regeneration, " + + "so consider disabling the gamerule for that.", property -> { + if (property.getBoolean()) { + if (foodManager == null) { + foodManager = new FoodTweaksManager(); + MinecraftForge.EVENT_BUS.register(foodManager); + } + } else { + if (foodManager != null) { + MinecraftForge.EVENT_BUS.unregister(foodManager); + foodManager = null; + } + } + }, true, true) + .addValue("foodValues", + new String[] {"minecraft:rabbit_stew|12|12.0", "minecraft:golden_carrot|8|14.4", + "minecraft:pumpkin_pie|8|12.0", "minecraft:golden_apple|10|9.6", + "minecraft:mushroom_stew|8|11", "minecraft:bread|6|11", + "minecraft:beetroot_soup|6|7.8", "minecraft:cooked_salmon|7|6.4", + "minecraft:cooked_fish|5|7.8", "minecraft:spider_eye|4|6.4", + "minecraft:baked_potato|5|5.2", "minecraft:apple|4|5.2", + "minecraft:cooked_beef|3|5.2", "minecraft:cooked_porkchop|3|5.2", + "minecraft:cooked_mutton|3|5.2", "minecraft:cooked_chicken|3|5.2", + "minecraft:cooked_rabbit|3|5.2", "minecraft:chorus_fruit|6|1.2", + "minecraft:cookie|4|3.2", "minecraft:carrot|4|2.4", "minecraft:melon|4|2.4", + "minecraft:beetroot|4|2.4", "minecraft:potato|4|2.4", + "minecraft:rotten_flesh|4|0.8", "minecraft:raw_salmon|2|2.4", + "minecraft:raw_fish|2|2.4", "minecraft:rabbit|2|2.4", + "minecraft:porkchop|2|2.4", "minecraft:beef|2|2.4", "minecraft:mutton|2|2.4", + "minecraft:chicken|2|2.4", "minecraft:poisonous_potato|2|0.8"}, Type.STRING, + "Modifications to food's value and saturation." + + " Remove all entries to leave as default vanilla values.", property -> { + FoodValueTweaker.foodValuesConfig = Lists.newArrayList(); + for (String foodConfigString : property.getStringList()) { + FoodConfig foodConfig = FoodConfig.parse(foodConfigString); + if (foodConfig != null) + FoodValueTweaker.foodValuesConfig.add(foodConfig); } }, true, true) .addValue("healMinFoodLevel", "4", Type.INTEGER, - "The minimum food level required to be able to heal.", new Consumer() { - @Override - public void accept(Property property) { - FoodTweaksManager.healMinFoodLevel = property.getInt(); - } - }) - .addValue("healTimeout", "20", Type.INTEGER, "The timeout between heals.", - new Consumer() { - @Override - public void accept(Property property) { - FoodTweaksManager.healTimeout = (byte) property.getInt(); - } - }) - .addValue("healAmount", "0.2", Type.DOUBLE, "The amount of healing done.", - new Consumer() { - @Override - public void accept(Property property) { - FoodTweaksManager.healAmount = (float) property.getDouble(); - } + "The minimum food level required to be able to heal.", property -> { + FoodTweaksManager.healMinFoodLevel = property.getInt(); }) + .addValue("healTimeout", "20", Type.INTEGER, "The timeout between heals.", property -> { + FoodTweaksManager.healTimeout = (byte) property.getInt(); + }) + .addValue("healAmount", "0.2", Type.DOUBLE, "The amount of healing done.", property -> { + FoodTweaksManager.healAmount = (float) property.getDouble(); + }) .addValue("healExhaustion", "3.0", Type.DOUBLE, - "The amount of exhaustion added when healing.", new Consumer() { - @Override - public void accept(Property property) { - FoodTweaksManager.healExhaustion = (float) property.getDouble(); - } - }) - ; + "The amount of exhaustion added when healing.", property -> { + FoodTweaksManager.healExhaustion = (float) property.getDouble(); + }); } } diff --git a/src/main/java/com/hea3ven/hardmodetweaks/gamerules/ProxyModHardModeTweaksGameRules.java b/src/main/java/com/hea3ven/hardmodetweaks/gamerules/ProxyModHardModeTweaksGameRules.java index 703a66d..dad9256 100644 --- a/src/main/java/com/hea3ven/hardmodetweaks/gamerules/ProxyModHardModeTweaksGameRules.java +++ b/src/main/java/com/hea3ven/hardmodetweaks/gamerules/ProxyModHardModeTweaksGameRules.java @@ -1,11 +1,8 @@ package com.hea3ven.hardmodetweaks.gamerules; -import java.util.function.Consumer; - import net.minecraft.world.GameRules; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property.Type; import com.hea3ven.tools.commonutils.mod.ProxyModModule; @@ -17,33 +14,26 @@ public class ProxyModHardModeTweaksGameRules extends ProxyModModule { @Override public CategoryConfigManagerBuilder getConfig() { - CategoryConfigManagerBuilder cfg = new CategoryConfigManagerBuilder("GameRules") - .addValue("enableGameRules", "true", Type.BOOLEAN, "Enable changing the game rules.", - new Consumer() { - @Override - public void accept(Property property) { - if (property.getBoolean()) { - if (rulesManager == null) { - rulesManager = new GameRulesManager(); - MinecraftForge.EVENT_BUS.register(rulesManager); - } - } else { - if (rulesManager != null) { - MinecraftForge.EVENT_BUS.unregister(rulesManager); - rulesManager = null; - } + CategoryConfigManagerBuilder cfg = + new CategoryConfigManagerBuilder("GameRules").addValue("enableGameRules", "true", + Type.BOOLEAN, "Enable changing the game rules.", property -> { + if (property.getBoolean()) { + if (rulesManager == null) { + rulesManager = new GameRulesManager(); + MinecraftForge.EVENT_BUS.register(rulesManager); + } + } else { + if (rulesManager != null) { + MinecraftForge.EVENT_BUS.unregister(rulesManager); + rulesManager = null; } } }); GameRules rules = new GameRules(); for (String ruleName : rules.getRules()) { - cfg = cfg.addValue(ruleName, rules.getString(ruleName), Type.STRING, "", - new Consumer() { - @Override - public void accept(Property property) { - GameRulesManager.gameRules.put(property.getName(), property.getString()); - } - }, false, true); + cfg = cfg.addValue(ruleName, rules.getString(ruleName), Type.STRING, "", property -> { + GameRulesManager.gameRules.put(property.getName(), property.getString()); + }, false, true); } return cfg; } diff --git a/src/main/java/com/hea3ven/hardmodetweaks/mobs/ProxyModHardModeTweaksMobs.java b/src/main/java/com/hea3ven/hardmodetweaks/mobs/ProxyModHardModeTweaksMobs.java index c7a140e..7718179 100644 --- a/src/main/java/com/hea3ven/hardmodetweaks/mobs/ProxyModHardModeTweaksMobs.java +++ b/src/main/java/com/hea3ven/hardmodetweaks/mobs/ProxyModHardModeTweaksMobs.java @@ -1,9 +1,6 @@ package com.hea3ven.hardmodetweaks.mobs; -import java.util.function.Consumer; - import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property.Type; import com.hea3ven.tools.commonutils.mod.ProxyModModule; @@ -14,56 +11,36 @@ public class ProxyModHardModeTweaksMobs extends ProxyModModule { @Override public CategoryConfigManagerBuilder getConfig() { - return new CategoryConfigManagerBuilder("Mobs") - .addValue("enableMobsTweak", "true", Type.BOOLEAN, "Enable tweaks for mobs.", - new Consumer() { - @Override - public void accept(Property property) { - if (property.getBoolean()) { - if (mobsManager == null) { - mobsManager = new MobsTweaksManager(); - MinecraftForge.EVENT_BUS.register(mobsManager); - } - } else { - if (mobsManager != null) { - MinecraftForge.EVENT_BUS.unregister(mobsManager); - mobsManager = null; - } - } - } - }) + return new CategoryConfigManagerBuilder("Mobs").addValue("enableMobsTweak", "true", Type.BOOLEAN, + "Enable tweaks for mobs.", property -> { + if (property.getBoolean()) { + if (mobsManager == null) { + mobsManager = new MobsTweaksManager(); + MinecraftForge.EVENT_BUS.register(mobsManager); + } + } else { + if (mobsManager != null) { + MinecraftForge.EVENT_BUS.unregister(mobsManager); + mobsManager = null; + } + } + }) .addValue("spidersApplySlowness", "true", Type.BOOLEAN, - "Enable to make spiders apply slowness when they attack.", - new Consumer() { - @Override - public void accept(Property property) { - MobsTweaksManager.spidersApplySlowness = property.getBoolean(); - } + "Enable to make spiders apply slowness when they attack.", property -> { + MobsTweaksManager.spidersApplySlowness = property.getBoolean(); }) .addValue("replaceCaveSpiderPoison", "true", Type.BOOLEAN, - "Enable to make it so cave spiders apply weakness in stead of poison.", - new Consumer() { - @Override - public void accept(Property property) { - MobsTweaksManager.replaceCaveSpiderPoison = property.getBoolean(); - } + "Enable to make it so cave spiders apply weakness in stead of poison.", property -> { + MobsTweaksManager.replaceCaveSpiderPoison = property.getBoolean(); }) .addValue("creeperSpawnTweak", "true", Type.BOOLEAN, - "Make it so that creepers only spawn on blocks without sky access.", - new Consumer() { - @Override - public void accept(Property property) { - MobsTweaksManager.creeperSpawnTweak = property.getBoolean(); - } + "Make it so that creepers only spawn on blocks without sky access.", property -> { + MobsTweaksManager.creeperSpawnTweak = property.getBoolean(); }) .addValue("zombieKnockbackResistance", "0.6d", Type.DOUBLE, "The value for zombies knockback resistance, use values between 0.0 and 1.0." + - " Set to 0.0 to disable.", - new Consumer() { - @Override - public void accept(Property property) { - MobsTweaksManager.zombieKnockbackResistance = (float) property.getDouble(); - } + " Set to 0.0 to disable.", property -> { + MobsTweaksManager.zombieKnockbackResistance = (float) property.getDouble(); }); } } diff --git a/src/main/java/com/hea3ven/hardmodetweaks/other/ProxyModHardModeTweaksOther.java b/src/main/java/com/hea3ven/hardmodetweaks/other/ProxyModHardModeTweaksOther.java index 072286a..acd035c 100644 --- a/src/main/java/com/hea3ven/hardmodetweaks/other/ProxyModHardModeTweaksOther.java +++ b/src/main/java/com/hea3ven/hardmodetweaks/other/ProxyModHardModeTweaksOther.java @@ -1,9 +1,6 @@ package com.hea3ven.hardmodetweaks.other; -import java.util.function.Consumer; - import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property.Type; import com.hea3ven.tools.commonutils.mod.ProxyModModule; @@ -15,33 +12,24 @@ public class ProxyModHardModeTweaksOther extends ProxyModModule { @Override public CategoryConfigManagerBuilder getConfig() { - return new CategoryConfigManagerBuilder("Other") - .addValue("enableAnimalAITweak", "true", Type.BOOLEAN, - "Enable changing the animals AI to make them run from their attackers.", - new Consumer() { - @Override - public void accept(Property property) { - if (property.getBoolean()) { - if (aiManager == null) { - aiManager = new AITweaksManager(); - MinecraftForge.EVENT_BUS.register(aiManager); - } - } else { - if (aiManager != null) { - MinecraftForge.EVENT_BUS.unregister(aiManager); - aiManager = null; - } - } - } - }) + return new CategoryConfigManagerBuilder("Other").addValue("enableAnimalAITweak", "true", Type.BOOLEAN, + "Enable changing the animals AI to make them run from their attackers.", property -> { + if (property.getBoolean()) { + if (aiManager == null) { + aiManager = new AITweaksManager(); + MinecraftForge.EVENT_BUS.register(aiManager); + } + } else { + if (aiManager != null) { + MinecraftForge.EVENT_BUS.unregister(aiManager); + aiManager = null; + } + } + }) .addValue("enableNonSolidLeaves", "true", Type.BOOLEAN, - "Enable tweak to make leaves blocks non-solid (like vines).", - new Consumer() { - @Override - public void accept(Property property) { - Hea3venTweaks.setConfig("NonSolidLeaves.enabled", - Boolean.toString(property.getBoolean())); - } + "Enable tweak to make leaves blocks non-solid (like vines).", property -> { + Hea3venTweaks.setConfig("NonSolidLeaves.enabled", + Boolean.toString(property.getBoolean())); }, true, true); } } diff --git a/src/main/java/com/hea3ven/hardmodetweaks/sleep/ProxyModHardModeTweaksSleep.java b/src/main/java/com/hea3ven/hardmodetweaks/sleep/ProxyModHardModeTweaksSleep.java index 0321caa..e66272e 100644 --- a/src/main/java/com/hea3ven/hardmodetweaks/sleep/ProxyModHardModeTweaksSleep.java +++ b/src/main/java/com/hea3ven/hardmodetweaks/sleep/ProxyModHardModeTweaksSleep.java @@ -1,9 +1,6 @@ package com.hea3ven.hardmodetweaks.sleep; -import java.util.function.Consumer; - import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property.Type; import com.hea3ven.tools.commonutils.mod.ProxyModModule; @@ -16,33 +13,26 @@ public class ProxyModHardModeTweaksSleep extends ProxyModModule { @Override public CategoryConfigManagerBuilder getConfig() { - return new CategoryConfigManagerBuilder("Sleep") - .addValue("enableSleepPrevention", "true", Type.BOOLEAN, - "Enable beds requiring a timeout after being placed before they can be used.", - new Consumer() { - @Override - public void accept(Property property) { - if (property.getBoolean()) { - if (sleepManager == null) { - sleepManager = new SleepManager(); - MinecraftForge.EVENT_BUS.register(sleepManager); - } - } else { - if (sleepManager != null) { - MinecraftForge.EVENT_BUS.unregister(sleepManager); - sleepManager = null; - } - } - } - }) + return new CategoryConfigManagerBuilder("Sleep").addValue("enableSleepPrevention", "true", + Type.BOOLEAN, "Enable beds requiring a timeout after being placed before they can be used.", + property -> { + if (property.getBoolean()) { + if (sleepManager == null) { + sleepManager = new SleepManager(); + MinecraftForge.EVENT_BUS.register(sleepManager); + } + } else { + if (sleepManager != null) { + MinecraftForge.EVENT_BUS.unregister(sleepManager); + sleepManager = null; + } + } + }) .addValue("sleepTimeout", "3", Type.INTEGER, "The number of days that must pass after placing a bed before it can be used.", - new Consumer() { - @Override - public void accept(Property property) { - SleepManager.sleepPreventionTimeout = (int) (property.getInt() * 24000 / - DayNightCycle.dayLengthMultiplier); - } + property -> { + SleepManager.sleepPreventionTimeout = + (int) (property.getInt() * 24000 / DayNightCycle.dayLengthMultiplier); }); } } diff --git a/src/main/java/com/hea3ven/hardmodetweaks/world/ProxyModHardModeTweaksWorld.java b/src/main/java/com/hea3ven/hardmodetweaks/world/ProxyModHardModeTweaksWorld.java index 569dcbc..91213f4 100644 --- a/src/main/java/com/hea3ven/hardmodetweaks/world/ProxyModHardModeTweaksWorld.java +++ b/src/main/java/com/hea3ven/hardmodetweaks/world/ProxyModHardModeTweaksWorld.java @@ -1,9 +1,6 @@ package com.hea3ven.hardmodetweaks.world; -import java.util.function.Consumer; - import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property.Type; import com.hea3ven.tools.commonutils.mod.ProxyModModule; @@ -14,33 +11,24 @@ public class ProxyModHardModeTweaksWorld extends ProxyModModule { @Override public CategoryConfigManagerBuilder getConfig() { - return new CategoryConfigManagerBuilder("World") - .addValue("enableWorldTweaks", "true", Type.BOOLEAN, - "Enable world tweaks.", - new Consumer() { - @Override - public void accept(Property property) { - if (property.getBoolean()) { - if (worldManager == null) { - worldManager = new WorldTweaksManager(); - MinecraftForge.EVENT_BUS.register(worldManager); - } - } else { - if (worldManager != null) { - MinecraftForge.EVENT_BUS.unregister(worldManager); - worldManager = null; - } - } - } - }) + return new CategoryConfigManagerBuilder("World").addValue("enableWorldTweaks", "true", Type.BOOLEAN, + "Enable world tweaks.", property -> { + if (property.getBoolean()) { + if (worldManager == null) { + worldManager = new WorldTweaksManager(); + MinecraftForge.EVENT_BUS.register(worldManager); + } + } else { + if (worldManager != null) { + MinecraftForge.EVENT_BUS.unregister(worldManager); + worldManager = null; + } + } + }) .addValue("maxBreakSpeed", "300", Type.INTEGER, "The maximum break speed allowed. For reference, diamond pickaxe is a" + - " break speed of 8, and with efficiency V it's speed is 34", - new Consumer() { - @Override - public void accept(Property property) { - WorldTweaksManager.maxBreakSpeed = property.getInt(); - } + " break speed of 8, and with efficiency V it's speed is 34", property -> { + WorldTweaksManager.maxBreakSpeed = property.getInt(); }); } }