Updated to 1.16.2-rc2
This commit is contained in:
@@ -326,7 +326,7 @@ public class CachedPlane {
|
||||
WorldData.instance().compassData().service().updateArea((ServerWorld) this.getWorld(), c);
|
||||
|
||||
// FIXME this was sending chunks to players...
|
||||
ChunkDataS2CPacket cdp = new ChunkDataS2CPacket(c, verticalBits, false);
|
||||
ChunkDataS2CPacket cdp = new ChunkDataS2CPacket(c, verticalBits);
|
||||
world.getChunkManager().threadedAnvilChunkStorage
|
||||
.getPlayersWatchingChunk(c.getPos(), false).forEach(spe -> spe.networkHandler.sendPacket(cdp));
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
|
||||
*/
|
||||
public class SpatialStorageBiome {
|
||||
|
||||
public static final Biome INSTANCE = new Biome.Settings()
|
||||
public static final Biome INSTANCE = new Biome.Builder()
|
||||
.generationSettings(new GenerationSettings.Builder()
|
||||
.surfaceBuilder(new ConfiguredSurfaceBuilder<>(SurfaceBuilder.NOPE, SurfaceBuilder.STONE_CONFIG))
|
||||
.build())
|
||||
@@ -39,6 +39,6 @@ public class SpatialStorageBiome {
|
||||
.temperature(0.5F).downfall(0.5F)
|
||||
.effects(new BiomeEffects.Builder().waterColor(4159204).waterFogColor(329011).fogColor(0).skyColor(0x111111)
|
||||
.build())
|
||||
.parent(null).spawnSettings(new SpawnSettings.Builder().creatureSpawnProbability(0).build()).build();
|
||||
.spawnSettings(new SpawnSettings.Builder().creatureSpawnProbability(0).build()).build();
|
||||
|
||||
}
|
||||
|
||||
@@ -18,21 +18,18 @@
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.core.Api;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryLookupCodec;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.ChunkRegion;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeAccess;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.biome.source.FixedBiomeSource;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
@@ -41,25 +38,34 @@ import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.StructuresConfig;
|
||||
import net.minecraft.world.gen.chunk.VerticalBlockSample;
|
||||
|
||||
import appeng.core.Api;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Chunk generator the spatial storage world.
|
||||
*/
|
||||
public class SpatialStorageChunkGenerator extends ChunkGenerator {
|
||||
|
||||
/**
|
||||
* This codec is necessary to restore the actual instance of the Biome we use,
|
||||
* since it is sources from the dynamic registries and <em>must be the same object as in the registry!</em>.
|
||||
* <p>If it was not the same object, then the Object->ID lookup would fail since it uses an identity hashmap
|
||||
* internally.
|
||||
*/
|
||||
public static final Codec<SpatialStorageChunkGenerator> CODEC
|
||||
= RegistryLookupCodec.of(Registry.BIOME_KEY).xmap(SpatialStorageChunkGenerator::new, SpatialStorageChunkGenerator::getBiomeRegistry).stable().codec();
|
||||
|
||||
private final Registry<Biome> biomeRegistry;
|
||||
|
||||
private final VerticalBlockSample columnSample;
|
||||
|
||||
public static final SpatialStorageChunkGenerator INSTANCE = new SpatialStorageChunkGenerator();
|
||||
|
||||
public static final Codec<SpatialStorageChunkGenerator> CODEC = RecordCodecBuilder
|
||||
.create((instance) -> instance.stable(INSTANCE));
|
||||
|
||||
private final BlockState defaultBlockState;
|
||||
|
||||
private SpatialStorageChunkGenerator() {
|
||||
super(createBiomeProvider(), createSettings());
|
||||
private SpatialStorageChunkGenerator(Registry<Biome> biomeRegistry) {
|
||||
super(createBiomeSource(biomeRegistry), createSettings());
|
||||
this.defaultBlockState = Api.instance().definitions().blocks().matrixFrame().block().getDefaultState();
|
||||
this.biomeRegistry = biomeRegistry;
|
||||
|
||||
// Vertical sample is mostly used for Feature generation, for those purposes
|
||||
// we're all filled with matrix blocks
|
||||
@@ -68,13 +74,18 @@ public class SpatialStorageChunkGenerator extends ChunkGenerator {
|
||||
this.columnSample = new VerticalBlockSample(columnSample);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Codec<? extends ChunkGenerator> getCodec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
private static BiomeSource createBiomeProvider() {
|
||||
return new FixedBiomeSource(SpatialStorageBiome.INSTANCE);
|
||||
private static FixedBiomeSource createBiomeSource(Registry<Biome> biomeRegistry) {
|
||||
return new FixedBiomeSource(biomeRegistry.method_31140(SpatialStorageDimensionIds.BIOME_KEY));
|
||||
}
|
||||
|
||||
public Registry<Biome> getBiomeRegistry() {
|
||||
return biomeRegistry;
|
||||
}
|
||||
|
||||
private static StructuresConfig createSettings() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.dimension.DimensionOptions;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
@@ -31,7 +32,7 @@ public final class SpatialStorageDimensionIds {
|
||||
* ID of the {@link net.minecraft.world.biome.Biome} used for the spatial
|
||||
* storage world.
|
||||
*/
|
||||
public static final Identifier BIOME_ID = AppEng.makeId("spatial_storage");
|
||||
public static final RegistryKey<Biome> BIOME_KEY = RegistryKey.of(Registry.BIOME_KEY, AppEng.makeId("spatial_storage"));
|
||||
|
||||
/**
|
||||
* ID of the {@link DimensionOptions} used for the spatial storage dimension.
|
||||
@@ -49,6 +50,11 @@ public final class SpatialStorageDimensionIds {
|
||||
public static final RegistryKey<World> WORLD_ID = RegistryKey.of(Registry.DIMENSION,
|
||||
AppEng.makeId("spatial_storage"));
|
||||
|
||||
/**
|
||||
* ID of the {@link net.minecraft.client.render.SkyProperties} used for the spatial storage world.
|
||||
*/
|
||||
public static Identifier SKY_PROPERTIES_ID = AppEng.makeId("spatial_storage");
|
||||
|
||||
private SpatialStorageDimensionIds() {
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -30,15 +30,13 @@ import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.TeleportTarget;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SpatialStorageHelper {
|
||||
|
||||
@@ -51,12 +49,20 @@ public class SpatialStorageHelper {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final ThreadLocal<TeleportTarget> teleportTarget = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* If an entity is currently being teleported, this will return the target within the target dimension.
|
||||
*/
|
||||
public TeleportTarget getTeleportTarget() {
|
||||
return teleportTarget.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mostly from dimensional doors.. which mostly got it form X-Comp.
|
||||
*
|
||||
* @param entity to be teleported entity
|
||||
* @param link destination
|
||||
*
|
||||
* @return teleported entity
|
||||
*/
|
||||
private Entity teleportEntity(Entity entity, final TelDestination link) {
|
||||
@@ -99,16 +105,20 @@ public class SpatialStorageHelper {
|
||||
ChunkStatus.FULL, true);
|
||||
|
||||
if (entity instanceof ServerPlayerEntity
|
||||
&& link.dim.getDimensionRegistryKey() == SpatialStorageDimensionIds.DIMENSION_TYPE_ID) {
|
||||
&& link.dim.getRegistryKey() == SpatialStorageDimensionIds.WORLD_ID) {
|
||||
AppEng.instance().getAdvancementTriggers().getSpatialExplorer().trigger((ServerPlayerEntity) entity);
|
||||
}
|
||||
|
||||
// FIXME FABRIC new METeleporter(link)
|
||||
float yaw = entity.yaw;
|
||||
entity = entity.moveToWorld(link.dim);
|
||||
entity.yaw = yaw;
|
||||
entity.refreshPositionAfterTeleport(link.x, link.y, link.z);
|
||||
entity.setVelocity(0, 0, 0);
|
||||
// Store in a threadlocal so that EntityMixin can return it for the Vanilla logic to use
|
||||
teleportTarget.set(new TeleportTarget(new Vec3d(link.x, link.y, link.z),
|
||||
Vec3d.ZERO,
|
||||
entity.yaw,
|
||||
entity.pitch));
|
||||
try {
|
||||
entity = entity.moveToWorld(link.dim);
|
||||
} finally {
|
||||
teleportTarget.remove();
|
||||
}
|
||||
|
||||
if (!passengersOnOtherSide.isEmpty()) {
|
||||
for (Entity passanger : passengersOnOtherSide) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.world.TeleportTarget;
|
||||
|
||||
/**
|
||||
* Allocates and manages plots for spatial storage in the spatial storage world.
|
||||
|
||||
Reference in New Issue
Block a user