use of net.minecraft.tileentity.TileEntityLockableLoot in project Pearcel-Mod by MiningMark48.
the class StructureGenPearcel3 method generateStructure.
public static void generateStructure(WorldServer world, BlockPos pos, Random random) {
MinecraftServer server = world.getMinecraftServer();
Template template = world.getStructureTemplateManager().getTemplate(server, STRUCTURE);
PlacementSettings settings = new PlacementSettings();
settings.setRotation(Rotation.NONE);
template.addBlocksToWorld(world, pos, settings);
Map<BlockPos, String> dataBlocks = template.getDataBlocks(pos, settings);
for (Map.Entry<BlockPos, String> entry : dataBlocks.entrySet()) {
String[] tokens = entry.getValue().split(" ");
if (tokens.length == 0)
return;
BlockPos dataPos = entry.getKey();
String s = tokens[0].toLowerCase();
if (s.equals("lootchest2")) {
String chestOrientation = tokens[1];
EnumFacing chestFacing = settings.getRotation().rotate(EnumFacing.byName(chestOrientation));
IBlockState chestState = Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, chestFacing);
world.setBlockState(dataPos, chestState);
TileEntity tile = world.getTileEntity(dataPos);
if (tile != null && tile instanceof TileEntityLockableLoot)
((TileEntityLockableLoot) tile).setLootTable(LOOT2, random.nextLong());
}
}
}
use of net.minecraft.tileentity.TileEntityLockableLoot in project Pearcel-Mod by MiningMark48.
the class StructureGenPearcel1 method generateStructure.
public static void generateStructure(WorldServer world, BlockPos pos, Random random) {
MinecraftServer server = world.getMinecraftServer();
Template template = world.getStructureTemplateManager().getTemplate(server, STRUCTURE);
PlacementSettings settings = new PlacementSettings();
settings.setRotation(Rotation.NONE);
template.addBlocksToWorld(world, pos, settings);
Map<BlockPos, String> dataBlocks = template.getDataBlocks(pos, settings);
for (Map.Entry<BlockPos, String> entry : dataBlocks.entrySet()) {
String[] tokens = entry.getValue().split(" ");
if (tokens.length == 0)
return;
BlockPos dataPos = entry.getKey();
String s = tokens[0].toLowerCase();
if (s.equals("lootchest")) {
String chestOrientation = tokens[1];
EnumFacing chestFacing = settings.getRotation().rotate(EnumFacing.byName(chestOrientation));
IBlockState chestState = Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, chestFacing);
world.setBlockState(dataPos, chestState);
TileEntity tile = world.getTileEntity(dataPos);
if (tile != null && tile instanceof TileEntityLockableLoot)
((TileEntityLockableLoot) tile).setLootTable(LOOT, random.nextLong());
} else if (s.equals("lootchest2")) {
String chestOrientation = tokens[1];
EnumFacing chestFacing = settings.getRotation().rotate(EnumFacing.byName(chestOrientation));
IBlockState chestState = Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, chestFacing);
world.setBlockState(dataPos, chestState);
TileEntity tile = world.getTileEntity(dataPos);
if (tile != null && tile instanceof TileEntityLockableLoot)
((TileEntityLockableLoot) tile).setLootTable(LOOT2, random.nextLong());
}
}
}
use of net.minecraft.tileentity.TileEntityLockableLoot in project Pearcel-Mod by MiningMark48.
the class StructureGenPearcel2 method generateStructure.
public static void generateStructure(WorldServer world, BlockPos pos, Random random) {
MinecraftServer server = world.getMinecraftServer();
Template template = world.getStructureTemplateManager().getTemplate(server, STRUCTURE);
PlacementSettings settings = new PlacementSettings();
settings.setRotation(Rotation.NONE);
template.addBlocksToWorld(world, pos, settings);
Map<BlockPos, String> dataBlocks = template.getDataBlocks(pos, settings);
for (Map.Entry<BlockPos, String> entry : dataBlocks.entrySet()) {
String[] tokens = entry.getValue().split(" ");
if (tokens.length == 0)
return;
BlockPos dataPos = entry.getKey();
String s = tokens[0].toLowerCase();
if (s.equals("lootchest")) {
String chestOrientation = tokens[1];
EnumFacing chestFacing = settings.getRotation().rotate(EnumFacing.byName(chestOrientation));
IBlockState chestState = Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, chestFacing);
world.setBlockState(dataPos, chestState);
TileEntity tile = world.getTileEntity(dataPos);
if (tile != null && tile instanceof TileEntityLockableLoot)
((TileEntityLockableLoot) tile).setLootTable(LOOT, random.nextLong());
} else if (s.equals("lootchest2")) {
String chestOrientation = tokens[1];
EnumFacing chestFacing = settings.getRotation().rotate(EnumFacing.byName(chestOrientation));
IBlockState chestState = Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, chestFacing);
world.setBlockState(dataPos, chestState);
TileEntity tile = world.getTileEntity(dataPos);
if (tile != null && tile instanceof TileEntityLockableLoot)
((TileEntityLockableLoot) tile).setLootTable(LOOT2, random.nextLong());
} else if (s.equals("epet")) {
int epetChance = random.nextInt(1000);
int topChance = random.nextInt(500);
IBlockState epetState = ModBlocks.pearcel_beacon.getDefaultState();
if (epetChance == 0) {
world.setBlockState(dataPos, epetState);
} else if (topChance == 0) {
world.setBlockState(dataPos, Blocks.OBSIDIAN.getDefaultState());
for (int i = 0; i <= 3; i++) {
world.setBlockState(dataPos.add(0, i + 1, 0), Blocks.GOLD_BLOCK.getDefaultState());
}
} else {
String chestOrientation = tokens[1];
EnumFacing chestFacing = settings.getRotation().rotate(EnumFacing.byName(chestOrientation));
IBlockState chestState = Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, chestFacing);
world.setBlockState(dataPos, chestState);
TileEntity tile = world.getTileEntity(dataPos);
if (tile != null && tile instanceof TileEntityLockableLoot)
((TileEntityLockableLoot) tile).setLootTable(LOOT, random.nextLong());
}
}
}
}
Aggregations