Java Code Examples for net.minecraft.util.WeightedRandom#Item

The following examples show how to use net.minecraft.util.WeightedRandom#Item . 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: RecipeHandlerLaserDrill.java    From NEI-Integration with MIT License 6 votes vote down vote up
@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");
    }
}
 
Example 2
Source File: RecipeHandlerLaserDrill.java    From NEI-Integration with MIT License 6 votes vote down vote up
@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));
                        }
                    }
                }
            }
        }
    }
}
 
Example 3
Source File: RecipeHandlerLaserDrill.java    From NEI-Integration with MIT License 6 votes vote down vote up
@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));
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 4
Source File: RecipeHandlerLaserDrill.java    From NEI-Integration with MIT License 6 votes vote down vote up
@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));
                        }
                    }
                }
            }
        }
    }
}