public static boolean renderEntityItem( EntityItem entity, ItemStack item, float bobing, float rotation, Random random, TextureManager engine, RenderBlocks renderBlocks) { IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(item, ENTITY); if (customRenderer == null) { return false; } if (customRenderer.shouldUseRenderHelper(ENTITY, item, ENTITY_ROTATION)) { GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F); } if (!customRenderer.shouldUseRenderHelper(ENTITY, item, ENTITY_BOBBING)) { GL11.glTranslatef(0.0F, -bobing, 0.0F); } boolean is3D = customRenderer.shouldUseRenderHelper(ENTITY, item, BLOCK_3D); engine.func_110577_a( item.getItemSpriteNumber() == 0 ? TextureMap.field_110575_b : TextureMap.field_110576_c); Block block = (item.itemID < Block.blocksList.length ? Block.blocksList[item.itemID] : null); if (is3D || (block != null && RenderBlocks.renderItemIn3d(block.getRenderType()))) { int renderType = (block != null ? block.getRenderType() : 1); float scale = (renderType == 1 || renderType == 19 || renderType == 12 || renderType == 2 ? 0.5F : 0.25F); if (RenderItem.renderInFrame) { GL11.glScalef(1.25F, 1.25F, 1.25F); GL11.glTranslatef(0.0F, 0.05F, 0.0F); GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); } GL11.glScalef(scale, scale, scale); int size = item.stackSize; int count = (size > 40 ? 5 : (size > 20 ? 4 : (size > 5 ? 3 : (size > 1 ? 2 : 1)))); for (int j = 0; j < count; j++) { GL11.glPushMatrix(); if (j > 0) { GL11.glTranslatef( ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / scale, ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / scale, ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / scale); } customRenderer.renderItem(ENTITY, item, renderBlocks, entity); GL11.glPopMatrix(); } } else { GL11.glScalef(0.5F, 0.5F, 0.5F); customRenderer.renderItem(ENTITY, item, renderBlocks, entity); } return true; }
@Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { if (block.getRenderType() == BuildCraftCore.blockByEntityModel) { EntityRenderIndex index = new EntityRenderIndex(block, metadata); if (blockByEntityRenders.containsKey(index)) { blockByEntityRenders.get(index).inventoryRender(-0.5, -0.5, -0.5, 0, 0); } } else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) { Tessellator tessellator = Tessellator.instance; block.setBlockBounds( Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos); renderer.func_83018_a(block); block.setBlockBoundsForItemRender(); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1F, 0.0F); renderer.renderBottomFace( block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderer.renderTopFace( block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1F); renderer.renderEastFace( block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderer.renderWestFace( block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1F, 0.0F, 0.0F); renderer.renderNorthFace( block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderer.renderSouthFace( block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, metadata)); tessellator.draw(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } }
@Override public boolean renderWorldBlock( IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { if (block.getRenderType() == BuildCraftCore.blockByEntityModel) { // renderblocks.renderStandardBlock(block, i, j, k); } else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) { Minecraft.getMinecraft().renderEngine.bindTexture(BLOCK_TEXTURE); legacyPipeRender(renderer, world, x, y, z, block, modelId); } return true; }
@Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { if (block.getRenderType() == BuildCraftCore.blockByEntityModel) { EntityRenderIndex index = new EntityRenderIndex(block, metadata); if (blockByEntityRenders.containsKey(index)) { blockByEntityRenders.get(index).inventoryRender(-0.5, -0.5, -0.5, 0, 0); } } else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) { Tessellator tessellator = Tessellator.instance; block.setBlockBounds( CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS); renderer.setRenderBoundsFromBlock(block); block.setBlockBoundsForItemRender(); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1F, 0.0F); renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1F); renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1F, 0.0F, 0.0F); renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); tessellator.draw(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } }
/** * Renders the entity shadows at the position, shadow alpha and partialTickTime. Args: entity, x, * y, z, shadowAlpha, partialTickTime */ private void renderShadow( Entity entityIn, double x, double y, double z, float shadowAlpha, float partialTicks) { GlStateManager.enableBlend(); GlStateManager.blendFunc(770, 771); this.renderManager.renderEngine.bindTexture(shadowTextures); World world = this.getWorldFromRenderManager(); GlStateManager.depthMask(false); float f = this.shadowSize; if (entityIn instanceof EntityLiving) { EntityLiving entityliving = (EntityLiving) entityIn; f *= entityliving.getRenderSizeModifier(); if (entityliving.isChild()) { f *= 0.5F; } } double d5 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks; double d0 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks; double d1 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks; int i = MathHelper.floor_double(d5 - (double) f); int j = MathHelper.floor_double(d5 + (double) f); int k = MathHelper.floor_double(d0 - (double) f); int l = MathHelper.floor_double(d0); int i1 = MathHelper.floor_double(d1 - (double) f); int j1 = MathHelper.floor_double(d1 + (double) f); double d2 = x - d5; double d3 = y - d0; double d4 = z - d1; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); for (BlockPos blockpos : BlockPos.getAllInBoxMutable(new BlockPos(i, k, i1), new BlockPos(j, l, j1))) { Block block = world.getBlockState(blockpos.down()).getBlock(); if (block.getRenderType() != -1 && world.getLightFromNeighbors(blockpos) > 3) { this.func_180549_a(block, x, y, z, blockpos, shadowAlpha, f, d2, d3, d4); } } tessellator.draw(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.disableBlend(); GlStateManager.depthMask(true); }
@Override public boolean isValidPaintSource(ItemStack paintSource) { if (paintSource == null) { return false; } Block block = Util.getBlockFromItemId(paintSource); if (block == null || block instanceof IPaintedBlock) { return false; } if (PaintSourceValidator.instance.isBlacklisted(paintSource)) { return false; } if (PaintSourceValidator.instance.isWhitelisted(paintSource)) { return true; } if (!Config.allowTileEntitiesAsPaintSource && block instanceof ITileEntityProvider) { return false; } if (block == EnderIO.blockFusedQuartz && paintSource.getItemDamage() < 2) { return true; } return block.getRenderType() == 0 || block.isOpaqueCube() || block.isNormalCube(); }
/** Will update this chunk renderer */ public void updateRenderer(EntityLivingBase p_147892_1_) { if (this.needsUpdate) { this.needsUpdate = false; int var2 = this.posX; int var3 = this.posY; int var4 = this.posZ; int var5 = this.posX + 16; int var6 = this.posY + 16; int var7 = this.posZ + 16; for (int var8 = 0; var8 < 2; ++var8) { this.skipRenderPass[var8] = true; } Chunk.isLit = false; HashSet var26 = new HashSet(); var26.addAll(this.tileEntityRenderers); this.tileEntityRenderers.clear(); Minecraft var9 = Minecraft.getMinecraft(); EntityLivingBase var10 = var9.renderViewEntity; int var11 = MathHelper.floor_double(var10.posX); int var12 = MathHelper.floor_double(var10.posY); int var13 = MathHelper.floor_double(var10.posZ); byte var14 = 1; ChunkCache var15 = new ChunkCache( this.worldObj, var2 - var14, var3 - var14, var4 - var14, var5 + var14, var6 + var14, var7 + var14, var14); if (!var15.extendedLevelsInChunkCache()) { ++chunksUpdated; RenderBlocks var16 = new RenderBlocks(var15); this.bytesDrawn = 0; this.vertexState = null; for (int var17 = 0; var17 < 2; ++var17) { boolean var18 = false; boolean var19 = false; boolean var20 = false; for (int var21 = var3; var21 < var6; ++var21) { for (int var22 = var4; var22 < var7; ++var22) { for (int var23 = var2; var23 < var5; ++var23) { Block var24 = var15.getBlock(var23, var21, var22); if (var24.getMaterial() != Material.air) { if (!var20) { var20 = true; this.preRenderBlocks(var17); } if (var17 == 0 && var24.hasTileEntity()) { TileEntity var25 = var15.getTileEntity(var23, var21, var22); if (TileEntityRendererDispatcher.instance.hasSpecialRenderer(var25)) { this.tileEntityRenderers.add(var25); } } int var28 = var24.getRenderBlockPass(); if (var28 > var17) { var18 = true; } else if (var28 == var17) { var19 |= var16.renderBlockByRenderType(var24, var23, var21, var22); if (var24.getRenderType() == 0 && var23 == var11 && var21 == var12 && var22 == var13) { var16.setRenderFromInside(true); var16.setRenderAllFaces(true); var16.renderBlockByRenderType(var24, var23, var21, var22); var16.setRenderFromInside(false); var16.setRenderAllFaces(false); } } } } } } if (var19) { this.skipRenderPass[var17] = false; } if (var20) { this.postRenderBlocks(var17, p_147892_1_); } else { var19 = false; } if (!var18) { break; } } } HashSet var27 = new HashSet(); var27.addAll(this.tileEntityRenderers); var27.removeAll(var26); this.tileEntities.addAll(var27); var26.removeAll(this.tileEntityRenderers); this.tileEntities.removeAll(var26); this.isChunkLit = Chunk.isLit; this.isInitialized = true; } }
private void pipeFacadeRenderer( RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) { float zFightOffset = 1F / 4096F; float[][] zeroState = new float[3][2]; // X START - END zeroState[0][0] = 0.0F - zFightOffset / 2; zeroState[0][1] = 1.0F + zFightOffset / 2; // Y START - END zeroState[1][0] = 0.0F - zFightOffset; zeroState[1][1] = facadeThickness; // Z START - END zeroState[2][0] = 0.0F; zeroState[2][1] = 1.0F; for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (state.facadeMatrix.getFacadeBlockId(direction) != 0) { Block renderBlock = Block.blocksList[state.facadeMatrix.getFacadeBlockId(direction)]; int renderMeta = state.facadeMatrix.getFacadeMetaId(direction); state.currentTexture = renderBlock.getIcon(direction.ordinal(), renderMeta); if (renderBlock.getRenderType() == 31) { if ((renderMeta & 12) == 4) { renderblocks.uvRotateEast = 1; renderblocks.uvRotateWest = 1; renderblocks.uvRotateTop = 1; renderblocks.uvRotateBottom = 1; } else if ((renderMeta & 12) == 8) { renderblocks.uvRotateSouth = 1; renderblocks.uvRotateNorth = 1; } } // Hollow facade if (state.pipeConnectionMatrix.isConnected(direction)) { float[][] rotated = deepClone(zeroState); rotated[2][0] = 0.0F; rotated[2][1] = Utils.pipeMinPos; rotated[1][0] -= zFightOffset / 2; transform(rotated, direction); block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); rotated = deepClone(zeroState); rotated[2][0] = Utils.pipeMaxPos; rotated[1][0] -= zFightOffset / 2; transform(rotated, direction); block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); rotated = deepClone(zeroState); rotated[0][0] = 0.0F; rotated[0][1] = Utils.pipeMinPos; rotated[1][1] -= zFightOffset; transform(rotated, direction); block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); rotated = deepClone(zeroState); rotated[0][0] = Utils.pipeMaxPos; rotated[0][1] = 1F; rotated[1][1] -= zFightOffset; transform(rotated, direction); block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); } else { // Solid facade float[][] rotated = deepClone(zeroState); transform(rotated, direction); block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); } if (renderBlock.getRenderType() == 31) { renderblocks.uvRotateSouth = 0; renderblocks.uvRotateEast = 0; renderblocks.uvRotateWest = 0; renderblocks.uvRotateNorth = 0; renderblocks.uvRotateTop = 0; renderblocks.uvRotateBottom = 0; } } } // X START - END zeroState[0][0] = Utils.pipeMinPos; zeroState[0][1] = Utils.pipeMaxPos; // Y START - END zeroState[1][0] = facadeThickness; zeroState[1][1] = Utils.pipeMinPos; // Z START - END zeroState[2][0] = Utils.pipeMinPos; zeroState[2][1] = Utils.pipeMaxPos; state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon( PipeIconProvider.PipeStructureCobblestone); // Structure Pipe for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) { float[][] rotated = deepClone(zeroState); transform(rotated, direction); block.setBlockBounds( rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); } } }
public static void renderItem(EntityLivingBase entity, ItemStack itemStack, int renderPass) { TextureManager texturemanager = FMLClientHandler.instance().getClient().getTextureManager(); Item item = itemStack.getItem(); Block block = Block.getBlockFromItem(item); GL11.glPushMatrix(); if (itemStack.getItemSpriteNumber() == 0 && item instanceof ItemBlock && RenderBlocks.renderItemIn3d(block.getRenderType())) { texturemanager.bindTexture(texturemanager.getResourceLocation(0)); if (itemStack != null && block != null && block.getRenderBlockPass() != 0) { GL11.glDepthMask(false); RenderHelper.BLOCK_RENDERER.renderBlockAsItem(block, itemStack.getItemDamage(), 1.0F); GL11.glDepthMask(true); } else { RenderHelper.BLOCK_RENDERER.renderBlockAsItem(block, itemStack.getItemDamage(), 1.0F); } } else { IIcon iicon = entity.getItemIcon(itemStack, renderPass); if (iicon == null) { GL11.glPopMatrix(); return; } texturemanager.bindTexture( texturemanager.getResourceLocation(itemStack.getItemSpriteNumber())); TextureUtil.func_152777_a(false, false, 1.0F); Tessellator tessellator = Tessellator.instance; float minU = iicon.getMinU(); float maxU = iicon.getMaxU(); float minV = iicon.getMinV(); float maxV = iicon.getMaxV(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef(0.0F, -0.3F, 0.0F); GL11.glScalef(1.5F, 1.5F, 1.5F); GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); ItemRenderer.renderItemIn2D( tessellator, maxU, minV, minU, maxV, iicon.getIconWidth(), iicon.getIconHeight(), 0.0625F); if (itemStack.hasEffect(renderPass)) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); texturemanager.bindTexture(RenderHelper.RES_ITEM_GLINT); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(768, 1, 1, 0); GL11.glColor4f(0.38F, 0.19F, 0.608F, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); GL11.glScalef(0.125F, 0.125F, 0.125F); float animOffset = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F; GL11.glTranslatef(animOffset, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(0.125F, 0.125F, 0.125F); animOffset = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; GL11.glTranslatef(-animOffset, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); texturemanager.bindTexture( texturemanager.getResourceLocation(itemStack.getItemSpriteNumber())); TextureUtil.func_147945_b(); } if (itemStack != null && block != null && block.getRenderBlockPass() != 0) { GL11.glDisable(GL11.GL_BLEND); } GL11.glPopMatrix(); }