コード例 #1
0
  public static ItemStack chargeHunger(
      ItemStack stack, World world, EntityPlayer player, String tag) {

    if (!stack.hasTagCompound()) {
      stack.setTagCompound(new NBTTagCompound());
    }
    NBTTagCompound nbtData = stack.getTagCompound();
    if (nbtData == null) {
      stack.getTagCompound().setInteger(tag, 0);
    }
    int points = stack.getTagCompound().getInteger(tag);
    if (player.isSneaking()) {
      int hunger = player.getFoodStats().getFoodLevel();

      int usedpoints = 20 - hunger;

      if (!(hunger >= 20)) {
        if (points - usedpoints > 1) {
          points -= usedpoints;
          nbtData.setInteger(tag, points);
          player.getFoodStats().addStats(20, 2.0F);

        } else if (points - usedpoints < 1) {
          nbtData.setInteger(tag, 0);
          player.getFoodStats().addStats(points, 2.0F);
        }
      }
    } else if (!world.isRemote) {
      FontHelper.sendMessage(
          FontHelper.translate("points.hunger") + ": " + stack.getTagCompound().getInteger(tag),
          world,
          player);
    }
    return stack;
  }
コード例 #2
0
  public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
    if (tool == 4 || tool == 5) {
      if (stack.getTagCompound() == null) {
        stack.setTagCompound(new NBTTagCompound());
      }
      NBTTagCompound tag = stack.getTagCompound();
      this.currentCharge = tag.getInteger("CurrentCharge");
      if (this.currentCharge > 24) {

        return false;
      } else {

        return true;
      }
    } else {
      if (stack.getTagCompound() == null) {
        stack.setTagCompound(new NBTTagCompound());
      }
      NBTTagCompound tag = stack.getTagCompound();
      this.currentCharge = tag.getInteger("CurrentCharge");
      if (this.currentCharge > 48) {

        return false;
      } else {

        return true;
      }
    }
  }
コード例 #3
0
 public float checkTemps(IInventory inv) {
   float temp = 0;
   float[] temp1 = new float[inv.getSizeInventory()];
   for (int i = 0; i < inv.getSizeInventory(); i++) {
     ItemStack is = inv.getStackInSlot(i);
     if (is != null
         && is.hasTagCompound()
         && !is.getItem().getUnlocalizedName(is).contains("Clay")) {
       if (is.getTagCompound().hasKey("temperature")) {
         temp1[i] = is.getTagCompound().getFloat("temperature");
         if (temp1[i] < TFC_ItemHeat.getMeltingPoint(is)) {
           return (float) -1;
         }
       } else {
         return (float) -1;
       }
     } else if (is == null) {
       temp1[i] = -1;
     }
   }
   int temp2 = 0;
   for (int i = 0; i < inv.getSizeInventory(); i++) {
     if (temp1[i] >= 0) {
       temp += temp1[i];
       temp2++;
     }
   }
   if (temp2 > 0) {
     temp /= temp2;
   }
   return temp;
 }
コード例 #4
0
 /**
  * Current implementations of this method in child classes do not use the entry argument beside
  * ev. They just raise the damage on the stack.
  */
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLivingBase,
     EntityLivingBase par3EntityLivingBase) {
   if (tool == 4 || tool == 5) {
     NBTTagCompound tag = par1ItemStack.getTagCompound();
     this.currentCharge = tag.getInteger("CurrentCharge");
     if (this.currentCharge >= 24) {
       this.currentCharge -= 24;
       tag.setInteger("CurrentCharge", this.currentCharge);
       int extra = this.doModuleHitAdditions(par2EntityLivingBase, par3EntityLivingBase);
       par2EntityLivingBase.attackEntityFrom(
           DamageSource.magic, 20 + extra); // /2 because its steel not the best material
       return false;
     }
     return false;
   } else {
     NBTTagCompound tag = par1ItemStack.getTagCompound();
     this.currentCharge = tag.getInteger("CurrentCharge");
     if (this.currentCharge >= 48) {
       this.currentCharge -= 48;
       tag.setInteger("CurrentCharge", this.currentCharge);
       int extra = this.doModuleHitAdditions(par2EntityLivingBase, par3EntityLivingBase);
       par2EntityLivingBase.attackEntityFrom(
           DamageSource.magic, 12 + extra / 2); // /2 because its steel not the best material
       return false;
     }
     return false;
   }
 }
コード例 #5
0
  public static boolean useHunger(
      ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par, String tag) {
    if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());
    NBTTagCompound nbtData = stack.getTagCompound();
    if (nbtData == null) {
      stack.getTagCompound().setInteger(tag, 0);
    }
    int points = stack.getTagCompound().getInteger(tag);

    if (!player.canPlayerEdit(x, y, z, par, stack)) {
      return false;
    }
    Block block = world.getBlock(x, y, z);
    if (block == Calculator.amethystLeaf) {
      int meta = world.getBlockMetadata(x, y, z);
      if (meta > 2) {
        points += 1;
        if (!world.isRemote) {
          world.setBlockMetadataWithNotify(x, y, z, 0, 2);
        }

        nbtData.setInteger(tag, points);
      }
    }
    return true;
  }
コード例 #6
0
  @Override
  public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {

    EntityPlayer par3EntityPlayer = (EntityPlayer) player;

    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(packet.data));

    ItemStack par1ItemStack;
    try {
      par1ItemStack = Packet.readItemStack(dis);
      Entity entityID = par3EntityPlayer.worldObj.getEntityByID(dis.readInt());

      if (par1ItemStack.getTagCompound() == null)
        par1ItemStack.setTagCompound(new NBTTagCompound());

      if (par1ItemStack.getTagCompound().hasKey(ModBreeds.tag)
          && (!par1ItemStack.getTagCompound().getString(ModBreeds.tag).equals("none"))) {
        par3EntityPlayer.addChatMessage(
            "Pet trap still has a  " + EntityList.getEntityString(entityID) + " inside !");
      } else {
        NBTTagCompound nbt = new NBTTagCompound();
        nbt.setString(ModBreeds.tag, EntityList.getEntityString(entityID));
        par1ItemStack.setTagCompound(nbt);
        entityID.setDead();
        par3EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack);
        if (!par3EntityPlayer.worldObj.isRemote)
          par3EntityPlayer.addChatMessage(
              "Stored a " + EntityList.getEntityString(entityID) + " in the Animal trap");
      }

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #7
0
 @Override
 public void addInformation(
     ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
   if (par1ItemStack.getTagCompound() == null) {
     par1ItemStack.setTagCompound(new NBTTagCompound());
   }
   NBTTagCompound tag = par1ItemStack.getTagCompound();
   if (tag.getString("Creator") == "") {
     tag.setString("Creator", par2EntityPlayer.username);
   }
   this.currentCharge = tag.getInteger("CurrentCharge");
   tag.setInteger("MaxStorage", this.maxStorage);
   this.maxStorage = tag.getInteger("MaxStorage");
   tag.setInteger("RechargeRate", this.rechargeRatePerTick);
   this.rechargeRatePerTick = tag.getInteger("RechargeRate");
   dimensionTravel = tag.getInteger("Dimension");
   x = tag.getInteger("posX");
   y = tag.getInteger("posY");
   z = tag.getInteger("posZ");
   if (x != null && y != null && z != null) {
     par3List.add("X: " + x.toString());
     par3List.add("Y: " + y.toString());
     par3List.add("Z: " + z.toString());
     par3List.add("Dimension: " + dimensionTravel);
     par3List.add(this.currentCharge + "/" + this.maxStorage + " MyJ");
     par3List.add("Creator: " + tag.getString("Creator"));
   }
 }
コード例 #8
0
  @Override
  public boolean matches(InventoryCrafting inventoryCrafting, World world) {
    ItemStack biomeRadar = null;
    ItemStack biomeEssence = null;

    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        ItemStack itemstack = inventoryCrafting.getStackInRowAndColumn(j, i);

        if (itemstack != null) {
          if (itemstack.getItem() == BOPItemHelper.get("biomeFinder"))
            biomeRadar = itemstack.copy();
          else if (itemstack.getItem() == BOPItemHelper.get("biomeEssence"))
            biomeEssence = itemstack.copy();
        }
      }
    }

    if (biomeRadar != null && biomeEssence != null) {
      if (!biomeEssence.hasTagCompound() || !biomeEssence.getTagCompound().hasKey("biomeID"))
        return false;

      int biomeID = biomeEssence.getTagCompound().getInteger("biomeID");

      if (!biomeRadar.hasTagCompound()) biomeRadar.setTagCompound(new NBTTagCompound());

      biomeRadar.getTagCompound().setInteger("biomeIDToFind", biomeID);
      biomeRadar.getTagCompound().setBoolean("foundBiome", false);

      recipeOutput = biomeRadar;

      return true;
    } else return false;
  }
コード例 #9
0
 @Override
 public void onContainerClosed(EntityPlayer par1EntityPlayer) {
   super.onContainerClosed(par1EntityPlayer);
   if (par1EntityPlayer.worldObj.isRemote) {
     NBTTagCompound tag = new NBTTagCompound();
     tag.setString("EntityId", mobID);
     tag.setShort("MinSpawnDelay", (short) minSpawnDelay);
     tag.setShort("MaxSpawnDelay", (short) maxSpawnDelay);
     tag.setShort("SpawnCount", (short) spawnCount);
     tag.setShort("MaxNearbyEntities", (short) maxNearbyEntities);
     tag.setShort("RequiredPlayerRange", (short) activatingRangeFromPlayer);
     tag.setShort("SpawnRange", (short) spawnRange);
     sendDataToServer(tag);
     return;
   }
   ItemStack builderItem = player.inventory.getCurrentItem();
   if (builderItem == null
       || builderItem.getItem() == null
       || builderItem.getItem() != AWStructuresItemLoader.spawnerPlacer) {
     return;
   }
   if (!builderItem.hasTagCompound() || !builderItem.getTagCompound().hasKey("spawnData")) {
     builderItem.setTagInfo("spawnData", new NBTTagCompound());
   }
   NBTTagCompound tag = new NBTTagCompound();
   tag.setString("EntityId", mobID);
   tag.setShort("MinSpawnDelay", (short) minSpawnDelay);
   tag.setShort("MaxSpawnDelay", (short) maxSpawnDelay);
   tag.setShort("SpawnCount", (short) spawnCount);
   tag.setShort("MaxNearbyEntities", (short) maxNearbyEntities);
   tag.setShort("RequiredPlayerRange", (short) activatingRangeFromPlayer);
   tag.setShort("SpawnRange", (short) spawnRange);
   builderItem.getTagCompound().setTag("spawnData", tag);
 }
コード例 #10
0
  @Override
  public void addInformation(
      ItemStack stack,
      net.minecraft.entity.player.EntityPlayer player,
      java.util.List list,
      boolean bool) {

    if (!stack.hasTagCompound()) {
      list.add("Unprogrammed");
    } else if (!hasValidDimension(stack)) {
      list.add(ChatFormatting.RED + "Programming Failed");
    } else {
      if (stack.getItemDamage() == 0) {
        String unknown = ChatFormatting.YELLOW + "???";
        String dimName = stack.getTagCompound().getString(dimensionNameIdentifier);

        list.add("Planet Name: " + ChatFormatting.DARK_GREEN + dimName);

        super.addInformation(stack, player, list, bool);

        // list.add("Mass: " + unknown);
        // list.add("Atmosphere Density: " + unknown);
        // list.add("Distance From Star: " + unknown);

      } else { // Space station
        list.add(
            "Station Id: "
                + ChatFormatting.DARK_GREEN
                + stack.getTagCompound().getString(dimensionNameIdentifier));
      }
    }
  }
コード例 #11
0
  public static ItemStack getSmelt(ItemStack smelt, ItemStack itemStack) {
    if (!itemStack.hasTagCompound() || !itemStack.getTagCompound().getBoolean("Smelt"))
      return smelt;
    NBTTagList items =
        itemStack.getTagCompound().getTagList("ItemsSmelt", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < items.tagCount(); ++i) {
      NBTTagCompound item = /*(NBTTagCompound)*/ items.getCompoundTagAt(i);
      byte slot = item.getByte("Slot");

      // Just double-checking that the saved slot index is within our inventory array bounds
      if (slot >= 0 && slot < 9) {
        if (!itemStack.getTagCompound().getBoolean("Invert")
            && ItemStack.loadItemStackFromNBT(item).isItemEqual(smelt))
          return FurnaceRecipes.smelting().getSmeltingResult(smelt) != null
              ? getOneSmelt(smelt)
              : smelt;
        else if (itemStack.getTagCompound().getBoolean("Invert")
            && !ItemStack.loadItemStackFromNBT(item).isItemEqual(smelt))
          return FurnaceRecipes.smelting().getSmeltingResult(smelt) != null
              ? getOneSmelt(smelt)
              : smelt;
      }
    }
    return smelt;
  }
コード例 #12
0
  public static ItemStack chargeHealth(
      ItemStack stack, World world, EntityPlayer player, String tag) {
    if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());

    NBTTagCompound nbtData = stack.getTagCompound();
    if (nbtData == null) {
      stack.getTagCompound().setInteger(tag, 0);
    }
    if (player.isSneaking()) {
      int points = stack.getTagCompound().getInteger(tag);
      if (points != 0) {
        int current = (int) player.getHealth();
        int max = (int) player.getMaxHealth();
        if (current != max & (current < max)) {
          int used = max - current;
          if (!(points - used < 0)) {
            nbtData.setInteger(tag, points - used);
            player.setHealth(player.getMaxHealth());
          } else if ((points - used < 0)) {
            nbtData.setInteger(tag, 0);
            player.setHealth(nbtData.getInteger(tag) + current);
          }
        }
      }
    } else {
      FontHelper.sendMessage(
          FontHelper.translate("points.health") + ": " + stack.getTagCompound().getInteger(tag),
          world,
          player);
    }
    return stack;
  }
コード例 #13
0
  @SuppressWarnings("incomplete-switch")
  @Override
  public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
    if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());

    if (stack.getItemDamage() >= stack.getMaxDamage() - 2) {
      NBTTagCompound tag = stack.getTagCompound();
      tag.setBoolean("destroyed", true);
      stack.setTagCompound(tag);

      return;
    }

    switch (this.armorType) {
      case HEAD:
        if (stack.getTagCompound().getBoolean("respiration")
            && stack.getItemDamage() < stack.getMaxDamage() - 16)
          if (player.getAir() == 0) {
            player.setAir(150);
            stack.damageItem(16, player);
          }
        break;
      case LEGS:
      case FEET:
        if (stack.getTagCompound().getBoolean("fall")) {
          if (player.fallDistance > 0) player.fallDistance = 0;
        }
    }
  }
コード例 #14
0
ファイル: EntityItem.java プロジェクト: JelkeNelisse/Mod
  /**
   * Tries to merge this item with the item passed as the parameter. Returns true if successful.
   * Either this item or the other item will be removed from the world.
   */
  public boolean combineItems(EntityItem par1EntityItem) {
    if (par1EntityItem == this) {
      return false;
    } else if (par1EntityItem.isEntityAlive() && this.isEntityAlive()) {
      ItemStack var2 = this.func_92014_d();
      ItemStack var3 = par1EntityItem.func_92014_d();

      if (var3.getItem() != var2.getItem()) {
        return false;
      } else if (var3.hasTagCompound() ^ var2.hasTagCompound()) {
        return false;
      } else if (var3.hasTagCompound() && !var3.getTagCompound().equals(var2.getTagCompound())) {
        return false;
      } else if (var3.getItem().getHasSubtypes() && var3.getItemDamage() != var2.getItemDamage()) {
        return false;
      } else if (var3.stackSize < var2.stackSize) {
        return par1EntityItem.combineItems(this);
      } else if (var3.stackSize + var2.stackSize > var3.getMaxStackSize()) {
        return false;
      } else {
        var3.stackSize += var2.stackSize;
        par1EntityItem.delayBeforeCanPickup =
            Math.max(par1EntityItem.delayBeforeCanPickup, this.delayBeforeCanPickup);
        par1EntityItem.age = Math.min(par1EntityItem.age, this.age);
        par1EntityItem.func_92013_a(var3);
        this.setDead();
        return true;
      }
    } else {
      return false;
    }
  }
コード例 #15
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int idk,
      float what,
      float these,
      float are) {
    ItemStack playerItem = player.getCurrentEquippedItem();

    if (playerItem != null) {
      if (playerItem.getItem() instanceof TelepositionFocus) {
        SoulNetworkHandler.checkAndSetItemPlayer(playerItem, player);

        if (playerItem.getTagCompound() == null) {
          playerItem.setTagCompound(new NBTTagCompound());
        }

        NBTTagCompound itemTag = playerItem.getTagCompound();
        itemTag.setInteger("xCoord", x);
        itemTag.setInteger("yCoord", y);
        itemTag.setInteger("zCoord", z);
        itemTag.setInteger("dimensionId", world.provider.dimensionId);
        return true;
      }
    }
    player.openGui(AlchemicalWizardry.instance, 1, world, x, y, z);
    return true;
  }
コード例 #16
0
  public ItemStack onItemRightClick(ItemStack bowl, World world, EntityPlayer player) {

    ChatComponentTranslation chatComponent;

    if (!bowl.hasTagCompound()) {
      bowl.setTagCompound(new NBTTagCompound());
    }
    if (!bowl.getTagCompound().hasKey("amount")) {
      bowl.getTagCompound().setInteger("amount", 0);
    }

    if (bowl.stackTagCompound.getInteger("amount") >= 100 && world.isRemote == false) {
      chatComponent =
          (ChatComponentTranslation)
              new ChatComponentTranslation("This Crucible has been filled.")
                  .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED));
      player.addChatComponentMessage(chatComponent);
    }

    if (bowl.stackTagCompound.getInteger("amount") <= 100) {
      if (player.inventory.hasItem(matryoshikassinners_Items.VillagerSoul)) {
        player.inventory.consumeInventoryItem(matryoshikassinners_Items.VillagerSoul);
        int amount = bowl.stackTagCompound.getInteger("amount");
        bowl.stackTagCompound.setInteger("amount", amount + 6);
        return bowl;
      }
      if (player.inventory.hasItem(matryoshikassinners_Items.AnimalSoul)) {
        player.inventory.consumeInventoryItem(matryoshikassinners_Items.AnimalSoul);
        int amount = bowl.stackTagCompound.getInteger("amount");
        bowl.stackTagCompound.setInteger("amount", amount + 2);
        return bowl;
      }
      if (player.inventory.hasItem(matryoshikassinners_Items.BuffMobSoul)) {
        player.inventory.consumeInventoryItem(matryoshikassinners_Items.BuffMobSoul);
        int amount = bowl.stackTagCompound.getInteger("amount");
        bowl.stackTagCompound.setInteger("amount", amount + 4);
        return bowl;
      }
      if (player.inventory.hasItem(matryoshikassinners_Items.ZombieSoul)) {
        player.inventory.consumeInventoryItem(matryoshikassinners_Items.ZombieSoul);
        int amount = bowl.stackTagCompound.getInteger("amount");
        bowl.stackTagCompound.setInteger("amount", amount + 1);
        return bowl;

      } else {
        if (world.isRemote == false) {
          chatComponent =
              (ChatComponentTranslation)
                  new ChatComponentTranslation(
                          "Currently holds: "
                              + bowl.stackTagCompound.getInteger("amount")
                              + " Soul-fragments")
                      .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED));
          player.addChatComponentMessage(chatComponent);
        }
      }
    }

    return bowl;
  }
コード例 #17
0
 /**
  * @param stack to extract the info from
  * @return
  */
 public static ItemStructureSettings getSettingsFor(ItemStack stack) {
   ItemStructureSettings settings = new ItemStructureSettings();
   NBTTagCompound tag;
   if (stack.hasTagCompound() && stack.getTagCompound().hasKey("structData")) {
     tag = stack.getTagCompound().getCompoundTag("structData");
   } else {
     tag = new NBTTagCompound();
   }
   for (int i = 0; i < 4; i++) {
     settings.setKeys[i] = false;
   }
   if (tag.hasKey("pos1")) {
     settings.pos1.read(tag.getCompoundTag("pos1"));
     settings.setKeys[0] = true;
   }
   if (tag.hasKey("pos2")) {
     settings.pos2.read(tag.getCompoundTag("pos2"));
     settings.setKeys[1] = true;
   }
   if (tag.hasKey("buildKey")) {
     settings.key.read(tag.getCompoundTag("buildKey"));
     settings.setKeys[2] = true;
     settings.buildFace = tag.getCompoundTag("buildKey").getInteger("face");
   }
   if (tag.hasKey("name")) {
     settings.name = tag.getString("name");
     settings.setKeys[3] = true;
   }
   return settings;
 }
コード例 #18
0
 public boolean onBlockDestroyed(
     ItemStack par1ItemStack,
     World par2World,
     int par3,
     int par4,
     int par5,
     int par6,
     EntityLivingBase par7EntityLivingBase) {
   if (tool == 4) {
     if (par1ItemStack.getTagCompound() == null) {
       par1ItemStack.setTagCompound(new NBTTagCompound());
     }
     NBTTagCompound tag = par1ItemStack.getTagCompound();
     this.currentCharge = tag.getInteger("CurrentCharge");
     if (this.currentCharge >= 48) {
       this.currentCharge -= 48;
       tag.setInteger("CurrentCharge", this.currentCharge);
       return true;
     } else return false;
   } else {
     if (par1ItemStack.getTagCompound() == null) {
       par1ItemStack.setTagCompound(new NBTTagCompound());
     }
     NBTTagCompound tag = par1ItemStack.getTagCompound();
     this.currentCharge = tag.getInteger("CurrentCharge");
     if (this.currentCharge >= 24) {
       this.currentCharge -= 24;
       tag.setInteger("CurrentCharge", this.currentCharge);
       return true;
     } else return false;
   }
 }
コード例 #19
0
  public static NBTTagCompound getCompoundTag(ItemStack itemStack, String tagName) {
    initNBTTagCompound(itemStack);

    if (!itemStack.getTagCompound().hasKey(tagName)) {
      itemStack.getTagCompound().setTag(tagName, new NBTTagCompound());
    }
    return itemStack.getTagCompound().getCompoundTag(tagName);
  }
コード例 #20
0
 public static NBTTagCompound getItemStackTag(ItemStack stack) {
   NBTTagCompound cmp = stack.getTagCompound();
   if (cmp == null) {
     stack.setTagCompound(new NBTTagCompound());
     cmp = stack.getTagCompound();
   }
   return cmp;
 }
コード例 #21
0
  @Override
  public boolean hasEffect(ItemStack itemStack) {
    if (itemStack.getTagCompound() == null) {
      itemStack.setTagCompound(new NBTTagCompound());
    }

    return hasEffect || itemStack.getTagCompound().getBoolean("hasEffect");
  }
コード例 #22
0
 public void setDefaultInfo(ItemStack itemStack, String info) {
   if (itemStack.getTagCompound() == null) {
     itemStack.setTagCompound(new NBTTagCompound());
   }
   NBTTagCompound stackCompound = itemStack.getTagCompound();
   stackCompound.setString("defaultInfo", info);
   itemStack.setTagCompound(stackCompound);
 }
コード例 #23
0
  public static NBTTagCompound getOrCreateTagCompound(ItemStack is) {
    if (!is.hasTagCompound()) {
      is.setTagCompound(new NBTTagCompound());
      is.getTagCompound().setInteger("moduleCount", 0);
    }

    return is.getTagCompound();
  }
コード例 #24
0
 @Override
 public float getFoodDecay(ItemStack is) {
   if (is.hasTagCompound() && is.getTagCompound().hasKey("foodDecay")) {
     NBTTagCompound nbt = is.getTagCompound();
     return nbt.getFloat("foodDecay");
   }
   return 0f;
 }
コード例 #25
0
 public static int getIntegerTag(ItemStack stack, String tag) {
   if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());
   NBTTagCompound nbtData = stack.getTagCompound();
   if (nbtData == null) {
     stack.getTagCompound().setInteger(tag, 0);
   }
   return stack.getTagCompound().getInteger(tag);
 }
コード例 #26
0
ファイル: ItemArmor.java プロジェクト: leijurv/MineBot
 /** Return whether the specified armor ItemStack has a color. */
 public boolean hasColor(ItemStack stack) {
   return this.material != ItemArmor.ArmorMaterial.LEATHER
       ? false
       : (!stack.hasTagCompound()
           ? false
           : (!stack.getTagCompound().hasKey("display", 10)
               ? false
               : stack.getTagCompound().getCompoundTag("display").hasKey("color", 3)));
 }
コード例 #27
0
ファイル: ItemTank.java プロジェクト: BraynStorm/FlowCraft
 @Override
 @SideOnly(Side.CLIENT)
 public void addInformation(
     ItemStack itemStack, EntityPlayer player, List dataList, boolean bool) {
   NBTTagCompound tag =
       itemStack.getTagCompound() != null ? itemStack.getTagCompound() : new NBTTagCompound();
   dataList.add("FluidID: " + tag.getInteger("tankFluidID"));
   dataList.add("Amount: " + tag.getInteger("tankFluidAmount"));
 }
コード例 #28
0
  @SubscribeEvent
  public void playerTick(TickEvent.PlayerTickEvent event) {
    EntityPlayer player = event.player;
    TPlayerStats stats = TPlayerStats.get(player);

    // Wall climb
    if (stats.climbWalls) {
      double motionX = player.posX - player.lastTickPosX;
      double motionZ = player.posZ - player.lastTickPosZ;
      double motionY = player.posY - player.lastTickPosY - 0.762;
      if (motionY > 0.0D && (motionX == 0D || motionZ == 0D)) {
        player.fallDistance = 0.0F;
      }
    }

    // Feet changes
    ItemStack feet = player.getCurrentArmor(0);
    if (feet != null) {
      if (feet.getItem() instanceof IModifyable && !player.isSneaking()) {
        NBTTagCompound tag =
            feet.getTagCompound().getCompoundTag(((IModifyable) feet.getItem()).getBaseTagName());
        int sole = tag.getInteger("Slimy Soles");
        if (sole > 0) {
          if (!player.isSneaking() && player.onGround && prevMotionY < -0.4)
            player.motionY = -prevMotionY * (Math.min(0.99, sole * 0.2));
        }
      }
      prevMotionY = player.motionY;
    }
    if (feet != prevFeet) {
      if (prevFeet != null && prevFeet.getItem() instanceof TravelGear) player.stepHeight -= 0.6f;
      if (feet != null && feet.getItem() instanceof TravelGear) player.stepHeight += 0.6f;
      prevFeet = feet;
    }
    // TODO: Proper minimap support
    /*ItemStack stack = player.inventory.getStackInSlot(8);
    if (stack != null && stack.getItem() instanceof ItemMap)
    {
        stack.getItem().onUpdate(stack, player.worldObj, player, 8, true);
    }*/
    if (!player.isPlayerSleeping()) {
      ItemStack chest = player.getCurrentArmor(2);
      if (chest == null || !(chest.getItem() instanceof IModifyable)) {
        if (!morphLoaded || !morphed) PlayerAbilityHelper.setEntitySize(player, 0.6F, 1.8F);
      } else {
        NBTTagCompound tag =
            chest.getTagCompound().getCompoundTag(((IModifyable) chest.getItem()).getBaseTagName());
        int dodge = tag.getInteger("Perfect Dodge");
        if (dodge > 0) {
          if (!morphLoaded || !morphed)
            PlayerAbilityHelper.setEntitySize(
                player, Math.max(0.15F, 0.6F - (dodge * 0.09f)), 1.8F - (dodge * 0.04f));
        }
      }
    }
  }
コード例 #29
0
  // ブロックのドロップ時に中身を落とす
  @Override
  public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
    TileIncenseBase tile = (TileIncenseBase) world.getTileEntity(x, y, z);
    if (tile != null) {
      ItemStack drop = tile.getItemstack();
      ItemStack ash = tile.getAsh();
      if (drop != null) {
        float f = world.rand.nextFloat() * 0.8F + 0.1F;
        float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
        float f2 = world.rand.nextFloat() * 0.8F + 0.1F;

        EntityItem entityitem =
            new EntityItem(
                world,
                (double) ((float) x + f),
                (double) ((float) y + f1),
                (double) ((float) z + f2),
                drop.copy());

        if (drop.hasTagCompound()) {
          entityitem.getEntityItem().setTagCompound((NBTTagCompound) drop.getTagCompound().copy());
        }

        float f3 = 0.05F;
        entityitem.motionX = (double) ((float) world.rand.nextGaussian() * f3);
        entityitem.motionY = (double) ((float) world.rand.nextGaussian() * f3 + 0.2F);
        entityitem.motionZ = (double) ((float) world.rand.nextGaussian() * f3);
        world.spawnEntityInWorld(entityitem);
      }
      if (ash != null) {
        float f = world.rand.nextFloat() * 0.8F + 0.1F;
        float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
        float f2 = world.rand.nextFloat() * 0.8F + 0.1F;

        EntityItem entityitem2 =
            new EntityItem(
                world,
                (double) ((float) x + f),
                (double) ((float) y + f1),
                (double) ((float) z + f2),
                ash.copy());

        if (ash.hasTagCompound()) {
          entityitem2.getEntityItem().setTagCompound((NBTTagCompound) ash.getTagCompound().copy());
        }

        float f3 = 0.05F;
        entityitem2.motionX = (double) ((float) world.rand.nextGaussian() * f3);
        entityitem2.motionY = (double) ((float) world.rand.nextGaussian() * f3 + 0.2F);
        entityitem2.motionZ = (double) ((float) world.rand.nextGaussian() * f3);
        world.spawnEntityInWorld(entityitem2);
      }
    }

    super.breakBlock(world, x, y, z, block, meta);
  }
コード例 #30
0
 @Override
 public int hashCode() {
   int hash = 7;
   hash = 41 * hash + stack.getItem().hashCode();
   hash = 41 * hash + stack.getItemDamage();
   hash = 41 * hash + stack.getCount();
   hash = 41 * hash + (stack.getTagCompound() == null ? 0 : stack.getTagCompound().hashCode());
   hash = 41 * hash + (this.wildcardSize ? 1 : 0);
   return hash;
 }