Search in sources :

Example 21 with IMultiblockComponent

use of forestry.api.multiblock.IMultiblockComponent 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)

Example 22 with IMultiblockComponent

use of forestry.api.multiblock.IMultiblockComponent in project ForestryMC by ForestryMC.

the class GreenhouseController method onMachineDisassembled.

@Override
protected void onMachineDisassembled() {
    super.onMachineDisassembled();
    provider.clear(false);
    provider.getStorage().removeProviderFromChunks();
    this.centerPos = BlockPos.ORIGIN;
    for (IMultiblockComponent comp : connectedParts) {
        if (comp instanceof ICamouflagedTile) {
            world.markBlockRangeForRenderUpdate(comp.getCoordinates(), comp.getCoordinates());
        }
    }
    limits = null;
}
Also used : ICamouflagedTile(forestry.api.core.ICamouflagedTile) IMultiblockComponent(forestry.api.multiblock.IMultiblockComponent)

Aggregations

IMultiblockComponent (forestry.api.multiblock.IMultiblockComponent)22 BlockPos (net.minecraft.util.math.BlockPos)13 TileEntity (net.minecraft.tileentity.TileEntity)7 ICamouflagedTile (forestry.api.core.ICamouflagedTile)6 HashSet (java.util.HashSet)6 IChunkProvider (net.minecraft.world.chunk.IChunkProvider)6 ICamouflageHandler (forestry.api.core.ICamouflageHandler)4 IMultiblockController (forestry.api.multiblock.IMultiblockController)4 Nullable (javax.annotation.Nullable)3 IMultiblockLogic (forestry.api.multiblock.IMultiblockLogic)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Set (java.util.Set)2 ItemStack (net.minecraft.item.ItemStack)2 HashMultiset (com.google.common.collect.HashMultiset)1 Multiset (com.google.common.collect.Multiset)1 GameProfile (com.mojang.authlib.GameProfile)1 MultiblockValidationException (forestry.core.multiblock.MultiblockValidationException)1 TileUtil (forestry.core.tiles.TileUtil)1