Exemplo n.º 1
0
  @Override
  public void onUpdate() {
    super.onUpdate();

    if (getRunning()) run();
    else postRun();

    if (Config.useFuel && !worldObj.isRemote) {
      if (inventory.getStackInSlot(0) != null
          && TileEntityFurnace.isItemFuel(inventory.getStackInSlot(0))
          && (fuel.get() + TileEntityFurnace.getItemBurnTime(inventory.getStackInSlot(0)))
              <= Config.maxFuelLevel)
        if (inventory.getStackInSlot(0).getItem().equals(Items.lava_bucket)) {
          fuel.modify(TileEntityFurnace.getItemBurnTime(inventory.decrStackSize(0, 1)));
          inventory.setInventorySlotContents(0, new ItemStack(Items.bucket));
        } else {
          fuel.modify(TileEntityFurnace.getItemBurnTime(inventory.decrStackSize(0, 1)));
        }

      if (fuel.isDirty()) sync();
    }

    lastTickPosX = posX;
    lastTickPosY = posY;
    lastTickPosZ = posZ;

    posX += motionX;
    posY += motionY;
    posZ += motionZ;

    setPosition(posX, posY, posZ);

    if (getTimeSinceHit() > 0) setTimeSinceHit(getTimeSinceHit() - 1);
    if (getDamageTaken() > 0) setDamageTaken(getDamageTaken() - 1);
  }
Exemplo n.º 2
0
  private boolean breakBlock(BlockCoord coord) {
    Block block = worldObj.getBlock(coord.x, coord.y, coord.z);
    int blockMetadata = worldObj.getBlockMetadata(coord.x, coord.y, coord.z);

    if (block.equals(Blocks.obsidian)
        || block.equals(Blocks.bedrock)
        || block.equals(Blocks.lava)
        || block.equals(Blocks.flowing_lava)) {
      setRunning(false);
      setMotion(0, 0, 0);
    } else if (block.isBlockSolid(worldObj, coord.x, coord.y, coord.z, blockMetadata)) {
      if (!Config.destroyBlocks) {
        for (int i = 10; i < 37; ++i) { // runs through slots 10-36 (mined inventory)
          if (block.getItemDropped(blockMetadata, rand, 0) == null)
            break; // check for beds, doors...
          ItemStack blockStack =
              new ItemStack(
                  block.getItemDropped(blockMetadata, rand, 0),
                  block.quantityDropped(rand),
                  blockMetadata);
          ItemStack stackInSlot = inventory.getStackInSlot(i);
          if (blockStack.stackSize == 0) break;
          if (stackInSlot != null) {
            if (InventoryUtils.areMergeCandidates(blockStack, stackInSlot)) {
              if (InventoryUtils.tryMergeStacks(blockStack, stackInSlot)) break;
            }
          } else {
            inventory.setInventorySlotContents(i, blockStack);
            break;
          }
        }
      }
      return worldObj.setBlockToAir(coord.x, coord.y, coord.z);
    }

    return false;
  }