Some tweaks to the farm

This commit is contained in:
modmuss50 2015-07-13 21:31:11 +01:00
parent fadba8db41
commit d2b2f34d64
4 changed files with 42 additions and 16 deletions

View file

@ -74,6 +74,7 @@ public class ConfigTechReborn {
public static int baseLesuOutput;
public static int lesuStoragePerBlock;
public static int euPerRF;
public static int farmEu;
// Charge
public static int AdvancedDrillCharge;
public static int LapotronPackCharge;
@ -598,6 +599,12 @@ public class ConfigTechReborn {
4,
StatCollector.translateToLocal("config.techreborn.euPerRF.tooltip"))
.getInt();
farmEu = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.farmeu"),
32,
StatCollector.translateToLocal("config.techreborn.farmeu.tooltip"))
.getInt();
// Teir

View file

@ -4,14 +4,9 @@ import com.mojang.authlib.GameProfile;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.IGrowable;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
@ -19,11 +14,11 @@ import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.world.BlockEvent;
import techreborn.api.farm.IFarmLogicDevice;
import techreborn.config.ConfigTechReborn;
import techreborn.lib.Location;
import techreborn.tiles.TileFarm;
import techreborn.util.ItemUtils;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@ -46,15 +41,17 @@ public class FarmTree implements IFarmLogicDevice {
if (tileFarm.getWorldObj().isRemote) {
return;
}
if (tileFarm.getWorldObj().getTotalWorldTime() % 20 == 0 || tileFarm.inventory.hasChanged) {
calculateFarmLand(tileFarm);
}
if (tileFarm.getWorldObj().getTotalWorldTime() % 10 == 0) {
farmLandTick(tileFarm);
saplinTick(tileFarm);
}
for (int i = 0; i < 5; i++) {
harvestTick(tileFarm);
if(tileFarm.energy.useEnergy(ConfigTechReborn.farmEu)){
if (tileFarm.getWorldObj().getTotalWorldTime() % 20 == 0 || tileFarm.inventory.hasChanged) {
calculateFarmLand(tileFarm);
}
if (tileFarm.getWorldObj().getTotalWorldTime() % 10 == 0) {
farmLandTick(tileFarm);
saplinTick(tileFarm);
}
for (int i = 0; i < 5; i++) {
harvestTick(tileFarm);
}
}
}

View file

@ -1,5 +1,7 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@ -8,31 +10,36 @@ import techreborn.api.farm.IFarmLogicContainer;
import techreborn.api.farm.IFarmLogicDevice;
import techreborn.util.Inventory;
public class TileFarm extends TileMachineBase implements IInventory {
public class TileFarm extends TileMachineBase implements IInventory, IEnergyTile {
public Inventory inventory = new Inventory(14, "TileFarm", 64);
IFarmLogicDevice logicDevice;
public int size = 4;
public BasicSink energy;
public TileFarm() {
energy = new BasicSink(this, 100000, 2);
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
energy.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
super.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound) {
energy.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
super.writeToNBT(tagCompound);
}
@Override
public void updateEntity() {
energy.updateEntity();
if(inventory.hasChanged){
if(inventory.getStackInSlot(0) != null && inventory.getStackInSlot(0).getItem() instanceof IFarmLogicContainer){
IFarmLogicContainer device = (IFarmLogicContainer) inventory.getStackInSlot(0).getItem();
@ -107,4 +114,17 @@ public class TileFarm extends TileMachineBase implements IInventory {
public boolean isItemValidForSlot(int slot, ItemStack stack) {
return inventory.isItemValidForSlot(slot, stack);
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
}

View file

@ -789,6 +789,8 @@ config.techreborn.aveargeEuOutTickTim=Eu out time
config.techreborn.aveargeEuOutTickTime.tooltip=How often in ticks to update the eu out
config.techreborn.euPerRF=Eu per RF
config.techreborn.euPerRF.tooltip=How many eu are in each RF
config.techreborn.farmeu=Farm EU per Tick
config.techreborn.farmeu.tooltip=Amount of eu used per tick by the farm
#ConfigGui
config.techreborn.category.general=General Configs