Search in sources :

Example 16 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project BluePower by Qmunity.

the class BPMultipartModel method getQuads.

@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
    BlockRendererDispatcher brd = Minecraft.getInstance().getBlockRenderer();
    Map<BlockState, IModelData> stateInfo = extraData.getData(TileBPMultipart.STATE_INFO);
    if (stateInfo != null) {
        return stateInfo.keySet().stream().flatMap(i -> brd.getBlockModel(i).getQuads(i, side, rand, stateInfo.get(i)).stream().map(q -> stateInfo.get(i).hasProperty(TileWire.COLOR_INFO) ? transform(q, stateInfo.get(i).getData(TileWire.COLOR_INFO), stateInfo.get(i).hasProperty(TileWire.LIGHT_INFO) ? stateInfo.get(i).getData(TileWire.LIGHT_INFO) : false) : q)).collect(Collectors.toList());
    } else {
        return Collections.emptyList();
    }
}
Also used : BakedQuadBuilder(net.minecraftforge.client.model.pipeline.BakedQuadBuilder) java.util(java.util) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) ItemOverrideList(net.minecraft.client.renderer.model.ItemOverrideList) Direction(net.minecraft.util.Direction) RayTraceResult(net.minecraft.util.math.RayTraceResult) Minecraft(net.minecraft.client.Minecraft) BlockState(net.minecraft.block.BlockState) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) MultipartUtils(com.bluepowermod.util.MultipartUtils) TileWire(com.bluepowermod.tile.tier1.TileWire) VertexTransformer(net.minecraftforge.client.model.pipeline.VertexTransformer) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) IModelData(net.minecraftforge.client.model.data.IModelData) IVertexConsumer(net.minecraftforge.client.model.pipeline.IVertexConsumer) Collectors(java.util.stream.Collectors) TileBPMultipart(com.bluepowermod.tile.TileBPMultipart) Pair(com.mojang.datafixers.util.Pair) BakedQuad(net.minecraft.client.renderer.model.BakedQuad) BlockRayTraceResult(net.minecraft.util.math.BlockRayTraceResult) VertexFormatElement(net.minecraft.client.renderer.vertex.VertexFormatElement) LightUtil(net.minecraftforge.client.model.pipeline.LightUtil) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) BlockState(net.minecraft.block.BlockState) IModelData(net.minecraftforge.client.model.data.IModelData) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) Nonnull(javax.annotation.Nonnull)

Example 17 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project MorePlanets by SteveKunG.

the class RenderFallingKoentusMeteor method doRender.

@Override
public void doRender(EntityFallingKoentusMeteor entity, double x, double y, double z, float entityYaw, float partialTicks) {
    IBlockState state = MPBlocks.FALLEN_KOENTUS_METEOR.getDefaultState();
    if (state.getRenderType() == EnumBlockRenderType.MODEL) {
        World world = entity.getWorldObj();
        if (state != world.getBlockState(new BlockPos(entity)) && state.getRenderType() != EnumBlockRenderType.INVISIBLE) {
            this.bindEntityTexture(entity);
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder vertexbuffer = tessellator.getBuffer();
            if (this.renderOutlines) {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }
            vertexbuffer.begin(GLConstants.QUADS, DefaultVertexFormats.BLOCK);
            BlockPos blockpos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
            GlStateManager.translate((float) (x - blockpos.getX() - 0.5D), (float) (y - blockpos.getY()), (float) (z - blockpos.getZ() - 0.5D));
            BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
            blockrendererdispatcher.getBlockModelRenderer().renderModel(world, blockrendererdispatcher.getModelForState(state), state, blockpos, vertexbuffer, false, MathHelper.getPositionRandom(entity.getOrigin()));
            tessellator.draw();
            if (this.renderOutlines) {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }
            GlStateManager.enableLighting();
            GlStateManager.popMatrix();
            super.doRender(entity, x, y, z, entityYaw, partialTicks);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 18 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project Immersive-Tech by FerroO2000.

the class TileRenderSteamTurbine method render.

@Override
public void render(TileEntitySteamTurbine te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false)) {
        return;
    }
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos blockPos = te.getPos();
    IBlockState state = getWorld().getBlockState(blockPos);
    if (state.getBlock() != ITContent.blockMetalMultiblock) {
        return;
    }
    state = state.getBlock().getActualState(state, getWorld(), blockPos);
    state = state.withProperty(IEProperties.DYNAMICRENDER, true);
    IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder worldRenderer = tessellator.getBuffer();
    ClientUtils.bindAtlas();
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    GlStateManager.translate(.5, .5, .5);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(7425);
    } else {
        GlStateManager.shadeModel(7424);
    }
    GlStateManager.rotate(te.getAnimation().getAnimationRotation() + (te.getAnimation().getAnimationStep() * partialTicks), te.facing.getFrontOffsetX(), 0, te.facing.getFrontOffsetZ());
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    worldRenderer.setTranslation(-.5 - blockPos.getX(), -.5 - blockPos.getY(), -.5 - blockPos.getZ());
    worldRenderer.color(255, 255, 255, 255);
    blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true);
    worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
    RenderHelper.enableStandardItemLighting();
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 19 with BlockRendererDispatcher

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

the class RenderSmallAsteroid method doRender.

@Override
public void doRender(EntitySmallAsteroid asteroid, double x, double y, double z, float f, float partialTickTime) {
    BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x, (float) y + 0.5F, (float) z);
    GL11.glRotatef(asteroid.rotationPitch, 1, 0, 0);
    GL11.glRotatef(asteroid.rotationYaw, 0, 1, 0);
    this.bindEntityTexture(asteroid);
    dispatcher.renderBlockBrightness(AsteroidBlocks.blockBasic.getDefaultState().withProperty(BlockBasicAsteroids.BASIC_TYPE, ASTEROID_0), 1.0F);
    GL11.glPopMatrix();
}
Also used : BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 20 with BlockRendererDispatcher

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

the class RenderWebShot method doRender.

@Override
public void doRender(EntityWebShot entity, double x, double y, double z, float par8, float partialTicks) {
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
    this.bindEntityTexture(entity);
    GlStateManager.rotate((entity.ticksExisted + partialTicks) * 50.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.scale(0.5F, 0.5F, 0.5F);
    GlStateManager.translate(-0.5F, -1F, 0.5F);
    blockrendererdispatcher.renderBlockBrightness(Blocks.WEB.getDefaultState(), 1.0F);
    GlStateManager.translate(0.0F, 0.0F, 1.0F);
    GlStateManager.popMatrix();
    RenderHelper.enableStandardItemLighting();
}
Also used : BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

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