Search in sources :

Example 41 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project LogisticsPipes by RS485.

the class SideConfigDisplay method renderBlock.

public void renderBlock(IBlockState state, BlockPos pos, IBlockAccess blockAccess, BufferBuilder worldRendererIn) {
    try {
        BlockRendererDispatcher blockrendererdispatcher = mc.getBlockRendererDispatcher();
        EnumBlockRenderType type = state.getRenderType();
        if (type != EnumBlockRenderType.MODEL) {
            blockrendererdispatcher.renderBlock(state, pos, blockAccess, worldRendererIn);
            return;
        }
        IBakedModel ibakedmodel = blockrendererdispatcher.getModelForState(state);
        state = state.getBlock().getExtendedState(state, world, pos);
        blockrendererdispatcher.getBlockModelRenderer().renderModel(blockAccess, ibakedmodel, state, pos, worldRendererIn, false);
    } catch (Throwable ignored) {
    }
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) EnumBlockRenderType(net.minecraft.util.EnumBlockRenderType)

Example 42 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project TechReborn by TechReborn.

the class RenderNukePrimed method doRender.

@Override
public void doRender(EntityNukePrimed entity, double x, double y, double z, float entityYaw, float partialTicks) {
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
    if ((float) entity.fuse - partialTicks + 1.0F < 10.0F) {
        float f = 1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 10.0F;
        f = MathHelper.clamp_float(f, 0.0F, 1.0F);
        f = f * f;
        f = f * f;
        float f1 = 1.0F + f * 0.3F;
        GlStateManager.scale(f1, f1, f1);
    }
    float f2 = (1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
    this.bindEntityTexture(entity);
    GlStateManager.translate(-0.5F, -0.5F, 0.5F);
    blockrendererdispatcher.renderBlockBrightness(ModBlocks.nuke.getDefaultState(), entity.getBrightness(partialTicks));
    GlStateManager.translate(0.0F, 0.0F, 1.0F);
    if (entity.fuse / 5 % 2 == 0) {
        GlStateManager.disableLighting();
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(770, 772);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1F);
        GlStateManager.doPolygonOffset(-3.0F, -3.0F);
        GlStateManager.enablePolygonOffset();
        blockrendererdispatcher.renderBlockBrightness(ModBlocks.nuke.getDefaultState().withProperty(BlockNuke.OVERLAY, true), 1.0F);
        GlStateManager.doPolygonOffset(0.0F, 0.0F);
        GlStateManager.disablePolygonOffset();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableBlend();
        GlStateManager.enableLighting();
    }
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
Also used : BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 43 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project Galacticraft by micdoodle8.

the class RenderProjectileTNT method doRender.

@Override
public void doRender(EntityProjectileTNT entity, double x, double y, double z, float par8, float partialTicks) {
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
    float f2 = (1.0F - ((float) entity.ticksExisted - partialTicks + 1.0F) / 100.0F) * 0.1F;
    this.bindEntityTexture(entity);
    GlStateManager.translate(-0.5F, -0.5F, 0.5F);
    blockrendererdispatcher.renderBlockBrightness(Blocks.TNT.getDefaultState(), entity.getBrightness());
    GlStateManager.translate(0.0F, 0.0F, 1.0F);
    if (entity.ticksExisted % 2 == 0) {
        GlStateManager.disableTexture2D();
        GlStateManager.disableLighting();
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(770, 772);
        GlStateManager.color(1.0F, 1.0F, 1.0F, f2);
        GlStateManager.doPolygonOffset(-3.0F, -3.0F);
        GlStateManager.enablePolygonOffset();
        blockrendererdispatcher.renderBlockBrightness(Blocks.TNT.getDefaultState(), 0.2F);
        GlStateManager.doPolygonOffset(0.0F, 0.0F);
        GlStateManager.disablePolygonOffset();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableBlend();
        GlStateManager.enableLighting();
        GlStateManager.enableTexture2D();
    }
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, par8, partialTicks);
}
Also used : BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 44 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project Wizardry by TeamWizardry.

the class StructureManager method bake.

/**
 * Called automatically in bake event. If baking again is required, you can use this.
 */
@SideOnly(Side.CLIENT)
public void bake(ResourceLocation resourceLocation) {
    Wizardry.LOGGER.info("Attempting to bake structure \"" + resourceLocation.toString() + "\"");
    WizardryStructure structure = structures.get(resourceLocation);
    if (structure == null) {
        Wizardry.LOGGER.error("Could not bake structure \"" + resourceLocation.toString() + "\". Does not seem to exist?");
        return;
    }
    HashMultimap<Integer, Template.BlockInfo> blocks = HashMultimap.create();
    for (Template.BlockInfo info : structure.blockInfos()) {
        if (info.blockState.getMaterial() == Material.AIR)
            continue;
        if (info.blockState.getRenderType() == EnumBlockRenderType.INVISIBLE)
            continue;
        blocks.put(info.blockState.getBlock().getRenderLayer().ordinal(), info);
    }
    BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    // noinspection ConstantConditions
    if (dispatcher == null) {
        Wizardry.LOGGER.error("Could not bake structure \"" + resourceLocation.toString() + "\". Dispatcher is null. Don't call bake so early?");
        return;
    }
    Tessellator tes = Tessellator.getInstance();
    BufferBuilder bb = tes.getBuffer();
    HashMap<Integer, int[]> cache = new HashMap<>();
    for (int layerID : blocks.keySet()) {
        bb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
        for (Template.BlockInfo info : blocks.get(layerID)) {
            if (info.blockState == null)
                continue;
            if (info.blockState.getMaterial() == Material.AIR)
                continue;
            if (info.blockState.getRenderType() == EnumBlockRenderType.INVISIBLE)
                continue;
            bb.setTranslation(info.pos.getX() - structure.getOrigin().getX(), info.pos.getY() - structure.getOrigin().getY(), info.pos.getZ() - structure.getOrigin().getZ());
            dispatcher.renderBlock(info.blockState, BlockPos.ORIGIN, structure.getWizardryAccess(), bb);
            bb.setTranslation(0, 0, 0);
        }
        cache.put(layerID, ClientUtilMethods.createCacheArrayAndReset(bb));
        bb.reset();
    }
    vboCache.put(resourceLocation, cache);
    Wizardry.LOGGER.info("Baking for structure \"" + resourceLocation.toString() + "\" completed.");
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) HashMap(java.util.HashMap) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) Template(net.minecraft.world.gen.structure.template.Template) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)44 IBlockState (net.minecraft.block.state.IBlockState)20 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)15 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)13 BlockPos (net.minecraft.util.math.BlockPos)13 Tessellator (net.minecraft.client.renderer.Tessellator)12 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 World (net.minecraft.world.World)5 Block (net.minecraft.block.Block)4 BlockModelShapes (net.minecraft.client.renderer.BlockModelShapes)4 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)3 IBakedModel (net.minecraft.client.renderer.model.IBakedModel)3 TileEntity (net.minecraft.tileentity.TileEntity)3 EnumFacing (net.minecraft.util.EnumFacing)3 IBlockAccess (net.minecraft.world.IBlockAccess)3 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)2 Nullable (javax.annotation.Nullable)2 BlockChest (net.minecraft.block.BlockChest)2 BlockEnderChest (net.minecraft.block.BlockEnderChest)2 BlockSign (net.minecraft.block.BlockSign)2