コード例 #1
0
  @Override
  protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
    NewDimData dimension;
    DungeonHelper dungeonHelper = DungeonHelper.instance();

    if (command.length > 1) {
      return DDCommandResult.TOO_MANY_ARGUMENTS;
    }

    DimLink link;
    DungeonData result;
    int x = MathHelper.floor_double(sender.posX);
    int y = MathHelper.floor_double(sender.posY);
    int z = MathHelper.floor_double(sender.posZ);
    int orientation =
        MathHelper.floor_double((sender.rotationYaw + 180.0F) * 4.0F / 360.0F - 0.5D) & 3;

    if (command.length == 0) {
      dimension = PocketManager.getDimensionData(sender.worldObj);
      link = dimension.createLink(x, y + 1, z, LinkType.DUNGEON, orientation);

      sender.worldObj.setBlock(x, y + 1, z, mod_pocketDim.blockRift, 0, 3);
      sendChat(sender, "Created a rift to a random dungeon.");
    } else {
      result = getRandomDungeonByPartialName(command[0], dungeonHelper.getRegisteredDungeons());
      if (result == null) {
        result = getRandomDungeonByPartialName(command[0], dungeonHelper.getUntaggedDungeons());
      }

      // Check if we found any matches
      if (result != null) {
        dimension = PocketManager.getDimensionData(sender.worldObj);
        link = dimension.createLink(x, y + 1, z, LinkType.DUNGEON, orientation);

        if (PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, result)) {
          // Create a rift to our selected dungeon and notify the player
          sender.worldObj.setBlock(x, y + 1, z, mod_pocketDim.blockRift, 0, 3);
          sendChat(
              sender,
              "Created a rift to \""
                  + result.schematicName()
                  + "\" dungeon (Dimension ID = "
                  + link.destination().getDimension()
                  + ").");
        } else {
          // Dungeon generation failed somehow. Notify the user and remove the useless link.
          dimension.deleteLink(link);
          sendChat(sender, "Dungeon generation failed unexpectedly!");
        }
      } else {
        // No matches!
        return new DDCommandResult(
            "Error: The specified dungeon was not found. Use 'list' to see a list of the available dungeons.");
      }
    }
    return DDCommandResult.SUCCESS;
  }
コード例 #2
0
ファイル: itemRiftRemover.java プロジェクト: Jaitsu/DimDoors
  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    // We invoke PlayerControllerMP.onPlayerRightClick() from here so that Minecraft
    // will invoke onItemUseFirst() on the client side. We'll tell it to pass the
    // request to the server, which will make sure that rift-related changes are
    // reflected on the server.

    if (!world.isRemote) {
      return stack;
    }

    MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
    if (hit != null) {
      int hx = hit.blockX;
      int hy = hit.blockY;
      int hz = hit.blockZ;
      NewDimData dimension = PocketManager.createDimensionData(world);
      DimLink link = dimension.getLink(hx, hy, hz);
      if (world.getBlock(hx, hy, hz) == mod_pocketDim.blockRift
          && link != null
          && player.canPlayerEdit(hx, hy, hz, hit.sideHit, stack)) {
        // Invoke onPlayerRightClick()
        FMLClientHandler.instance()
            .getClient()
            .playerController
            .onPlayerRightClick(player, world, stack, hx, hy, hz, hit.sideHit, hit.hitVec);
      }
    }
    return stack;
  }
コード例 #3
0
 @Override
 public void placeLink(World world, int x, int y, int z) {
   if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID) {
     NewDimData dimension = PocketManager.createDimensionData(world);
     DimLink link = dimension.getLink(x, y, z);
     if (link == null) {
       dimension.createLink(x, y, z, LinkType.POCKET, world.getBlockMetadata(x, y - 1, z));
     }
   }
 }
コード例 #4
0
ファイル: itemRiftRemover.java プロジェクト: Jaitsu/DimDoors
  @Override
  public boolean onItemUseFirst(
      ItemStack stack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float hitX,
      float hitY,
      float hitZ) {

    // We want to use onItemUseFirst() here so that this code will run on the server side,
    // so we don't need the client to send link-related updates to the server. Still,
    // check whether we have a rift in sight before passing the request over.

    // On integrated servers, the link won't be removed immediately because of the rift
    // removal animation. That means we'll have a chance to check for the link before
    // it's deleted. Otherwise the Rift Remover's durability wouldn't drop.
    MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
    if (hit != null) {
      x = hit.blockX;
      y = hit.blockY;
      z = hit.blockZ;

      NewDimData dimension = PocketManager.createDimensionData(world);
      DimLink link = dimension.getLink(x, y, z);
      if (world.getBlock(x, y, z) == mod_pocketDim.blockRift
          && link != null
          && player.canPlayerEdit(x, y, z, side, stack)) {
        // Tell the rift's tile entity to do its removal animation
        TileEntity tileEntity = world.getTileEntity(x, y, z);
        if (tileEntity != null && tileEntity instanceof TileEntityRift) {
          ((TileEntityRift) tileEntity).shouldClose = true;
          tileEntity.markDirty();
        } else if (!world.isRemote) {
          // Only set the block to air on the server side so that we don't
          // tell the server to remove the rift block before it can use the
          // Rift Remover. Otherwise, it won't know to reduce durability.
          world.setBlockToAir(x, y, z);
        }
        if (world.isRemote) {
          // Tell the server about this
          return false;
        } else {
          if (!player.capabilities.isCreativeMode) {
            stack.damageItem(1, player);
          }
          player.worldObj.playSoundAtEntity(player, mod_pocketDim.modid + ":riftClose", 0.8f, 1);
        }
      }
    }
    return true;
  }