예제 #1
0
  /** allows items to add custom lines of information to the mouseover description */
  @Override
  public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {

    if (NBTHelper.getBoolean(itemStack, "isSet")) {
      list.remove("Right Click to examine text");
      // String owner = NBTHelper.getString(itemStack, "owner");
      // String command = NBTHelper.getString(itemStack, "command");

      list.add("Owner: " + NBTHelper.getString(itemStack, "owner"));
      if (NBTHelper.getString(itemStack, "owner").equals(player.getDisplayName())) {
        list.add(EnumChatFormatting.GREEN + "Command:" + NBTHelper.getString(itemStack, "command"));
      } else {
        list.add(
            EnumChatFormatting.RED
                + "Command: "
                + EnumChatFormatting.OBFUSCATED
                + NBTHelper.getString(itemStack, "command"));
      }
    } else {
      list.add("Right Click to examine text");
    }
    /*
    String owner = itemStack.stackTagCompound.getString("owner");
    int code = itemStack.stackTagCompound.getInteger("code");
    list.add("owner: " + owner);
    if (owner.equals(player.username)) {
        list.add(EnumChatFormatting.GREEN + "code: " + code);
    } else {
        list.add(EnumChatFormatting.RED + "code: "
                + EnumChatFormatting.OBFUSCATED + code);
    }
    */

  }
예제 #2
0
  /** Returns true if the item can be used on the given entity, e.g. shears on sheep. */
  @Override
  public boolean itemInteractionForEntity(
      ItemStack itemStack, EntityPlayer entityPlayer, EntityLivingBase entity) {
    if (itemStack != null) {
      onItemRightClick(itemStack, entity.worldObj, entityPlayer);
      if (NBTHelper.getString(itemStack, "command") != null
          && NBTHelper.getString(itemStack, "command") == "/kill Entity") {
        if (entity != null && !entity.worldObj.isRemote) {
          ChatHelper.send(entityPlayer, "Attempting to damage entity: " + entity.toString());
          entity.attackEntityFrom(
              DamageSource.outOfWorld, Float.MAX_VALUE); // MAKE A NEW DAMAGE SOURCE
          // entity.setHealth(0.0F);
          // entity.setDead();
        }
      }
    }

    return true;
  }
예제 #3
0
  @Override
  public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) {
    LogHelper.info("CoolDown: " + coolDown);
    LogHelper.info("World.isRemote: " + world.isRemote);
    LogHelper.info("entityPlayer.worldObj.isRemote: " + entityPlayer.worldObj.isRemote);

    coolDown();

    if (entityPlayer.isSneaking()
        && entityPlayer.capabilities.isCreativeMode) // Change command in creative (MOVE THIS!)
    {
      NBTHelper.setInteger(itemStack, "commandID", NBTHelper.getInt(itemStack, "commandID") + 1);
      if (NBTHelper.getInt(itemStack, "commandID") > 4)
        NBTHelper.setInteger(itemStack, "commandID", 0);
    } else {
      if (!world.isRemote) {

        if (NBTHelper.getBoolean(itemStack, "isSet")) {
          LogHelper.info("Entered Function"); // DEBUG

          if (NBTHelper.getString(itemStack, "owner") == entityPlayer.getDisplayName()) {
            runCommand(itemStack, world, entityPlayer);
            ChatHelper.send(entityPlayer, "Command: " + NBTHelper.getString(itemStack, "command"));
            --itemStack.stackSize;
          } else {
            ChatHelper.send(entityPlayer, "You do not understand the symbols on the page.");
          }

        } else {
          NBTHelper.setBoolean(itemStack, "isSet", true);
          LogHelper.info("Entered Else"); // DEBUG
          ChatHelper.send(
              entityPlayer, EnumChatFormatting.BLUE + "The scroll reveals its true power!");
          NBTHelper.setBoolean(itemStack, "isSet", true);
          NBTHelper.setString(itemStack, "owner", entityPlayer.getDisplayName());
          NBTHelper.setString(itemStack, "command", getCommand(itemStack));
        }
      }
    }
    return itemStack;
  }