@Override
 public void onBlockPlaced(World world, int i, int j, int k, int l) {
   world.setBlockWithNotify(i, j + 1, k, mod_RocketScience.blockWarheadId);
   world.setBlockMetadata(i, j + 1, k, world.getBlockMetadata(i, j, k));
 }
示例#2
0
  @Override
  public boolean onBlockActivated(
      World world,
      int i,
      int j,
      int k,
      EntityPlayer entityplayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    // Drop through if the player is sneaking
    if (entityplayer.isSneaking()) return false;

    Item equipped =
        entityplayer.getCurrentEquippedItem() != null
            ? entityplayer.getCurrentEquippedItem().getItem()
            : null;
    if (equipped instanceof IToolWrench
        && ((IToolWrench) equipped).canWrench(entityplayer, i, j, k)) {

      int meta = world.getBlockMetadata(i, j, k);

      switch (ForgeDirection.values()[meta]) {
        case WEST:
          world.setBlockMetadata(i, j, k, ForgeDirection.SOUTH.ordinal());
          break;
        case EAST:
          world.setBlockMetadata(i, j, k, ForgeDirection.NORTH.ordinal());
          break;
        case NORTH:
          world.setBlockMetadata(i, j, k, ForgeDirection.WEST.ordinal());
          break;
        case SOUTH:
        default:
          world.setBlockMetadata(i, j, k, ForgeDirection.EAST.ordinal());
          break;
      }
      ((IToolWrench) equipped).wrenchUsed(entityplayer, i, j, k);
      world.markBlockNeedsUpdate(i, j, k);
      return true;
    } else {

      LiquidStack liquid =
          LiquidManager.getLiquidForFilledItem(entityplayer.getCurrentEquippedItem());

      if (liquid != null) {
        int qty =
            ((TileRefinery) world.getBlockTileEntity(i, j, k))
                .fill(ForgeDirection.UNKNOWN, liquid, true);

        if (qty != 0 && !BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
          entityplayer.inventory.setInventorySlotContents(
              entityplayer.inventory.currentItem,
              Utils.consumeItem(entityplayer.inventory.getCurrentItem()));
        }

        return true;
      }
    }

    if (!CoreProxy.proxy.isRenderWorld(world))
      entityplayer.openGui(BuildCraftFactory.instance, GuiIds.REFINERY, world, i, j, k);

    return true;
  }
 protected void setMetadata(World world, int x, int y, int z, int metadata) {
   if (doBlockNotify) world.setBlockMetadataWithNotify(x, y, z, metadata);
   else if (world.blockExists(x, y, z) && world.getChunkFromBlockCoords(x, z).field_50025_o) {
     if (world.setBlockMetadata(x, y, z, metadata)) world.markBlockNeedsUpdate(x, y, z);
   } else world.setBlockMetadata(x, y, z, metadata);
 }