static void renderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite) { ICCBlockRenderer renderer = blockRendererList.get(state.getRenderType()); if (renderer != null) { state = state.getActualState(world, pos); //TODO This needs to be optimized, probably not the most efficient thing in the world.. BufferBuilder parent = Tessellator.getInstance().getBuffer(); BakingVertexBuffer buffer = BakingVertexBuffer.create(); buffer.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ()); buffer.begin(7, parent.getVertexFormat()); renderer.handleRenderBlockDamage(world, pos, state, sprite, buffer); buffer.finishDrawing(); buffer.setTranslation(0, 0, 0); BlockModelRenderer modelRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer(); modelRenderer.renderModel(world, new PerspectiveAwareBakedModel(buffer.bake(), TransformUtils.DEFAULT_BLOCK, new ModelProperties(true, true, null)), state, pos, parent, true); } }
private static void renderBackpack(IBackpack backpack, float ticks, boolean renderStraps) { ItemStack stack = backpack.getStack(); int color = ProxyClient.ITEM_COLOR.colorMultiplier(stack, 0); BlockModelRenderer renderer = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer(); Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); float r = (color >> 16 & 0xFF) / 255.0F; float g = (color >> 8 & 0xFF) / 255.0F; float b = (color & 0xFF) / 255.0F; renderModel(backpack, renderer, ticks, renderStraps, r, g, b, false); if (stack.isItemEnchanted()) renderEnchanted(backpack, renderer, ticks, renderStraps); }
private static void renderModel(IBackpack backpack, BlockModelRenderer renderer, float ticks, boolean renderStraps, float r, float g, float b, boolean useEnch) { IBakedModel baseModel = (useEnch ? ProxyClient.MODEL_BACKPACK_ENCH : ProxyClient.MODEL_BACKPACK); renderer.renderModelBrightnessColor(baseModel, 1.0F, r, g, b); if (renderStraps) renderer.renderModelBrightnessColor(ProxyClient.MODEL_BACKPACK_STRAPS, 1.0F, r, g, b); float lidAngle = 0.0F; IBackpackType type = backpack.getType(); if (type != null) { int lidTicks = backpack.getLidTicks(); int prevLidTicks = backpack.getPrevLidTicks(); lidAngle = type.getLidAngle(lidTicks, prevLidTicks, ticks % 1); } // FIXME: Allow for custom, adjustable lid position. float lidYOffset = 9 / 16.0F; float lidZOffset = 5 / 16.0F; GlStateManager.pushMatrix(); GlStateManager.translate(0.0F, lidYOffset, lidZOffset); GlStateManager.rotate(lidAngle, -1.0F, 0.0F, 0.0F); GlStateManager.translate(0.0F, -lidYOffset, -lidZOffset); IBakedModel topModel = (useEnch ? ProxyClient.MODEL_BACKPACK_ENCH_TOP : ProxyClient.MODEL_BACKPACK_TOP); renderer.renderModelBrightnessColor(topModel, 1.0F, r, g, b); GlStateManager.popMatrix(); }
public BlockModelRenderer.AmbientOcclusionFace getAoFace() { return this.aoFace; }
@Override public BlockModelRenderer getBlockModelRenderer() { return parentDispatcher.getBlockModelRenderer(); }
private static void renderEnchanted(IBackpack backpack, BlockModelRenderer renderer, float ticks, boolean renderStraps) { Minecraft mc = Minecraft.getMinecraft(); float glintStrength = WearableBackpacks.CONFIG.cosmetic.enchantEffectOpacity.get().floatValue(); if (glintStrength <= 0) return; float glintScale = 1.5F; float animProgress = ticks / 10; int color = IntermodUtils.getRuneColor(backpack.getStack()); float r = (color >> 16 & 0xFF) / 255.0F * glintStrength; float g = (color >> 8 & 0xFF) / 255.0F * glintStrength; float b = (color & 0xFF) / 255.0F * glintStrength; mc.getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT); mc.entityRenderer.setupFogColor(true); GlStateManager.disableLighting(); GlStateManager.depthMask(false); GlStateManager.depthFunc(GL11.GL_EQUAL); GlStateManager.enableBlend(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE); for (int i = 0; i < 2; ++i) { GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.loadIdentity(); GlStateManager.scale(glintScale, glintScale, glintScale); GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(0.0F, animProgress * (0.001F + i * 0.003F) * 20.0F, 0.0F); GlStateManager.matrixMode(GL11.GL_MODELVIEW); renderModel(backpack, renderer, ticks, renderStraps, r, g, b, true); } GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.loadIdentity(); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.disableBlend(); GlStateManager.depthFunc(GL11.GL_LEQUAL); GlStateManager.depthMask(true); GlStateManager.enableLighting(); mc.entityRenderer.setupFogColor(false); }