From 6f97394fbfb6c80444a1ad3eba2530ce37eb95a2 Mon Sep 17 00:00:00 2001 From: OneEyeMaker Date: Mon, 25 Sep 2017 09:39:34 +0300 Subject: [PATCH] Added configuration for Drill --- .../mod/config/ConfigCategories.java | 1 + .../mod/config/ConfigValues.java | 2 +- .../config/values/ConfigIntListValues.java | 4 ++- .../mod/config/values/ConfigIntValues.java | 6 +++- .../mod/items/ItemDrill.java | 33 +++++++++++-------- .../actuallyadditions/mod/util/StackUtil.java | 11 +++++-- 6 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java index 3ee27cd20..b7bfe203c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java @@ -18,6 +18,7 @@ public enum ConfigCategories{ MACHINE_VALUES("Machine Values", "Values for Machines"), MOB_DROPS("Mob Drops", "Everything regarding Item drops from mobs"), WORLD_GEN("World Gen", "Everything regarding World Generation"), + TOOL_ENERGY_VALUES("Tool Energy Values", "Energy values for Tools"), OTHER("Other", "Everything else"); public final String name; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java index a27a2d661..b048bfcf6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java @@ -28,7 +28,7 @@ public final class ConfigValues{ public static void defineConfigValues(Configuration config){ for(ConfigIntValues currConf : ConfigIntValues.values()){ - currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getInt(); + currConf.currentValue = config.getInt(currConf.name, currConf.category, currConf.defaultValue, currConf.min, currConf.max, currConf.desc); } for(ConfigBoolValues currConf : ConfigBoolValues.values()){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntListValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntListValues.java index 400a2f854..2aef0c35e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntListValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntListValues.java @@ -17,7 +17,9 @@ public enum ConfigIntListValues{ ORE_GEN_DIMENSION_BLACKLIST("OreGen Dimension Blacklist", ConfigCategories.WORLD_GEN, new int[0], "The list of IDs that Actually Additions OreGen (Ex: Black Quartz) is banned in. This also applies for other world gen like lush caves."), PLANT_DIMENSION_BLACKLIST("Plant Blacklist", ConfigCategories.WORLD_GEN, new int[0], "The list of IDs of the dimensions that Actually Additions Plants (Rice for example) are banned in."), OIL_POWER("Oil Gen: Power Values", ConfigCategories.MACHINE_VALUES, new int[]{40, 80, 100, 120}, "The amount of power that the 4 tiers of oils generate (in order)"), - OIL_TIME("Oil Gen: Time Values", ConfigCategories.MACHINE_VALUES, new int[]{100, 120, 280, 400}, "The amount of time that the 4 tiers of oils work for (in order)"); + OIL_TIME("Oil Gen: Time Values", ConfigCategories.MACHINE_VALUES, new int[]{100, 120, 280, 400}, "The amount of time that the 4 tiers of oils work for (in order)"), + + DRILL_AUGMENTS_ENERGY_USE("Drill: Energy Use Per Augment", ConfigCategories.TOOL_ENERGY_VALUES, new int[]{50, 75, 175, 100, 40, 80, 10, 30, 0}, "Additional amount of energy Drill Augments use per mined block. Order of augments: Speed I, Speed II, Speed III, Silk Touch, Fortune I, Fortune II, Mining I, Mining II, Block Placing"); public final String name; public final String category; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java index e869f6ba9..e2c8f7ee4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java @@ -29,7 +29,11 @@ public enum ConfigIntValues{ FONT_SIZE_MEDIUM("Booklet Medium Font Size", ConfigCategories.OTHER, 0, 0, 500, "The size of the booklet's medium font in percent. Set to 0 to use defaults from the lang file."), FONT_SIZE_LARGE("Booklet Large Font Size", ConfigCategories.OTHER, 0, 0, 500, "The size of the booklet's large font in percent. Set to 0 to use defaults from the lang file."), - ELEVEN("What is 11", ConfigCategories.OTHER, 11, 0, 12, "11?"); + ELEVEN("What is 11", ConfigCategories.OTHER, 11, 0, 12, "11?"), + + DRILL_ENERGY_CAPACITY("Drill: Energy Capacity", ConfigCategories.TOOL_ENERGY_VALUES, 250000, 1000, 1000000000, "Amount of energy Drill can store."), + DRILL_ENERGY_TRANSFER("Drill: Energy Transfer Rate", ConfigCategories.TOOL_ENERGY_VALUES, 1000, 1, 1000000000, "Amount of energy Drill can receive per tick."), + DRILL_ENERGY_USE("Drill: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 100, 1, 1000000000, "Amount of energy Drill uses to mine block."); public final String name; public final String category; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java index 63effdca7..ca941d91d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java @@ -13,6 +13,8 @@ package de.ellpeck.actuallyadditions.mod.items; import com.google.common.collect.Multimap; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors; +import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues; +import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; @@ -49,10 +51,9 @@ import java.util.Set; public class ItemDrill extends ItemEnergy{ public static final int HARVEST_LEVEL = 4; - private static final int ENERGY_USE = 100; public ItemDrill(String name){ - super(250000, 1000, name); + super(ConfigIntValues.DRILL_ENERGY_CAPACITY.getValue(), ConfigIntValues.DRILL_ENERGY_TRANSFER.getValue(), name); this.setMaxDamage(0); this.setHasSubtypes(true); @@ -191,7 +192,7 @@ public class ItemDrill extends ItemEnergy{ Multimap map = super.getAttributeModifiers(slot, stack); if(slot == EntityEquipmentSlot.MAINHAND){ - map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Drill Modifier", this.getEnergyStored(stack) >= ENERGY_USE ? 8.0F : 0.1F, 0)); + map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Drill Modifier", this.getEnergyStored(stack) >= ConfigIntValues.DRILL_ENERGY_USE.getValue() ? 8.0F : 0.1F, 0)); map.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool Modifier", -2.5F, 0)); } @@ -270,41 +271,47 @@ public class ItemDrill extends ItemEnergy{ * @return The Energy use per Block */ public int getEnergyUsePerBlock(ItemStack stack){ - int use = ENERGY_USE; + int energyUse = ConfigIntValues.DRILL_ENERGY_USE.getValue(); + int[] augmentsEnergyUse = ConfigIntListValues.DRILL_AUGMENTS_ENERGY_USE.getValue(); //Speed if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED)){ - use += 50; + energyUse += augmentsEnergyUse[0]; if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_II)){ - use += 75; + energyUse += augmentsEnergyUse[1]; if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_III)){ - use += 175; + energyUse += augmentsEnergyUse[2]; } } } //Silk Touch if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)){ - use += 100; + energyUse += augmentsEnergyUse[3]; } //Fortune if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)){ - use += 40; + energyUse += augmentsEnergyUse[4]; if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II)){ - use += 80; + energyUse += augmentsEnergyUse[5]; } } //Size if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)){ - use += 10; + energyUse += augmentsEnergyUse[6]; if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)){ - use += 30; + energyUse += augmentsEnergyUse[7]; } } - return use; + //Block Placing + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.PLACER)){ + energyUse += augmentsEnergyUse[8]; + } + + return energyUse; } /** diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java index 9b130c52c..8a7fc8802 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java @@ -36,9 +36,14 @@ public final class StackUtil{ } public static boolean isValid(ItemStack stack){//Stacks are nonnull. If we are making null stacks we're stupid anyway. - if(stack == null) AwfulUtil.callTheFuckinPolice("Oh yeah some idiot somewhere threw a null itemstack at us, might've been us, but whatever"); - Item i = stack.getItem(); - if(i instanceof IDisableableItem) return !((IDisableableItem) i).isDisabled(); + if(stack == null){ + AwfulUtil.callTheFuckinPolice("Oh yeah some idiot somewhere threw a null itemstack at us, might've been us, but whatever"); + return false; + } + Item i = stack.getItem(); + if(i instanceof IDisableableItem){ + return !((IDisableableItem) i).isDisabled(); + } return !stack.isEmpty(); }