public void renderAlchemicalChest(
      TileAlchemicalChest tileAlchemicalChest, double x, double y, double z, float tick) {

    ForgeDirection direction = null;

    if (tileAlchemicalChest.getWorldObj() != null) {
      direction = ForgeDirection.getOrientation(tileAlchemicalChest.getBlockMetadata());
    }

    ForgeHooksClient.bindTexture(Sprites.MODEL_ALCHEMICAL_CHEST, 0);
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
    GL11.glScalef(1.0F, -1.0F, -1.0F);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    short angle = 0;

    if (direction != null) {
      if (direction == ForgeDirection.NORTH) {
        angle = 180;
      } else if (direction == ForgeDirection.SOUTH) {
        angle = 0;
      } else if (direction == ForgeDirection.WEST) {
        angle = 90;
      } else if (direction == ForgeDirection.EAST) {
        angle = -90;
      }
    }

    GL11.glRotatef((float) angle, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    float adjustedLidAngle =
        tileAlchemicalChest.prevLidAngle
            + (tileAlchemicalChest.lidAngle - tileAlchemicalChest.prevLidAngle) * tick;
    adjustedLidAngle = 1.0F - adjustedLidAngle;
    adjustedLidAngle = 1.0F - adjustedLidAngle * adjustedLidAngle * adjustedLidAngle;
    this.modelChest.chestLid.rotateAngleX = -(adjustedLidAngle * (float) Math.PI / 2.0F);
    this.modelChest.renderAll();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  }
コード例 #2
0
  public ContainerAlchemicalChest(
      InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest) {
    this.tileAlchemicalChest = tileAlchemicalChest;
    tileAlchemicalChest.openChest();

    if (this.tileAlchemicalChest.getState() == 0) {
      chestInventoryRows = SMALL_CHEST_INVENTORY_ROWS;
      chestInventoryColumns = SMALL_CHEST_INVENTORY_COLUMNS;
    } else if (this.tileAlchemicalChest.getState() == 1) {
      chestInventoryRows = MEDIUM_CHEST_INVENTORY_ROWS;
      chestInventoryColumns = MEDIUM_CHEST_INVENTORY_COLUMNS;
    } else if (this.tileAlchemicalChest.getState() == 2) {
      chestInventoryRows = LARGE_CHEST_INVENTORY_ROWS;
      chestInventoryColumns = LARGE_CHEST_INVENTORY_COLUMNS;
    }

    // Add the Alchemical Chest slots to the container
    for (int chestRowIndex = 0; chestRowIndex < chestInventoryRows; ++chestRowIndex) {
      for (int chestColumnIndex = 0; chestColumnIndex < chestInventoryColumns; ++chestColumnIndex) {
        if (this.tileAlchemicalChest.getState() == 0) {
          this.addSlotToContainer(
              new Slot(
                  tileAlchemicalChest,
                  chestColumnIndex + chestRowIndex * chestInventoryColumns,
                  8 + chestColumnIndex * 18,
                  18 + chestRowIndex * 18));
        } else if (this.tileAlchemicalChest.getState() == 1) {
          this.addSlotToContainer(
              new Slot(
                  tileAlchemicalChest,
                  chestColumnIndex + chestRowIndex * chestInventoryColumns,
                  8 + chestColumnIndex * 18,
                  18 + chestRowIndex * 18));
        } else if (this.tileAlchemicalChest.getState() == 2) {
          this.addSlotToContainer(
              new Slot(
                  tileAlchemicalChest,
                  chestColumnIndex + chestRowIndex * chestInventoryColumns,
                  8 + chestColumnIndex * 18,
                  8 + chestRowIndex * 18));
        }
      }
    }

    // Add the player's inventory slots to the container
    for (int inventoryRowIndex = 0;
        inventoryRowIndex < PLAYER_INVENTORY_ROWS;
        ++inventoryRowIndex) {
      for (int inventoryColumnIndex = 0;
          inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS;
          ++inventoryColumnIndex) {
        if (this.tileAlchemicalChest.getState() == 0) {
          this.addSlotToContainer(
              new Slot(
                  inventoryPlayer,
                  inventoryColumnIndex + inventoryRowIndex * 9 + 9,
                  35 + inventoryColumnIndex * 18,
                  104 + inventoryRowIndex * 18));
        } else if (this.tileAlchemicalChest.getState() == 1) {
          this.addSlotToContainer(
              new Slot(
                  inventoryPlayer,
                  inventoryColumnIndex + inventoryRowIndex * 9 + 9,
                  35 + inventoryColumnIndex * 18,
                  158 + inventoryRowIndex * 18));
        } else if (this.tileAlchemicalChest.getState() == 2) {
          this.addSlotToContainer(
              new Slot(
                  inventoryPlayer,
                  inventoryColumnIndex + inventoryRowIndex * 9 + 9,
                  44 + inventoryColumnIndex * 18,
                  174 + inventoryRowIndex * 18));
        }
      }
    }

    // Add the player's action bar slots to the container
    for (int actionBarSlotIndex = 0;
        actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS;
        ++actionBarSlotIndex) {
      if (this.tileAlchemicalChest.getState() == 0) {
        this.addSlotToContainer(
            new Slot(inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 162));
      } else if (this.tileAlchemicalChest.getState() == 1) {
        this.addSlotToContainer(
            new Slot(inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 216));
      } else if (this.tileAlchemicalChest.getState() == 2) {
        this.addSlotToContainer(
            new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232));
      }
    }
  }
コード例 #3
0
 /** Callback for when the crafting gui is closed. */
 @Override
 public void onContainerClosed(EntityPlayer entityPlayer) {
   super.onContainerClosed(entityPlayer);
   tileAlchemicalChest.closeChest();
 }