Continue mapping migration
This commit is contained in:
parent
99ade39404
commit
f03fd03bd0
499 changed files with 12567 additions and 12723 deletions
|
@ -7,82 +7,78 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.PaneBlock;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.decoration.EndCrystalEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.structure.Structure;
|
||||
import net.minecraft.structure.StructurePlacementData;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.boss.enderdragon.EndCrystal;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.IronBarsBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.feature.EndSpikeFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.EndSpikeFeatureConfig;
|
||||
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||
import net.minecraft.world.level.levelgen.feature.SpikeFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.SpikeConfiguration;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import ru.betterend.BetterEnd;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.StructureHelper;
|
||||
import ru.betterend.util.WorldDataUtil;
|
||||
import ru.betterend.world.generator.GeneratorOptions;
|
||||
|
||||
@Mixin(EndSpikeFeature.class)
|
||||
@Mixin(SpikeFeature.class)
|
||||
public class EndSpikeFeatureMixin {
|
||||
@Inject(method = "generate", at = @At("HEAD"), cancellable = true)
|
||||
private void beSpikeGenerate(WorldGenLevel structureWorldAccess, ChunkGenerator chunkGenerator, Random random,
|
||||
BlockPos blockPos, EndSpikeFeatureConfig endSpikeFeatureConfig, CallbackInfoReturnable<Boolean> info) {
|
||||
private void beSpikeGenerate(WorldGenLevel structureWorldAccess, ChunkGenerator chunkGenerator, Random random, BlockPos blockPos, SpikeConfiguration endSpikeFeatureConfig, CallbackInfoReturnable<Boolean> info) {
|
||||
if (!GeneratorOptions.hasPillars()) {
|
||||
info.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "generateSpike", at = @At("HEAD"), cancellable = true)
|
||||
private void be_generateSpike(ServerLevelAccessor world, Random random, EndSpikeFeatureConfig config,
|
||||
EndSpikeFeature.Spike spike, CallbackInfo info) {
|
||||
private void be_generateSpike(ServerLevelAccessor world, Random random, SpikeConfiguration config, SpikeFeature.EndSpike spike, CallbackInfo info) {
|
||||
int x = spike.getCenterX();
|
||||
int z = spike.getCenterZ();
|
||||
int radius = spike.getRadius();
|
||||
int minY = 0;
|
||||
|
||||
|
||||
long lx = (long) x;
|
||||
long lz = (long) z;
|
||||
if (lx * lx + lz * lz < 10000) {
|
||||
String pillarID = String.format("%d_%d", x, z);
|
||||
CompoundTag pillar = WorldDataUtil.getCompoundTag("pillars");
|
||||
boolean haveValue = pillar.contains(pillarID);
|
||||
minY = haveValue ? pillar.getInt(pillarID)
|
||||
: world.getChunk(x >> 4, z >> 4).sampleHeightmap(Type.WORLD_SURFACE, x & 15, z);
|
||||
minY = haveValue ? pillar.getInt(pillarID) : world.getChunk(x >> 4, z >> 4).getHeight(Types.WORLD_SURFACE, x & 15, z);
|
||||
if (!haveValue) {
|
||||
pillar.putInt(pillarID, minY);
|
||||
WorldDataUtil.saveFile();
|
||||
}
|
||||
} else {
|
||||
minY = world.getChunk(x >> 4, z >> 4).sampleHeightmap(Type.WORLD_SURFACE, x & 15, z);
|
||||
}
|
||||
|
||||
else {
|
||||
minY = world.getChunk(x >> 4, z >> 4).getHeight(Types.WORLD_SURFACE, x & 15, z);
|
||||
}
|
||||
|
||||
int maxY = minY + spike.getHeight() - 64;
|
||||
|
||||
|
||||
if (GeneratorOptions.replacePillars() && be_radiusInRange(radius)) {
|
||||
radius--;
|
||||
Structure base = StructureHelper.readStructure(BetterEnd.makeID("pillars/pillar_base_" + radius));
|
||||
Structure top = StructureHelper.readStructure(
|
||||
BetterEnd.makeID("pillars/pillar_top_" + radius + (spike.isGuarded() ? "_cage" : "")));
|
||||
StructureTemplate base = StructureHelper.readStructure(BetterEnd.makeID("pillars/pillar_base_" + radius));
|
||||
StructureTemplate top = StructureHelper.readStructure(BetterEnd.makeID("pillars/pillar_top_" + radius + (spike.isGuarded() ? "_cage" : "")));
|
||||
BlockPos side = base.getSize();
|
||||
BlockPos pos1 = new BlockPos(x - (side.getX() >> 1), minY - 3, z - (side.getZ() >> 1));
|
||||
minY = pos1.getY() + side.getY();
|
||||
side = top.getSize();
|
||||
BlockPos pos2 = new BlockPos(x - (side.getX() >> 1), maxY, z - (side.getZ() >> 1));
|
||||
maxY = pos2.getY();
|
||||
|
||||
StructurePlacementData data = new StructurePlacementData();
|
||||
base.place(world, pos1, data, random);
|
||||
top.place(world, pos2, data, random);
|
||||
|
||||
|
||||
StructurePlaceSettings data = new StructurePlaceSettings();
|
||||
base.placeInWorldChunk(world, pos1, data, random);
|
||||
top.placeInWorldChunk(world, pos2, data, random);
|
||||
|
||||
int r2 = radius * radius + 1;
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
for (int px = -radius; px <= radius; px++) {
|
||||
|
@ -95,10 +91,10 @@ public class EndSpikeFeatureMixin {
|
|||
for (int py = minY; py < maxY; py++) {
|
||||
mut.setY(py);
|
||||
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
|
||||
if ((px == radius || px == -radius || pz == radius || pz == -radius)
|
||||
&& random.nextInt(24) == 0) {
|
||||
if ((px == radius || px == -radius || pz == radius || pz == -radius) && random.nextInt(24) == 0) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, Blocks.CRYING_OBSIDIAN);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, Blocks.OBSIDIAN);
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +102,8 @@ public class EndSpikeFeatureMixin {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
minY -= 15;
|
||||
int r2 = radius * radius + 1;
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
|
@ -130,13 +127,13 @@ public class EndSpikeFeatureMixin {
|
|||
mut.setZ(z);
|
||||
mut.setY(maxY);
|
||||
BlocksHelper.setWithoutUpdate(world, mut, Blocks.BEDROCK);
|
||||
|
||||
EndCrystalEntity crystal = EntityType.END_CRYSTAL.create(world.toServerWorld());
|
||||
crystal.setBeamTarget(config.getPos());
|
||||
|
||||
EndCrystal crystal = EntityType.END_CRYSTAL.create(world.getLevel());
|
||||
crystal.setBeamTarget(config.getCrystalBeamTarget());
|
||||
crystal.setInvulnerable(config.isCrystalInvulnerable());
|
||||
crystal.refreshPositionAndAngles(x + 0.5D, maxY + 1, z + 0.5D, random.nextFloat() * 360.0F, 0.0F);
|
||||
world.spawnEntity(crystal);
|
||||
|
||||
crystal.moveTo(x + 0.5D, maxY + 1, z + 0.5D, random.nextFloat() * 360.0F, 0.0F);
|
||||
world.addFreshEntity(crystal);
|
||||
|
||||
if (spike.isGuarded()) {
|
||||
for (int px = -2; px <= 2; ++px) {
|
||||
boolean bl = Mth.abs(px) == 2;
|
||||
|
@ -147,13 +144,8 @@ public class EndSpikeFeatureMixin {
|
|||
if (bl || bl2 || bl3) {
|
||||
boolean bl4 = px == -2 || px == 2 || bl3;
|
||||
boolean bl5 = pz == -2 || pz == 2 || bl3;
|
||||
BlockState blockState = (BlockState) ((BlockState) ((BlockState) ((BlockState) Blocks.IRON_BARS
|
||||
.defaultBlockState().with(PaneBlock.NORTH, bl4 && pz != -2))
|
||||
.with(PaneBlock.SOUTH, bl4 && pz != 2)).with(PaneBlock.WEST,
|
||||
bl5 && px != -2)).with(PaneBlock.EAST, bl5 && px != 2);
|
||||
BlocksHelper.setWithoutUpdate(world,
|
||||
mut.set(spike.getCenterX() + px, maxY + py, spike.getCenterZ() + pz),
|
||||
blockState);
|
||||
BlockState blockState = (BlockState) ((BlockState) ((BlockState) ((BlockState) Blocks.IRON_BARS.defaultBlockState().setValue(IronBarsBlock.NORTH, bl4 && pz != -2)).setValue(IronBarsBlock.SOUTH, bl4 && pz != 2)).setValue(IronBarsBlock.WEST, bl5 && px != -2)).setValue(IronBarsBlock.EAST, bl5 && px != 2);
|
||||
BlocksHelper.setWithoutUpdate(world, mut.set(spike.getCenterX() + px, maxY + py, spike.getCenterZ() + pz), blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +155,7 @@ public class EndSpikeFeatureMixin {
|
|||
|
||||
info.cancel();
|
||||
}
|
||||
|
||||
|
||||
private boolean be_radiusInRange(int radius) {
|
||||
return radius > 1 && radius < 6;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue