Java 类net.minecraft.world.storage.loot.functions.SetDamage 实例源码
项目:Loot-Tables
文件:LootTablesMod.java
@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"));
}
}
}
项目:Dark-Utilities
文件:FeatureEnchantedRing.java
@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"));
}
}
}
项目:EnderIO
文件:LootManager.java
private @Nonnull SetDamage setDamage(Item item, int damage) {
return new SetDamage(NO_CONDITIONS, new RandomValueRange(damage > 0 ? damage : 1, damage > 0 ? damage : item.getMaxDamage()));
}