use of forestry.api.multiblock.IMultiblockController in project ForestryMC by ForestryMC.
the class BlockGreenhouse method getCamouflageBlock.
@Override
public ItemStack getCamouflageBlock(IBlockAccess world, BlockPos pos) {
if (world == null || pos == null) {
return ItemStack.EMPTY;
}
TileEntity tile = TileUtil.getTile(world, pos, TileEntity.class);
if (tile instanceof ICamouflagedTile) {
ICamouflagedTile block = (ICamouflagedTile) tile;
ItemStack camouflageStack = ItemStack.EMPTY;
if (tile instanceof ICamouflageHandler) {
ICamouflageHandler tileHandler = (ICamouflageHandler) tile;
ItemStack tileCamouflageStack = tileHandler.getCamouflageBlock();
ItemStack defaultCamouflageStack = tileHandler.getDefaultCamouflageBlock();
if (!ItemStackUtil.isIdenticalItem(tileCamouflageStack, defaultCamouflageStack)) {
camouflageStack = tileCamouflageStack;
}
}
if (camouflageStack.isEmpty() && tile instanceof IMultiblockComponent) {
IMultiblockComponent component = (IMultiblockComponent) tile;
IMultiblockController controller = component.getMultiblockLogic().getController();
if (controller instanceof ICamouflageHandler) {
ICamouflageHandler multiblockHandler = (ICamouflageHandler) controller;
camouflageStack = multiblockHandler.getCamouflageBlock();
}
if (!controller.isAssembled()) {
camouflageStack = ItemStack.EMPTY;
}
}
return camouflageStack;
}
return ItemStack.EMPTY;
}
use of forestry.api.multiblock.IMultiblockController in project ForestryMC by ForestryMC.
the class CamouflageUtil method getCamouflageHandler.
@Nullable
public static ICamouflageHandler getCamouflageHandler(IBlockAccess world, BlockPos pos) {
TileEntity tile = TileUtil.getTile(world, pos, TileEntity.class);
if (tile instanceof ICamouflagedTile) {
ICamouflagedTile block = (ICamouflagedTile) tile;
ICamouflageHandler handler = null;
if (tile instanceof ICamouflageHandler) {
handler = (ICamouflageHandler) tile;
}
if ((handler == null || handler.getCamouflageBlock().isEmpty()) && tile instanceof IMultiblockComponent) {
IMultiblockComponent component = (IMultiblockComponent) tile;
IMultiblockController controller = component.getMultiblockLogic().getController();
if (controller instanceof ICamouflageHandler) {
handler = (ICamouflageHandler) controller;
}
}
return handler;
}
return null;
}
use of forestry.api.multiblock.IMultiblockController in project ForestryMC by ForestryMC.
the class CamouflageUtil method getCamouflageBlock.
public static ItemStack getCamouflageBlock(@Nullable IBlockAccess world, @Nullable BlockPos pos) {
if (world == null || pos == null) {
return ItemStack.EMPTY;
}
TileEntity tile = TileUtil.getTile(world, pos, TileEntity.class);
if (tile instanceof ICamouflagedTile) {
ICamouflagedTile block = (ICamouflagedTile) tile;
ItemStack camouflageStack = ItemStack.EMPTY;
if (tile instanceof ICamouflageHandler) {
ICamouflageHandler tileHandler = (ICamouflageHandler) tile;
ItemStack tileCamouflageStack = tileHandler.getCamouflageBlock();
ItemStack defaultCamouflageStack = tileHandler.getDefaultCamouflageBlock();
if (!ItemStackUtil.isIdenticalItem(tileCamouflageStack, defaultCamouflageStack)) {
camouflageStack = tileCamouflageStack;
}
}
if (camouflageStack.isEmpty() && tile instanceof IMultiblockComponent) {
IMultiblockComponent component = (IMultiblockComponent) tile;
IMultiblockController controller = component.getMultiblockLogic().getController();
if (controller.isAssembled() && controller instanceof ICamouflageHandler) {
ICamouflageHandler multiblockHandler = (ICamouflageHandler) controller;
camouflageStack = multiblockHandler.getCamouflageBlock();
}
}
return camouflageStack;
}
return ItemStack.EMPTY;
}
Aggregations