當前位置: 首頁>>代碼示例>>Java>>正文


Java WeightedRandom.Item方法代碼示例

本文整理匯總了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();
}
 
開發者ID:AdlyTempleton,項目名稱:Aura-Cascade,代碼行數:23,代碼來源:OreDropManager.java

示例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");
    }
}
 
開發者ID:Tonius,項目名稱:NEI-Integration,代碼行數:25,代碼來源:RecipeHandlerLaserDrill.java

示例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));
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:Tonius,項目名稱:NEI-Integration,代碼行數:19,代碼來源:RecipeHandlerLaserDrill.java

示例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));
                            }
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:Tonius,項目名稱:NEI-Integration,代碼行數:21,代碼來源:RecipeHandlerLaserDrill.java

示例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));
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:Tonius,項目名稱:NEI-Integration,代碼行數:20,代碼來源:RecipeHandlerLaserDrill.java


注:本文中的net.minecraft.util.WeightedRandom.Item方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。