コード例 #1
0
  @Override
  public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) {
    modelBloodAltar.renderBloodAltar((TEAltar) tileEntity, d0, d1, d2);
    modelBloodAltar.renderBloodLevel((TEAltar) tileEntity, d0, d1, d2);

    if (tileEntity instanceof TEAltar) {
      TEAltar tileAltar = (TEAltar) tileEntity;
      GL11.glDisable(GL11.GL_LIGHTING);
      GL11.glDisable(GL11.GL_CULL_FACE);
      /** Render the ghost item inside of the Altar, slowly spinning */
      GL11.glPushMatrix();

      if (tileAltar.getStackInSlot(0) != null) {
        float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(0));
        float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
        EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorldObj());
        ghostEntityItem.hoverStart = 0.0F;
        ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(0));
        // translateGhostItemByOrientation(ghostEntityItem.getEntityItem(), d0, d1, d2,
        // ForgeDirection.DOWN);
        float displacement = 0.2F;

        if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) {
          GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F);
        } else {
          GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.6F, (float) d2 + 0.5F);
        }

        // GL11.glTranslatef((float) tileAltar.xCoord + 0.5F, (float) tileAltar.yCoord + 2.7F,
        // (float) tileAltar.zCoord + 0.5F);
        GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
        GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F);
        customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0);
      }

      GL11.glPopMatrix();
      GL11.glEnable(GL11.GL_CULL_FACE);
      GL11.glEnable(GL11.GL_LIGHTING);
    }
  }
コード例 #2
0
  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (!world.isRemote) {
      EnergyItems.checkAndSetItemOwner(stack, player);
      NBTTagCompound itemTag = stack.stackTagCompound;

      if (itemTag == null || itemTag.getString("ownerName").equals("")) return stack;

      String ownerName = itemTag.getString("ownerName");

      int currentEssence = EnergyItems.getCurrentEssence(ownerName);

      TileEntity te = Utils.getTargetTile(player);
      if (te != null && te instanceof TEAltar) {
        TEAltar altar = (TEAltar) te;
        float selfSacrifiseMultiplier = altar.getSelfSacrificeMultiplier() * 10;
        float sacrifiseMultiplier = altar.getSacrificeMultiplier() * 10;

        int sacrifise = (int) (500 + ((500 / 100) * sacrifiseMultiplier));
        int selfSacrifise = (int) (200 + ((200 / 100) * selfSacrifiseMultiplier));
        player.addChatComponentMessage(
            new ChatComponentText(
                EnumChatFormatting.RED
                    + "Stored: "
                    + EnumChatFormatting.GRAY
                    + altar.getCurrentBlood()
                    + "/"
                    + altar.getCapacity()));
        player.addChatComponentMessage(
            new ChatComponentText(
                EnumChatFormatting.RED + "Tier: " + EnumChatFormatting.GRAY + altar.getTier()));
        player.addChatComponentMessage(
            new ChatComponentText(
                EnumChatFormatting.RED
                    + "Self-Sacrifice: "
                    + EnumChatFormatting.GRAY
                    + selfSacrifise
                    + " LP"));
        player.addChatComponentMessage(
            new ChatComponentText(
                EnumChatFormatting.RED
                    + "Sacrifice: "
                    + EnumChatFormatting.GRAY
                    + sacrifise
                    + " LP"));

        if (altar.getStackInSlot(0) != null) {
          AltarRecipe recipe =
              AltarRecipeRegistry.getAltarRecipeForItemAndTier(
                  altar.getStackInSlot(0), altar.getTier());
          if (recipe != null && recipe.getResult() != null) {
            player.addChatComponentMessage(
                new ChatComponentText(
                    EnumChatFormatting.RED
                        + "Progress: "
                        + EnumChatFormatting.GRAY
                        + altar.getProgress()
                        + "/"
                        + recipe.getLiquidRequired()));
            player.addChatComponentMessage(
                new ChatComponentText(
                    EnumChatFormatting.RED
                        + "Output: "
                        + EnumChatFormatting.GRAY
                        + recipe.getResult().getDisplayName()));
          }

          if (altar.getStackInSlot(0).getItem() instanceof IBloodOrb) {
            IBloodOrb orb = (IBloodOrb) altar.getStackInSlot(0).getItem();
            float orbMultiplier = altar.getOrbMultiplier() * 2;
            int orbStorage =
                (int) (orb.getMaxEssence() + ((orb.getMaxEssence() / 100) * orbMultiplier));
            player.addChatComponentMessage(
                new ChatComponentText(
                    EnumChatFormatting.RED
                        + "Orb Storage: "
                        + EnumChatFormatting.GRAY
                        + orbStorage
                        + " LP"));
          }
        }
      } else {
        World worldSave = MinecraftServer.getServer().worldServers[0];
        if (worldSave != null) {
          LifeEssenceNetwork data = EssenceHelper.getLifeEssenceNetwork(ownerName, worldSave);
          if (data != null)
            player.addChatComponentMessage(
                new ChatComponentText(
                    EnumChatFormatting.RED
                        + "Network Essence: "
                        + EnumChatFormatting.GRAY
                        + currentEssence
                        + " LP"));
        }
      }
    }
    return stack;
  }