mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 17:44:55 +00:00
56 lines
1.9 KiB
Java
56 lines
1.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 forestry.farming.blocks.BlockFarm;
|
|
import net.minecraft.block.state.IBlockState;
|
|
import net.minecraft.util.EnumFacing;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.World;
|
|
|
|
import forestry.api.farming.DefaultFarmListener;
|
|
import forestry.api.farming.FarmDirection;
|
|
import forestry.api.farming.IFarmListener;
|
|
import forestry.api.farming.IFarmLogic;
|
|
import forestry.api.multiblock.IFarmComponent;
|
|
|
|
public class TileFarmControl extends TileFarm implements IFarmComponent.Listener {
|
|
|
|
private final IFarmListener farmListener;
|
|
|
|
public TileFarmControl() {
|
|
this.farmListener = new ControlFarmListener(this);
|
|
}
|
|
|
|
@Override
|
|
public IFarmListener getFarmListener() {
|
|
return farmListener;
|
|
}
|
|
|
|
private static class ControlFarmListener extends DefaultFarmListener {
|
|
private final TileFarmControl tile;
|
|
|
|
public ControlFarmListener(TileFarmControl tile) {
|
|
this.tile = tile;
|
|
}
|
|
|
|
@Override
|
|
public boolean cancelTask(IFarmLogic logic, FarmDirection direction) {
|
|
BlockPos pos = tile.getPos();
|
|
EnumFacing facing = direction.getFacing();
|
|
World world = tile.getWorldObj();
|
|
IBlockState blockState = world.getBlockState(pos.offset(facing));
|
|
return !(blockState.getBlock() instanceof BlockFarm) && world.getRedstonePower(pos, facing) > 0;
|
|
}
|
|
}
|
|
|
|
}
|