Skip to content

Commit

Permalink
* Update to java 8
Browse files Browse the repository at this point in the history
  • Loading branch information
hea3ven committed May 5, 2016
1 parent dc4856b commit bde3c8e
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 294 deletions.
2 changes: 1 addition & 1 deletion Hea3venTweaks
Submodule Hea3venTweaks updated 1 files
+2 −2 build.gradle
4 changes: 2 additions & 2 deletions mcbuild.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 : '')
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Property>() {
@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<Property>() {
@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<Property>() {
@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);
}
}
42 changes: 24 additions & 18 deletions src/main/java/com/hea3ven/hardmodetweaks/food/FoodValueTweaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<Property>() {
@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<Property>() {
@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<Property>() {
@Override
public void accept(Property property) {
FoodTweaksManager.healMinFoodLevel = property.getInt();
}
})
.addValue("healTimeout", "20", Type.INTEGER, "The timeout between heals.",
new Consumer<Property>() {
@Override
public void accept(Property property) {
FoodTweaksManager.healTimeout = (byte) property.getInt();
}
})
.addValue("healAmount", "0.2", Type.DOUBLE, "The amount of healing done.",
new Consumer<Property>() {
@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<Property>() {
@Override
public void accept(Property property) {
FoodTweaksManager.healExhaustion = (float) property.getDouble();
}
})
;
"The amount of exhaustion added when healing.", property -> {
FoodTweaksManager.healExhaustion = (float) property.getDouble();
});
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Property>() {
@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<Property>() {
@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;
}
Expand Down
Loading

0 comments on commit bde3c8e

Please sign in to comment.