resolve merge conflicts

This commit is contained in:
dfsek
2021-05-28 14:50:24 -07:00
parent 94611913c3
commit cba3388cb1
10 changed files with 63 additions and 38 deletions

View File

@@ -9,6 +9,7 @@ import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
import com.dfsek.terra.api.world.locate.AsyncStructureFinder;
import com.dfsek.terra.config.pack.ConfigPack;
import com.dfsek.terra.fabric.TerraFabricPlugin;
import com.dfsek.terra.fabric.mixin.StructureAccessorAccessor;
import com.dfsek.terra.fabric.util.FabricAdapter;
import com.dfsek.terra.world.TerraWorld;
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
@@ -25,14 +26,15 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.registry.DynamicRegistryManager;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.Heightmap;
import net.minecraft.world.SpawnHelper;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeAccess;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ProtoChunk;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.ChunkRandom;
import net.minecraft.world.gen.GenerationStep;
@@ -46,6 +48,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
public class FabricChunkGeneratorWrapper extends ChunkGenerator implements GeneratorWrapper {
private final long seed;
@@ -120,11 +123,6 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
return super.locateStructure(world, feature, center, radius, skipExistingChunks);
}
@Override
public void populateNoise(WorldAccess world, StructureAccessor accessor, Chunk chunk) {
delegate.generateChunkData((World) world, new FastRandom(), chunk.getPos().x, chunk.getPos().z, (ChunkData) chunk);
}
@Override
public void carve(long seed, BiomeAccess access, Chunk chunk, GenerationStep.Carver carver) {
if(pack.getTemplate().vanillaCaves()) super.carve(seed, access, chunk, carver);
@@ -136,6 +134,14 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
super.setStructureStarts(dynamicRegistryManager, structureAccessor, chunk, structureManager, worldSeed);
}
@Override
public CompletableFuture<Chunk> populateNoise(Executor executor, StructureAccessor accessor, Chunk chunk) {
return CompletableFuture.supplyAsync(() -> {
delegate.generateChunkData((World) ((StructureAccessorAccessor) accessor).getWorld(), new FastRandom(), chunk.getPos().x, chunk.getPos().z, (ChunkData) chunk);
return chunk;
}, executor);
}
@Override
public boolean isStrongholdStartingChunk(ChunkPos chunkPos) {
if(pack.getTemplate().vanillaStructures()) return super.isStrongholdStartingChunk(chunkPos);
@@ -143,7 +149,12 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
}
@Override
public int getHeight(int x, int z, Heightmap.Type heightmapType) {
public int getHeightOnGround(int x, int z, Heightmap.Type heightmap, HeightLimitView world) {
return super.getHeightOnGround(x, z, heightmap, world);
}
@Override
public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView heightmapType) {
TerraWorld world = TerraFabricPlugin.getInstance().getWorld(dimensionType);
Sampler sampler = world.getConfig().getSamplerCache().getChunk(FastMath.floorDiv(x, 16), FastMath.floorDiv(z, 16));
int cx = FastMath.floorMod(x, 16);
@@ -157,11 +168,11 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
}
@Override
public BlockView getColumnSample(int x, int z) {
public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView view) {
TerraWorld world = TerraFabricPlugin.getInstance().getWorld(dimensionType);
int height = getHeight(x, z, Heightmap.Type.WORLD_SURFACE);
int height = getHeight(x, z, Heightmap.Type.WORLD_SURFACE, view);
BlockState[] array = new BlockState[256];
for(int y = 255; y >= 0; y--) {
for(int y = view.getBottomY()+view.getHeight(); y >= view.getBottomY(); y--) {
if(y > height) {
if(y > ((UserDefinedBiome) world.getBiomeProvider().getBiome(x, z)).getConfig().getSeaLevel()) {
array[y] = Blocks.AIR.getDefaultState();
@@ -173,18 +184,18 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
}
}
return new VerticalBlockSample(array);
return new VerticalBlockSample(view.getBottomY(), array);
}
@Override
public void populateEntities(ChunkRegion region) {
if(pack.getTemplate().vanillaMobs()) {
int cx = region.getCenterChunkX();
int cy = region.getCenterChunkZ();
int cx = region.getCenterPos().x;
int cy = region.getCenterPos().z;
Biome biome = region.getBiome((new ChunkPos(cx, cy)).getStartPos());
ChunkRandom chunkRandom = new ChunkRandom();
chunkRandom.setPopulationSeed(region.getSeed(), cx << 4, cy << 4);
SpawnHelper.populateEntities(region, biome, cx, cy, chunkRandom);
SpawnHelper.populateEntities(region, biome, region.getCenterPos(), chunkRandom);
}
}

View File

@@ -8,6 +8,7 @@ import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.util.FeatureContext;
import java.util.Random;
@@ -20,8 +21,10 @@ public class PopulatorFeature extends Feature<DefaultFeatureConfig> {
}
@Override
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
public boolean generate(FeatureContext<DefaultFeatureConfig> context) {
ChunkGenerator chunkGenerator = context.getGenerator();
if(!(chunkGenerator instanceof FabricChunkGeneratorWrapper)) return true;
StructureWorldAccess world = context.getWorld();
FabricChunkGeneratorWrapper gen = (FabricChunkGeneratorWrapper) chunkGenerator;
gen.getHandle().getPopulators().forEach(populator -> populator.populate((World) world, (Chunk) world));
return true;

View File

@@ -1,12 +1,14 @@
package com.dfsek.terra.fabric.mixin.access;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.MobSpawnerLogic;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(MobSpawnerLogic.class)
public interface MobSpawnerLogicAccessor {
@Invoker("getEntityId")
Identifier callGetEntityId();
Identifier callGetEntityId(World world, BlockPos blockPos);
}

View File

@@ -9,6 +9,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Intrinsic;
@@ -18,6 +19,7 @@ import org.spongepowered.asm.mixin.Shadow;
@Mixin(BlockEntity.class)
@Implements(@Interface(iface = BlockState.class, prefix = "terra$", remap = Interface.Remap.NONE))
public abstract class BlockEntityMixin {
@Final
@Shadow
protected BlockPos pos;
@Shadow
@@ -56,7 +58,7 @@ public abstract class BlockEntityMixin {
}
public boolean terra$update(boolean applyPhysics) {
if(hasWorld()) world.getChunk(pos).setBlockEntity(pos, (BlockEntity) (Object) this);
if(hasWorld()) world.getChunk(pos).setBlockEntity((BlockEntity) (Object) this);
return true;
}
}

View File

@@ -5,9 +5,14 @@ import com.dfsek.terra.api.platform.block.state.SerialState;
import com.dfsek.terra.api.platform.entity.EntityType;
import com.dfsek.terra.fabric.TerraFabricPlugin;
import com.dfsek.terra.fabric.mixin.access.MobSpawnerLogicAccessor;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.MobSpawnerBlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.MobSpawnerLogic;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
@@ -16,12 +21,16 @@ import org.spongepowered.asm.mixin.Shadow;
@Mixin(MobSpawnerBlockEntity.class)
@Implements(@Interface(iface = MobSpawner.class, prefix = "terra$", remap = Interface.Remap.NONE))
public abstract class MobSpawnerBlockEntityMixin {
public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
private MobSpawnerBlockEntityMixin(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}
@Shadow
public abstract MobSpawnerLogic getLogic();
public EntityType terra$getSpawnedType() {
return (EntityType) Registry.ENTITY_TYPE.get(((MobSpawnerLogicAccessor) getLogic()).callGetEntityId());
return (EntityType) Registry.ENTITY_TYPE.get(((MobSpawnerLogicAccessor) getLogic()).callGetEntityId(world, pos));
}
public void terra$setSpawnedType(@NotNull EntityType creatureType) {

View File

@@ -20,18 +20,18 @@ public abstract class SignBlockEntityMixin {
@Shadow
@Final
private Text[] text;
private Text[] texts;
public @NotNull String[] terra$getLines() {
String[] lines = new String[text.length];
for(int i = 0; i < text.length; i++) {
lines[i] = text[i].asString();
String[] lines = new String[texts.length];
for(int i = 0; i < texts.length; i++) {
lines[i] = texts[i].asString();
}
return lines;
}
public @NotNull String terra$getLine(int index) throws IndexOutOfBoundsException {
return text[index].asString();
return texts[index].asString();
}
public void terra$setLine(int index, @NotNull String line) throws IndexOutOfBoundsException {

View File

@@ -7,6 +7,7 @@ import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.fabric.block.FabricBlock;
import com.dfsek.terra.fabric.block.FabricBlockData;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.ChunkRegion;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Final;
@@ -20,18 +21,14 @@ import org.spongepowered.asm.mixin.Shadow;
public abstract class ChunkRegionMixin {
@Final
@Shadow
private int centerChunkX;
@Final
@Shadow
private int centerChunkZ;
private ChunkPos centerPos;
public int terra$getX() {
return centerChunkX;
return centerPos.x;
}
public int terra$getZ() {
return centerChunkZ;
return centerPos.z;
}
public World terra$getWorld() {
@@ -39,7 +36,7 @@ public abstract class ChunkRegionMixin {
}
public Block terra$getBlock(int x, int y, int z) {
BlockPos pos = new BlockPos(x + (centerChunkX << 4), y, z + (centerChunkZ << 4));
BlockPos pos = new BlockPos(x + (centerPos.x << 4), y, z + (centerPos.z << 4));
return new FabricBlock(pos, (ChunkRegion) (Object) this);
}
@@ -48,7 +45,7 @@ public abstract class ChunkRegionMixin {
}
public void terra$setBlock(int x, int y, int z, @NotNull BlockData blockData) {
((ChunkRegion) (Object) this).setBlockState(new BlockPos(x + (centerChunkX << 4), y, z + (centerChunkZ << 4)), ((FabricBlockData) blockData).getHandle(), 0);
((ChunkRegion) (Object) this).setBlockState(new BlockPos(x + (centerPos.x << 4), y, z + (centerPos.z << 4)), ((FabricBlockData) blockData).getHandle(), 0);
}
// getHandle already added in world/ChunkRegionMixin.

View File

@@ -34,7 +34,7 @@ public abstract class ChunkRegionMixin {
private long seed;
public int terra$getMaxHeight() {
return ((ChunkRegion) (Object) this).getDimensionHeight();
return (((ChunkRegion) (Object) this).getBottomY()) + ((ChunkRegion) (Object) this).getHeight();
}
@SuppressWarnings("deprecation")
@@ -64,7 +64,7 @@ public abstract class ChunkRegionMixin {
}
public int terra$getMinHeight() {
return 0;
return ((ChunkRegion) (Object) this).getBottomY();
}
@Intrinsic

View File

@@ -13,6 +13,7 @@ import com.dfsek.terra.fabric.block.FabricBlock;
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.ServerWorldAccess;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
@@ -27,7 +28,7 @@ public abstract class ServerWorldMixin {
public abstract long getSeed();
public int terra$getMaxHeight() {
return ((ServerWorld) (Object) this).getDimensionHeight();
return (((ServerWorld) (Object) this).getBottomY()) + ((ServerWorld) (Object) this).getHeight();
}
public ChunkGenerator terra$getGenerator() {
@@ -55,7 +56,7 @@ public abstract class ServerWorldMixin {
}
public int terra$getMinHeight() {
return 0;
return ((ServerWorld) (Object) this).getBottomY();
}
@Intrinsic

View File

@@ -4,7 +4,7 @@
"package": "com.dfsek.terra.fabric.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"StructureAccessorAccessor"
"StructureAccessorAccessor",
"CommandManagerMixin",
"GeneratorOptionsMixin",
"ServerWorldMixin",