mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 03:39:09 +00:00
48 lines
1.9 KiB
Java
48 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.greenhouse;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.World;
|
|
|
|
import forestry.api.greenhouse.IGreenhouseHelper;
|
|
import forestry.api.greenhouse.IGreenhouseState;
|
|
import forestry.api.greenhouse.IInternalBlock;
|
|
import forestry.core.multiblock.IMultiblockControllerInternal;
|
|
import forestry.core.multiblock.MultiblockRegistry;
|
|
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
|
import forestry.greenhouse.multiblock.InternalBlockCheck;
|
|
|
|
public class GreenhouseHelper implements IGreenhouseHelper {
|
|
|
|
@Override
|
|
public IGreenhouseState getGreenhouseState(World world, BlockPos pos) {
|
|
if (MultiblockRegistry.getControllersFromWorld(world) != null) {
|
|
for (IMultiblockControllerInternal controllerInternal : MultiblockRegistry.getControllersFromWorld(world)) {
|
|
if (controllerInternal instanceof IGreenhouseControllerInternal) {
|
|
if (controllerInternal.isAssembled()) {
|
|
if (isPositionInGreenhouse((IGreenhouseControllerInternal) controllerInternal, pos)) {
|
|
return ((IGreenhouseControllerInternal) controllerInternal).createState();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private static boolean isPositionInGreenhouse(IGreenhouseControllerInternal controller, BlockPos pos) {
|
|
IInternalBlock checkBlock = new InternalBlockCheck(pos);
|
|
return controller.getInternalBlocks().contains(checkBlock);
|
|
}
|
|
|
|
}
|