Search in sources :

Example 11 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project NewHorizonsCoreMod by GTNewHorizons.

the class OilGeneratorFix method getTopBlock.

private int getTopBlock(World pWorld, int pLocX, int pLocZ) {
    Chunk tChunk = pWorld.getChunkFromBlockCoords(pLocX, pLocZ);
    int y = tChunk.getTopFilledSegment() + 15;
    int trimmedX = pLocX & 0xF;
    int trimmedZ = pLocZ & 0xF;
    for (; y > 0; y--) {
        Block tBlock = tChunk.getBlock(trimmedX, y, trimmedZ);
        if (!tBlock.isAir(pWorld, pLocX, y, pLocZ)) {
            if ((tBlock instanceof BlockStaticLiquid)) {
                return y;
            }
            if ((tBlock instanceof BlockFluidBase)) {
                return y;
            }
            if ((tBlock instanceof IFluidBlock)) {
                return y;
            }
            if (tBlock.getMaterial().blocksMovement()) {
                if (!(tBlock instanceof BlockFlower)) {
                    return y - 1;
                }
            }
        }
    }
    return -1;
}
Also used : BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) BlockStaticLiquid(net.minecraft.block.BlockStaticLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) Chunk(net.minecraft.world.chunk.Chunk) BlockFlower(net.minecraft.block.BlockFlower)

Example 12 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project RebornCore by TechReborn.

the class LogicBlock method addItemsToList.

private void addItemsToList(IItemHandler inventory, List<ItemStack> items) {
    for (int i = 0; i < inventory.getSlots(); i++) {
        ItemStack itemStack = inventory.getStackInSlot(i);
        if (itemStack == ItemStack.EMPTY) {
            continue;
        }
        if (itemStack != ItemStack.EMPTY && itemStack.getCount() > 0) {
            if (itemStack.getItem() instanceof ItemBlock) {
                if (((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockFluidBase || ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockStaticLiquid || ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockDynamicLiquid) {
                    continue;
                }
            }
        }
        items.add(itemStack.copy());
    }
}
Also used : BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) BlockStaticLiquid(net.minecraft.block.BlockStaticLiquid) BlockDynamicLiquid(net.minecraft.block.BlockDynamicLiquid) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 13 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project RebornCore by TechReborn.

the class BlockMachineBase method addItemsToList.

private void addItemsToList(IInventory inventory, List<ItemStack> items) {
    for (int i = 0; i < inventory.getSizeInventory(); i++) {
        ItemStack itemStack = inventory.getStackInSlot(i);
        if (itemStack == ItemStack.EMPTY) {
            continue;
        }
        if (itemStack != ItemStack.EMPTY && itemStack.getCount() > 0) {
            if (itemStack.getItem() instanceof ItemBlock) {
                if (((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockFluidBase || ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockStaticLiquid || ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockDynamicLiquid) {
                    continue;
                }
            }
        }
        items.add(itemStack.copy());
    }
}
Also used : BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) BlockStaticLiquid(net.minecraft.block.BlockStaticLiquid) BlockDynamicLiquid(net.minecraft.block.BlockDynamicLiquid) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 14 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project TechReborn by TechReborn.

the class BlockTransformer method dropInventory.

protected List<ItemStack> dropInventory(IBlockAccess world, BlockPos pos, ItemStack itemToDrop) {
    TileEntity tileEntity = world.getTileEntity(pos);
    if (tileEntity == null) {
        System.out.print("Null");
        return null;
    }
    if (!(tileEntity instanceof IInventory)) {
        System.out.print("Not INstance");
        return null;
    }
    IInventory inventory = (IInventory) tileEntity;
    List<ItemStack> items = new ArrayList<>();
    for (int i = 0; i < inventory.getSizeInventory(); i++) {
        ItemStack itemStack = inventory.getStackInSlot(i);
        if (itemStack.isEmpty()) {
            continue;
        }
        if (!itemStack.isEmpty() && itemStack.getCount() > 0) {
            if (itemStack.getItem() instanceof ItemBlock) {
                if (((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockFluidBase || ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockStaticLiquid || ((ItemBlock) itemStack.getItem()).getBlock() instanceof BlockDynamicLiquid) {
                    continue;
                }
            }
        }
        items.add(itemStack.copy());
    }
    items.add(itemToDrop.copy());
    return items;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) BlockStaticLiquid(net.minecraft.block.BlockStaticLiquid) ArrayList(java.util.ArrayList) BlockDynamicLiquid(net.minecraft.block.BlockDynamicLiquid) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 15 with BlockFluidBase

use of net.minecraftforge.fluids.BlockFluidBase in project GregTech by GregTechCE.

the class BakedModelHandler method onModelsBake.

@SubscribeEvent
public void onModelsBake(ModelBakeEvent event) {
    for (BlockFluidBase fluidBlock : fluidBlocks) {
        Fluid fluid = ObfuscationReflectionHelper.getPrivateValue(BlockFluidBase.class, fluidBlock, "definedFluid");
        ModelFluid modelFluid = new ModelFluid(fluid);
        IBakedModel bakedModel = modelFluid.bake(modelFluid.getDefaultState(), DefaultVertexFormats.ITEM, TextureUtils::getTexture);
        ModelResourceLocation resourceLocation = getSimpleModelLocation(fluidBlock);
        event.getModelRegistry().putObject(resourceLocation, bakedModel);
    }
    for (Tuple<Block, String> tuple : builtInBlocks) {
        ModelResourceLocation resourceLocation = getSimpleModelLocation(tuple.getFirst());
        ModelBuiltInRenderer bakedModel = new ModelBuiltInRenderer(tuple.getSecond());
        event.getModelRegistry().putObject(resourceLocation, bakedModel);
    }
}
Also used : BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) Fluid(net.minecraftforge.fluids.Fluid) ModelFluid(net.minecraftforge.client.model.ModelFluid) ModelFluid(net.minecraftforge.client.model.ModelFluid) TextureUtils(codechicken.lib.texture.TextureUtils) Block(net.minecraft.block.Block) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

BlockFluidBase (net.minecraftforge.fluids.BlockFluidBase)18 Block (net.minecraft.block.Block)10 BlockPos (net.minecraft.util.math.BlockPos)6 BlockStaticLiquid (net.minecraft.block.BlockStaticLiquid)5 IBlockState (net.minecraft.block.state.IBlockState)5 BlockLiquid (net.minecraft.block.BlockLiquid)4 BlockDynamicLiquid (net.minecraft.block.BlockDynamicLiquid)3 ItemBlock (net.minecraft.item.ItemBlock)3 ItemStack (net.minecraft.item.ItemStack)3 EnumFacing (net.minecraft.util.EnumFacing)3 Fluid (net.minecraftforge.fluids.Fluid)3 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)3 HashSet (java.util.HashSet)2 BlockFlower (net.minecraft.block.BlockFlower)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 PathNodeType (net.minecraft.pathfinding.PathNodeType)2 PathPoint (net.minecraft.pathfinding.PathPoint)2 Chunk (net.minecraft.world.chunk.Chunk)2 IControllable (buildcraft.api.tiles.IControllable)1 CropHandlerPlantable (buildcraft.core.crops.CropHandlerPlantable)1