net.minecraft.util.BlockRenderLayer Java Examples
The following examples show how to use
net.minecraft.util.BlockRenderLayer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GuiComponentSideSelector.java From OpenModsLib with MIT License | 6 votes |
private void drawBlock() { final Tessellator tessellator = Tessellator.getInstance(); final BufferBuilder wr = tessellator.getBuffer(); final BlockRendererDispatcher dispatcher = parent.getMinecraft().getBlockRendererDispatcher(); for (BlockRenderLayer layer : BlockRenderLayer.values()) { if (blockState.getBlock().canRenderInLayer(blockState, layer)) { net.minecraftforge.client.ForgeHooksClient.setRenderLayer(layer); wr.setTranslation(-0.5, -0.5, -0.5); wr.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); dispatcher.renderBlock(blockState, FakeBlockAccess.ORIGIN, access, wr); tessellator.draw(); } } wr.setTranslation(0.0D, 0.0D, 0.0D); net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null); }
Example #2
Source File: InvPipeRenderer.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean renderBlock(IBlockAccess world, BlockPos pos, IBlockState state, BufferBuilder buffer) { CCRenderState renderState = CCRenderState.instance(); renderState.reset(); renderState.bind(buffer); renderState.setBrightness(world, pos); IVertexOperation[] pipeline = {new Translation(pos)}; BlockInventoryPipe block = (BlockInventoryPipe) state.getBlock(); TileEntityInventoryPipe tileEntity = (TileEntityInventoryPipe) block.getPipeTileEntity(world, pos); if (tileEntity == null) { return false; } int paintingColor = tileEntity.getInsulationColor(); int connectedSidesMask = block.getActualConnections(tileEntity, world); BlockRenderLayer renderLayer = MinecraftForgeClient.getRenderLayer(); if (renderLayer == BlockRenderLayer.SOLID) { renderPipe(renderState, pipeline, paintingColor, connectedSidesMask); } ICoverable coverable = tileEntity.getCoverableImplementation(); coverable.renderCovers(renderState, new Matrix4().translate(pos.getX(), pos.getY(), pos.getZ()), renderLayer); return true; }
Example #3
Source File: BlockRenderLayerDeserializer.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
@Override public BlockRenderLayer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { if (json.isJsonPrimitive()) { JsonPrimitive primitive = json.getAsJsonPrimitive(); if (primitive.isString()) { String string = primitive.getAsString(); if (string.equals("solid")) return BlockRenderLayer.SOLID; if (string.equals("mippedCutout")) return BlockRenderLayer.CUTOUT_MIPPED; if (string.equals("cutout")) return BlockRenderLayer.CUTOUT; if (string.equals("translucent")) return BlockRenderLayer.TRANSLUCENT; } } throw new JsonParseException("Invalid block render layer: " + json); }
Example #4
Source File: MultiLayerModel.java From OpenModsLib with MIT License | 6 votes |
public MultiLayerBakedModel(Map<BlockRenderLayer, IBakedModel> models, IBakedModel base, IBakedModel missing, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms) { super(base, cameraTransforms); this.models = ImmutableMap.copyOf(models); this.missing = missing; final List<BakedQuad> quads = Lists.newArrayList(); for (BlockRenderLayer layer : BlockRenderLayer.values()) { final IBakedModel model = models.get(layer); if (model != null) { buildQuadsForLayer(quads, model); } } this.quads = ImmutableList.copyOf(quads); }
Example #5
Source File: BlockGrass.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/******************************************************************************* * 2. Rendering *******************************************************************************/ @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT_MIPPED; }
Example #6
Source File: MultiLayerModel.java From OpenModsLib with MIT License | 5 votes |
@Nonnull @Override public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) { final BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer(); if (layer == null) { return side == null? quads : ImmutableList.<BakedQuad> of(); } final IBakedModel model = models.get(layer); return MoreObjects.firstNonNull(model, missing).getQuads(state, side, rand); }
Example #7
Source File: ForgeHaxHooks.java From ForgeHax with MIT License | 5 votes |
public static BlockRenderLayer onRenderBlockInLayer( Block block, IBlockState state, BlockRenderLayer layer, BlockRenderLayer compareToLayer) { if (HOOK_onRenderBlockInLayer.reportHook()) { RenderBlockInLayerEvent event = new RenderBlockInLayerEvent(block, state, layer, compareToLayer); MinecraftForge.EVENT_BUS.post(event); return event.getLayer(); } else { return layer; } }
Example #8
Source File: BlockVegDesert.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/******************************************************************************* * 2. Rendering *******************************************************************************/ @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; }
Example #9
Source File: BlockCactus.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/******************************************************************************* * 2. Rendering *******************************************************************************/ @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; }
Example #10
Source File: LitematicaRenderer.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public void piecewiseRenderCutout(boolean renderColliding, float partialTicks) { if (this.renderPiecewiseBlocks) { this.mc.profiler.startSection("litematica_blocks_cutout"); if (renderColliding) { GlStateManager.enablePolygonOffset(); GlStateManager.doPolygonOffset(-0.3f, -0.6f); } this.startShaderIfEnabled(); this.getWorldRenderer().renderBlockLayer(BlockRenderLayer.CUTOUT, partialTicks, this.entity); this.disableShader(); if (renderColliding) { GlStateManager.doPolygonOffset(0f, 0f); GlStateManager.disablePolygonOffset(); } this.mc.profiler.endSection(); } }
Example #11
Source File: PhysObjectRenderManager.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
public void renderBlockLayer(BlockRenderLayer layerToRender, double partialTicks, int pass, ICamera iCamera) { if (renderChunks == null) { renderChunks = new PhysRenderChunk[parent.getOwnedChunks().chunkLengthX()][parent .getOwnedChunks() .chunkLengthZ()]; for (int xChunk = 0; xChunk < parent.getOwnedChunks().chunkLengthX(); xChunk++) { for (int zChunk = 0; zChunk < parent.getOwnedChunks().chunkLengthZ(); zChunk++) { renderChunks[xChunk][zChunk] = new PhysRenderChunk(parent, parent .getChunkAt(xChunk + parent.getOwnedChunks().minX(), zChunk + parent.getOwnedChunks().minZ())); } } } GL11.glPushMatrix(); Minecraft.getMinecraft().entityRenderer.enableLightmap(); // int i = parent.wrapper.getBrightnessForRender((float) partialTicks); // int j = i % 65536; // int k = i / 65536; // OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) // j, (float) k); // GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); applyRenderTransform(partialTicks); for (PhysRenderChunk[] chunkArray : renderChunks) { for (PhysRenderChunk renderChunk : chunkArray) { renderChunk.renderBlockLayer(layerToRender, partialTicks, pass, iCamera); } } Minecraft.getMinecraft().entityRenderer.disableLightmap(); GL11.glPopMatrix(); }
Example #12
Source File: PhysRenderChunk.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
public void renderBlockLayer(BlockRenderLayer layerToRender, double partialTicks, int pass) { switch (layerToRender) { case CUTOUT: if (needsCutoutUpdate) { updateList(layerToRender); } GL11.glCallList(glCallListCutout); break; case CUTOUT_MIPPED: if (needsCutoutMippedUpdate) { updateList(layerToRender); } GL11.glCallList(glCallListCutoutMipped); break; case SOLID: if (needsSolidUpdate) { updateList(layerToRender); } GL11.glCallList(glCallListSolid); break; case TRANSLUCENT: if (needsTranslucentUpdate) { updateList(layerToRender); } GL11.glCallList(glCallListTranslucent); break; default: break; } }
Example #13
Source File: BlockAncientDevice.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/******************************************************************************* * 2. Rendering *******************************************************************************/ @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; }
Example #14
Source File: PhysRenderChunk.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
public void renderBlockLayer(BlockRenderLayer layerToRender, double partialTicks, int pass, ICamera iCamera) { for (int i = 0; i < 16; i++) { IVSRenderChunk renderChunk = renderChunks[i]; if (renderChunk != null) { AxisAlignedBB renderChunkBB = new AxisAlignedBB(chunk.x << 4, renderChunk.minY(), chunk.z << 4, (chunk.x << 4) + 15, renderChunk.maxY(), (chunk.z << 4) + 15); Polygon polygon = new Polygon(renderChunkBB, toRender.getShipTransformationManager().getRenderTransform(), TransformType.SUBSPACE_TO_GLOBAL); AxisAlignedBB inWorldBB = polygon.getEnclosedAABB(); // Only render chunks that can be shown by the camera. if (iCamera.isBoundingBoxInFrustum(inWorldBB)) { renderChunk.renderBlockLayer(layerToRender, partialTicks, pass); } } } }
Example #15
Source File: BlockSmallVessel.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/******************************************************************************* * 2. Rendering *******************************************************************************/ @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; }
Example #16
Source File: MultiLayerModel.java From OpenModsLib with MIT License | 5 votes |
@Override public MultiLayerModel process(ImmutableMap<String, String> customData) { final ModelUpdater updater = new ModelUpdater(customData); final Optional<ResourceLocation> base = updater.get("base", ModelUpdater.MODEL_LOCATION, this.base); final Map<BlockRenderLayer, ResourceLocation> models = Maps.newHashMap(); for (BlockRenderLayer layer : BlockRenderLayer.values()) { final ResourceLocation result = updater.get(layer.toString(), ModelUpdater.MODEL_LOCATION, this.models.get(layer)); if (result != null) models.put(layer, result); } return updater.hasChanged()? new MultiLayerModel(base, models) : this; }
Example #17
Source File: PhysRenderChunk.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
public void renderBlockLayer(BlockRenderLayer layerToRender, double partialTicks, int pass) { switch (layerToRender) { case CUTOUT: if (needsCutoutUpdate) { updateList(layerToRender); } FastBlockModelRenderer.renderVertexBuffer(cutoutBuffer); break; case CUTOUT_MIPPED: if (needsCutoutMippedUpdate) { updateList(layerToRender); } FastBlockModelRenderer.renderVertexBuffer(cutoutMippedBuffer); break; case SOLID: if (needsSolidUpdate) { updateList(layerToRender); } FastBlockModelRenderer.renderVertexBuffer(solidBuffer); break; case TRANSLUCENT: if (needsTranslucentUpdate) { updateList(layerToRender); } FastBlockModelRenderer.renderVertexBuffer(translucentBuffer); break; default: break; } }
Example #18
Source File: LitematicaRenderer.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public void piecewiseRenderSolid(boolean renderColliding, float partialTicks) { if (this.renderPiecewiseBlocks) { this.mc.profiler.startSection("litematica_blocks_solid"); if (renderColliding) { GlStateManager.enablePolygonOffset(); GlStateManager.doPolygonOffset(-0.3f, -0.6f); } this.startShaderIfEnabled(); this.getWorldRenderer().renderBlockLayer(BlockRenderLayer.SOLID, partialTicks, this.entity); this.disableShader(); if (renderColliding) { GlStateManager.doPolygonOffset(0f, 0f); GlStateManager.disablePolygonOffset(); } this.mc.profiler.endSection(); } }
Example #19
Source File: CoverShutter.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void renderCover(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, Cuboid6 plateBox, BlockRenderLayer layer) { Textures.SHUTTER.renderSided(attachedSide, plateBox, renderState, pipeline, translation); }
Example #20
Source File: BlockPressurizedFluidTank.java From AdvancedRocketry with MIT License | 4 votes |
@Override public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; }
Example #21
Source File: BlockMagiciansWorktable.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) { return (layer == BlockRenderLayer.CUTOUT) || (layer == BlockRenderLayer.TRANSLUCENT); }
Example #22
Source File: BlockSapling.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; }
Example #23
Source File: BlockCaptainsChair.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Override public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT; }
Example #24
Source File: CoverRoboticArm.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void renderCover(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, Cuboid6 plateBox, BlockRenderLayer layer) { Textures.ARM_OVERLAY.renderSided(attachedSide, plateBox, renderState, pipeline, translation); }
Example #25
Source File: CompiledChunkSchematic.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void setLayerStarted(BlockRenderLayer layer) { throw new UnsupportedOperationException(); }
Example #26
Source File: BlockShipHelm.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Override public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT; }
Example #27
Source File: BlockFrame.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT_MIPPED; }
Example #28
Source File: CompiledChunkSchematic.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void setLayerUsed(BlockRenderLayer layer) { throw new UnsupportedOperationException(); }
Example #29
Source File: PhysRenderChunk.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
private void updateList(BlockRenderLayer layerToUpdate) { if (parent.toRender.getShipRenderer() == null) { return; } BlockPos offsetPos = parent.toRender.getShipRenderer().offsetPos; if (offsetPos == null) { return; } Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); worldrenderer.begin(7, DefaultVertexFormats.BLOCK); worldrenderer.setTranslation(-offsetPos.getX(), -offsetPos.getY(), -offsetPos.getZ()); GL11.glPushMatrix(); switch (layerToUpdate) { case CUTOUT: GLAllocation.deleteDisplayLists(glCallListCutout); GL11.glNewList(glCallListCutout, GL11.GL_COMPILE); break; case CUTOUT_MIPPED: GLAllocation.deleteDisplayLists(glCallListCutoutMipped); GL11.glNewList(glCallListCutoutMipped, GL11.GL_COMPILE); break; case SOLID: GLAllocation.deleteDisplayLists(glCallListSolid); GL11.glNewList(glCallListSolid, GL11.GL_COMPILE); break; case TRANSLUCENT: GLAllocation.deleteDisplayLists(glCallListTranslucent); GL11.glNewList(glCallListTranslucent, GL11.GL_COMPILE); break; default: break; } GlStateManager.pushMatrix(); // worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); IBlockState iblockstate; BlockRenderLayer oldLayer = MinecraftForgeClient.getRenderLayer(); ForgeHooksClient.setRenderLayer(layerToUpdate); MutableBlockPos pos = new MutableBlockPos(); for (int x = chunkToRender.x * 16; x < chunkToRender.x * 16 + 16; x++) { for (int z = chunkToRender.z * 16; z < chunkToRender.z * 16 + 16; z++) { for (int y = yMin; y <= yMax; y++) { pos.setPos(x, y, z); iblockstate = chunkToRender.getBlockState(pos); try { if (iblockstate.getBlock() .canRenderInLayer(iblockstate, layerToUpdate)) { Minecraft.getMinecraft().getBlockRendererDispatcher() .renderBlock(iblockstate, pos, chunkToRender.world, worldrenderer); } } catch (NullPointerException e) { System.out.println( "Something was null! LValkyrienSkiesBase/render/PhysRenderChunk#updateList"); } } } } tessellator.draw(); // worldrenderer.finishDrawing(); ForgeHooksClient.setRenderLayer(oldLayer); GlStateManager.popMatrix(); GL11.glEndList(); GL11.glPopMatrix(); worldrenderer.setTranslation(0, 0, 0); switch (layerToUpdate) { case CUTOUT: needsCutoutUpdate = false; break; case CUTOUT_MIPPED: needsCutoutMippedUpdate = false; break; case SOLID: needsSolidUpdate = false; break; case TRANSLUCENT: needsTranslucentUpdate = false; break; default: break; } }
Example #30
Source File: CoverSolarPanel.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void renderCover(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, Cuboid6 plateBox, BlockRenderLayer layer) { Textures.SOLAR_PANEL.renderSided(attachedSide, plateBox, renderState, pipeline, translation); }