Java 类net.minecraft.world.storage.loot.functions.LootFunction 实例源码

项目:Clef    文件:EventHandlerServer.java   
@SubscribeEvent
public void onLootTableEvent(LootTableLoadEvent event)
{
    if(Clef.config.lootSpawnRate > 0)
    {
        for(String s : Clef.config.disabledLootChests)
        {
            if(event.getName().toString().equals(s))
            {
                return;
            }
        }
        if(event.getName().getResourcePath().contains("chest"))
        {
            event.getTable().addPool(new LootPool(new LootEntry[] { new LootEntryItem(Clef.itemInstrument, Clef.config.lootSpawnRate, 0, new LootFunction[] { new LootFunction(new LootCondition[0])
            {
                @Override
                public ItemStack apply(ItemStack stack, Random rand, LootContext context)
                {
                    InstrumentLibrary.assignRandomInstrument(stack);
                    return stack;
                }
            } }, new LootCondition[0], "clef_instrument_pool") }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0), "clef_instrument"));
        }
    }
}
项目:Backmemed    文件:LootEntryItem.java   
public static LootEntryItem deserialize(JsonObject object, JsonDeserializationContext deserializationContext, int weightIn, int qualityIn, LootCondition[] conditionsIn)
{
    Item item = JsonUtils.getItem(object, "name");
    LootFunction[] alootfunction;

    if (object.has("functions"))
    {
        alootfunction = (LootFunction[])JsonUtils.deserializeClass(object, "functions", deserializationContext, LootFunction[].class);
    }
    else
    {
        alootfunction = new LootFunction[0];
    }

    return new LootEntryItem(item, weightIn, qualityIn, alootfunction, conditionsIn);
}
项目:CustomWorldGen    文件:LootEntryItem.java   
public static LootEntryItem deserialize(JsonObject object, JsonDeserializationContext deserializationContext, int weightIn, int qualityIn, LootCondition[] conditionsIn)
{
    String name = net.minecraftforge.common.ForgeHooks.readLootEntryName(object, "item");
    Item item = JsonUtils.getItem(object, "name");
    LootFunction[] alootfunction;

    if (object.has("functions"))
    {
        alootfunction = (LootFunction[])JsonUtils.deserializeClass(object, "functions", deserializationContext, LootFunction[].class);
    }
    else
    {
        alootfunction = new LootFunction[0];
    }

    return new LootEntryItem(item, weightIn, qualityIn, alootfunction, conditionsIn, name);
}
项目:PurificatiMagicae    文件:PapyrusRegistry.java   
public void addNotImportantToTable(LootTable table)
{
    List<LootEntry> entrs = new ArrayList<>();
    for (PapyrusData p : getPapyruses())
    {
        if (!p.isImportant())
        {
            NBTTagCompound tag = new NBTTagCompound();
            tag.setString("papyrus_id", p.getPapyrusId());
            entrs.add(new LootEntryItem(ItemRegistry.papyrus, 1, 1, new LootFunction[]{new SetNBT(new LootCondition[]{}, tag)}, new LootCondition[]{}, p.getPapyrusId()));
        }
    }
    table.addPool(new LootPool(entrs.toArray(new LootEntry[]{}), new LootCondition[]{}, new RandomValueRange(0, 1), new RandomValueRange(0), "papyruses"));
}
项目:EndermanEvolution    文件:ModEvents.java   
@SubscribeEvent
public void onLootTablesLoaded(LootTableLoadEvent event) {
    if ((event.getName().equals(LootTableList.CHESTS_ABANDONED_MINESHAFT)) || (event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) || (event.getName().equals(LootTableList.CHESTS_DESERT_PYRAMID)) || (event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) || (event.getName().equals(LootTableList.CHESTS_STRONGHOLD_LIBRARY)) || (event.getName().equals(LootTableList.CHESTS_END_CITY_TREASURE))) {
        LootPool mainPool = event.getTable().getPool("main");
        if (mainPool != null) {
            if (event.getName().equals(LootTableList.CHESTS_ABANDONED_MINESHAFT) || event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE) || event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) {
                mainPool.addEntry(new LootEntryItem(ModItems.FRIENDER_PEARL, 10, 0, new LootFunction[] {}, new LootCondition[0], ModGlobals.MODID + ":friender_pearl_loot"));
            }
        }
    }

}
项目:Backmemed    文件:LootEntryItem.java   
public void addLoot(Collection<ItemStack> stacks, Random rand, LootContext context)
{
    ItemStack itemstack = new ItemStack(this.item);

    for (LootFunction lootfunction : this.functions)
    {
        if (LootConditionManager.testAllConditions(lootfunction.getConditions(), rand, context))
        {
            itemstack = lootfunction.apply(itemstack, rand, context);
        }
    }

    if (!itemstack.func_190926_b())
    {
        if (itemstack.func_190916_E() < this.item.getItemStackLimit())
        {
            stacks.add(itemstack);
        }
        else
        {
            int i = itemstack.func_190916_E();

            while (i > 0)
            {
                ItemStack itemstack1 = itemstack.copy();
                itemstack1.func_190920_e(Math.min(itemstack.getMaxStackSize(), i));
                i -= itemstack1.func_190916_E();
                stacks.add(itemstack1);
            }
        }
    }
}
项目:BetterBeginningsReborn    文件:BBEventHandler.java   
private static void replaceCookedWithCharred(LootPool targetPool, Item targetItem, ItemStack replacementStack, int minCount, int maxCount)
   {
List<LootFunction> charredFunctions = Lists.newArrayList();
if(replacementStack.getItemDamage() != 0) charredFunctions.add(LootUtil.createSetMetadata(replacementStack.getItemDamage()));
if(replacementStack.getTagCompound() != null) charredFunctions.add(LootUtil.createSetNBT(replacementStack.getTagCompound()));
charredFunctions.add(LootUtil.createCountFunction(minCount, maxCount));
charredFunctions.add(LootUtil.createLootingFunc(0, 1));

LootCondition notOnFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(false)}, EntityTarget.THIS);
LootCondition onFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(true)}, EntityTarget.THIS);

targetPool.removeEntry(targetItem.getRegistryName().toString());
targetPool.addEntry(new LootEntryItem(targetItem, 1, 1, new LootFunction[] {LootUtil.createCountFunction(1, 3), LootUtil.createLootingFunc(0, 1)}, new LootCondition[] {notOnFire}, targetItem.getRegistryName().toString()));
targetPool.addEntry(new LootEntryItem(replacementStack.getItem(), 1, 1, charredFunctions.toArray(new LootFunction[charredFunctions.size()]), new LootCondition[] {onFire}, ModMain.MODID + ":charred_+" + targetItem.getRegistryName().getResourcePath().toString()));
   }
项目:BetterBeginningsReborn    文件:BBEventHandler.java   
private void removeSmeltFunction(LootPool pool, Item targetItem, Item replacement, int minCount, int maxCount)
   {
LootCondition notOnFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(false)}, EntityTarget.THIS);
LootCondition onFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(true)}, EntityTarget.THIS);

pool.removeEntry(targetItem.getRegistryName().toString());
pool.addEntry(new LootEntryItem(targetItem, 1, 1, new LootFunction[] {LootUtil.createCountFunction(1, 3), LootUtil.createLootingFunc(0, 1)}, new LootCondition[] {notOnFire}, targetItem.getRegistryName().toString()));
pool.addEntry(new LootEntryItem(replacement, 1, 1, new LootFunction[] {LootUtil.createCountFunction(1, 3), LootUtil.createLootingFunc(0, 1)}, new LootCondition[] {onFire}, replacement.getRegistryName().toString()));
   }
项目:CustomWorldGen    文件:LootEntryItem.java   
public void addLoot(Collection<ItemStack> stacks, Random rand, LootContext context)
{
    ItemStack itemstack = new ItemStack(this.item);

    for (LootFunction lootfunction : this.functions)
    {
        if (LootConditionManager.testAllConditions(lootfunction.getConditions(), rand, context))
        {
            itemstack = lootfunction.apply(itemstack, rand, context);
        }
    }

    if (itemstack.stackSize > 0)
    {
        if (itemstack.stackSize < this.item.getItemStackLimit(itemstack))
        {
            stacks.add(itemstack);
        }
        else
        {
            int i = itemstack.stackSize;

            while (i > 0)
            {
                ItemStack itemstack1 = itemstack.copy();
                itemstack1.stackSize = Math.min(itemstack.getMaxStackSize(), i);
                i -= itemstack1.stackSize;
                stacks.add(itemstack1);
            }
        }
    }
}
项目:runesofwizardry-classics    文件:LootUtils.java   
/**
 * Converts a LootTable to a list of possible drops, only looks for Item and metadata.
 * @param table the loot table to get items from
 * @return a LinkedList of the stacks in the loot table
 */
public static List<ItemStack> tableToItemStacks(LootTable table){
    List<ItemStack> stacks = new LinkedList<>();
    for(LootPool p:getPools(table)){
        for(LootEntry entry:getEntries(p)){
            if(entry instanceof LootEntryItem){
                LootEntryItem ei = (LootEntryItem)entry;
                Item item = getItem(ei);
                LootFunction[] functs = getFunctions(ei);
                boolean metaSet = false;
                for(LootFunction func:functs){
                    if(func instanceof SetMetadata){
                        metaSet=true;
                        RandomValueRange range = (RandomValueRange)ReflectionHelper.getPrivateValue(SetMetadata.class, (SetMetadata)func, "metaRange","field_186573_b");
                        int meta = MathHelper.floor(range.getMin());
                        stacks.add(new ItemStack(item,1,meta));
                    }
                }
                if(!metaSet)stacks.add(new ItemStack(item));
            }
            /* won't bother with this case for now
            else if(entry instanceof LootEntryTable){
                //restart with that table
                ResourceLocation location = (ResourceLocation) ReflectionHelper.getPrivateValue(LootEntryTable.class, (LootEntryTable)entry, "table","field_186371_a");
            }
            */
        }
    }
    return stacks;
}
项目:Minecraft-Flux    文件:MCFluxEvents.java   
@SubscribeEvent
public static void onLootTableLoad(LootTableLoadEvent e) {
    final ResourceLocation rl = e.getName();
    if (rl.equals(LootTableList.CHESTS_VILLAGE_BLACKSMITH) || rl.equals(LootTableList.CHESTS_ABANDONED_MINESHAFT) || rl.equals(LootTableList.CHESTS_JUNGLE_TEMPLE)) {
        final LootTable lt = e.getTable();
        LootPool lp = lt.getPool("pool0");
        if (lp == null)
            lp = lt.getPool("main");
        if (lp != null) {
            lp.addEntry(new LootEntryItem(MCFluxResources.UPCHIP, 20, 0, new LootFunction[0], new LootCondition[0], "mcflux:loot/upchip"));
        }
    }
}
项目:Loot-Tables    文件:LootTablesMod.java   
@SubscribeEvent
public void onLootTablesLoaded (LootTableLoadEvent event) {

    // Checks to see if the loot table being loaded is the basic dungeon chest.
    if (event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) {

        // Gets pool2 from the loot table. This pool is where common loot like zombie flesh
        // bones and string goes.
        final LootPool pool2 = event.getTable().getPool("pool2");

        // Makes sure the pool has not been deleted.
        if (pool2 != null) {

            // Adds cookies to the loot pool. Has a weight of 10 and spawns in stacks of 1
            // to 5.
            pool2.addEntry(new LootEntryItem(Items.COOKIE, 10, 0, new LootFunction[] { new SetCount(new LootCondition[0], new RandomValueRange(1, 5)) }, new LootCondition[0], "tutorial:cookie"));

            // Adds Lime Green Dye to the loot pool. Has a weight of 10.
            pool2.addEntry(new LootEntryItem(Items.DYE, 10, 0, new LootFunction[] { new SetDamage(new LootCondition[0], new RandomValueRange(10, 10)) }, new LootCondition[0], "tutorial:dyes"));
        }
    }

    // Checks to see if the loot table being loaded is for the mob we are looking for
    if (event.getName().equals(LootTableList.ENTITIES_PIG)) {

        // Gets main from the loot table. This pool is where the basic drops like porkchop are.
        final LootPool main = event.getTable().getPool("main");

        // Makes sure that the main pool actually exists. It can be deleted by other mods.
        if (main != null) {

            // Adds a carrot to the pool. Carrots will now drop just as often as pork chops.
            main.addEntry(new LootEntryItem(Items.CARROT, 1, 0, new LootFunction[0], new LootCondition[0], "tutorial:carrot"));

            // Adds an apple to the loot pool. This entry is only used if the pig was killed by a player.
            main.addEntry(new LootEntryItem(Items.APPLE, 1, 0, new LootFunction[0], new LootCondition[] { new KilledByPlayer(false)}, "tutorial:player"));
        }
    }
}
项目:Dark-Utilities    文件:FeatureEnchantedRing.java   
@SubscribeEvent
public void onLootTableLoad (LootTableLoadEvent event) {

    if (allowDungeonLoot && event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) {

        final LootPool main = event.getTable().getPool("main");

        if (main != null) {
            main.addEntry(new LootEntryItem(itemRing, weight, 0, new LootFunction[] { new SetDamage(new LootCondition[0], new RandomValueRange(0, ItemRing.varients.length - 1)) }, new LootCondition[0], "darkutils:nether_rings"));
        }
    }
}
项目:Dark-Utilities    文件:FeatureMaterial.java   
@SubscribeEvent
public void onLootTableLoad (LootTableLoadEvent event) {

    final LootTable table = event.getTable();

    if (skeletonDropDust && event.getName().equals(LootTableList.ENTITIES_WITHER_SKELETON)) {

        final LootPool pool1 = table.getPool("pool1");

        if (pool1 != null) {
            pool1.addEntry(new LootEntryItem(itemMaterial, dustDropWeight, 0, new LootFunction[0], new LootCondition[0], DarkUtils.MOD_ID + ":wither_dust"));
        }
    }
}
项目:Bookshelf    文件:LootBuilder.java   
public LootBuilder (String name, String pool, int weight, int quality, Item item, List<LootCondition> conditions, List<LootFunction> functions) {

        this.name = name;
        this.pool = pool;
        this.weight = weight;
        this.quality = quality;
        this.item = item;
        this.conditions = conditions;
        this.functions = functions;
    }
项目:EnderIO    文件:LootManager.java   
private @Nonnull LootEntry createLootEntry(@Nonnull Item item, int meta, int minStackSize, int maxStackSize, float chance) {
  LootCondition[] chanceCond = new LootCondition[] { new RandomChance(chance) };
  final ResourceLocation registryName = NullHelper.notnull(item.getRegistryName(), "found unregistered item");
  if (item.isDamageable()) {
    return new LootEntryItem(item, 1, 1, new LootFunction[] { setCount(minStackSize, maxStackSize), setDamage(item, meta), setEnergy() }, chanceCond,
        registryName.toString() + ":" + meta);
  } else {
    return new LootEntryItem(item, 1, 1, new LootFunction[] { setCount(minStackSize, maxStackSize), setMetadata(meta) }, chanceCond,
        registryName.toString() + ":" + meta);
  }
}
项目:Backmemed    文件:LootEntryItem.java   
public LootEntryItem(Item itemIn, int weightIn, int qualityIn, LootFunction[] functionsIn, LootCondition[] conditionsIn)
{
    super(weightIn, qualityIn, conditionsIn);
    this.item = itemIn;
    this.functions = functionsIn;
}
项目:BetterBeginningsReborn    文件:BBEventHandler.java   
@SubscribeEvent
   public void onLootTableLoad(LootTableLoadEvent e)
   {
Worldgen.addLoot(e.getTable(), e.getName());
if (BBConfig.moreBones)
{
    if(e.getName().equals(LootTableList.ENTITIES_SKELETON))
    {
    LootPool pool1 = e.getTable().getPool("pool1");
    pool1.removeEntry("minecraft:bone");
    pool1.addEntry(new LootEntryItem(Items.BONE, 1, 1, new LootFunction[] {LootUtil.createCountFunction(1, 3), LootUtil.createLootingFunc(0, 1)}, LootUtil.NO_CONDITIONS, Items.BONE.getRegistryName().toString()));
    }
}
if (BBConfig.flamingAnimalsDropCharredMeat)
{
    if(e.getName().equals(LootTableList.ENTITIES_COW))
    {
    replaceCookedWithCharred(e.getTable().getPool("pool1"), Items.BEEF, new ItemStack(RegisterItems.charredMeat, 1, ItemCharredMeat.META_MEAT), 1, 3);
    }
    else if(e.getName().equals(LootTableList.ENTITIES_PIG))
    {
    replaceCookedWithCharred(e.getTable().getPool("main"), Items.PORKCHOP, new ItemStack(RegisterItems.charredMeat, 1, ItemCharredMeat.META_MEAT), 1, 3);
    }
    else if(e.getName().equals(LootTableList.ENTITIES_CHICKEN))
    {
    replaceCookedWithCharred(e.getTable().getPool("pool1"), Items.CHICKEN, new ItemStack(RegisterItems.charredMeat, 1, ItemCharredMeat.META_CHICKEN), 1, 1);
    }
    else if(e.getName().equals(LootTableList.ENTITIES_SHEEP))
    {
    replaceCookedWithCharred(e.getTable().getPool("main"), Items.MUTTON, new ItemStack(RegisterItems.charredMeat, 1, ItemCharredMeat.META_MUTTON), 1, 2);
    }
    else if(e.getName().equals(LootTableList.ENTITIES_RABBIT))
    {
    replaceCookedWithCharred(e.getTable().getPool("pool1"), Items.RABBIT, new ItemStack(RegisterItems.charredMeat, 1, ItemCharredMeat.META_RABBIT), 0, 1);
    }
}
else
{
    if(e.getName().equals(LootTableList.ENTITIES_COW))
    {
    removeSmeltFunction(e.getTable().getPool("pool1"), Items.BEEF, Items.COOKED_BEEF, 1, 3);
    }
    else if(e.getName().equals(LootTableList.ENTITIES_PIG))
    {
    removeSmeltFunction(e.getTable().getPool("main"), Items.PORKCHOP, Items.COOKED_PORKCHOP, 1, 3);
    }
    else if(e.getName().equals(LootTableList.ENTITIES_CHICKEN))
    {
    removeSmeltFunction(e.getTable().getPool("pool1"), Items.CHICKEN, Items.COOKED_CHICKEN, 1, 1);
    }
    else if(e.getName().equals(LootTableList.ENTITIES_SHEEP))
    {
    removeSmeltFunction(e.getTable().getPool("main"), Items.MUTTON, Items.COOKED_MUTTON, 1, 2);
    }
    else if(e.getName().equals(LootTableList.ENTITIES_RABBIT))
    {
    removeSmeltFunction(e.getTable().getPool("pool1"), Items.RABBIT, Items.COOKED_RABBIT, 0, 1);
    }
}
if(e.getName().equals(LootTableList.ENTITIES_SPIDER) || e.getName().equals(LootTableList.ENTITIES_CAVE_SPIDER))
{
    if (!BBConfig.spidersDropString)
    {
    e.getTable().getPool("main").removeEntry("minecraft:string");
    }
    e.getTable().getPool("main").addEntry(new LootEntryItem(RegisterItems.silk, 1, 1, new LootFunction[] {LootUtil.createCountFunction(2, 4), LootUtil.createLootingFunc(0, 1)}, LootUtil.NO_CONDITIONS, RegisterItems.silk.getRegistryName().toString()));
}
   }
项目:BetterBeginningsReborn    文件:LootUtil.java   
public static void addItemToTable(LootTable table, String poolName, Item item, int weight, int quality, LootFunction... functions)
   {
addItemToTable(table, poolName, item, weight, quality, functions, NO_CONDITIONS);
   }
项目:BetterBeginningsReborn    文件:LootUtil.java   
public static void addItemToTable(LootTable table, String poolName, Item item, int weight, int quality, LootFunction[] functions, LootCondition[] conditions)
   {
table.getPool("main").addEntry(new LootEntryItem(item, weight, quality, functions, conditions, item.getRegistryName().toString()));
   }
项目:CustomWorldGen    文件:LootEntryItem.java   
public LootEntryItem(Item itemIn, int weightIn, int qualityIn, LootFunction[] functionsIn, LootCondition[] conditionsIn, String entryName)
{
    super(weightIn, qualityIn, conditionsIn, entryName);
    this.item = itemIn;
    this.functions = functionsIn;
}
项目:runesofwizardry-classics    文件:LootUtils.java   
public static LootFunction[] getFunctions(LootEntryItem lootEntry)
{
    return ReflectionHelper.getPrivateValue(LootEntryItem.class, lootEntry, "functions", "field_186369_b");
}
项目:CrystalMod    文件:LootHelper.java   
public static LootEntryItem createLootEntryItem(Item item, int weight, int quality) {
    return createLootEntryItem(item, weight, quality, new LootFunction[]{});
}
项目:CrystalMod    文件:LootHelper.java   
public static LootEntryItem createLootEntryItem(Item item, int weight, int quality, LootFunction[] lootFunctions, LootCondition... lootConditions) {
    return new LootEntryItem(item, weight, quality, lootFunctions, lootConditions, CrystalMod.prefix(item.getUnlocalizedName()));
}
项目:MobHunter    文件:LootHandler.java   
private static void addLoot(LootPool pool, Item item, int weight)
{
    pool.addEntry(new LootEntryItem(item, weight, 0, new LootFunction[0], new LootCondition[0], Reference.MOD_ID + item.getUnlocalizedName()));
}
项目:Cyclic    文件:LootTableModule.java   
private void addLoot(LootPool main, Item item, int rando) {
  if (item != null) {//shortcut fix bc of new module config system that can delete items   
    main.addEntry(new LootEntryItem(item, rando, 0, new LootFunction[0], new LootCondition[0], Const.MODRES + item.getUnlocalizedName()));
  }
}
项目:EnderIO    文件:LootManager.java   
private @Nonnull LootEntry createLootEntry(@Nonnull ItemStack stack, int minStackSize, int maxStackSize, float chance) {
  LootCondition[] chanceCond = new LootCondition[] { new RandomChance(chance) };
  final ResourceLocation registryName = NullHelper.notnull(stack.getItem().getRegistryName(), "found unregistered item");
  return new LootEntryItem(stack.getItem(), 1, 1, new LootFunction[] { setCount(minStackSize, maxStackSize), setMetadata(stack.getMetadata()) }, chanceCond,
      registryName.toString() + ":" + stack.getMetadata());
}
项目:EnderIO    文件:LootManager.java   
private @Nonnull LootEntry createDarkSteelLootEntry(@Nonnull Item item, int meta, int minStackSize, int maxStackSize, float chance) {
  LootCondition[] chanceCond = new LootCondition[] { new RandomChance(chance) };
  final ResourceLocation registryName = NullHelper.notnull(item.getRegistryName(), "found unregistered item");
  return new LootEntryItem(item, 1, 1, new LootFunction[] { setCount(minStackSize, maxStackSize), setDamage(item, meta), setUpgrades(), setEnergy() },
      chanceCond, registryName.toString() + ":" + meta);
}
项目:EnderIO    文件:LootManager.java   
private @Nonnull LootEntry createLootCapacitor(float chance) {
  capCount++;
  return new LootEntryItem(itemBasicCapacitor.getItemNN(), 1, 1, new LootFunction[] { ls, setMetadata(3, 4) },
      new LootCondition[] { new RandomChance(chance) }, itemBasicCapacitor.getUnlocalisedName() + capCount);
}
项目:Bookshelf    文件:LootBuilder.java   
public LootBuilder (String name, String pool, int weight, Item item) {

        this(name, pool, weight, 0, item, new ArrayList<LootCondition>(), new ArrayList<LootFunction>());
    }
项目:Bookshelf    文件:LootBuilder.java   
/**
 * Gets a List of functions for the entry.
 *
 * @return A List of functions for the entry.
 */
public List<LootFunction> getFunctions () {

    return this.functions;
}
项目:Bookshelf    文件:LootBuilder.java   
/**
 * Adds a function to the entry.
 *
 * @param function The function to add.
 * @return The LootBuilder object.
 */
public LootBuilder addFunction (LootFunction function) {

    this.functions.add(function);
    return this;
}
项目:Bookshelf    文件:LootBuilder.java   
/**
 * Builds the LootEntryItem so it can be used with vanilla MC.
 *
 * @return The LootEntryItem that was built.
 */
public LootEntryItem build () {

    return new LootEntryItem(this.item, this.weight, this.quality, this.functions.toArray(new LootFunction[0]), this.conditions.toArray(new LootCondition[0]), this.name);
}
项目:Bookshelf    文件:RegistryHelper.java   
/**
 * Creates a new loot entry that will be added to the loot pools when a world is loaded.
 *
 * @param location The loot table to add the loot to. You can use
 *        {@link net.minecraft.world.storage.loot.LootTableList} for convenience.
 * @param name The name of the entry being added. This will be prefixed with {@link #modid}
 *        .
 * @param pool The name of the pool to add the entry to. This pool must already exist.
 * @param weight The weight of the entry.
 * @param quality The quality of the entry. Quality is an optional value which modifies the
 *        weight of an entry based on the player's luck level. totalWeight = weight +
 *        (quality * luck)
 * @param item The item to add.
 * @param conditions A list of loot conditions.
 * @param functions A list of loot functions.
 * @return A builder object. It can be used to fine tune the loot entry.
 */
public LootBuilder addLoot (ResourceLocation location, String name, String pool, int weight, int quality, Item item, List<LootCondition> conditions, List<LootFunction> functions) {

    return this.addLoot(location, new LootBuilder(this.modid + ":" + name, pool, weight, quality, item, conditions, functions));
}