Exemplo n.º 1
0
  /** Sets state (open or closed). */
  public static void setState(TEBase TE, int state, boolean playSound) {
    int temp = BlockProperties.getMetadata(TE) & 0xffbf;
    temp |= state << 6;

    World world = TE.getWorldObj();

    if (!world.isRemote && playSound) {
      world.playAuxSFXAtEntity((EntityPlayer) null, 1003, TE.xCoord, TE.yCoord, TE.zCoord, 0);
    }

    BlockProperties.setMetadata(TE, temp);
  }
Exemplo n.º 2
0
  @Override
  /** Called upon block activation (right click on the block.) */
  protected void postOnBlockActivated(
      TEBase TE,
      EntityPlayer entityPlayer,
      int side,
      float hitX,
      float hitY,
      float hitZ,
      List<Boolean> altered,
      List<Boolean> decInv) {
    if (!Safe.isOpen(TE) && canPlayerActivate(TE, entityPlayer)) {

      TECarpentersSafe TE_safe = (TECarpentersSafe) TE;
      ItemStack itemStack = entityPlayer.getHeldItem();

      if (itemStack != null && itemStack.getItem().equals(Items.gold_ingot)) {
        if (!TE_safe.hasUpgrade()) {
          if (TE_safe.incSizeInventory()) {
            TE.getWorldObj().markBlockForUpdate(TE.xCoord, TE.yCoord, TE.zCoord);
            decInv.add(true);
            return;
          }
        }
      }

      if (!decInv.contains(true)) {
        entityPlayer.displayGUIChest((TECarpentersSafe) TE);
      }
    } else {
      ChatHandler.sendMessageToPlayer("message.block_lock.name", entityPlayer);
    }

    /*
     * Safe should always return true because it either warns the player
     * that it is locked, or it returns the GUI.
     */
    altered.add(true);
  }