Search in sources :

Example 1 with ICamouflageHandler

use of forestry.api.core.ICamouflageHandler in project ForestryMC by ForestryMC.

the class BlockGreenhouse method getCamouflageHandler.

@Override
public 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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IMultiblockController(forestry.api.multiblock.IMultiblockController) ICamouflagedTile(forestry.api.core.ICamouflagedTile) ICamouflageHandler(forestry.api.core.ICamouflageHandler) IMultiblockComponent(forestry.api.multiblock.IMultiblockComponent)

Example 2 with ICamouflageHandler

use of forestry.api.core.ICamouflageHandler 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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IMultiblockController(forestry.api.multiblock.IMultiblockController) ICamouflagedTile(forestry.api.core.ICamouflagedTile) ICamouflageHandler(forestry.api.core.ICamouflageHandler) IMultiblockComponent(forestry.api.multiblock.IMultiblockComponent) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ICamouflageHandler

use of forestry.api.core.ICamouflageHandler in project ForestryMC by ForestryMC.

the class BlockClimatiser method getCamouflageBlock.

@Override
public ItemStack getCamouflageBlock(IBlockAccess world, BlockPos pos) {
    if (world == null || pos == null) {
        return ItemStack.EMPTY;
    }
    ICamouflageHandler handler = getCamouflageHandler(world, pos);
    if (handler != null) {
        ItemStack camouflageStack = handler.getCamouflageBlock();
        ItemStack defaultCamouflageStack = handler.getDefaultCamouflageBlock();
        if (!ItemStackUtil.isIdenticalItem(camouflageStack, defaultCamouflageStack)) {
            return camouflageStack;
        }
    }
    return ItemStack.EMPTY;
}
Also used : ICamouflageHandler(forestry.api.core.ICamouflageHandler) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ICamouflageHandler

use of forestry.api.core.ICamouflageHandler 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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IMultiblockController(forestry.api.multiblock.IMultiblockController) ICamouflagedTile(forestry.api.core.ICamouflagedTile) ICamouflageHandler(forestry.api.core.ICamouflageHandler) IMultiblockComponent(forestry.api.multiblock.IMultiblockComponent) Nullable(javax.annotation.Nullable)

Example 5 with ICamouflageHandler

use of forestry.api.core.ICamouflageHandler 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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IMultiblockController(forestry.api.multiblock.IMultiblockController) ICamouflagedTile(forestry.api.core.ICamouflagedTile) ICamouflageHandler(forestry.api.core.ICamouflageHandler) IMultiblockComponent(forestry.api.multiblock.IMultiblockComponent) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ICamouflageHandler (forestry.api.core.ICamouflageHandler)6 ICamouflagedTile (forestry.api.core.ICamouflagedTile)4 IMultiblockComponent (forestry.api.multiblock.IMultiblockComponent)4 IMultiblockController (forestry.api.multiblock.IMultiblockController)4 ItemStack (net.minecraft.item.ItemStack)4 TileEntity (net.minecraft.tileentity.TileEntity)4 ItemInventoryCamouflageSprayCan (forestry.greenhouse.inventory.ItemInventoryCamouflageSprayCan)1 Nullable (javax.annotation.Nullable)1