mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-25 06:14:46 +00:00
86 lines
2.9 KiB
Java
86 lines
2.9 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.tiles;
|
|
|
|
import net.minecraft.inventory.IInventory;
|
|
import net.minecraft.inventory.ISidedInventory;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
import net.minecraftforge.items.IItemHandler;
|
|
import net.minecraftforge.items.wrapper.InvWrapper;
|
|
|
|
import forestry.api.multiblock.IFarmComponent;
|
|
import forestry.core.inventory.AdjacentInventoryCache;
|
|
import forestry.core.tiles.AdjacentTileCache;
|
|
import forestry.core.utils.InventoryUtil;
|
|
|
|
// 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};
|
|
|
|
private final AdjacentTileCache tileCache;
|
|
private final AdjacentInventoryCache inventoryCache;
|
|
|
|
public TileFarmHatch() {
|
|
this.tileCache = new AdjacentTileCache(this);
|
|
this.inventoryCache = new AdjacentInventoryCache(this, tileCache, new AdjacentInventoryCache.ITileFilter() {
|
|
@Override
|
|
public boolean matches(TileEntity tile) {
|
|
return !(tile instanceof TileFarm) && tile.getPos().getY() < getPos().getY();
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
public boolean allowsAutomation() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void updateServer(int tickCount) {
|
|
if (tickCount % 40 == 0) {
|
|
IInventory productInventory = getMultiblockLogic().getController().getFarmInventory().getProductInventory();
|
|
IItemHandler productItemHandler = new InvWrapper(productInventory);
|
|
|
|
if (!InventoryUtil.moveOneItemToPipe(productItemHandler, tileCache, dumpDirections)) {
|
|
InventoryUtil.moveItemStack(productItemHandler, inventoryCache.getAdjacentInventories());
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void updateClient(int tickCount) {
|
|
|
|
}
|
|
|
|
// 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;
|
|
// }
|
|
|
|
}
|