Java Code Examples for net.minecraft.item.Item#getMaxDamage()
The following examples show how to use
net.minecraft.item.Item#getMaxDamage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AliquoFish.java From Ex-Aliquo with MIT License | 6 votes |
static void addBooty() { if (Configurations.fishingOysters) { Fishing.loot.addLoot(new Loot(new ItemStack(getBlock(Info.marioyster)), RodQuality.GOOD, Rarity.GOOD, 100, 0, false)); } Fishing.loot.addLoot(new Loot(new ItemStack(getBlock(Info.mariores), 1, 7), RodQuality.OLD, Rarity.JUNK, 50, 0, false)); if (Modules.isActive(Modules.worldplus)) { Item coral = getItem(Info.maricoral); for (int i = 2; i < coral.getMaxDamage(); i++) { Fishing.loot.addLoot(new Loot(new ItemStack(coral, 1, i), RodQuality.OLD, Rarity.JUNK, 200, 0, false)); } } }
Example 2
Source File: AdapterTileSteamTurbine.java From OpenPeripheral-Integration with MIT License | 5 votes |
@ScriptCallable(description = "Get the undamagedness of the rotor, from 0% (dead) to 100% (brand new)", returnTypes = ReturnType.NUMBER) public Integer getTurbineRotorStatus(Object tileSteamTurbine) { IInventory inventory = GET_INVENTORY.call(tileSteamTurbine); if (inventory != null && inventory.getSizeInventory() >= 1) { ItemStack itemStack = inventory.getStackInSlot(0); if (itemStack != null) { Item item = itemStack.getItem(); if (item != null) { return 100 - (int)(itemStack.getItemDamage() * 100.0 / item.getMaxDamage()); } } } return null; }
Example 3
Source File: BWCoreStaticReplacementMethodes.java From bartworks with MIT License | 4 votes |
@SuppressWarnings("ALL") public static ItemStack findCachedMatchingRecipe(InventoryCrafting inventoryCrafting, World world) { int i = 0; ItemStack itemstack = null; ItemStack itemstack1 = null; int j; for (j = 0; j < inventoryCrafting.getSizeInventory(); ++j) { ItemStack itemstack2 = inventoryCrafting.getStackInSlot(j); if (itemstack2 != null) { if (i == 0) { itemstack = itemstack2; } if (i == 1) { itemstack1 = itemstack2; } ++i; } } if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && itemstack.getItem().isRepairable()) { Item item = itemstack.getItem(); int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay(); int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay(); int l = j1 + k + item.getMaxDamage() * 5 / 100; int i1 = item.getMaxDamage() - l; if (i1 < 0) { i1 = 0; } return new ItemStack(itemstack.getItem(), 1, i1); } else { IRecipe iPossibleRecipe = null; int index = 0; for (Iterator<IRecipe> it = RECENTLYUSEDRECIPES.iterator(); it.hasNext(); ++index) { IRecipe RECENTLYUSEDRECIPE = it.next(); if (RECENTLYUSEDRECIPE.matches(inventoryCrafting, world)) { iPossibleRecipe = RECENTLYUSEDRECIPE; break; } } if (iPossibleRecipe != null) { RECENTLYUSEDRECIPES.addPrioToNode(index); return iPossibleRecipe.getCraftingResult(inventoryCrafting); } ItemStack stack = null; HashSet<IRecipe> recipeSet = new NonNullWrappedHashSet<>(); List recipeList = CraftingManager.getInstance().getRecipeList(); for (int k = 0; k < recipeList.size(); k++) { recipeSet.add((IRecipe) recipeList.get(k)); } Object[] arr = recipeSet.parallelStream().filter(r -> r.matches(inventoryCrafting, world)).toArray(); if (arr.length == 0) return null; IRecipe recipe = (IRecipe) arr[0]; stack = recipe.getCraftingResult(inventoryCrafting); if (arr.length != 1) return stack; if (stack != null) RECENTLYUSEDRECIPES.addLast(recipe); return stack; } }