net.minecraft.world.storage.loot.LootEntryItem Java Examples
The following examples show how to use
net.minecraft.world.storage.loot.LootEntryItem.
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: ChestGenHooks.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
public static void addItem(ResourceLocation lootTable, ItemStack item, int minAmount, int additionalAmount, int weight) { LootEntryItem itemEntry = new LootEntryItem(item.getItem(), weight, 1, new LootFunction[]{ new LootFunction(NO_CONDITIONS) { @Override public ItemStack apply(ItemStack stack, Random rand, LootContext context) { stack.setItemDamage(item.getItemDamage()); stack.setTagCompound(item.getTagCompound()); stack.setCount(minAmount + rand.nextInt(additionalAmount)); return stack; } } }, NO_CONDITIONS, "#gregtech:loot_" + item.toString()); if (lootEntryItems.containsKey(lootTable)) { lootEntryItems.get(lootTable).add(itemEntry); } else { lootEntryItems.put(lootTable, Lists.newArrayList(itemEntry)); } }
Example #2
Source File: GTEventLootTableLoad.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public void onLootTableLoad(LootTableLoadEvent event) { /* * Iterates both the stack array and resource location array to create a 2d * table */ if (GTConfig.general.addLootItems) { for (ItemStack item : lootpool) { for (ResourceLocation table : loottable) { if (event.getName().equals(table)) { event.getTable().getPool("main").addEntry(new LootEntryItem(item.getItem(), 16, 0, new LootFunction[] { createCountFunction(1, 6) }, NO_CONDITIONS, getStackResourceName(item))); } } } } }
Example #3
Source File: SakuraEventLoader.java From Sakura_mod with MIT License | 5 votes |
public static void addFishingLoot(ItemStack stack,int weight){ LootCondition[] lootConditions = new LootCondition[0]; LootFunction[] setMeta = new LootFunction[] { new SetMetadata(lootConditions, new RandomValueRange(stack.getMetadata())) }; LootEntry entry = new LootEntryItem(stack.getItem(), weight, 0, setMeta, lootConditions, stack.getUnlocalizedName()); FishinglootPools.add(entry); }
Example #4
Source File: ChestGenHooks.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void onWorldLoad(LootTableLoadEvent event) { LootPool mainPool = event.getTable().getPool("main"); if (mainPool != null && lootEntryItems.containsKey(event.getName())) { ArrayList<LootEntryItem> entryItems = lootEntryItems.get(event.getName()); for (LootEntryItem entry : entryItems) { mainPool.addEntry(entry); } } if (mainPool != null && rollVals.containsKey(event.getName())) { RandomValueRange rangeAdd = rollVals.get(event.getName()); RandomValueRange range = mainPool.getRolls(); mainPool.setRolls(new RandomValueRange(range.getMin() + rangeAdd.getMin(), range.getMax() + rangeAdd.getMax())); } }