From efb642cefe3408c7d9ea72de89aaa71edb04f159 Mon Sep 17 00:00:00 2001 From: OneEyeMaker Date: Fri, 22 Sep 2017 08:06:15 +0300 Subject: [PATCH] Added configuration for Growth and Magnetic Rings --- .../mod/config/values/ConfigIntValues.java | 11 +++++++++- .../mod/items/ItemGrowthRing.java | 21 +++++++++++-------- .../mod/items/ItemMagnetRing.java | 9 ++++---- 3 files changed, 27 insertions(+), 14 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 9d6a3c905..4d00641f1 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 @@ -50,7 +50,16 @@ public enum ConfigIntValues{ FILLER_ENERGY_CAPACITY("Handheld Filler: Energy Capacity", ConfigCategories.TOOL_ENERGY_VALUES, 500000, 1000, 1000000000, "Amount of energy Handheld Filler can store"), FILLER_ENERGY_TRANSFER("Handheld Filler: Energy Transfer Rate", ConfigCategories.TOOL_ENERGY_VALUES, 1000, 1, 1000000000, "Amount of energy Handheld Filler can receive per tick"), - FILLER_ENERGY_USE("Handheld Filler: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 1500, 1, 1000000000, "Amount of energy used by Handheld Filler to perform action"); + FILLER_ENERGY_USE("Handheld Filler: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 1500, 1, 1000000000, "Amount of energy used by Handheld Filler to place block"), + + GROWTH_RING_ENERGY_CAPACITY("Growth Ring: Energy Capacity", ConfigCategories.TOOL_ENERGY_VALUES, 1000000, 1000, 1000000000, "Amount of energy Growth Ring can store"), + GROWTH_RING_ENERGY_TRANSFER("Growth Ring: Energy Transfer Rate", ConfigCategories.TOOL_ENERGY_VALUES, 2000, 1, 1000000000, "Amount of energy Growth Ring can receive per tick"), + GROWTH_RING_ENERGY_USE("Growth Ring: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 300, 1, 1000000000, "Amount of energy used by Growth Ring to fertilize crop"), + GROWTH_RING_FERTILIZE_ATTEMPTS("Growth Ring: Fertilize Attempts", ConfigCategories.TOOL_VALUES, 45, 1, 100, "Amount of attempts to fertilize crops; Growth Ring can fertilize up to this number of crops every 30 ticks"), + + MAGNETIC_RING_ENERGY_CAPACITY("Magnetic Ring: Energy Capacity", ConfigCategories.TOOL_ENERGY_VALUES, 200000, 1000, 1000000000, "Amount of energy Magnetic Ring can store"), + MAGNETIC_RING_ENERGY_TRANSFER("Magnetic Ring: Energy Transfer Rate", ConfigCategories.TOOL_ENERGY_VALUES, 1000, 1, 1000000000, "Amount of energy Magnetic Ring can receive per tick"), + MAGNETIC_RING_ENERGY_USE("Magnetic Ring: Energy Use", ConfigCategories.TOOL_ENERGY_VALUES, 50, 1, 1000000000, "Amount of energy used by Magnetic Ring to suck item"); 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..f3e257197 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,10 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.ArrayList; +import java.util.List; + +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; @@ -25,13 +29,10 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; -import java.util.ArrayList; -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(); @@ -67,7 +68,8 @@ public class ItemGrowthRing extends ItemEnergy{ //Fertilizing the Blocks if(!blocks.isEmpty()){ - for(int i = 0; i < 45; i++){ + int fertilizeAttempts = ConfigIntValues.GROWTH_RING_FERTILIZE_ATTEMPTS.getValue(); + for(int i = 0; i < fertilizeAttempts; i++){ if(this.getEnergyStored(stack) >= energyUse){ BlockPos pos = blocks.get(world.rand.nextInt(blocks.size())); @@ -80,10 +82,11 @@ public class ItemGrowthRing extends ItemEnergy{ IBlockState newState = world.getBlockState(pos); if(newState.getBlock().getMetaFromState(newState) != metaBefore){ world.playEvent(2005, pos, 0); - } - if(!player.capabilities.isCreativeMode){ - this.extractEnergyInternal(stack, energyUse, false); + // Extract energy only if crop was fertilized + if(!player.capabilities.isCreativeMode){ + this.extractEnergyInternal(stack, energyUse, false); + } } } else{ 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..378f2ce5c 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,9 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.ArrayList; + +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; @@ -24,12 +27,10 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; -import java.util.ArrayList; - public class ItemMagnetRing extends ItemEnergy{ public ItemMagnetRing(String name){ - super(200000, 1000, name); + super(ConfigIntValues.MAGNETIC_RING_ENERGY_CAPACITY.getValue(), ConfigIntValues.MAGNETIC_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.MAGNETIC_RING_ENERGY_USE.getValue() * StackUtil.getStackSize(item.getItem()); if(this.getEnergyStored(stack) >= energyForItem){ ItemStack oldItem = StackUtil.validateCopy(item.getItem());