net.minecraft.world.storage.loot.RandomValueRange Java Examples

The following examples show how to use net.minecraft.world.storage.loot.RandomValueRange. 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: SakuraEventLoader.java    From Sakura_mod with MIT License 5 votes vote down vote up
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 #2
Source File: ChestGenHooks.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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()));
    }
}
 
Example #3
Source File: ChestGenHooks.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void addRolls(ResourceLocation tableLocation, int minAdd, int maxAdd) {
    rollVals.put(tableLocation, new RandomValueRange(minAdd, maxAdd));
}
 
Example #4
Source File: GTEventLootTableLoad.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static SetCount createCountFunction(float min, float max) {
	return new SetCount(NO_CONDITIONS, new RandomValueRange(min, max));
}