mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 03:15:28 +00:00
116 lines
3.4 KiB
Java
116 lines
3.4 KiB
Java
/*******************************************************************************
|
|
* Copyright (c) 2011-2014 SirSengir. All rights reserved. This program and the accompanying materials are made
|
|
* available under the terms of the GNU Lesser Public License v3 which accompanies this distribution, and is available
|
|
* at http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
*
|
|
* Various Contributors including, but not limited to: SirSengir (original work), CovertJaguar, Player, Binnie,
|
|
* MysteriousAges
|
|
******************************************************************************/
|
|
package forestry.farming.logic;
|
|
|
|
import java.util.ArrayDeque;
|
|
import java.util.Collection;
|
|
import java.util.Deque;
|
|
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.init.Items;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.world.World;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import forestry.api.farming.FarmDirection;
|
|
import forestry.api.farming.Farmables;
|
|
import forestry.api.farming.ICrop;
|
|
import forestry.api.farming.IFarmHousing;
|
|
import forestry.api.farming.IFarmable;
|
|
import forestry.core.utils.ItemStackUtil;
|
|
import forestry.core.utils.vect.Vect;
|
|
|
|
public class FarmLogicReeds extends FarmLogic {
|
|
|
|
private final IFarmable[] germlings;
|
|
|
|
public FarmLogicReeds(IFarmHousing housing) {
|
|
super(housing);
|
|
Collection<IFarmable> farmables = Farmables.farmables.get(FarmableReference.Poales.get());
|
|
germlings = farmables.toArray(new IFarmable[farmables.size()]);
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public IIcon getIcon() {
|
|
return Items.reeds.getIconFromDamage(0);
|
|
}
|
|
|
|
@Override
|
|
public String getName() {
|
|
if (isManual) {
|
|
return "Manual Reed Farm";
|
|
} else {
|
|
return "Managed Reed Farm";
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int getFertilizerConsumption() {
|
|
return 10;
|
|
}
|
|
|
|
@Override
|
|
public int getWaterConsumption(float hydrationModifier) {
|
|
return (int) (20 * hydrationModifier);
|
|
}
|
|
|
|
@Override
|
|
public boolean isAcceptedResource(ItemStack itemstack) {
|
|
if (isManual) {
|
|
return false;
|
|
}
|
|
|
|
return ItemStackUtil.equals(Blocks.sand, itemstack) || ItemStackUtil.equals(Blocks.dirt, itemstack);
|
|
}
|
|
|
|
@Override
|
|
public boolean isAcceptedGermling(ItemStack itemstack) {
|
|
if (isManual) {
|
|
return false;
|
|
}
|
|
|
|
return itemstack.getItem() == Items.reeds;
|
|
}
|
|
|
|
@Override
|
|
public boolean isAcceptedWindfall(ItemStack stack) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public Collection<ItemStack> collect() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public boolean cultivate(int x, int y, int z, FarmDirection direction, int extent) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public Collection<ICrop> harvest(int x, int y, int z, FarmDirection direction, int extent) {
|
|
World world = getWorld();
|
|
|
|
Deque<ICrop> crops = new ArrayDeque<>();
|
|
for (int i = 0; i < extent; i++) {
|
|
Vect position = translateWithOffset(x, y + 1, z, direction, i);
|
|
for (IFarmable seed : germlings) {
|
|
ICrop crop = seed.getCropAt(world, position.x, position.y, position.z);
|
|
if (crop != null) {
|
|
crops.push(crop);
|
|
}
|
|
}
|
|
}
|
|
return crops;
|
|
}
|
|
}
|