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

项目:FirstAid    文件:EventHandler.java   
@SubscribeEvent
public static void onLootTableLoad(LootTableLoadEvent event) {
    ResourceLocation tableName = event.getName();
    LootPool pool = null;
    int bandage = 0, plaster = 0, morphine = 0;
    if (tableName.equals(LootTableList.CHESTS_SPAWN_BONUS_CHEST)) {
        pool = event.getTable().getPool("main");
        bandage = 8;
        plaster = 16;
        morphine = 4;
    } else if (tableName.equals(LootTableList.CHESTS_STRONGHOLD_CORRIDOR) || tableName.equals(LootTableList.CHESTS_STRONGHOLD_CROSSING) || tableName.equals(LootTableList.CHESTS_ABANDONED_MINESHAFT)) {
        pool = event.getTable().getPool("main");
        bandage = 20;
        plaster = 24;
        morphine = 8;
    }

    if (pool != null) {
        pool.addEntry(new LootEntryItem(FirstAidItems.BANDAGE, bandage, 0, new SetCount[]{new SetCount(new LootCondition[0], new RandomValueRange(1, 3))}, new LootCondition[0], FirstAid.MODID + "bandage"));
        pool.addEntry(new LootEntryItem(FirstAidItems.PLASTER, plaster, 0, new SetCount[]{new SetCount(new LootCondition[0], new RandomValueRange(1, 5))}, new LootCondition[0], FirstAid.MODID + "plaster"));
        pool.addEntry(new LootEntryItem(FirstAidItems.MORPHINE, morphine, 0, new SetCount[]{new SetCount(new LootCondition[0], new RandomValueRange(1, 2))}, new LootCondition[0], FirstAid.MODID + "morphine"));
    }
}
项目: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"));
        }
    }
}
项目:BetterBeginningsReborn    文件:LootUtil.java   
public static SetCount createCountFunction(float min,float max)
   {
return createCountFunction(min, max, NO_CONDITIONS);
   }
项目:BetterBeginningsReborn    文件:LootUtil.java   
public static SetCount createCountFunction(float min,float max, LootCondition... conditionsIn)
   {
return new SetCount(conditionsIn, new RandomValueRange(min, max));
   }
项目:EnderIO    文件:LootManager.java   
private @Nonnull SetCount setCount(int min, int max) {
  return new SetCount(NO_CONDITIONS, new RandomValueRange(min, min));
}
项目: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 item The item to add.
 * @param meta The metadata for the loot.
 * @param min The smallest item size.
 * @param max The largest item size.
 * @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, Item item, int meta, int min, int max) {

    final LootBuilder loot = this.addLoot(location, name, pool, weight, item, meta);
    loot.addFunction(new SetCount(new LootCondition[0], new RandomValueRange(min, max)));
    return loot;
}