本文整理匯總了Java中net.minecraft.util.WeightedRandom.getTotalWeight方法的典型用法代碼示例。如果您正苦於以下問題:Java WeightedRandom.getTotalWeight方法的具體用法?Java WeightedRandom.getTotalWeight怎麽用?Java WeightedRandom.getTotalWeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.WeightedRandom
的用法示例。
在下文中一共展示了WeightedRandom.getTotalWeight方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getWeightedBiomeEntry
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
protected BiomeEntry getWeightedBiomeEntry()
{
if(biomeEntries == null || biomeEntries.isEmpty())
return new BiomeEntry(BiomeGenBase.ocean, 100);
List<BiomeEntry> biomeList = biomeEntries;
int totalWeight = WeightedRandom.getTotalWeight(biomeList);
int weight = nextInt(Math.max(totalWeight / 10,1)) * 10;
return (BiomeEntry)WeightedRandom.getItem(biomeList, weight);
}
示例2: getWeightedBiomeEntry
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
protected BiomeManager.BiomeEntry getWeightedBiomeEntry(BiomeManager.BiomeType type)
{
List<BiomeManager.BiomeEntry> biomeList = biomes[type.ordinal()];
int totalWeight = WeightedRandom.getTotalWeight(biomeList);
int weight = BiomeManager.isTypeListModded(type)?nextInt(totalWeight):nextInt(totalWeight / 10) * 10;
return (BiomeManager.BiomeEntry)WeightedRandom.getItem(biomeList, weight);
}
示例3: getWeightedBiomeFromList
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
private int getWeightedBiomeFromList(List<BiomeEntry> biomeList){
int totalWeight = WeightedRandom.getTotalWeight(biomeList);
long randomLong = this.nextLong(totalWeight / 10);
int randomNr = (int)randomLong * 10;
BiomeEntry entry = (BiomeEntry)WeightedRandom.getItem(biomeList, randomNr);
int biomeID = entry.biome.biomeID;
return ((BiomeEntry)WeightedRandom.getItem(biomeList, (int)this.nextLong(WeightedRandom.getTotalWeight(biomeList) / 10) * 10)).biome.biomeID;
}
示例4: register
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
@Override
public void register(IModRegistry registry) {
if (BlockRegistry.sludgeRefinerBlock.isEnabled()) {
int maxWeight = WeightedRandom.getTotalWeight(BlockRegistry.sludgeRefinerBlock.getItems());
List<SludgeRefinerRecipeWrapper> wrapperList = new ArrayList<>();
BlockRegistry.sludgeRefinerBlock.getItems().forEach(itemStackWeightedItem -> wrapperList.add(new SludgeRefinerRecipeWrapper(itemStackWeightedItem, maxWeight)));
registry.addRecipes(wrapperList, sludgeRefinerRecipeCategory.getUid());
registry.addRecipeCatalyst(new ItemStack(BlockRegistry.sludgeRefinerBlock), sludgeRefinerRecipeCategory.getUid());
}
if (BlockRegistry.bioReactorBlock.isEnabled()) {
List<ReactorRecipeWrapper> bioreactor = new ArrayList<>();
BioReactorEntry.BIO_REACTOR_ENTRIES.forEach(entry -> bioreactor.add(new ReactorRecipeWrapper(entry.getStack(), FluidsRegistry.BIOFUEL, BlockRegistry.bioReactorBlock.getBaseAmount())));
registry.addRecipes(bioreactor, bioReactorRecipeCategory.getUid());
registry.addRecipeCatalyst(new ItemStack(BlockRegistry.bioReactorBlock), bioReactorRecipeCategory.getUid());
}
if (BlockRegistry.proteinReactorBlock.isEnabled()) {
List<ReactorRecipeWrapper> proteinreactor = new ArrayList<>();
ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES.forEach(entry -> proteinreactor.add(new ReactorRecipeWrapper(entry.getStack(), FluidsRegistry.PROTEIN, BlockRegistry.proteinReactorBlock.getBaseAmount())));
registry.addRecipes(proteinreactor, proteinReactorRecipeCategory.getUid());
registry.addRecipeCatalyst(new ItemStack(BlockRegistry.proteinReactorBlock), proteinReactorRecipeCategory.getUid());
}
if (BlockRegistry.laserBaseBlock.isEnabled() || BlockRegistry.laserDrillBlock.isEnabled()) {
List<ItemStackWeightedItem> item = new ArrayList<>();
LaserDrillEntry.LASER_DRILL_ENTRIES.forEach(entry -> item.add(new ItemStackWeightedItem(entry.getStack(), entry.getWeight())));
final int laserMaxWeight = WeightedRandom.getTotalWeight(item);
List<LaserRecipeWrapper> laserRecipeWrappers = new ArrayList<>();
LaserDrillEntry.LASER_DRILL_ENTRIES.forEach(entry -> laserRecipeWrappers.add(new LaserRecipeWrapper(new ItemStackWeightedItem(entry.getStack(), entry.getWeight()), laserMaxWeight, entry.getLaserMeta())));
registry.addRecipes(laserRecipeWrappers, laserRecipeCategory.getUid());
registry.addRecipeCatalyst(new ItemStack(BlockRegistry.laserDrillBlock), laserRecipeCategory.getUid());
registry.addRecipeCatalyst(new ItemStack(BlockRegistry.laserBaseBlock), laserRecipeCategory.getUid());
}
if (BlockRegistry.resourcefulFurnaceBlock.isEnabled())
registry.addRecipeCatalyst(new ItemStack(BlockRegistry.resourcefulFurnaceBlock), VanillaRecipeCategoryUid.SMELTING);
if (BlockRegistry.potionEnervatorBlock.isEnabled())
registry.addRecipeCatalyst(new ItemStack(BlockRegistry.potionEnervatorBlock), VanillaRecipeCategoryUid.BREWING);
registry.addRecipes(Arrays.asList(
new MachineProduceWrapper(BlockRegistry.sporesRecreatorBlock, new ItemStack(Blocks.BROWN_MUSHROOM)),
new MachineProduceWrapper(BlockRegistry.sporesRecreatorBlock, new ItemStack(Blocks.RED_MUSHROOM)),
new MachineProduceWrapper(BlockRegistry.sewageCompostSolidiferBlock, new ItemStack(ItemRegistry.fertilizer)),
new MachineProduceWrapper(BlockRegistry.dyeMixerBlock, new ItemStack(Items.DYE, 1, OreDictionary.WILDCARD_VALUE)),
new MachineProduceWrapper(BlockRegistry.lavaFabricatorBlock, new ItemStack(Items.LAVA_BUCKET)),
new MachineProduceWrapper(BlockRegistry.waterResourcesCollectorBlock, new ItemStack(Items.FISH, 1, OreDictionary.WILDCARD_VALUE)),
new MachineProduceWrapper(BlockRegistry.mobRelocatorBlock, FluidUtil.getFilledBucket(new FluidStack(FluidsRegistry.ESSENCE, 1000))),
new MachineProduceWrapper(BlockRegistry.cropRecolectorBlock, FluidUtil.getFilledBucket(new FluidStack(FluidsRegistry.SLUDGE, 1000))),
new MachineProduceWrapper(BlockRegistry.waterCondensatorBlock, FluidUtil.getFilledBucket(new FluidStack(FluidRegistry.WATER, 1000))),
new MachineProduceWrapper(BlockRegistry.animalResourceHarvesterBlock, FluidUtil.getFilledBucket(new FluidStack(FluidsRegistry.MILK, 1000))),
new MachineProduceWrapper(BlockRegistry.mobSlaughterFactoryBlock, FluidUtil.getFilledBucket(new FluidStack(FluidsRegistry.MEAT, 1000))),
new MachineProduceWrapper(BlockRegistry.mobSlaughterFactoryBlock, FluidUtil.getFilledBucket(new FluidStack(FluidsRegistry.PINK_SLIME, 1000))),
new MachineProduceWrapper(BlockRegistry.treeFluidExtractorBlock, FluidUtil.getFilledBucket(new FluidStack(FluidsRegistry.LATEX, 1000))),
new MachineProduceWrapper(BlockRegistry.latexProcessingUnitBlock, new ItemStack(ItemRegistry.tinyDryRubber)),
new MachineProduceWrapper(BlockRegistry.animalByproductRecolectorBlock, FluidUtil.getFilledBucket(new FluidStack(FluidsRegistry.SEWAGE, 1000))),
new MachineProduceWrapper(BlockRegistry.lavaFabricatorBlock, FluidUtil.getFilledBucket(new FluidStack(FluidRegistry.LAVA, 1000))),
new MachineProduceWrapper(BlockRegistry.proteinReactorBlock, FluidUtil.getFilledBucket(new FluidStack(FluidsRegistry.PROTEIN, 1000)))).stream().filter(machineProduceWrapper -> ((CustomOrientedBlock) machineProduceWrapper.getBlock()).isEnabled()).collect(Collectors.toList()),
machineProduceCategory.getUid());
if (BlockRegistry.materialStoneWorkFactoryBlock.isEnabled()) {
NonNullList<ItemStack> wrappers = NonNullList.create();
findAllStoneWorkOutputs(wrappers, new ItemStack(Blocks.COBBLESTONE), 0);
wrappers.stream().filter(stack -> !stack.isEmpty()).forEach(stack -> registry.addRecipes(Collections.singletonList(new MachineProduceWrapper(BlockRegistry.materialStoneWorkFactoryBlock, stack)), machineProduceCategory.getUid()));
}
if (BlockRegistry.petrifiedFuelGeneratorBlock.isEnabled()) {
List<PetrifiedBurnTimeWrapper> petrifiedBurnTimeWrappers = new ArrayList<>();
registry.getIngredientRegistry().getFuels().stream().filter(stack -> !(stack.getItem() instanceof ItemBucket)).forEach(stack -> petrifiedBurnTimeWrappers.add(new PetrifiedBurnTimeWrapper(stack, TileEntityFurnace.getItemBurnTime(stack))));
registry.addRecipes(petrifiedBurnTimeWrappers, petrifiedBurnTimeCategory.getUid());
registry.addRecipeCatalyst(new ItemStack(BlockRegistry.petrifiedFuelGeneratorBlock), petrifiedBurnTimeCategory.getUid());
}
if (CustomConfiguration.enableBookEntriesInJEI) {
for (BookCategory category : BookCategory.values()) {
registry.addRecipes(category.getEntries().values().stream().map(ManualWrapper::new).collect(Collectors.toList()), manualCategory.getUid());
}
registry.addRecipeCatalyst(new ItemStack(ItemRegistry.bookManualItem), manualCategory.getUid());
}
}
示例5: WeightedBakedModel
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
public WeightedBakedModel(List<WeightedBakedModel.MyWeighedRandomItem> p_i46073_1_)
{
this.models = p_i46073_1_;
this.totalWeight = WeightedRandom.getTotalWeight(p_i46073_1_);
this.baseModel = ((WeightedBakedModel.MyWeighedRandomItem)p_i46073_1_.get(0)).model;
}
示例6: WeightedBakedModel
import net.minecraft.util.WeightedRandom; //導入方法依賴的package包/類
public WeightedBakedModel(List<WeightedBakedModel.WeightedModel> modelsIn)
{
this.models = modelsIn;
this.totalWeight = WeightedRandom.getTotalWeight(modelsIn);
this.baseModel = ((WeightedBakedModel.WeightedModel)modelsIn.get(0)).model;
}