本文整理汇总了Java中net.minecraftforge.common.ChestGenHooks.generateStacks方法的典型用法代码示例。如果您正苦于以下问题:Java ChestGenHooks.generateStacks方法的具体用法?Java ChestGenHooks.generateStacks怎么用?Java ChestGenHooks.generateStacks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.common.ChestGenHooks
的用法示例。
在下文中一共展示了ChestGenHooks.generateStacks方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateRandomChestContents
import net.minecraftforge.common.ChestGenHooks; //导入方法依赖的package包/类
/**
* Generates a number of random chest contents, placing them in the chest either completely
* at random or only in empty slots, as designated by the parameters
*/
public static void generateRandomChestContents(Random rand, List<WeightedRandomChestContent> weightedContents, IInventory chest, int numItems, boolean atRandom) {
for (int i = 0; i < numItems; ++i) {
WeightedRandomChestContent weightedChest = (WeightedRandomChestContent) WeightedRandom.getRandomItem(rand, weightedContents);
ItemStack[] stacks = ChestGenHooks.generateStacks(rand, weightedChest.theItemId, weightedChest.minStackSize, weightedChest.maxStackSize);
for (ItemStack item : stacks) {
if (atRandom) {
chest.setInventorySlotContents(rand.nextInt(chest.getSizeInventory()), item);
} else {
addItemToInventoryAtRandom(rand, item, chest, 3);
}
}
}
}
示例2: generateChestContent
import net.minecraftforge.common.ChestGenHooks; //导入方法依赖的package包/类
@Override
protected ItemStack[] generateChestContent(Random random, IInventory newInventory)
{
ItemStack[] a = ChestGenHooks.generateStacks(random, theItemId, theMinimumChanceToGenerateItem, theMaximumChanceToGenerateItem);
for(int i=a.length-1; i>=0; --i) {
a[i] = ArtifactsAPI.artifacts.applyRandomEffects(a[i]);
}
return a;
}
示例3: generateChestContent
import net.minecraftforge.common.ChestGenHooks; //导入方法依赖的package包/类
@Override
protected ItemStack[] generateChestContent(Random random, IInventory newInventory) {
// pick a random item from the group
WeightedRandomChestContent randomLoot = (WeightedRandomChestContent)WeightedRandom.getRandomItem(random, this.weightedLoot);
return ChestGenHooks.generateStacks(random, randomLoot.theItemId, this.theMinimumChanceToGenerateItem, this.theMaximumChanceToGenerateItem);
}
示例4: generateChestContent
import net.minecraftforge.common.ChestGenHooks; //导入方法依赖的package包/类
/**
* Allow a mod to submit a custom implementation that can delegate item stack generation beyond simple stack lookup
*
* @param random The current random for generation
* @param newInventory The inventory being generated (do not populate it, but you can refer to it)
* @return An array of {@link ItemStack} to put into the chest
*/
protected ItemStack[] generateChestContent(Random random, IInventory newInventory)
{
return ChestGenHooks.generateStacks(random, theItemId, theMinimumChanceToGenerateItem, theMaximumChanceToGenerateItem);
}