use of net.minecraft.structure.Structure in project Biome-Makeover by Lemonszz.
the class SurfaceFossilFeature method generate.
@Override
public boolean generate(StructureWorldAccess structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, DefaultFeatureConfig defaultFeatureConfig) {
BlockRotation rot = BlockRotation.random(random);
int fossilIndex = random.nextInt(FOSSILS.length);
StructureManager structureManager = structureWorldAccess.toServerWorld().getServer().getStructureManager();
Structure structure = structureManager.getStructureOrBlank(FOSSILS[fossilIndex]);
ChunkPos chunkPos = new ChunkPos(blockPos);
BlockBox blockBox = new BlockBox(chunkPos.getStartX(), 0, chunkPos.getStartZ(), chunkPos.getEndX(), 256, chunkPos.getEndZ());
StructurePlacementData placeData = (new StructurePlacementData()).setRotation(rot).setBoundingBox(blockBox).setRandom(random).addProcessor(BlockIgnoreStructureProcessor.IGNORE_STRUCTURE_BLOCKS);
BlockPos size = structure.getRotatedSize(rot);
int x = random.nextInt(16 - size.getX());
int z = random.nextInt(16 - size.getZ());
int y = 256;
for (int xx = 0; xx < size.getX(); xx++) {
for (int zz = 0; zz < size.getZ(); ++zz) {
y = Math.min(y, structureWorldAccess.getTopY(Heightmap.Type.OCEAN_FLOOR_WG, blockPos.getX() + xx + x, blockPos.getZ() + zz + z));
}
}
if (fossilIndex < 4)
y -= RandomUtil.randomRange(1, Math.max(2, size.getY() - 2));
BlockPos generatePos = structure.offsetByTransformedSize(blockPos.add(x, y, z), BlockMirror.NONE, rot);
BlockRotStructureProcessor process = new BlockRotStructureProcessor(1F);
placeData.clearProcessors().addProcessor(process);
structure.place(structureWorldAccess, generatePos, generatePos, placeData, random, 4);
return true;
}
use of net.minecraft.structure.Structure in project Biome-Makeover by Lemonszz.
the class SimpleStructurePieceMixin method generate.
@Inject(method = "generate", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/structure/Structure;getInfosForBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;Lnet/minecraft/block/Block;)Ljava/util/List;"))
public void generate(StructureWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox box, ChunkPos chunkPos, BlockPos blockPos, CallbackInfoReturnable<Boolean> cbi) {
if (this instanceof DirectionalDataHandler) {
List<Structure.StructureBlockInfo> list = this.structure.getInfosForBlock(this.pos, this.placementData, BMBlocks.DIRECTIONAL_DATA);
for (Structure.StructureBlockInfo info : list) {
if (info.tag != null) {
String meta = info.tag.getString("metadata");
Direction dir = info.state.get(FacingBlock.FACING);
world.setBlockState(info.pos, Blocks.AIR.getDefaultState(), 3);
((DirectionalDataHandler) this).handleDirectionalMetadata(meta, dir, info.pos, world, random, box);
}
}
}
}
Aggregations