Search in sources :

Example 1 with BlockBPMicroblock

use of com.bluepowermod.block.BlockBPMicroblock in project BluePower by Qmunity.

the class BPMicroblockModel method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
    List<BakedQuad> outquads = new ArrayList<>();
    IBakedModel typeModel = Minecraft.getInstance().getBlockRenderer().getBlockModel(this.defBlock.defaultBlockState());
    IBakedModel sizeModel = Minecraft.getInstance().getModelManager().getModel(new ModelResourceLocation(defSize.getRegistryName(), "face=" + Direction.WEST));
    if (state != null && state.getBlock() instanceof BlockBPMicroblock) {
        sizeModel = Minecraft.getInstance().getModelManager().getModel(new ModelResourceLocation(state.getBlock().getRegistryName(), "face=" + state.getValue(BlockBPMicroblock.FACING)));
    }
    List<BakedQuad> sizeModelQuads = sizeModel.getQuads(state, side, rand);
    TextureAtlasSprite sprite = typeModel.getParticleIcon();
    for (BakedQuad quad : sizeModelQuads) {
        List<BakedQuad> typeModelQuads = typeModel.getQuads(this.defBlock.defaultBlockState(), quad.getDirection(), rand);
        if (typeModelQuads.size() > 0) {
            sprite = typeModelQuads.get(0).getSprite();
        }
        outquads.add(transform(quad, sprite, Direction.EAST, defBlock));
    }
    return outquads;
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BlockBPMicroblock(com.bluepowermod.block.BlockBPMicroblock)

Example 2 with BlockBPMicroblock

use of com.bluepowermod.block.BlockBPMicroblock in project BluePower by Qmunity.

the class Renderers method init.

public static void init() {
    ClientRegistry.bindTileEntityRenderer(BPTileEntityType.LAMP, RenderLamp::new);
    ClientRegistry.bindTileEntityRenderer(BPTileEntityType.ENGINE, RenderEngine::new);
    for (Item item : BPItems.itemList) {
        if (item instanceof IBPColoredItem) {
            Minecraft.getInstance().getItemColors().register(new BPItemColor(), item);
        }
    }
    for (Block block : BPBlocks.blockList) {
        if (block instanceof IBPColoredBlock) {
            Minecraft.getInstance().getBlockColors().register(new BPBlockColor(), block);
            Minecraft.getInstance().getItemColors().register(new BPBlockColor(), Item.byBlock(block));
        }
        if (block instanceof BlockLampSurface || block instanceof BlockGateBase || block instanceof BlockBattery)
            RenderTypeLookup.setRenderLayer(block, RenderType.cutout());
        if (block instanceof BlockBPGlass || block instanceof BlockBPMicroblock || block instanceof BlockBPMultipart)
            RenderTypeLookup.setRenderLayer(block, RenderType.translucent());
    }
    RenderTypeLookup.setRenderLayer(BPBlocks.indigo_flower, RenderType.cutout());
    RenderTypeLookup.setRenderLayer(BPBlocks.flax_crop, RenderType.cutout());
    RenderTypeLookup.setRenderLayer(BPBlocks.cracked_basalt_lava, RenderType.cutout());
    RenderTypeLookup.setRenderLayer(BPBlocks.cracked_basalt_decorative, RenderType.cutout());
    RenderTypeLookup.setRenderLayer(BPBlocks.rubber_leaves, RenderType.cutout());
    RenderTypeLookup.setRenderLayer(BPBlocks.rubber_sapling, RenderType.cutout());
    RenderTypeLookup.setRenderLayer(BPBlocks.tube, RenderType.cutout());
}
Also used : BlockBPMultipart(com.bluepowermod.block.BlockBPMultipart) BlockLampSurface(com.bluepowermod.block.lighting.BlockLampSurface) BlockBPMicroblock(com.bluepowermod.block.BlockBPMicroblock) BlockBattery(com.bluepowermod.block.power.BlockBattery) BlockBPGlass(com.bluepowermod.block.worldgen.BlockBPGlass) Item(net.minecraft.item.Item) Block(net.minecraft.block.Block) BlockGateBase(com.bluepowermod.block.gates.BlockGateBase)

Example 3 with BlockBPMicroblock

use of com.bluepowermod.block.BlockBPMicroblock in project BluePower by Qmunity.

the class MicroblockRecipe method matches.

@Override
public boolean matches(CraftingInventory inv, World worldIn) {
    int blockCount = 0;
    int saw = 0;
    for (int i = 0; i < inv.getContainerSize(); ++i) {
        ItemStack stack = inv.getItem(i);
        if (!stack.isEmpty()) {
            if (stack.getItem() instanceof BlockItem && (Block.byItem(stack.getItem()) instanceof BlockBPMicroblock || !Block.byItem(stack.getItem()).hasTileEntity(Block.byItem(stack.getItem()).defaultBlockState()))) {
                VoxelShape shape = null;
                try {
                    shape = Block.byItem(stack.getItem()).defaultBlockState().getShape(null, null);
                } catch (NullPointerException ignored) {
                // Shulker Boxes try to query the Tile Entity
                }
                if (shape == VoxelShapes.block() || Block.byItem(stack.getItem()) == BPBlocks.half_block || Block.byItem(stack.getItem()) == BPBlocks.panel) {
                    blockCount++;
                }
            } else if (stack.getItem() instanceof ItemSaw) {
                saw++;
            } else {
                return false;
            }
        }
    }
    return blockCount == 1 && saw == 1;
}
Also used : VoxelShape(net.minecraft.util.math.shapes.VoxelShape) ItemStack(net.minecraft.item.ItemStack) BlockItem(net.minecraft.item.BlockItem) ItemSaw(com.bluepowermod.item.ItemSaw) BlockBPMicroblock(com.bluepowermod.block.BlockBPMicroblock)

Example 4 with BlockBPMicroblock

use of com.bluepowermod.block.BlockBPMicroblock in project BluePower by Qmunity.

the class BPMicroblockModel method getQuads.

@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
    Pair<Block, Integer> info = extraData.getData(TileBPMicroblock.PROPERTY_INFO);
    if (info != null) {
        IBakedModel typeModel = Minecraft.getInstance().getBlockRenderer().getBlockModel(info.getKey().defaultBlockState());
        IBakedModel sizeModel = Minecraft.getInstance().getModelManager().getModel(new ModelResourceLocation(defSize.getRegistryName(), "face=" + Direction.WEST));
        List<BakedQuad> bakedQuads = new ArrayList<>();
        if (state != null && state.getBlock() instanceof BlockBPMicroblock) {
            sizeModel = Minecraft.getInstance().getModelManager().getModel(new ModelResourceLocation(state.getBlock().getRegistryName(), "face=" + state.getValue(BlockBPMicroblock.FACING)));
        }
        List<BakedQuad> sizeModelQuads = sizeModel.getQuads(state, side, rand);
        if (state != null) {
            TextureAtlasSprite sprite = typeModel.getParticleIcon();
            for (BakedQuad quad : sizeModelQuads) {
                List<BakedQuad> typeModelQuads = typeModel.getQuads(info.getKey().defaultBlockState(), quad.getDirection(), rand);
                if (typeModelQuads.size() > 0) {
                    sprite = typeModelQuads.get(0).getSprite();
                }
                bakedQuads.add(transform(quad, sprite, state.getValue(BlockBPMicroblock.FACING), defBlock));
            }
            return bakedQuads;
        }
    }
    return Collections.emptyList();
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Block(net.minecraft.block.Block) BlockBPMicroblock(com.bluepowermod.block.BlockBPMicroblock) Nonnull(javax.annotation.Nonnull)

Aggregations

BlockBPMicroblock (com.bluepowermod.block.BlockBPMicroblock)4 Block (net.minecraft.block.Block)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 BlockBPMultipart (com.bluepowermod.block.BlockBPMultipart)1 BlockGateBase (com.bluepowermod.block.gates.BlockGateBase)1 BlockLampSurface (com.bluepowermod.block.lighting.BlockLampSurface)1 BlockBattery (com.bluepowermod.block.power.BlockBattery)1 BlockBPGlass (com.bluepowermod.block.worldgen.BlockBPGlass)1 ItemSaw (com.bluepowermod.item.ItemSaw)1 Nonnull (javax.annotation.Nonnull)1 BlockItem (net.minecraft.item.BlockItem)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 VoxelShape (net.minecraft.util.math.shapes.VoxelShape)1