本文整理匯總了Java中net.minecraft.util.WeightedRandom.Item方法的典型用法代碼示例。如果您正苦於以下問題:Java WeightedRandom.Item方法的具體用法?Java WeightedRandom.Item怎麽用?Java WeightedRandom.Item使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.WeightedRandom
的用法示例。
在下文中一共展示了WeightedRandom.Item方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getOreToPut
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
public static ItemStack getOreToPut() {
List<WeightedRandom.Item> values = new ArrayList<net.minecraft.util.WeightedRandom.Item>();
for (String s : oreNames.keySet())
values.add(new StringRandomItem(oreNames.get(s), s));
String ore = ((StringRandomItem) WeightedRandom.getRandomItem(new Random(), values)).s;
List<ItemStack> ores = OreDictionary.getOres(ore);
for (ItemStack stack : ores) {
Item item = stack.getItem();
String clname = item.getClass().getName();
if (clname.startsWith("gregtech") || clname.startsWith("gregapi")) {
continue;
}
return stack.copy();
}
return getOreToPut();
}
示例2: prepare
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
@Override
public void prepare() {
laserOres = MFRRegistry.getLaserOres();
for (WeightedRandom.Item ore : laserOres) {
totalWeight += ore.itemWeight;
}
laserPreferredOres = new HashMap<Integer, List<ItemStack>>();
for (int i = 0; i <= 15; i++) {
List<ItemStack> preferredOres = MFRRegistry.getLaserPreferredOres(i);
laserPreferredOres.put(i, preferredOres);
}
TileEntityLaserDrillPrecharger dummyPrecharger = new TileEntityLaserDrillPrecharger();
TileEntityLaserDrill dummyDrill = new TileEntityLaserDrill();
energyPerOperation = dummyPrecharger.getActivationEnergy() * dummyDrill.getWorkMax();
dummyPrecharger = null;
dummyDrill = null;
laserFocus = GameRegistry.findItem("MineFactoryReloaded", "laserfocus");
if (laserFocus == null) {
laserFocus = GameRegistry.findItem("MineFactoryReloaded", "item.mfr.laserfocus");
}
}
示例3: loadAllRecipes
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
@Override
public void loadAllRecipes() {
for (WeightedRandom.Item drop : laserOres) {
if (drop instanceof WeightedRandomItemStack) {
ItemStack dropStack = ((WeightedRandomItemStack) drop).getStack();
for (int i : laserPreferredOres.keySet()) {
List<ItemStack> preferredStacks = laserPreferredOres.get(i);
if (preferredStacks != null) {
for (ItemStack preferredStack : preferredStacks) {
if (Utils.areStacksSameTypeCraftingSafe(preferredStack, dropStack)) {
this.arecipes.add(new CachedLaserDrillRecipe(dropStack, drop.itemWeight, i));
}
}
}
}
}
}
}
示例4: loadCraftingRecipes
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
@Override
public void loadCraftingRecipes(ItemStack result) {
for (WeightedRandom.Item drop : laserOres) {
if (drop instanceof WeightedRandomItemStack) {
if (Utils.areStacksSameTypeCraftingSafe(((WeightedRandomItemStack) drop).getStack(), result)) {
ItemStack dropStack = ((WeightedRandomItemStack) drop).getStack();
for (int i : laserPreferredOres.keySet()) {
List<ItemStack> preferredStacks = laserPreferredOres.get(i);
if (preferredStacks != null) {
for (ItemStack preferredStack : preferredStacks) {
if (Utils.areStacksSameTypeCraftingSafe(preferredStack, dropStack)) {
this.arecipes.add(new CachedLaserDrillRecipe(dropStack, drop.itemWeight, i));
}
}
}
}
}
}
}
}
示例5: loadUsageRecipes
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
@Override
public void loadUsageRecipes(ItemStack ingred) {
int dmg = ingred.getItemDamage();
if (ingred.getItem() == laserFocus && dmg <= 15) {
for (WeightedRandom.Item drop : laserOres) {
if (drop instanceof WeightedRandomItemStack) {
ItemStack dropStack = ((WeightedRandomItemStack) drop).getStack();
List<ItemStack> preferredStacks = laserPreferredOres.get(dmg);
if (preferredStacks != null) {
for (ItemStack preferredStack : preferredStacks) {
if (Utils.areStacksSameTypeCraftingSafe(preferredStack, dropStack)) {
this.arecipes.add(new CachedLaserDrillRecipe(dropStack, drop.itemWeight, dmg));
}
}
}
}
}
}
}