mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-22 04:52:26 +00:00
Remove Unused Files
This commit is contained in:
1 parent
cc50a05f43
commit
521514f3d2
7 files changed
+177
-231
No files matched your search
@@ -1,29 +0,0 @@
|
||||
package forestry.api.cultivation;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.farming.IFarmInventory;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.api.genetics.IHousing;
|
||||
|
||||
public interface IPlanterHousing extends IHousing {
|
||||
/**
|
||||
* Callback for {@link IFarmLogic}s to plant a sapling, seed, germling, stem.
|
||||
* Will remove the appropriate germling from the farm's inventory.
|
||||
* It's up to the logic to only call this on a valid location.
|
||||
*
|
||||
* @return true if planting was successful, false otherwise.
|
||||
*/
|
||||
boolean plantGermling(IFarmable germling, World world, BlockPos pos);
|
||||
|
||||
/* INTERACTION WITH HATCHES */
|
||||
IFarmInventory getFarmInventory();
|
||||
|
||||
/* LOGIC */
|
||||
IFarmLogic getFarmLogic();
|
||||
|
||||
/* GUI */
|
||||
int getStoredFertilizerScaled(int scale);
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.cultivation.IPlanterHousing;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.api.farming.IFarmable;
|
||||
@@ -21,9 +20,9 @@ import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.inventory.InventoryAdapterRestricted;
|
||||
import forestry.core.inventory.wrappers.InventoryMapper;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
import forestry.cultivation.tiles.TilePlanter;
|
||||
import forestry.farming.multiblock.IFarmInventoryInternal;
|
||||
|
||||
public class InventoryPlanter extends InventoryAdapterRestricted implements IFarmInventoryInternal {
|
||||
@@ -43,14 +42,14 @@ public class InventoryPlanter extends InventoryAdapterRestricted implements IFar
|
||||
|
||||
private static final int FERTILIZER_MODIFIER = ForestryAPI.activeMode.getIntegerSetting("farms.fertilizer.modifier");
|
||||
|
||||
private final IPlanterHousing housing;
|
||||
private final TilePlanter housing;
|
||||
|
||||
private final IInventory resourcesInventory;
|
||||
private final IInventory germlingsInventory;
|
||||
private final IInventory productInventory;
|
||||
private final IInventory fertilizerInventory;
|
||||
|
||||
public InventoryPlanter(IPlanterHousing housing) {
|
||||
public InventoryPlanter(TilePlanter housing) {
|
||||
super(SLOT_COUNT, "Items");
|
||||
this.housing = housing;
|
||||
|
||||
@@ -70,7 +69,7 @@ public class InventoryPlanter extends InventoryAdapterRestricted implements IFar
|
||||
return acceptsAsResource(itemStack);
|
||||
} else if (SlotUtil.isSlotInRange(slotIndex, SLOT_CAN, SLOT_CAN_COUNT)) {
|
||||
FluidStack fluid = FluidUtil.getFluidContained(itemStack);
|
||||
return fluid != null && ((ILiquidTankTile) housing).getTankManager().canFillFluidType(fluid);
|
||||
return fluid != null && housing.getTankManager().canFillFluidType(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package forestry.cultivation.items;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import forestry.core.utils.FieldsAreNonnullByDefault;
|
||||
@@ -1,10 +0,0 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package forestry.cultivation.network;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import forestry.core.utils.FieldsAreNonnullByDefault;
|
||||
@@ -6,7 +6,6 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -28,7 +27,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.cultivation.IPlanterHousing;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
@@ -64,28 +62,28 @@ import forestry.farming.gui.IFarmLedgerDelegate;
|
||||
import forestry.farming.multiblock.FarmFertilizerManager;
|
||||
import forestry.farming.multiblock.FarmHydrationManager;
|
||||
|
||||
public abstract class TilePlanter extends TilePowered implements IFarmHousing, IPlanterHousing, IClimatised, ILiquidTankTile, IOwnedTile, IStreamableGui {
|
||||
public abstract class TilePlanter extends TilePowered implements IFarmHousing, IClimatised, ILiquidTankTile, IOwnedTile, IStreamableGui {
|
||||
|
||||
private final static int ALLOWED_EXTENT = 4;
|
||||
|
||||
private int platformHeight = -1;
|
||||
private final Map<FarmDirection, List<FarmTarget>> targets = new EnumMap<>(FarmDirection.class);
|
||||
private final Stack<ItemStack> pendingProduce = new Stack<>();
|
||||
private final List<ICrop> pendingCrops = new LinkedList<>();
|
||||
private final IFarmLogic logic;
|
||||
|
||||
private final FarmHydrationManager hydrationManager;
|
||||
private final FarmFertilizerManager fertilizerManager;
|
||||
private final InventoryPlanter inventory;
|
||||
private final TankManager tankManager;
|
||||
private final StandardTank resourceTank;
|
||||
private final OwnerHandler ownerHandler = new OwnerHandler();
|
||||
|
||||
private int platformHeight = -1;
|
||||
private Stage stage = Stage.CULTIVATE;
|
||||
@Nullable
|
||||
private Vec3i offset;
|
||||
@Nullable
|
||||
private Vec3i area;
|
||||
@Nullable
|
||||
public Iterator<BlockPos.MutableBlockPos> areaIterator;
|
||||
|
||||
public TilePlanter(String identifier) {
|
||||
this(FarmRegistry.getInstance().getFarmLogic(identifier));
|
||||
@@ -105,53 +103,6 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I
|
||||
setTicksPerWorkCycle(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound data) {
|
||||
data = super.writeToNBT(data);
|
||||
hydrationManager.writeToNBT(data);
|
||||
tankManager.writeToNBT(data);
|
||||
fertilizerManager.writeToNBT(data);
|
||||
ownerHandler.writeToNBT(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
hydrationManager.readFromNBT(data);
|
||||
tankManager.readFromNBT(data);
|
||||
fertilizerManager.readFromNBT(data);
|
||||
ownerHandler.readFromNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag() {
|
||||
NBTTagCompound data = super.getUpdateTag();
|
||||
hydrationManager.writeToNBT(data);
|
||||
tankManager.writeToNBT(data);
|
||||
fertilizerManager.writeToNBT(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(PacketBufferForestry data) {
|
||||
tankManager.writeData(data);
|
||||
hydrationManager.writeData(data);
|
||||
fertilizerManager.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(PacketBufferForestry data) throws IOException {
|
||||
tankManager.readData(data);
|
||||
hydrationManager.readData(data);
|
||||
fertilizerManager.readData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOwnerHandler getOwnerHandler() {
|
||||
return ownerHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPos(BlockPos posIn) {
|
||||
super.setPos(posIn);
|
||||
@@ -163,12 +114,6 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
targets.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
@@ -251,8 +196,90 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I
|
||||
return false;
|
||||
}
|
||||
|
||||
protected final BlockPos translateWithOffset(BlockPos pos, FarmDirection farmDirection, int step) {
|
||||
return VectUtil.scale(farmDirection.getFacing().getDirectionVec(), step).add(pos);
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound data) {
|
||||
data = super.writeToNBT(data);
|
||||
hydrationManager.writeToNBT(data);
|
||||
tankManager.writeToNBT(data);
|
||||
fertilizerManager.writeToNBT(data);
|
||||
ownerHandler.writeToNBT(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
hydrationManager.readFromNBT(data);
|
||||
tankManager.readFromNBT(data);
|
||||
fertilizerManager.readFromNBT(data);
|
||||
ownerHandler.readFromNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(PacketBufferForestry data) {
|
||||
tankManager.writeData(data);
|
||||
hydrationManager.writeData(data);
|
||||
fertilizerManager.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(PacketBufferForestry data) throws IOException {
|
||||
tankManager.readData(data);
|
||||
hydrationManager.readData(data);
|
||||
fertilizerManager.readData(data);
|
||||
}
|
||||
|
||||
private void setUpFarmlandTargets() {
|
||||
BlockPos targetStart = getCoords();
|
||||
|
||||
FarmHelper.createTargets(world, this, targets, targetStart, ALLOWED_EXTENT, 1, 1, pos, pos);
|
||||
FarmHelper.setExtents(world, this, targets);
|
||||
}
|
||||
|
||||
private boolean cullCrop(ICrop crop) {
|
||||
final int fertilizerConsumption = logic.getFertilizerConsumption();
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
// Check fertilizer
|
||||
Boolean hasFertilizer = fertilizerManager.hasFertilizer(inventory, fertilizerConsumption);
|
||||
if (errorLogic.setCondition(!hasFertilizer, EnumErrorCode.NO_FERTILIZER)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check water
|
||||
float hydrationModifier = hydrationManager.getHydrationModifier();
|
||||
int waterConsumption = logic.getWaterConsumption(hydrationModifier);
|
||||
FluidStack requiredLiquid = new FluidStack(FluidRegistry.WATER, waterConsumption);
|
||||
boolean hasLiquid = requiredLiquid.amount == 0 || hasLiquid(requiredLiquid);
|
||||
|
||||
if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NO_LIQUID_FARM)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NonNullList<ItemStack> harvested = crop.harvest();
|
||||
if (harvested != null) {
|
||||
// Remove fertilizer and water
|
||||
fertilizerManager.removeFertilizer(inventory, fertilizerConsumption);
|
||||
removeLiquid(requiredLiquid);
|
||||
|
||||
inventory.stowHarvest(harvested, pendingProduce);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean collectWindfall() {
|
||||
NonNullList<ItemStack> collected = logic.collect(world, this);
|
||||
if (collected.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ItemStack produce : collected) {
|
||||
inventory.addProduce(produce);
|
||||
pendingProduce.push(produce);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private FarmWorkStatus cultivateTargets(FarmWorkStatus farmWorkStatus, List<FarmTarget> farmTargets, FarmDirection farmSide) {
|
||||
@@ -296,100 +323,19 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I
|
||||
return farmWorkStatus;
|
||||
}
|
||||
|
||||
private boolean collectWindfall() {
|
||||
NonNullList<ItemStack> collected = logic.collect(world, this);
|
||||
if (collected.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ItemStack produce : collected) {
|
||||
inventory.addProduce(produce);
|
||||
pendingProduce.push(produce);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean cullCrop(ICrop crop) {
|
||||
final int fertilizerConsumption = logic.getFertilizerConsumption();
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
// Check fertilizer
|
||||
Boolean hasFertilizer = fertilizerManager.hasFertilizer(inventory, fertilizerConsumption);
|
||||
if (errorLogic.setCondition(!hasFertilizer, EnumErrorCode.NO_FERTILIZER)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check water
|
||||
float hydrationModifier = hydrationManager.getHydrationModifier();
|
||||
int waterConsumption = logic.getWaterConsumption(hydrationModifier);
|
||||
FluidStack requiredLiquid = new FluidStack(FluidRegistry.WATER, waterConsumption);
|
||||
boolean hasLiquid = requiredLiquid.amount == 0 || hasLiquid(requiredLiquid);
|
||||
|
||||
if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NO_LIQUID_FARM)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NonNullList<ItemStack> harvested = crop.harvest();
|
||||
if (harvested != null) {
|
||||
// Remove fertilizer and water
|
||||
fertilizerManager.removeFertilizer(inventory, fertilizerConsumption);
|
||||
removeLiquid(requiredLiquid);
|
||||
|
||||
inventory.stowHarvest(harvested, pendingProduce);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredFertilizerScaled(int scale) {
|
||||
return fertilizerManager.getStoredFertilizerScaled(inventory, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLiquid(FluidStack liquid) {
|
||||
FluidStack drained = resourceTank.drainInternal(liquid, false);
|
||||
return liquid.isFluidStackIdentical(drained);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiContainer getGui(EntityPlayer player, int data) {
|
||||
return new GuiPlanter(this, player.inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerPlanter(this, player.inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantGermling(IFarmable germling, World world, BlockPos pos) {
|
||||
EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner());
|
||||
return player != null && inventory.plantGermling(germling, player, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantGermling(IFarmable farmable, World world, BlockPos pos, FarmDirection direction) {
|
||||
EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner());
|
||||
return player != null && inventory.plantGermling(farmable, player, pos, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFarmInventory getFarmInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFarmLogic getFarmLogic() {
|
||||
return logic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCoords() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3i getArea() {
|
||||
if (area == null) {
|
||||
area = new Vec3i(7 + ALLOWED_EXTENT * 2, 13, 7 + ALLOWED_EXTENT * 2);
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3i getOffset() {
|
||||
if (offset == null) {
|
||||
@@ -399,25 +345,54 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I
|
||||
return offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3i getArea() {
|
||||
if (area == null) {
|
||||
area = new Vec3i(7 + ALLOWED_EXTENT * 2, 13, 7 + ALLOWED_EXTENT * 2);
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doWork() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLiquid(FluidStack liquid) {
|
||||
FluidStack drained = resourceTank.drainInternal(liquid, false);
|
||||
return liquid.isFluidStackIdentical(drained);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLiquid(FluidStack liquid) {
|
||||
resourceTank.drain(liquid.amount, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantGermling(IFarmable germling, World world, BlockPos pos) {
|
||||
EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner());
|
||||
return player != null && inventory.plantGermling(germling, player, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOwnerHandler getOwnerHandler() {
|
||||
return ownerHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantGermling(IFarmable farmable, World world, BlockPos pos, FarmDirection direction) {
|
||||
EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner());
|
||||
return player != null && inventory.plantGermling(farmable, player, pos, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPlatform(World world, BlockPos pos) {
|
||||
return pos.getY() == platformHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSquare() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFarmInventory getFarmInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFarmLogic(FarmDirection direction, IFarmLogic logic) {
|
||||
}
|
||||
@@ -431,6 +406,44 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I
|
||||
return getFarmLogic();
|
||||
}
|
||||
|
||||
public IFarmLogic getFarmLogic() {
|
||||
return logic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredFertilizerScaled(int scale) {
|
||||
return fertilizerManager.getStoredFertilizerScaled(inventory, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
targets.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getUpdateTag() {
|
||||
NBTTagCompound data = super.getUpdateTag();
|
||||
hydrationManager.writeToNBT(data);
|
||||
tankManager.writeToNBT(data);
|
||||
fertilizerManager.writeToNBT(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
protected final BlockPos translateWithOffset(BlockPos pos, FarmDirection farmDirection, int step) {
|
||||
return VectUtil.scale(farmDirection.getFacing().getDirectionVec(), step).add(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiContainer getGui(EntityPlayer player, int data) {
|
||||
return new GuiPlanter(this, player.inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerPlanter(this, player.inventory);
|
||||
}
|
||||
|
||||
public IFarmLedgerDelegate getFarmLedgerDelegate() {
|
||||
return hydrationManager;
|
||||
}
|
||||
@@ -462,27 +475,10 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPlatform(World world, BlockPos pos) {
|
||||
return pos.getY() == platformHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSquare() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setUpFarmlandTargets() {
|
||||
BlockPos targetStart = getCoords();
|
||||
|
||||
FarmHelper.createTargets(world, this, targets, targetStart, ALLOWED_EXTENT, 1, 1, pos, pos);
|
||||
FarmHelper.setExtents(world, this, targets);
|
||||
}
|
||||
|
||||
public abstract ItemStack[] createGermlingStacks();
|
||||
|
||||
public abstract ItemStack[] createResourceStacks();
|
||||
|
||||
public abstract ItemStack[] createProductionStacks();
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user