mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Compiles for 1.9! Very buggy, some things are missing.
This commit is contained in:
1 parent
5d74c1254b
commit
7bf554b024
135 files changed
+1710
-1919
No files matched your search
@@ -12,6 +12,7 @@ package forestry.farming.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockBush;
|
||||
@@ -49,7 +50,7 @@ public class BlockMushroom extends BlockBush implements IItemModelRegister, IGro
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,81 +1,68 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
import ic2.api.crops.ICropTile;
|
||||
|
||||
public class CropBasicIC2Crop extends Crop {
|
||||
private final TileEntity tileEntity;
|
||||
|
||||
public CropBasicIC2Crop(World world, TileEntity tileEntity, Vect position) {
|
||||
super(world, position);
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCrop(Vect pos) {
|
||||
return canHarvestCrop(this.tileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
return getCropDrops(this.tileEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is an instance of ICropTile.
|
||||
* @param tileEntity tile entity to be checked.
|
||||
* @return true if there is an IC2 crop and false otherwise.
|
||||
*/
|
||||
@Optional.Method(modid = PluginIC2.modId)
|
||||
public static boolean isIC2Crop(TileEntity tileEntity) {
|
||||
if (tileEntity instanceof ICropTile) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an IC2 crop is ready to be harvested.
|
||||
* @param tileEntity tile entity to be checked.
|
||||
* @return true if crop size is optimal for harvest and false otherwise.
|
||||
*/
|
||||
@Optional.Method(modid = PluginIC2.modId)
|
||||
public static boolean canHarvestCrop(TileEntity tileEntity) {
|
||||
if (isIC2Crop(tileEntity)) {
|
||||
ICropTile crop = (ICropTile) tileEntity;
|
||||
if (crop.getCrop() == null) {
|
||||
return false;
|
||||
}
|
||||
if (crop.getCurrentSize() == crop.getCrop().getOptimalHarvestSize(crop)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function takes care of everything related to the harvesting of the
|
||||
* crop meaning it will calculate the drops and also do setSizeAfterHarvest().
|
||||
* @param tileEntity tile entity to be checked.
|
||||
* @return list containing the drops.
|
||||
*/
|
||||
@Optional.Method(modid = PluginIC2.modId)
|
||||
private static List<ItemStack> getCropDrops(TileEntity tileEntity) {
|
||||
if (isIC2Crop(tileEntity)) {
|
||||
ICropTile crop = (ICropTile) tileEntity;
|
||||
return crop.performHarvest();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// TODO: IC2 for 1.9
|
||||
public class CropBasicIC2Crop {//extends Crop {
|
||||
// private final TileEntity tileEntity;
|
||||
//
|
||||
// public CropBasicIC2Crop(World world, TileEntity tileEntity, Vect position) {
|
||||
// super(world, position);
|
||||
// this.tileEntity = tileEntity;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected boolean isCrop(Vect pos) {
|
||||
// return canHarvestCrop(this.tileEntity);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected Collection<ItemStack> harvestBlock(Vect pos) {
|
||||
// return getCropDrops(this.tileEntity);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Check if there is an instance of ICropTile.
|
||||
// * @param tileEntity tile entity to be checked.
|
||||
// * @return true if there is an IC2 crop and false otherwise.
|
||||
// */
|
||||
// @Optional.Method(modid = PluginIC2.modId)
|
||||
// public static boolean isIC2Crop(TileEntity tileEntity) {
|
||||
// if (tileEntity instanceof ICropTile) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Check if an IC2 crop is ready to be harvested.
|
||||
// * @param tileEntity tile entity to be checked.
|
||||
// * @return true if crop size is optimal for harvest and false otherwise.
|
||||
// */
|
||||
// @Optional.Method(modid = PluginIC2.modId)
|
||||
// public static boolean canHarvestCrop(TileEntity tileEntity) {
|
||||
// if (isIC2Crop(tileEntity)) {
|
||||
// ICropTile crop = (ICropTile) tileEntity;
|
||||
// if (crop.getCrop() == null) {
|
||||
// return false;
|
||||
// }
|
||||
// if (crop.getCurrentSize() == crop.getCrop().getOptimalHarvestSize(crop)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * This function takes care of everything related to the harvesting of the
|
||||
// * crop meaning it will calculate the drops and also do setSizeAfterHarvest().
|
||||
// * @param tileEntity tile entity to be checked.
|
||||
// * @return list containing the drops.
|
||||
// */
|
||||
// @Optional.Method(modid = PluginIC2.modId)
|
||||
// private static List<ItemStack> getCropDrops(TileEntity tileEntity) {
|
||||
// if (isIC2Crop(tileEntity)) {
|
||||
// ICropTile crop = (ICropTile) tileEntity;
|
||||
// return crop.performHarvest();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
@@ -13,6 +13,7 @@ package forestry.farming.logic;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -79,7 +80,8 @@ public abstract class FarmLogicCrops extends FarmLogicWatered {
|
||||
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(pos, direction, i);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getWorld(), position)) {
|
||||
IBlockState state = world.getBlockState(position);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(state, world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.farming.logic;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -89,7 +90,8 @@ public class FarmLogicEnder extends FarmLogicHomogeneous {
|
||||
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(pos, direction, i);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(world, position)) {
|
||||
IBlockState state = world.getBlockState(position);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(state, world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.farming.logic;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -89,7 +90,8 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
|
||||
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(pos, direction, i);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(world, position)) {
|
||||
IBlockState blockState = world.getBlockState(position);
|
||||
if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(blockState, world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,82 +1,68 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
// TODO: IC2 for 1.9
|
||||
public class FarmableBasicIC2Crop {//implements IFarmable {
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.compat.PluginIC2;
|
||||
|
||||
import ic2.api.crops.ICropTile;
|
||||
|
||||
public class FarmableBasicIC2Crop implements IFarmable {
|
||||
|
||||
/**
|
||||
* Perform some of the actions of the crop-matron.
|
||||
*/
|
||||
@Optional.Method(modid = PluginIC2.modId)
|
||||
public static void babysitCrop(TileEntity tileEntity) {
|
||||
if (CropBasicIC2Crop.isIC2Crop(tileEntity)) {
|
||||
ICropTile crop = (ICropTile) tileEntity;
|
||||
/*
|
||||
This part might be unbalanced until a custom farm logic is added and makes use of weed-ex.
|
||||
if (crop.getCrop() != null) {
|
||||
if (crop.getCrop().isWeed(crop)) {
|
||||
crop.reset();
|
||||
}
|
||||
}*/
|
||||
if (crop.getStorageWater() <= 200) {
|
||||
crop.setStorageWater(200);
|
||||
}
|
||||
if (crop.getStorageNutrient() <= 100) {
|
||||
crop.setStorageNutrient(crop.getStorageNutrient() + 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
TileEntity crop = world.getTileEntity(pos);
|
||||
if (CropBasicIC2Crop.isIC2Crop(crop)) {
|
||||
babysitCrop(crop);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICrop getCropAt(World world, BlockPos pos) {
|
||||
TileEntity crop = world.getTileEntity(pos);
|
||||
if (crop == null) {
|
||||
return null;
|
||||
}
|
||||
if (!CropBasicIC2Crop.isIC2Crop(crop)) {
|
||||
return null;
|
||||
}
|
||||
if (!CropBasicIC2Crop.canHarvestCrop(crop)) {
|
||||
return null;
|
||||
}
|
||||
return new CropBasicIC2Crop(world, crop, new Vect(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindfall(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
// /**
|
||||
// * Perform some of the actions of the crop-matron.
|
||||
// */
|
||||
// @Optional.Method(modid = PluginIC2.modId)
|
||||
// public static void babysitCrop(TileEntity tileEntity) {
|
||||
// if (CropBasicIC2Crop.isIC2Crop(tileEntity)) {
|
||||
// ICropTile crop = (ICropTile) tileEntity;
|
||||
// /*
|
||||
// This part might be unbalanced until a custom farm logic is added and makes use of weed-ex.
|
||||
// if (crop.getCrop() != null) {
|
||||
// if (crop.getCrop().isWeed(crop)) {
|
||||
// crop.reset();
|
||||
// }
|
||||
// }*/
|
||||
// if (crop.getStorageWater() <= 200) {
|
||||
// crop.setStorageWater(200);
|
||||
// }
|
||||
// if (crop.getStorageNutrient() <= 100) {
|
||||
// crop.setStorageNutrient(crop.getStorageNutrient() + 100);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
// TileEntity crop = world.getTileEntity(pos);
|
||||
// if (CropBasicIC2Crop.isIC2Crop(crop)) {
|
||||
// babysitCrop(crop);
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ICrop getCropAt(World world, BlockPos pos) {
|
||||
// TileEntity crop = world.getTileEntity(pos);
|
||||
// if (crop == null) {
|
||||
// return null;
|
||||
// }
|
||||
// if (!CropBasicIC2Crop.isIC2Crop(crop)) {
|
||||
// return null;
|
||||
// }
|
||||
// if (!CropBasicIC2Crop.canHarvestCrop(crop)) {
|
||||
// return null;
|
||||
// }
|
||||
// return new CropBasicIC2Crop(world, crop, new Vect(pos));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isGermling(ItemStack itemstack) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isWindfall(ItemStack itemstack) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
@@ -13,6 +13,8 @@ package forestry.farming.logic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
@@ -51,7 +53,7 @@ public class FarmableGE implements IFarmable {
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0);
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,8 @@ package forestry.farming.logic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
@@ -68,7 +70,7 @@ public class FarmableGenericCrop implements IFarmable {
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0);
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,8 @@ package forestry.farming.logic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
@@ -90,7 +92,7 @@ public class FarmableGenericSapling implements IFarmable {
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0);
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class FarmableVanillaMushroom extends FarmableGenericSapling {
|
||||
public ICrop getCropAt(World world, BlockPos pos) {
|
||||
Block block = BlockUtil.getBlock(world, pos);
|
||||
|
||||
if (block != Blocks.BROWN_MUSHROOM_block && block != Blocks.RED_MUSHROOM_block) {
|
||||
if (block != Blocks.BROWN_MUSHROOM_BLOCK && block != Blocks.RED_MUSHROOM_BLOCK) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
@@ -41,7 +43,7 @@ public class FarmableVanillaSapling extends FarmableGenericSapling {
|
||||
|
||||
return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), pos);
|
||||
} else {
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0);
|
||||
return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,29 +10,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.tiles;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
import forestry.api.multiblock.IFarmComponent;
|
||||
import forestry.core.inventory.AdjacentInventoryCache;
|
||||
import forestry.core.tiles.AdjacentTileCache;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.triggers.FarmingTriggers;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
import buildcraft.api.statements.ITriggerInternal;
|
||||
import buildcraft.api.statements.ITriggerProvider;
|
||||
|
||||
@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmComponent.Active, ITriggerProvider {
|
||||
// TODO: Buildcraft for 1.9
|
||||
//@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmComponent.Active {
|
||||
|
||||
private static final EnumFacing[] dumpDirections = new EnumFacing[]{EnumFacing.DOWN};
|
||||
|
||||
@@ -70,21 +60,22 @@ public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmCom
|
||||
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
if (!getMultiblockLogic().isConnected()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return FarmingTriggers.allExternalTriggers;
|
||||
}
|
||||
// TODO: Buildcraft for 1.9
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
//
|
||||
// /* ITRIGGERPROVIDER */
|
||||
// @Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
// @Override
|
||||
// public Collection<ITriggerExternal> getExternalTriggers(EnumFacing side, TileEntity tile) {
|
||||
// if (!getMultiblockLogic().isConnected()) {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
//
|
||||
// return FarmingTriggers.allExternalTriggers;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -10,36 +10,30 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.triggers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.core.triggers.Trigger;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class FarmingTriggers {
|
||||
public static Trigger lowResourceLiquid50;
|
||||
public static Trigger lowResourceLiquid25;
|
||||
public static Trigger lowSoil128;
|
||||
public static Trigger lowSoil64;
|
||||
public static Trigger lowSoil32;
|
||||
public static Trigger lowFertilizer50;
|
||||
public static Trigger lowFertilizer25;
|
||||
public static Trigger lowGermlings25;
|
||||
public static Trigger lowGermlings10;
|
||||
public static List<ITriggerExternal> allExternalTriggers;
|
||||
// public static Trigger lowResourceLiquid50;
|
||||
// public static Trigger lowResourceLiquid25;
|
||||
// public static Trigger lowSoil128;
|
||||
// public static Trigger lowSoil64;
|
||||
// public static Trigger lowSoil32;
|
||||
// public static Trigger lowFertilizer50;
|
||||
// public static Trigger lowFertilizer25;
|
||||
// public static Trigger lowGermlings25;
|
||||
// public static Trigger lowGermlings10;
|
||||
// public static List<ITriggerExternal> allExternalTriggers;
|
||||
|
||||
public static void initialize() {
|
||||
allExternalTriggers = Arrays.asList(
|
||||
lowResourceLiquid50 = new TriggerLowLiquid("lowLiquid.50", 0.5f),
|
||||
lowResourceLiquid25 = new TriggerLowLiquid("lowLiquid.25", 0.25f),
|
||||
lowSoil128 = new TriggerLowSoil(128),
|
||||
lowSoil64 = new TriggerLowSoil(64),
|
||||
lowSoil32 = new TriggerLowSoil(32),
|
||||
lowFertilizer50 = new TriggerLowFertilizer("lowFertilizer.50", 0.5f),
|
||||
lowFertilizer25 = new TriggerLowFertilizer("lowFertilizer.25", 0.25f),
|
||||
lowGermlings25 = new TriggerLowGermlings("lowGermlings.25", 0.25f),
|
||||
lowGermlings10 = new TriggerLowGermlings("lowGermlings.10", 0.1f)
|
||||
);
|
||||
// allExternalTriggers = Arrays.asList(
|
||||
// lowResourceLiquid50 = new TriggerLowLiquid("lowLiquid.50", 0.5f),
|
||||
// lowResourceLiquid25 = new TriggerLowLiquid("lowLiquid.25", 0.25f),
|
||||
// lowSoil128 = new TriggerLowSoil(128),
|
||||
// lowSoil64 = new TriggerLowSoil(64),
|
||||
// lowSoil32 = new TriggerLowSoil(32),
|
||||
// lowFertilizer50 = new TriggerLowFertilizer("lowFertilizer.50", 0.5f),
|
||||
// lowFertilizer25 = new TriggerLowFertilizer("lowFertilizer.25", 0.25f),
|
||||
// lowGermlings25 = new TriggerLowGermlings("lowGermlings.25", 0.25f),
|
||||
// lowGermlings10 = new TriggerLowGermlings("lowGermlings.10", 0.1f)
|
||||
// );
|
||||
}
|
||||
}
|
||||
@@ -10,39 +10,29 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.triggers;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class TriggerLowFertilizer {//} extends Trigger {
|
||||
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
public class TriggerLowFertilizer extends Trigger {
|
||||
|
||||
private final float threshold;
|
||||
|
||||
public TriggerLowFertilizer(String tag, float threshold) {
|
||||
super(tag, "lowFertilizer");
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
IInventory fertilizerInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getFertilizerInventory();
|
||||
return InventoryUtil.containsPercent(fertilizerInventory, threshold);
|
||||
}
|
||||
// private final float threshold;
|
||||
//
|
||||
// public TriggerLowFertilizer(String tag, float threshold) {
|
||||
// super(tag, "lowFertilizer");
|
||||
// this.threshold = threshold;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
// if (!(tile instanceof TileFarmHatch)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
// IInventory fertilizerInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getFertilizerInventory();
|
||||
// return InventoryUtil.containsPercent(fertilizerInventory, threshold);
|
||||
// }
|
||||
}
|
||||
@@ -10,42 +10,34 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.triggers;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class TriggerLowGermlings extends Trigger {
|
||||
|
||||
private final float threshold;
|
||||
|
||||
public TriggerLowGermlings(String tag, float threshold) {
|
||||
super(tag, "lowGermlings");
|
||||
// super(tag, "lowGermlings");
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
IInventory germlingsInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getGermlingsInventory();
|
||||
return InventoryUtil.containsPercent(germlingsInventory, threshold);
|
||||
}
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Return true if the tile given in parameter activates the trigger, given the parameters.
|
||||
// */
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
// if (!(tile instanceof TileFarmHatch)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
// IInventory germlingsInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getGermlingsInventory();
|
||||
// return InventoryUtil.containsPercent(germlingsInventory, threshold);
|
||||
// }
|
||||
}
|
||||
@@ -10,49 +10,40 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.triggers;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class TriggerLowLiquid extends Trigger {
|
||||
|
||||
private final float threshold;
|
||||
|
||||
public TriggerLowLiquid(String tag, float threshold) {
|
||||
super(tag, "lowLiquid");
|
||||
// super(tag, "lowLiquid");
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given
|
||||
* the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
ITankManager tankManager = tileHatch.getMultiblockLogic().getController().getTankManager();
|
||||
|
||||
IFluidTank tank = tankManager.getTank(0);
|
||||
if (tank.getCapacity() == 0) {
|
||||
return false;
|
||||
}
|
||||
return (float) tank.getFluidAmount() / tank.getCapacity() <= threshold;
|
||||
}
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return super.getDescription() + " < " + threshold * 100 + "%";
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Return true if the tile given in parameter activates the trigger, given
|
||||
// * the parameters.
|
||||
// */
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
// if (!(tile instanceof TileFarmHatch)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
// ITankManager tankManager = tileHatch.getMultiblockLogic().getController().getTankManager();
|
||||
//
|
||||
// IFluidTank tank = tankManager.getTank(0);
|
||||
// if (tank.getCapacity() == 0) {
|
||||
// return false;
|
||||
// }
|
||||
// return (float) tank.getFluidAmount() / tank.getCapacity() <= threshold;
|
||||
// }
|
||||
}
|
||||
@@ -10,65 +10,54 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.triggers;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.api.farming.IFarmInventory;
|
||||
import forestry.api.multiblock.IFarmController;
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
|
||||
// TODO: Buildcraft for 1.9
|
||||
public class TriggerLowSoil extends Trigger {
|
||||
|
||||
private final int threshold;
|
||||
|
||||
public TriggerLowSoil(int threshold) {
|
||||
super("lowSoil." + threshold, "lowSoil");
|
||||
// super("lowSoil." + threshold, "lowSoil");
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return super.getDescription() + " < " + threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxParameters() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the tile given in parameter activates the trigger, given
|
||||
* the parameters.
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
IStatementParameter parameter = null;
|
||||
if (parameters.length > 0) {
|
||||
parameter = parameters[0];
|
||||
}
|
||||
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
IFarmController farmController = tileHatch.getMultiblockLogic().getController();
|
||||
IFarmInventory farmInventory = farmController.getFarmInventory();
|
||||
|
||||
if (parameter == null || parameter.getItemStack() == null) {
|
||||
IInventory resourcesInventory = farmInventory.getResourcesInventory();
|
||||
return InventoryUtil.containsPercent(resourcesInventory, threshold);
|
||||
} else {
|
||||
ItemStack filter = parameter.getItemStack().copy();
|
||||
filter.stackSize = threshold;
|
||||
return farmInventory.hasResources(new ItemStack[]{filter});
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// public String getDescription() {
|
||||
// return super.getDescription() + " < " + threshold;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int maxParameters() {
|
||||
// return 1;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Return true if the tile given in parameter activates the trigger, given
|
||||
// * the parameters.
|
||||
// */
|
||||
// @Override
|
||||
// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
// IStatementParameter parameter = null;
|
||||
// if (parameters.length > 0) {
|
||||
// parameter = parameters[0];
|
||||
// }
|
||||
//
|
||||
// if (!(tile instanceof TileFarmHatch)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
// IFarmController farmController = tileHatch.getMultiblockLogic().getController();
|
||||
// IFarmInventory farmInventory = farmController.getFarmInventory();
|
||||
//
|
||||
// if (parameter == null || parameter.getItemStack() == null) {
|
||||
// IInventory resourcesInventory = farmInventory.getResourcesInventory();
|
||||
// return InventoryUtil.containsPercent(resourcesInventory, threshold);
|
||||
// } else {
|
||||
// ItemStack filter = parameter.getItemStack().copy();
|
||||
// filter.stackSize = threshold;
|
||||
// return farmInventory.hasResources(new ItemStack[]{filter});
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Reference in new issue
Block a user