use of net.minecraft.world.gen.structure.template.PlacementSettings in project minecolonies by Minecolonies.
the class WindowBuildTool method updateRotation.
/**
* Updates the rotation of the structure depending on the input.
*
* @param rotation the rotation to be set.
*/
private static void updateRotation(final int rotation) {
final PlacementSettings settings = new PlacementSettings();
switch(rotation) {
case ROTATE_RIGHT:
settings.setRotation(Rotation.CLOCKWISE_90);
break;
case ROTATE_180:
settings.setRotation(Rotation.CLOCKWISE_180);
break;
case ROTATE_LEFT:
settings.setRotation(Rotation.COUNTERCLOCKWISE_90);
break;
default:
settings.setRotation(Rotation.NONE);
}
Settings.instance.setRotation(rotation);
if (Settings.instance.getActiveStructure() != null) {
Settings.instance.getActiveStructure().setPlacementSettings(settings.setMirror(Settings.instance.getMirror()));
}
}
use of net.minecraft.world.gen.structure.template.PlacementSettings 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());
}
}
}
}
use of net.minecraft.world.gen.structure.template.PlacementSettings 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());
}
}
}
Aggregations