本文整理匯總了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());
}
}