Fixed 'place'-Methods
This commit is contained in:
parent
4bf09362be
commit
a82f30b95d
17 changed files with 103 additions and 52 deletions
|
@ -11,6 +11,7 @@ import net.minecraft.world.level.block.Mirror;
|
|||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor;
|
||||
|
@ -75,8 +76,10 @@ public class CrashedShipFeature extends NBTStructureFeature {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
|
||||
NoneFeatureConfiguration featureConfig) {
|
||||
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
|
||||
Random random = featureConfig.random();
|
||||
BlockPos center = featureConfig.origin();
|
||||
WorldGenLevel world = featureConfig.level();
|
||||
center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);
|
||||
center = getGround(world, center);
|
||||
BoundingBox bounds = makeBox(center);
|
||||
|
@ -88,7 +91,7 @@ public class CrashedShipFeature extends NBTStructureFeature {
|
|||
StructureTemplate structure = getStructure(world, center, random);
|
||||
Rotation rotation = getRotation(world, center, random);
|
||||
Mirror mirror = getMirror(world, center, random);
|
||||
BlockPos offset = StructureTemplate.transform(structure.getSize(), mirror, rotation, BlockPos.ZERO);
|
||||
BlockPos offset = StructureTemplate.transform(new BlockPos(structure.getSize()), mirror, rotation, BlockPos.ZERO);
|
||||
center = center.offset(0, getYOffset(structure, world, center, random) + 0.5, 0);
|
||||
StructurePlaceSettings placementData = new StructurePlaceSettings().setRotation(rotation).setMirror(mirror);
|
||||
center = center.offset(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
|
||||
|
@ -97,10 +100,10 @@ public class CrashedShipFeature extends NBTStructureFeature {
|
|||
bounds = StructureHelper.intersectBoxes(bounds, structB);
|
||||
|
||||
addStructureData(placementData);
|
||||
structure.placeInWorldChunk(world, center, placementData.setBoundingBox(bounds), random);
|
||||
structure.placeInWorld(world, center, center, placementData.setBoundingBox(bounds), random, 2);
|
||||
|
||||
StructureHelper.erodeIntense(world, bounds, random);
|
||||
BlockFixer.fixBlocks(world, new BlockPos(bounds.x0, bounds.y0, bounds.z0), new BlockPos(bounds.x1, bounds.y1, bounds.z1));
|
||||
BlockFixer.fixBlocks(world, new BlockPos(bounds.minX(), bounds.minY(), bounds.minZ()), new BlockPos(bounds.maxX(), bounds.maxY(), bounds.maxZ()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue