Added configuration for Growth and Magnetic Rings

This commit is contained in:
OneEyeMaker 2017-09-22 08:06:15 +03:00
parent b86abff2f5
commit efb642cefe
3 changed files with 27 additions and 14 deletions

View file

@ -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;

View file

@ -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<BlockPos> blocks = new ArrayList<BlockPos>();
@ -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{

View file

@ -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());