示例#1
0
  /**
   * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses
   * this to count ticks and creates a new spawn inside its implementation.
   */
  public void updateEntity() {
    super.updateEntity();

    if (!CoreLib.isClient(this.worldObj)) {
      int var1 = 0;
      int var2 = 0;
      int var3 = 0;
      int var4 = 0;
      this.cacheCon();

      for (int var5 = 0; var5 < 6; ++var5) {
        if ((this.ConCache & 1 << var5) != 0) {
          WorldCoord var6 = new WorldCoord(this);
          var6.step(var5);
          Integer var7 = PipeLib.getPressure(this.worldObj, var6, var5 ^ 1);

          if (var7 != null) {
            var3 = Math.min(var7.intValue(), var3);
            var4 = Math.max(var7.intValue(), var4);
            var1 += var7.intValue();
            ++var2;
          }
        }
      }

      if (var2 == 0) {
        this.Pressure = 0;
      } else {
        if (var3 < 0) {
          ++var3;
        }

        if (var4 > 0) {
          --var4;
        }

        this.Pressure = Math.max(var3, Math.min(var4, var1 / var2 + Integer.signum(var1)));
      }

      PipeLib.movePipeLiquid(this.worldObj, this, new WorldCoord(this), this.ConCache);
      this.dirtyBlock();

      if (!CoreLib.isClient(this.worldObj) && (this.worldObj.getWorldTime() & 16L) == 0L) {
        this.sendItemUpdate();
      }
    }
  }
  public boolean onItemUseFirst(
      ItemStack var1,
      EntityPlayer var2,
      World var3,
      int var4,
      int var5,
      int var6,
      int var7,
      float var8,
      float var9,
      float var10) {
    if (CoreLib.isClient(var3)) {
      return false;
    } else {
      boolean var11 = false;

      if (var2 != null && var2.isSneaking()) {
        var11 = true;
      }

      int var12 = var3.getBlockId(var4, var5, var6);
      int var13 = var3.getBlockMetadata(var4, var5, var6);

      if (var12 != Block.redstoneRepeaterIdle.blockID
          && var12 != Block.redstoneRepeaterActive.blockID) {
        if (var12 == Block.dispenser.blockID) {
          var13 = var13 & 3 ^ var13 >> 2;
          var13 += 2;
          var3.setBlock(var4, var5, var6, var13);
          var1.damageItem(1, var2);
          return true;
        } else if (var12 != Block.pistonBase.blockID && var12 != Block.pistonStickyBase.blockID) {
          IRotatable var14 =
              (IRotatable) CoreLib.getTileEntity(var3, var4, var5, var6, IRotatable.class);

          if (var14 == null) {
            return false;
          } else {
            MovingObjectPosition var15 = CoreLib.retraceBlock(var3, var2, var4, var5, var6);

            if (var15 == null) {
              return false;
            } else {
              int var16 = var14.getPartMaxRotation(var15.subHit, var11);

              if (var16 == 0) {
                return false;
              } else {
                int var17 = var14.getPartRotation(var15.subHit, var11);
                ++var17;

                if (var17 > var16) {
                  var17 = 0;
                }

                var14.setPartRotation(var15.subHit, var11, var17);
                var1.damageItem(1, var2);
                return true;
              }
            }
          }
        } else {
          ++var13;

          if (var13 > 5) {
            var13 = 0;
          }

          var3.setBlock(var4, var5, var6, var13);
          var1.damageItem(1, var2);
          return true;
        }
      } else {
        var3.setBlock(var4, var5, var6, var13 & 12 | var13 + 1 & 3);
        var1.damageItem(1, var2);
        return true;
      }
    }
  }