本文整理汇总了Java中net.minecraft.tileentity.TileEntityChest.setLootTable方法的典型用法代码示例。如果您正苦于以下问题:Java TileEntityChest.setLootTable方法的具体用法?Java TileEntityChest.setLootTable怎么用?Java TileEntityChest.setLootTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.tileentity.TileEntityChest
的用法示例。
在下文中一共展示了TileEntityChest.setLootTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLootTable
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
private static void setLootTable(TileEntityChest chestEntity, World world, int multiplier)
{
double common = 75 / multiplier;
double uncommon = 15;
double rare = 6;
double legendary = 3;
double exotic = 1;
RandomCollection<ResourceLocation> loottables = new RandomCollection<ResourceLocation>();
loottables.add(common, ModLootTables.common_chest);
loottables.add(uncommon, ModLootTables.uncommon_chest);
loottables.add(rare, ModLootTables.rare_chest);
loottables.add(legendary, ModLootTables.legendary_chest);
loottables.add(exotic, ModLootTables.exotic_chest);
ResourceLocation table = loottables.next(world.rand);
chestEntity.setLootTable(table, world.rand.nextLong());
if (table == ModLootTables.common_chest) chestEntity.setCustomName("Common Chest");
else if (table == ModLootTables.uncommon_chest) chestEntity.setCustomName("Uncommon Chest");
else if (table == ModLootTables.rare_chest) chestEntity.setCustomName("Rare Chest");
else if (table == ModLootTables.legendary_chest) chestEntity.setCustomName("Legendary Chest");
else if (table == ModLootTables.exotic_chest) chestEntity.setCustomName("Exotic Chest");
}
示例2: generateChestContents
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
/**
* Generate trapped chests with items.
*/
public static void generateChestContents(ComponentGraveStone component, World world, Random random, int xCoord, int yCoord, int zCoord, EnumFacing facing, ResourceLocation loot, boolean trapped) {
int x = component.getXWithOffset(xCoord, zCoord);
int y = component.getYWithOffset(yCoord);
int z = component.getZWithOffset(xCoord, zCoord);
BlockPos pos = new BlockPos(x, y, z);
IBlockState chest;
if (trapped) {
chest = StateHelper.getChest(StateHelper.TRAPPED_CHEST, facing);
} else {
chest = StateHelper.getChest(StateHelper.CHEST, facing);
}
world.setBlockState(pos, chest, 2);
TileEntityChest tileentity = (TileEntityChest) world.getTileEntity(pos);
if (tileentity != null) {
tileentity.setLootTable(loot, random.nextLong());
}
}