From e2169c36410307c5c7b2a684d711771dfb56cf82 Mon Sep 17 00:00:00 2001 From: OneEyeMaker Date: Mon, 25 Sep 2017 10:21:15 +0300 Subject: [PATCH] Added configuration for energy powered Rings --- .../mod/config/values/ConfigIntValues.java | 11 ++++++++++- .../actuallyadditions/mod/items/ItemGrowthRing.java | 12 +++++++----- .../actuallyadditions/mod/items/ItemMagnetRing.java | 5 +++-- .../mod/items/ItemWaterRemovalRing.java | 5 +++-- 4 files changed, 23 insertions(+), 10 deletions(-) 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 0f5cf347a..4dde77311 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 @@ -36,7 +36,16 @@ public enum ConfigIntValues{ DRILL_ENERGY_USE("Drill: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 100, 1, 1000000000, "Amount of energy Drill uses to mine block."), HANDHELD_FILLER_ENERGY_CAPACITY("Handheld Filler: Energy Capacity", ConfigCategories.TOOL_ENERGY_VALUES, 500000, 1000, 1000000000, "Amount of energy Handheld Filler can store."), HANDHELD_FILLER_ENERGY_TRANSFER("Handheld Filler: Energy Transfer Rate", ConfigCategories.TOOL_ENERGY_VALUES, 1000, 1, 1000000000, "Amount of energy Handheld Filler can receive per tick."), - HANDHELD_FILLER_ENERGY_USE("Handheld Filler: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 1500, 1, 1000000000, "Amount of energy Handheld Filler uses to place block."); + HANDHELD_FILLER_ENERGY_USE("Handheld Filler: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 1500, 1, 1000000000, "Amount of energy Handheld Filler uses to place block."), + GROWTH_RING_ENERGY_CAPACITY("Ring Of Growth: Energy Capacity", ConfigCategories.TOOL_ENERGY_VALUES, 1000000, 1000, 1000000000, "Amount of energy Ring Of Growth can store."), + GROWTH_RING_ENERGY_TRANSFER("Ring Of Growth: Energy Transfer Rate", ConfigCategories.TOOL_ENERGY_VALUES, 2000, 1, 1000000000, "Amount of energy Ring Of Growth can receive per tick."), + GROWTH_RING_ENERGY_USE("Ring Of Growth: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 300, 1, 1000000000, "Amount of energy Ring Of Growth uses to fertilize plant."), + MAGNETISM_RING_ENERGY_CAPACITY("Ring Of Magnetism: Energy Capacity", ConfigCategories.TOOL_ENERGY_VALUES, 200000, 1000, 1000000000, "Amount of energy Ring Of Magnetism can store."), + MAGNETISM_RING_ENERGY_TRANSFER("Ring Of Magnetism: Energy Transfer Rate", ConfigCategories.TOOL_ENERGY_VALUES, 1000, 1, 1000000000, "Amount of energy Ring Of Magnetism can receive per tick."), + MAGNETISM_RING_ENERGY_USE("Ring Of Magnetism: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 50, 1, 1000000000, "Amount of energy Ring Of Magnetism uses to pick up item."), + LIQUID_BANNING_RING_ENERGY_CAPACITY("Ring Of Liquid Banning: Energy Capacity", ConfigCategories.TOOL_ENERGY_VALUES, 800000, 1000, 1000000000, "Amount of energy Ring Of Liquid Banning can store."), + LIQUID_BANNING_RING_ENERGY_TRANSFER("Ring Of Liquid Banning: Energy Transfer Rate", ConfigCategories.TOOL_ENERGY_VALUES, 1000, 1, 1000000000, "Amount of energy Ring Of Liquid Banning can receive per tick."), + LIQUID_BANNING_RING_ENERGY_USE("Ring Of Liquid Banning: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 150, 1, 1000000000, "Amount of energy Ring Of Liquid Banning uses to remove liquid block."); public final String name; public final String category; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java index 9e845eae6..78745fe65 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.items; +import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; @@ -31,7 +32,7 @@ import java.util.List; public class ItemGrowthRing extends ItemEnergy{ public ItemGrowthRing(String name){ - super(1000000, 2000, name); + super(ConfigIntValues.GROWTH_RING_ENERGY_CAPACITY.getValue(), ConfigIntValues.GROWTH_RING_ENERGY_TRANSFER.getValue(), name); } @Override @@ -43,7 +44,7 @@ public class ItemGrowthRing extends ItemEnergy{ EntityPlayer player = (EntityPlayer)entity; ItemStack equipped = player.getHeldItemMainhand(); - int energyUse = 300; + int energyUse = ConfigIntValues.GROWTH_RING_ENERGY_USE.getValue(); if(StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse){ List blocks = new ArrayList(); @@ -80,11 +81,12 @@ public class ItemGrowthRing extends ItemEnergy{ IBlockState newState = world.getBlockState(pos); if(newState.getBlock().getMetaFromState(newState) != metaBefore){ world.playEvent(2005, pos, 0); + // Consume energy only if plant was fertilized + if(!player.capabilities.isCreativeMode){ + this.extractEnergyInternal(stack, energyUse, false); + } } - if(!player.capabilities.isCreativeMode){ - this.extractEnergyInternal(stack, energyUse, false); - } } else{ break; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java index 2f16155a2..47efb8985 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.items; +import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; @@ -29,7 +30,7 @@ import java.util.ArrayList; public class ItemMagnetRing extends ItemEnergy{ public ItemMagnetRing(String name){ - super(200000, 1000, name); + super(ConfigIntValues.MAGNETISM_RING_ENERGY_CAPACITY.getValue(), ConfigIntValues.MAGNETISM_RING_ENERGY_TRANSFER.getValue(), name); } @Override @@ -49,7 +50,7 @@ public class ItemMagnetRing extends ItemEnergy{ if(!items.isEmpty()){ for(EntityItem item : items){ if(!item.isDead && !item.cannotPickup()){ - int energyForItem = 50*StackUtil.getStackSize(item.getItem()); + int energyForItem = ConfigIntValues.MAGNETISM_RING_ENERGY_USE.getValue()*StackUtil.getStackSize(item.getItem()); if(this.getEnergyStored(stack) >= energyForItem){ ItemStack oldItem = StackUtil.validateCopy(item.getItem()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java index 04778a76f..d02b32275 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.mod.items; +import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; @@ -26,7 +27,7 @@ import net.minecraft.world.World; public class ItemWaterRemovalRing extends ItemEnergy{ public ItemWaterRemovalRing(String name){ - super(800000, 1000, name); + super(ConfigIntValues.LIQUID_BANNING_RING_ENERGY_CAPACITY.getValue(), ConfigIntValues.LIQUID_BANNING_RING_ENERGY_TRANSFER.getValue(), name); } @Override @@ -38,7 +39,7 @@ public class ItemWaterRemovalRing extends ItemEnergy{ EntityPlayer player = (EntityPlayer)entity; ItemStack equipped = player.getHeldItemMainhand(); - int energyUse = 150; + int energyUse = ConfigIntValues.LIQUID_BANNING_RING_ENERGY_USE.getValue(); if(StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse){ //Setting everything to air