当前位置: 首页>>代码示例>>Java>>正文


Java RandomValueRange类代码示例

本文整理汇总了Java中net.minecraft.world.storage.loot.RandomValueRange的典型用法代码示例。如果您正苦于以下问题:Java RandomValueRange类的具体用法?Java RandomValueRange怎么用?Java RandomValueRange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RandomValueRange类属于net.minecraft.world.storage.loot包,在下文中一共展示了RandomValueRange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLootTableLoad

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
@SubscribeEvent
public void onLootTableLoad(LootTableLoadEvent event) {
    if (ConfigHandler.general.enableDungeonLoot) {
        String prefix = "minecraft:chests/";
        String name = event.getName().toString();
        if (name.startsWith(prefix)) {
            String file = name.substring(name.indexOf(prefix) + prefix.length());
            switch (file) {
                case "abandoned_mineshaft":
                case "desert_pyramid":
                case "jungle_temple":
                case "simple_dungeon":
                case "spawn_bonus_chest":
                case "stronghold_corridor":
                case "village_blacksmith":
                    LootEntry entry = new LootEntryTable(RL("inject/simple_dungeon_loot"), 1, 0,  new LootCondition[0], "pneumaticcraft_inject_entry");
                    LootPool pool = new LootPool(new LootEntry[]{entry}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "pneumaticcraft_inject_pool");
                    event.getTable().addPool(pool);
                    break;
                default:
                    break;
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:EventHandlerPneumaticCraft.java

示例2: onLootTableLoad

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
@SubscribeEvent
public static void onLootTableLoad(LootTableLoadEvent event) {
    ResourceLocation tableName = event.getName();
    LootPool pool = null;
    int bandage = 0, plaster = 0, morphine = 0;
    if (tableName.equals(LootTableList.CHESTS_SPAWN_BONUS_CHEST)) {
        pool = event.getTable().getPool("main");
        bandage = 8;
        plaster = 16;
        morphine = 4;
    } else if (tableName.equals(LootTableList.CHESTS_STRONGHOLD_CORRIDOR) || tableName.equals(LootTableList.CHESTS_STRONGHOLD_CROSSING) || tableName.equals(LootTableList.CHESTS_ABANDONED_MINESHAFT)) {
        pool = event.getTable().getPool("main");
        bandage = 20;
        plaster = 24;
        morphine = 8;
    }

    if (pool != null) {
        pool.addEntry(new LootEntryItem(FirstAidItems.BANDAGE, bandage, 0, new SetCount[]{new SetCount(new LootCondition[0], new RandomValueRange(1, 3))}, new LootCondition[0], FirstAid.MODID + "bandage"));
        pool.addEntry(new LootEntryItem(FirstAidItems.PLASTER, plaster, 0, new SetCount[]{new SetCount(new LootCondition[0], new RandomValueRange(1, 5))}, new LootCondition[0], FirstAid.MODID + "plaster"));
        pool.addEntry(new LootEntryItem(FirstAidItems.MORPHINE, morphine, 0, new SetCount[]{new SetCount(new LootCondition[0], new RandomValueRange(1, 2))}, new LootCondition[0], FirstAid.MODID + "morphine"));
    }
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:24,代码来源:EventHandler.java

示例3: testCondition

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
public boolean testCondition(Random rand, LootContext context)
{
    Entity entity = context.getEntity(this.target);

    if (entity == null)
    {
        return false;
    }
    else
    {
        Scoreboard scoreboard = entity.world.getScoreboard();

        for (Entry<String, RandomValueRange> entry : this.scores.entrySet())
        {
            if (!this.entityScoreMatch(entity, scoreboard, (String)entry.getKey(), (RandomValueRange)entry.getValue()))
            {
                return false;
            }
        }

        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:EntityHasScore.java

示例4: testCondition

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
public boolean testCondition(Random rand, LootContext context)
{
    Entity entity = context.getEntity(this.target);

    if (entity == null)
    {
        return false;
    }
    else
    {
        Scoreboard scoreboard = entity.worldObj.getScoreboard();

        for (Entry<String, RandomValueRange> entry : this.scores.entrySet())
        {
            if (!this.entityScoreMatch(entity, scoreboard, (String)entry.getKey(), (RandomValueRange)entry.getValue()))
            {
                return false;
            }
        }

        return true;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:EntityHasScore.java

示例5: getToxicWaterCatch

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
protected List<ItemStack> getToxicWaterCatch(Set<BiomeDictionary.Type> biomeTypesList) {
    List<ItemStack> tempList = new ArrayList<>();
    int chance = this.rand.nextInt(100) + Math.round(luck);

    if (chance < 50) {
        tempList.add(new ItemStack(Items.BONE));
        tempList.add(new ItemStack(Items.ROTTEN_FLESH));
        tempList.add(new ItemStack(Items.SPIDER_EYE));
        tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.GREEN_JELLYFISH.ordinal()));
        tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.BONE_FISH.ordinal()));
    } else if (chance < 80) {
        tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.SPOOKYFIN.ordinal()));
    } else if (chance < 95) {
        tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.CURSED_KOI.ordinal()));
    } else {
        if (chance < 98) {
            tempList.add(new ItemStack(Blocks.SKULL, 1, 0)); // SKELETON
            tempList.add(new ItemStack(Blocks.SKULL, 1, 2)); // ZOMBIE
        } else {
            EnchantmentHelper.addRandomEnchantment(rand, new ItemStack(GSItem.ENCHANTED_SKULL, 1, 0), new RandomValueRange(30, 40).generateInt(rand), true);
        }
    }
    return tempList;
}
 
开发者ID:NightKosh,项目名称:Gravestone-mod-Extended,代码行数:25,代码来源:EntityBoneFishHook.java

示例6: onLootTableLoad

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
@SubscribeEvent
public void onLootTableLoad(LootTableLoadEvent event) {
  LootPool main = event.getTable().getPool(LOOTPOOLNAME);
  if (main == null) {
    //create my own.  EX: mobs that have no drops (bats) also have empty loot table, so i have to inject an entry in the table before I fill it
    event.getTable().addPool(new LootPool(new LootEntry[0], new LootCondition[0], new RandomValueRange(1F, 2F), new RandomValueRange(1F, 1F), LOOTPOOLNAME));
    main = event.getTable().getPool(LOOTPOOLNAME);
    if (main == null) {
      ModCyclic.logger.error("could not insert Loot Pool for table :" + event.getName().toString());
      return;
    }
  }
  if (enableChestLoot) {
    onLootChestTableLoad(main, event);
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:17,代码来源:LootTableModule.java

示例7: addPool

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
private static void addPool(LootTable table)
{
	LootEntry common = new LootEntryTable(new ResourceLocation("lootslashconquer:chests/common_chest"), 60, 1, new LootCondition[0], "common");
	LootEntry uncommon = new LootEntryTable(new ResourceLocation("lootslashconquer:chests/uncommon_chest"), 25, 1, new LootCondition[0], "uncommon");
	LootEntry rare = new LootEntryTable(new ResourceLocation("lootslashconquer:chests/rare_chest"), 10, 1, new LootCondition[0], "rare");
	LootEntry legendary = new LootEntryTable(new ResourceLocation("lootslashconquer:chests/legendary_chest"), 5, 1, new LootCondition[0], "legendary");
	LootEntry exotic = new LootEntryTable(new ResourceLocation("lootslashconquer:chests/exotic_chest"), 2, 1, new LootCondition[0], "exotic");

	LootPool pool = new LootPool(new LootEntry[] { common, uncommon, rare, legendary, exotic }, new LootCondition[0], new RandomValueRange(0, 1), new RandomValueRange(0), "loot");

	table.addPool(pool);
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:13,代码来源:EventLoadLootTable.java

示例8: addTables

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
@SubscribeEvent
public void addTables(LootTableLoadEvent event){
    String name = event.getName().toString();
    if(Randores.getConfigObj().getModules().isDungeonLoot()) {
        if (is(name, chests)) {
            event.getTable().addPool(new LootPool(new LootEntry[] {new RandoresLootEntry(1, 2, true, 10, 20, new LootCondition[0], "randores_flexible_loot_entry")}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "randores_flexible_pool"));
        } else if (name.contains("end_city_treasure")) {
            event.getTable().addPool(new LootPool(new LootEntry[] {new RandoresLootEntry(1, 5, true, 20, 50, new LootCondition[0], "randores_flexible_loot_entry")}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "randores_flexible_pool"));
        } else if (name.contains("spawn_bonus_chest")) {
            event.getTable().addPool(new LootPool(new LootEntry[] {new RandoresLootEntry(1, 1, false, 0, 0, new LootCondition[0], "randores_flexible_loot_entry")}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "randores_flexible_pool"));
        }
    }
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:14,代码来源:RandoresLoot.java

示例9: entityScoreMatch

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
protected boolean entityScoreMatch(Entity entityIn, Scoreboard scoreboardIn, String objectiveStr, RandomValueRange rand)
{
    ScoreObjective scoreobjective = scoreboardIn.getObjective(objectiveStr);

    if (scoreobjective == null)
    {
        return false;
    }
    else
    {
        String s = entityIn instanceof EntityPlayerMP ? entityIn.getName() : entityIn.getCachedUniqueIdString();
        return !scoreboardIn.entityHasObjective(s, scoreobjective) ? false : rand.isInRange(scoreboardIn.getOrCreateScore(s, scoreobjective).getScorePoints());
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:EntityHasScore.java

示例10: serialize

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
public void serialize(JsonObject json, EntityHasScore value, JsonSerializationContext context)
{
    JsonObject jsonobject = new JsonObject();

    for (Entry<String, RandomValueRange> entry : value.scores.entrySet())
    {
        jsonobject.add((String)entry.getKey(), context.serialize(entry.getValue()));
    }

    json.add("scores", jsonobject);
    json.add("entity", context.serialize(value.target));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:EntityHasScore.java

示例11: deserialize

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
public EntityHasScore deserialize(JsonObject json, JsonDeserializationContext context)
{
    Set<Entry<String, JsonElement>> set = JsonUtils.getJsonObject(json, "scores").entrySet();
    Map<String, RandomValueRange> map = Maps.<String, RandomValueRange>newLinkedHashMap();

    for (Entry<String, JsonElement> entry : set)
    {
        map.put(entry.getKey(), JsonUtils.deserializeClass((JsonElement)entry.getValue(), "score", context, RandomValueRange.class));
    }

    return new EntityHasScore(map, (LootContext.EntityTarget)JsonUtils.deserializeClass(json, "entity", context, LootContext.EntityTarget.class));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:EntityHasScore.java

示例12: Modifier

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
private Modifier(String modifName, String attrName, int operationIn, RandomValueRange randomAmount, EntityEquipmentSlot[] slotsIn, @Nullable UUID uuidIn)
{
    this.modifierName = modifName;
    this.attributeName = attrName;
    this.operation = operationIn;
    this.amount = randomAmount;
    this.uuid = uuidIn;
    this.slots = slotsIn;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:10,代码来源:SetAttributes.java

示例13: lootTableLoad

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
@SubscribeEvent
public void lootTableLoad(final LootTableLoadEvent event) {
	if (NemesisConfig.DISCOVERY_ENABLED && isLootTarget(event)) {

		// TODO improve roll settings

		String name = LOOT_TABLE.toString();
		LootEntry entry = new LootEntryTable(LOOT_TABLE, 1, 0, new LootCondition[0], name);

		RandomValueRange rolls = new RandomValueRange(0, 1);
		LootPool pool = new LootPool(new LootEntry[] { entry }, new LootCondition[0], rolls, rolls, name);
		event.getTable().addPool(pool);
	}
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:15,代码来源:LootHandler.java

示例14: tableToItemStacks

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
/**
 * Converts a LootTable to a list of possible drops, only looks for Item and metadata.
 * @param table the loot table to get items from
 * @return a LinkedList of the stacks in the loot table
 */
public static List<ItemStack> tableToItemStacks(LootTable table){
	List<ItemStack> stacks = new LinkedList<>();
	for(LootPool p:getPools(table)){
		for(LootEntry entry:getEntries(p)){
			if(entry instanceof LootEntryItem){
				LootEntryItem ei = (LootEntryItem)entry;
				Item item = getItem(ei);
				LootFunction[] functs = getFunctions(ei);
				boolean metaSet = false;
				for(LootFunction func:functs){
					if(func instanceof SetMetadata){
						metaSet=true;
						RandomValueRange range = (RandomValueRange)ReflectionHelper.getPrivateValue(SetMetadata.class, (SetMetadata)func, "metaRange","field_186573_b");
						int meta = MathHelper.floor(range.getMin());
						stacks.add(new ItemStack(item,1,meta));
					}
				}
				if(!metaSet)stacks.add(new ItemStack(item));
			}
			/* won't bother with this case for now
			else if(entry instanceof LootEntryTable){
				//restart with that table
				ResourceLocation location = (ResourceLocation) ReflectionHelper.getPrivateValue(LootEntryTable.class, (LootEntryTable)entry, "table","field_186371_a");
			}
			*/
		}
	}
	return stacks;
}
 
开发者ID:Xilef11,项目名称:runesofwizardry-classics,代码行数:35,代码来源:LootUtils.java

示例15: getLavaCatch

import net.minecraft.world.storage.loot.RandomValueRange; //导入依赖的package包/类
@Override
protected List<ItemStack> getLavaCatch(Set<BiomeDictionary.Type> biomeTypesList) {
    List<ItemStack> tempList = new ArrayList<>();

    int chance = this.rand.nextInt(100) + Math.round(luck);
    if (!biomeTypesList.contains(BiomeDictionary.Type.NETHER)) {
        if (chance < 80) {
            tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.OBSIDIFISH.ordinal()));
        } else if (chance < 95) {
            tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.MAGMA_JELLYFISH.ordinal()));
        } else {
            if (chance < 98) {
                tempList.add(new ItemStack(Blocks.SKULL, 1, 1)); //WITHER SKULL
            } else {
                EnchantmentHelper.addRandomEnchantment(rand, new ItemStack(GSItem.ENCHANTED_SKULL, 1, 1), new RandomValueRange(40, 50).generateInt(rand), true);
            }
        }
    } else {
        if (chance < 40) {
            tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.NETHER_SALMON.ordinal()));
        } else if (chance < 80) {
            tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.MAGMA_JELLYFISH.ordinal()));
            tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.QUARTZ_COD.ordinal()));
            tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.WITHERED_CRUCIAN.ordinal()));
        } else if (chance < 95) {
            tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.FLAREFIN_KOI.ordinal()));
            tempList.add(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.BLAZE_COD.ordinal()));
        } else {
            if (chance < 98) {
                tempList.add(new ItemStack(Blocks.SKULL, 1, 1)); //WITHER SKULL
            } else {
                EnchantmentHelper.addRandomEnchantment(rand, new ItemStack(GSItem.ENCHANTED_SKULL, 1, 1), new RandomValueRange(40, 50).generateInt(rand), true);
            }
        }
    }
    return tempList;
}
 
开发者ID:NightKosh,项目名称:Gravestone-mod-Extended,代码行数:38,代码来源:EntityObsidianFishHook.java


注:本文中的net.minecraft.world.storage.loot.RandomValueRange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。