Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -2,9 +2,9 @@ package ru.betterend.world.features;
import java.util.Random;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Material;
import net.minecraft.structure.Structure;
import net.minecraft.structure.Structure.StructureBlockInfo;
import net.minecraft.structure.StructurePlacementData;
@ -12,10 +12,10 @@ import net.minecraft.structure.processor.BlockIgnoreStructureProcessor;
import net.minecraft.structure.processor.StructureProcessor;
import net.minecraft.structure.processor.StructureProcessorType;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Identifier;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.math.BlockBox;
import net.minecraft.util.math.BlockPos;
import net.minecraft.core.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.WorldView;
import net.minecraft.world.gen.chunk.ChunkGenerator;
@ -33,7 +33,8 @@ public class CrashedShipFeature extends NBTStructureFeature {
@Override
protected Structure getStructure(StructureWorldAccess world, BlockPos pos, Random random) {
if (structure == null) {
structure = world.toServerWorld().getStructureManager().getStructureOrBlank(new Identifier("end_city/ship"));
structure = world.toServerWorld().getStructureManager()
.getStructureOrBlank(new ResourceLocation("end_city/ship"));
if (structure == null) {
structure = StructureHelper.readStructure(STRUCTURE_PATH);
}
@ -48,12 +49,12 @@ public class CrashedShipFeature extends NBTStructureFeature {
if (x * x + z * z < 3600) {
return false;
}
return pos.getY() > 5 && world.getBlockState(pos.down()).isIn(EndTags.GEN_TERRAIN);
return pos.getY() > 5 && world.getBlockState(pos.below()).isIn(EndTags.GEN_TERRAIN);
}
@Override
protected BlockRotation getRotation(StructureWorldAccess world, BlockPos pos, Random random) {
return BlockRotation.random(random);
protected Rotation getRotation(StructureWorldAccess world, BlockPos pos, Random random) {
return Rotation.random(random);
}
@Override
@ -72,48 +73,53 @@ public class CrashedShipFeature extends NBTStructureFeature {
protected TerrainMerge getTerrainMerge(StructureWorldAccess world, BlockPos pos, Random random) {
return TerrainMerge.NONE;
}
@Override
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center, DefaultFeatureConfig featureConfig) {
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos center,
DefaultFeatureConfig featureConfig) {
center = new BlockPos(((center.getX() >> 4) << 4) | 8, 128, ((center.getZ() >> 4) << 4) | 8);
center = getGround(world, center);
BlockBox bounds = makeBox(center);
if (!canSpawn(world, center, random)) {
return false;
}
Structure structure = getStructure(world, center, random);
BlockRotation rotation = getRotation(world, center, random);
Rotation rotation = getRotation(world, center, random);
BlockMirror mirror = getMirror(world, center, random);
BlockPos offset = Structure.transformAround(structure.getSize(), mirror, rotation, BlockPos.ORIGIN);
center = center.add(0, getYOffset(structure, world, center, random) + 0.5, 0);
StructurePlacementData placementData = new StructurePlacementData().setRotation(rotation).setMirror(mirror);
center = center.add(-offset.getX() * 0.5, 0, -offset.getZ() * 0.5);
BlockBox structB = structure.calculateBoundingBox(placementData, center);
bounds = StructureHelper.intersectBoxes(bounds, structB);
addStructureData(placementData);
structure.place(world, center, placementData.setBoundingBox(bounds), random);
StructureHelper.erodeIntense(world, bounds, random);
BlocksHelper.fixBlocks(world, new BlockPos(bounds.minX, bounds.minY, bounds.minZ), new BlockPos(bounds.maxX, bounds.maxY, bounds.maxZ));
BlocksHelper.fixBlocks(world, new BlockPos(bounds.minX, bounds.minY, bounds.minZ),
new BlockPos(bounds.maxX, bounds.maxY, bounds.maxZ));
return true;
}
@Override
protected void addStructureData(StructurePlacementData data) {
data.addProcessor(BlockIgnoreStructureProcessor.IGNORE_AIR_AND_STRUCTURE_BLOCKS).addProcessor(REPLACER).setIgnoreEntities(true);
data.addProcessor(BlockIgnoreStructureProcessor.IGNORE_AIR_AND_STRUCTURE_BLOCKS).addProcessor(REPLACER)
.setIgnoreEntities(true);
}
static {
REPLACER = new StructureProcessor() {
@Override
public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos, StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2, StructurePlacementData structurePlacementData) {
public StructureBlockInfo process(WorldView worldView, BlockPos pos, BlockPos blockPos,
StructureBlockInfo structureBlockInfo, StructureBlockInfo structureBlockInfo2,
StructurePlacementData structurePlacementData) {
BlockState state = structureBlockInfo2.state;
if (state.isOf(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) {
if (state.is(Blocks.SPAWNER) || state.getMaterial().equals(Material.WOOL)) {
return new StructureBlockInfo(structureBlockInfo2.pos, AIR, null);
}
return structureBlockInfo2;