本文整理匯總了Java中net.minecraft.world.storage.loot.functions.SetDamage類的典型用法代碼示例。如果您正苦於以下問題:Java SetDamage類的具體用法?Java SetDamage怎麽用?Java SetDamage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SetDamage類屬於net.minecraft.world.storage.loot.functions包,在下文中一共展示了SetDamage類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onLootTablesLoaded
import net.minecraft.world.storage.loot.functions.SetDamage; //導入依賴的package包/類
@SubscribeEvent
public void onLootTablesLoaded (LootTableLoadEvent event) {
// Checks to see if the loot table being loaded is the basic dungeon chest.
if (event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) {
// Gets pool2 from the loot table. This pool is where common loot like zombie flesh
// bones and string goes.
final LootPool pool2 = event.getTable().getPool("pool2");
// Makes sure the pool has not been deleted.
if (pool2 != null) {
// Adds cookies to the loot pool. Has a weight of 10 and spawns in stacks of 1
// to 5.
pool2.addEntry(new LootEntryItem(Items.COOKIE, 10, 0, new LootFunction[] { new SetCount(new LootCondition[0], new RandomValueRange(1, 5)) }, new LootCondition[0], "tutorial:cookie"));
// Adds Lime Green Dye to the loot pool. Has a weight of 10.
pool2.addEntry(new LootEntryItem(Items.DYE, 10, 0, new LootFunction[] { new SetDamage(new LootCondition[0], new RandomValueRange(10, 10)) }, new LootCondition[0], "tutorial:dyes"));
}
}
// Checks to see if the loot table being loaded is for the mob we are looking for
if (event.getName().equals(LootTableList.ENTITIES_PIG)) {
// Gets main from the loot table. This pool is where the basic drops like porkchop are.
final LootPool main = event.getTable().getPool("main");
// Makes sure that the main pool actually exists. It can be deleted by other mods.
if (main != null) {
// Adds a carrot to the pool. Carrots will now drop just as often as pork chops.
main.addEntry(new LootEntryItem(Items.CARROT, 1, 0, new LootFunction[0], new LootCondition[0], "tutorial:carrot"));
// Adds an apple to the loot pool. This entry is only used if the pig was killed by a player.
main.addEntry(new LootEntryItem(Items.APPLE, 1, 0, new LootFunction[0], new LootCondition[] { new KilledByPlayer(false)}, "tutorial:player"));
}
}
}
示例2: onLootTableLoad
import net.minecraft.world.storage.loot.functions.SetDamage; //導入依賴的package包/類
@SubscribeEvent
public void onLootTableLoad (LootTableLoadEvent event) {
if (allowDungeonLoot && event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) {
final LootPool main = event.getTable().getPool("main");
if (main != null) {
main.addEntry(new LootEntryItem(itemRing, weight, 0, new LootFunction[] { new SetDamage(new LootCondition[0], new RandomValueRange(0, ItemRing.varients.length - 1)) }, new LootCondition[0], "darkutils:nether_rings"));
}
}
}
示例3: setDamage
import net.minecraft.world.storage.loot.functions.SetDamage; //導入依賴的package包/類
private @Nonnull SetDamage setDamage(Item item, int damage) {
return new SetDamage(NO_CONDITIONS, new RandomValueRange(damage > 0 ? damage : 1, damage > 0 ? damage : item.getMaxDamage()));
}