use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.
the class GenericWorldGenerator method spawnItemFrame.
private EntityItemFrame spawnItemFrame(World world, int x, int y, int z) {
EntityItemFrame frame = new EntityItemFrame(world, new BlockPos(x, y, z + 1), EnumFacing.NORTH);
WorldTools.spawnEntity(world, frame);
frame.setPosition(x, y, z);
return frame;
}
use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.
the class GenericWorldGenerator method generateDungeon.
private void generateDungeon(World world, Random random, int midx, int starty, int midz) {
boolean doSmallAntenna = random.nextInt(4) == 0;
boolean doExtraFeature = random.nextInt(4) == 0;
Block cornerBlock;
switch(random.nextInt(3)) {
case 0:
cornerBlock = ModBlocks.dimensionalCrossBlock;
break;
case 1:
cornerBlock = ModBlocks.dimensionalPattern1Block;
break;
case 2:
cornerBlock = ModBlocks.dimensionalPattern2Block;
break;
default:
cornerBlock = ModBlocks.dimensionalCross2Block;
}
Block buildingBlock = Blocks.STAINED_HARDENED_CLAY;
int color = random.nextInt(5);
if (color == 0) {
color = 3;
} else if (color == 1) {
color = 9;
} else if (color == 2) {
color = 11;
} else {
color = 0;
buildingBlock = ModBlocks.dimensionalBlankBlock;
}
// Spawn the building
for (int x = midx - 3; x <= midx + 3; x++) {
for (int z = midz - 3; z <= midz + 3; z++) {
boolean corner = (x == midx - 3 || x == midx + 3) && (z == midz - 3 || z == midz + 3);
boolean xside = x == midx - 3 || x == midx + 3;
boolean zside = z == midz - 3 || z == midz + 3;
boolean antenna = (x == midx - 2 && z == midz - 2);
boolean smallAntenna = doSmallAntenna && (x == midx + 2 && z == midz + 2);
world.setBlockState(new BlockPos(x, starty, z), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
if (corner) {
world.setBlockState(new BlockPos(x, starty + 1, z), cornerBlock.getStateFromMeta(1), 2);
world.setBlockState(new BlockPos(x, starty + 2, z), cornerBlock.getStateFromMeta(1), 2);
world.setBlockState(new BlockPos(x, starty + 3, z), cornerBlock.getStateFromMeta(1), 2);
} else if (xside) {
world.setBlockState(new BlockPos(x, starty + 1, z), buildingBlock.getStateFromMeta(color), 2);
if (z >= midz - 1 && z <= midz + 1) {
world.setBlockState(new BlockPos(x, starty + 2, z), Blocks.GLASS_PANE.getStateFromMeta(0), 2);
} else {
world.setBlockState(new BlockPos(x, starty + 2, z), buildingBlock.getStateFromMeta(color), 2);
}
world.setBlockState(new BlockPos(x, starty + 3, z), buildingBlock.getStateFromMeta(color), 2);
} else if (zside) {
world.setBlockState(new BlockPos(x, starty + 1, z), buildingBlock.getStateFromMeta(color), 2);
world.setBlockState(new BlockPos(x, starty + 2, z), buildingBlock.getStateFromMeta(color), 2);
world.setBlockState(new BlockPos(x, starty + 3, z), buildingBlock.getStateFromMeta(color), 2);
} else {
world.setBlockToAir(new BlockPos(x, starty + 1, z));
world.setBlockToAir(new BlockPos(x, starty + 2, z));
world.setBlockToAir(new BlockPos(x, starty + 3, z));
}
if (antenna) {
world.setBlockState(new BlockPos(x, starty + 4, z), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
world.setBlockState(new BlockPos(x, starty + 5, z), Blocks.IRON_BARS.getDefaultState(), 2);
world.setBlockState(new BlockPos(x, starty + 6, z), Blocks.IRON_BARS.getDefaultState(), 2);
world.setBlockState(new BlockPos(x, starty + 7, z), Blocks.IRON_BARS.getDefaultState(), 2);
world.setBlockState(new BlockPos(x, starty + 8, z), Blocks.GLOWSTONE.getDefaultState(), 3);
} else if (smallAntenna) {
world.setBlockState(new BlockPos(x, starty + 4, z), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
world.setBlockState(new BlockPos(x, starty + 5, z), Blocks.IRON_BARS.getDefaultState(), 2);
world.setBlockToAir(new BlockPos(x, starty + 6, z));
world.setBlockToAir(new BlockPos(x, starty + 7, z));
world.setBlockToAir(new BlockPos(x, starty + 8, z));
} else {
world.setBlockState(new BlockPos(x, starty + 4, z), Blocks.STONE_SLAB.getDefaultState(), 2);
world.setBlockToAir(new BlockPos(x, starty + 5, z));
world.setBlockToAir(new BlockPos(x, starty + 6, z));
world.setBlockToAir(new BlockPos(x, starty + 7, z));
world.setBlockToAir(new BlockPos(x, starty + 8, z));
}
// Spawn stone under the building for as long as it is air.
WorldGenerationTools.fillEmptyWithStone(world, x, starty - 1, z);
}
}
if (doExtraFeature) {
if (!WorldGenerationTools.isSolid(world, midx + 4, starty, midz - 3)) {
world.setBlockState(new BlockPos(midx + 4, starty, midz - 3), Blocks.IRON_BARS.getDefaultState(), 2);
}
world.setBlockState(new BlockPos(midx + 4, starty + 1, midz - 3), Blocks.IRON_BARS.getDefaultState(), 2);
world.setBlockState(new BlockPos(midx + 4, starty + 2, midz - 3), Blocks.IRON_BARS.getDefaultState(), 2);
if (!WorldGenerationTools.isSolid(world, midx + 5, starty, midz - 3)) {
world.setBlockState(new BlockPos(midx + 5, starty, midz - 3), buildingBlock.getStateFromMeta(color), 2);
}
world.setBlockState(new BlockPos(midx + 5, starty + 1, midz - 3), buildingBlock.getStateFromMeta(color), 2);
world.setBlockState(new BlockPos(midx + 5, starty + 2, midz - 3), buildingBlock.getStateFromMeta(color), 2);
WorldGenerationTools.fillEmptyWithStone(world, midx + 4, starty - 1, midz - 3);
WorldGenerationTools.fillEmptyWithStone(world, midx + 5, starty - 1, midz - 3);
}
// Clear the space before the door.
for (int x = midx - 3; x <= midx + 3; x++) {
for (int y = starty + 1; y <= starty + 3; y++) {
world.setBlockToAir(new BlockPos(x, y, midz - 4));
}
}
// Small platform before the door
world.setBlockState(new BlockPos(midx - 1, starty, midz - 4), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
world.setBlockState(new BlockPos(midx, starty, midz - 4), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
world.setBlockState(new BlockPos(midx + 1, starty, midz - 4), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 2);
world.setBlockState(new BlockPos(midx, starty + 1, midz - 3), Blocks.IRON_DOOR.getStateFromMeta(1), 2);
world.setBlockState(new BlockPos(midx, starty + 2, midz - 3), Blocks.IRON_DOOR.getStateFromMeta(8), 2);
world.setBlockState(new BlockPos(midx - 1, starty + 2, midz - 4), Blocks.STONE_BUTTON.getStateFromMeta(4), 2);
world.setBlockState(new BlockPos(midx + 1, starty + 2, midz - 2), Blocks.STONE_BUTTON.getStateFromMeta(3), 2);
world.setBlockState(new BlockPos(midx, starty + 3, midz + 3), Blocks.REDSTONE_LAMP.getDefaultState(), 2);
world.setBlockState(new BlockPos(midx, starty + 3, midz + 2), Blocks.LEVER.getStateFromMeta(4), 2);
world.setBlockState(new BlockPos(midx + 2, starty + 1, midz - 2), Blocks.CHEST.getDefaultState(), 2);
RarityRandomSelector.Distribution<Integer> bestDistribution = DimletRandomizer.getRandomDimlets().createDistribution(0.2f);
TileEntityChest chest = (TileEntityChest) world.getTileEntity(new BlockPos(midx + 2, starty + 1, midz - 2));
for (int i = 0; i < random.nextInt(4) + 3; i++) {
ItemStack stack = DimletRandomizer.getRandomPart(random);
chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), stack);
}
if (WorldgenConfiguration.enableDimletsInRFToolsDungeons > 0) {
for (int i = 0; i < random.nextInt(WorldgenConfiguration.enableDimletsInRFToolsDungeons); i++) {
DimletKey key = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
if (key != null) {
ItemStack stack = KnownDimletConfiguration.getDimletStack(key);
chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), stack);
}
}
}
// Always generate a few cosmetic dimlets
for (int i = 0; i < WorldgenConfiguration.uncraftableDimletsInRFToolsDungeons; i++) {
RarityRandomSelector<Integer, DimletKey> dimlets = DimletRandomizer.getRandomUncraftableDimlets();
DimletKey key = dimlets.select(bestDistribution, random);
if (key != null) {
ItemStack stack = KnownDimletConfiguration.getDimletStack(key);
chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), stack);
}
}
for (int i = 0; i < random.nextInt(2); i++) {
chest.setInventorySlotContents(random.nextInt(chest.getSizeInventory()), new ItemStack(ModItems.dimletParcelItem));
}
EntityItemFrame frame1 = spawnItemFrame(world, midx - 1, starty + 2, midz + 2);
EntityItemFrame frame2 = spawnItemFrame(world, midx, starty + 2, midz + 2);
EntityItemFrame frame3 = spawnItemFrame(world, midx + 1, starty + 2, midz + 2);
if (WorldgenConfiguration.enableDimletsInRFToolsFrames) {
DimletKey rd1 = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
if (rd1 != null) {
frame1.setDisplayedItem(KnownDimletConfiguration.getDimletStack(rd1));
}
DimletKey rd2 = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
if (rd2 != null) {
frame2.setDisplayedItem(KnownDimletConfiguration.getDimletStack(rd2));
}
DimletKey rd3 = DimletRandomizer.getRandomDimlets().select(bestDistribution, random);
if (rd3 != null) {
frame3.setDisplayedItem(KnownDimletConfiguration.getDimletStack(rd3));
}
} else {
frame1.setDisplayedItem(DimletRandomizer.getRandomPart(random));
frame2.setDisplayedItem(DimletRandomizer.getRandomPart(random));
frame3.setDisplayedItem(DimletRandomizer.getRandomPart(random));
}
}
use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.
the class GenericWorldGenerator method generateSpawnPlatform.
private void generateSpawnPlatform(World world) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.getDimension());
int midx = 8;
int midz = 8;
int starty;
if (information.getTerrainType() == TerrainType.TERRAIN_SOLID) {
starty = 64;
} else if (information.getTerrainType() == TerrainType.TERRAIN_INVERTIGO) {
starty = WorldGenerationTools.findUpsideDownEmptySpot(world, midx, midz);
} else {
starty = WorldGenerationTools.findSuitableEmptySpot(world, midx, midz);
}
if (starty == -1) {
// No suitable spot. We will carve something out.
starty = 64;
} else {
// Go one up
starty++;
}
boolean shelter = information.isShelter();
if (information.getTerrainType() == TerrainType.TERRAIN_LIQUID) {
shelter = true;
}
int bounds = 3;
if (shelter) {
bounds = 4;
}
for (int x = -bounds; x <= bounds; x++) {
for (int z = -bounds; z <= bounds; z++) {
if (x == 0 && z == 0) {
RFToolsDim.teleportationManager.createReceiver(world, new BlockPos(x + midx, starty, z + midz), information.getName(), -1);
} else if (x == 0 && (z == 2 || z == -2)) {
world.setBlockState(new BlockPos(x + midx, starty, z + midz), Blocks.GLOWSTONE.getDefaultState(), 3);
} else {
world.setBlockState(new BlockPos(x + midx, starty, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 2);
}
for (int y = 1; y <= 3; y++) {
world.setBlockToAir(new BlockPos(x + midx, starty + y, z + midz));
}
// Check the top layer. If it is something other then air we will replace it with clay as well.
if (!world.isAirBlock(new BlockPos(x + midx, starty + 4, z + midz))) {
world.setBlockState(new BlockPos(x + midx, starty + 4, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 2);
}
}
}
if (shelter) {
for (int y = 1; y <= 3; y++) {
for (int x = -bounds; x <= bounds; x++) {
for (int z = -bounds; z <= bounds; z++) {
if (x == -bounds || x == bounds || z == -bounds || z == bounds) {
if (z == 0 && y >= 2 && y <= 3 || x == 0 && y >= 2 && y <= 3 && z == bounds) {
world.setBlockState(new BlockPos(x + midx, starty + y, z + midz), Blocks.GLASS_PANE.getStateFromMeta(0), 2);
} else if (x == 0 && y == 1 && z == -bounds) {
world.setBlockState(new BlockPos(x + midx, starty + y, z + midz), Blocks.IRON_DOOR.getStateFromMeta(1), 2);
} else if (x == 0 && y == 2 && z == -bounds) {
world.setBlockState(new BlockPos(x + midx, starty + y, z + midz), Blocks.IRON_DOOR.getStateFromMeta(8), 2);
} else {
world.setBlockState(new BlockPos(x + midx, starty + y, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(9), 2);
}
}
}
}
}
for (int x = -bounds; x <= bounds; x++) {
for (int z = -bounds; z <= bounds; z++) {
world.setBlockState(new BlockPos(x + midx, starty + 4, z + midz), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(9), 2);
}
}
world.setBlockState(new BlockPos(midx - 1, starty + 2, midz - bounds - 1), Blocks.STONE_BUTTON.getStateFromMeta(4), 2);
world.setBlockState(new BlockPos(midx + 1, starty + 2, midz - bounds + 1), Blocks.STONE_BUTTON.getStateFromMeta(3), 2);
world.setBlockState(new BlockPos(midx + 1, starty, midz - bounds - 1), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 2);
world.setBlockState(new BlockPos(midx, starty, midz - bounds - 1), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 2);
world.setBlockState(new BlockPos(midx - 1, starty, midz - bounds - 1), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 2);
world.setBlockState(new BlockPos(midx + 1, starty, midz - bounds - 2), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 2);
world.setBlockState(new BlockPos(midx, starty, midz - bounds - 2), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 2);
world.setBlockState(new BlockPos(midx - 1, starty, midz - bounds - 2), Blocks.STAINED_HARDENED_CLAY.getStateFromMeta(3), 2);
}
registerReceiver(world, dimensionManager, information, midx, midz, starty);
}
use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.
the class GenericChunkGenerator method genStandardOre2.
private static void genStandardOre2(World worldIn, Random random, int blockCount, WorldGenerator generator, int centerHeight, int spread, BlockPos chunkPos) {
for (int i = 0; i < blockCount; ++i) {
BlockPos blockpos = chunkPos.add(random.nextInt(16), random.nextInt(spread) + random.nextInt(spread) + centerHeight - spread, random.nextInt(16));
generator.generate(worldIn, random, blockpos);
}
}
use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.
the class GenericChunkGenerator method genStandardOre1.
private static void genStandardOre1(World worldIn, Random random, int blockCount, WorldGenerator generator, int minHeight, int maxHeight, BlockPos chunkPos) {
if (maxHeight < minHeight) {
int i = minHeight;
minHeight = maxHeight;
maxHeight = i;
} else if (maxHeight == minHeight) {
if (minHeight < 255) {
++maxHeight;
} else {
--minHeight;
}
}
for (int j = 0; j < blockCount; ++j) {
BlockPos blockpos = chunkPos.add(random.nextInt(16), random.nextInt(maxHeight - minHeight) + minHeight, random.nextInt(16));
generator.generate(worldIn, random, blockpos);
}
}
Aggregations