本文整理匯總了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);
}