コード例 #1
0
  @Override
  public void doRender(
      EntityPrimedCharge entity,
      double x,
      double y,
      double z,
      float p_76986_8_,
      float partialTicks) {

    BlockRendererDispatcher blockrendererdispatcher =
        Minecraft.getMinecraft().getBlockRendererDispatcher();
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
    float f2;

    if ((float) entity.fuse - partialTicks + 1.0F < 10.0F) {
      f2 = 1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 10.0F;
      f2 = MathHelper.clamp_float(f2, 0.0F, 1.0F);
      f2 *= f2;
      f2 *= f2;
      float f3 = 1.0F + f2 * 0.3F;
      GlStateManager.scale(f3, f3, f3);
    }

    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(
        entity.getBlock().getDefaultState(), entity.getBrightness(partialTicks));
    GlStateManager.translate(0.0F, 0.0F, 1.0F);

    if (entity.fuse / 5 % 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(entity.getBlock().getDefaultState(), 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.enableTexture2D();
    }

    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, p_76986_8_, partialTicks);
  }
コード例 #2
0
  // RenderGlobal.drawBlockDamageTexture
  public void drawBlockDamageTexture(
      Tessellator tessellatorIn,
      WorldRenderer worldRendererIn,
      Entity entityIn,
      float partialTicks,
      World world,
      List<BlockPos> blocks) {
    double d0 =
        entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
    double d1 =
        entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
    double d2 =
        entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;

    TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
    int progress =
        (int) (Minecraft.getMinecraft().playerController.curBlockDamageMP * 10f) - 1; // 0-10

    if (progress < 0) return;

    renderEngine.bindTexture(TextureMap.locationBlocksTexture);
    // preRenderDamagedBlocks BEGIN
    GlStateManager.tryBlendFuncSeparate(774, 768, 1, 0);
    GlStateManager.enableBlend();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F);
    GlStateManager.doPolygonOffset(-3.0F, -3.0F);
    GlStateManager.enablePolygonOffset();
    GlStateManager.alphaFunc(516, 0.1F);
    GlStateManager.enableAlpha();
    GlStateManager.pushMatrix();
    // preRenderDamagedBlocks END

    worldRendererIn.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    worldRendererIn.setTranslation(-d0, -d1, -d2);
    worldRendererIn.markDirty();

    for (BlockPos blockpos : blocks) {
      double d3 = (double) blockpos.getX() - d0;
      double d4 = (double) blockpos.getY() - d1;
      double d5 = (double) blockpos.getZ() - d2;
      Block block = world.getBlockState(blockpos).getBlock();
      TileEntity te = world.getTileEntity(blockpos);
      boolean hasBreak =
          block instanceof BlockChest
              || block instanceof BlockEnderChest
              || block instanceof BlockSign
              || block instanceof BlockSkull;
      if (!hasBreak) hasBreak = te != null && te.canRenderBreaking();

      if (!hasBreak) {
        IBlockState iblockstate = world.getBlockState(blockpos);

        if (iblockstate.getBlock().getMaterial() != Material.air) {
          TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[progress];
          BlockRendererDispatcher blockrendererdispatcher =
              Minecraft.getMinecraft().getBlockRendererDispatcher();
          blockrendererdispatcher.renderBlockDamage(
              iblockstate, blockpos, textureatlassprite, world);
        }
      }
    }

    tessellatorIn.draw();
    worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D);
    // postRenderDamagedBlocks BEGIN
    GlStateManager.disableAlpha();
    GlStateManager.doPolygonOffset(0.0F, 0.0F);
    GlStateManager.disablePolygonOffset();
    GlStateManager.enableAlpha();
    GlStateManager.depthMask(true);
    GlStateManager.popMatrix();
    // postRenderDamagedBlocks END
  }