Compare commits
17 Commits
section-oc
...
v0.2.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ceb4936d9d | ||
|
|
3cb888e894 | ||
|
|
7bedc1a7de | ||
|
|
718f6e1369 | ||
|
|
da9ab708a6 | ||
|
|
f22335f0b6 | ||
|
|
a3f2328000 | ||
|
|
529b9a44bb | ||
|
|
1e9a6504a1 | ||
|
|
9c46dcbb94 | ||
|
|
9a1e04389a | ||
|
|
29084d8e3f | ||
|
|
41790ecf1a | ||
|
|
8af7bccdfd | ||
|
|
5f9b3571f8 | ||
|
|
9adfb2514d | ||
|
|
bf2cd1c571 |
@@ -24,7 +24,8 @@ dependencies {
|
||||
include "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}"
|
||||
modImplementation "com.terraformersmc:modmenu:${rootProject.modmenu_version}"
|
||||
|
||||
modImplementation fabricApiLibs.fabric.api
|
||||
modImplementation fabricApiLibs.command.api.v2
|
||||
modImplementation fabricApiLibs.lifecycle.events.v1
|
||||
include fabricApiLibs.command.api.v2
|
||||
include fabricApiLibs.base
|
||||
}
|
||||
|
||||
@@ -2,21 +2,25 @@ package ca.spottedleaf.moonrise.fabric;
|
||||
|
||||
import ca.spottedleaf.moonrise.common.PlatformHooks;
|
||||
import ca.spottedleaf.moonrise.common.util.ConfigHolder;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
||||
import com.mojang.datafixers.DSL;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.GenerationChunkHolder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.datafix.DataFixTypes;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ImposterProtoChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatusTasks;
|
||||
@@ -28,6 +32,8 @@ import java.util.function.Predicate;
|
||||
|
||||
public final class FabricHooks implements PlatformHooks {
|
||||
|
||||
private static final boolean HAS_FABRIC_LIFECYCLE_EVENTS = FabricLoader.getInstance().isModLoaded("fabric-lifecycle-events-v1");
|
||||
|
||||
@Override
|
||||
public String getBrand() {
|
||||
return "Moonrise";
|
||||
@@ -62,7 +68,12 @@ public final class FabricHooks implements PlatformHooks {
|
||||
|
||||
@Override
|
||||
public void chunkFullStatusComplete(final LevelChunk newChunk, final ProtoChunk original) {
|
||||
ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad((ServerLevel)newChunk.getLevel(), newChunk);
|
||||
if (HAS_FABRIC_LIFECYCLE_EVENTS) {
|
||||
ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad((ServerLevel)newChunk.getLevel(), newChunk);
|
||||
if (!(original instanceof ImposterProtoChunk)) {
|
||||
ServerChunkEvents.CHUNK_GENERATE.invoker().onChunkGenerate((ServerLevel)newChunk.getLevel(), newChunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,13 +82,15 @@ public final class FabricHooks implements PlatformHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkHolderTicketChange(final ServerLevel world, final NewChunkHolder holder, final int oldLevel, final int newLevel) {
|
||||
public void onChunkHolderTicketChange(final ServerLevel world, final ChunkHolder holder, final int oldLevel, final int newLevel) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chunkUnloadFromWorld(final LevelChunk chunk) {
|
||||
ServerChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload((ServerLevel)chunk.getLevel(), chunk);
|
||||
if (HAS_FABRIC_LIFECYCLE_EVENTS) {
|
||||
ServerChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload((ServerLevel)chunk.getLevel(), chunk);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,12 +166,12 @@ public final class FabricHooks implements PlatformHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long configAutoSaveInterval() {
|
||||
public long configAutoSaveInterval(final ServerLevel world) {
|
||||
return ConfigHolder.getConfig().chunkSaving.autoSaveInterval.getTimeTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int configMaxAutoSavePerTick() {
|
||||
public int configMaxAutoSavePerTick(final ServerLevel world) {
|
||||
return ConfigHolder.getConfig().chunkSaving.maxAutoSaveChunksPerTick;
|
||||
}
|
||||
|
||||
@@ -173,9 +186,11 @@ public final class FabricHooks implements PlatformHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag convertNBT(final DataFixTypes type, final DataFixer dataFixer, final CompoundTag nbt,
|
||||
public CompoundTag convertNBT(final DSL.TypeReference type, final DataFixer dataFixer, final CompoundTag nbt,
|
||||
final int fromVersion, final int toVersion) {
|
||||
return type.update(dataFixer, nbt, fromVersion, toVersion);
|
||||
return (CompoundTag)dataFixer.update(
|
||||
type, new Dynamic<>(NbtOps.INSTANCE, nbt), fromVersion, toVersion
|
||||
).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,7 @@ minecraft_version=1.21.3
|
||||
loader_version=0.16.7
|
||||
supported_minecraft_versions=1.21.3
|
||||
neoforge_version=21.3.0-beta
|
||||
fabric_api_version=0.106.1+1.21.3
|
||||
fabric_api_version=0.107.0+1.21.3
|
||||
snakeyaml_version=2.2
|
||||
concurrentutil_version=0.0.2-SNAPSHOT
|
||||
cloth_version=16.0.141
|
||||
@@ -16,6 +16,6 @@ modmenu_version=12.0.0-beta.1
|
||||
fabric_lithium_version=mc1.21.1-0.14.0-beta.1
|
||||
neo_lithium_version=BrMIoIMv
|
||||
# Mod Properties
|
||||
mod_version=0.2.0-SNAPSHOT
|
||||
mod_version=0.2.0-beta.2
|
||||
maven_group=ca.spottedleaf.moonrise
|
||||
archives_base_name=moonrise
|
||||
|
||||
@@ -3,14 +3,16 @@ package ca.spottedleaf.moonrise.neoforge;
|
||||
import ca.spottedleaf.moonrise.common.PlatformHooks;
|
||||
import ca.spottedleaf.moonrise.common.util.ConfigHolder;
|
||||
import ca.spottedleaf.moonrise.common.util.CoordinateUtils;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
||||
import com.mojang.datafixers.DSL;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.GenerationChunkHolder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.datafix.DataFixTypes;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
@@ -80,10 +82,12 @@ public final class NeoForgeHooks implements PlatformHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkHolderTicketChange(final ServerLevel world, final NewChunkHolder holder, final int oldLevel, final int newLevel) {
|
||||
public void onChunkHolderTicketChange(final ServerLevel world, final ChunkHolder holder, final int oldLevel, final int newLevel) {
|
||||
final ChunkPos pos = holder.getPos();
|
||||
|
||||
EventHooks.fireChunkTicketLevelUpdated(
|
||||
world, CoordinateUtils.getChunkKey(holder.chunkX, holder.chunkZ),
|
||||
oldLevel, newLevel, holder.vanillaChunkHolder
|
||||
world, CoordinateUtils.getChunkKey(pos.x, pos.z),
|
||||
oldLevel, newLevel, holder
|
||||
);
|
||||
}
|
||||
|
||||
@@ -185,12 +189,12 @@ public final class NeoForgeHooks implements PlatformHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long configAutoSaveInterval() {
|
||||
public long configAutoSaveInterval(final ServerLevel world) {
|
||||
return ConfigHolder.getConfig().chunkSaving.autoSaveInterval.getTimeTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int configMaxAutoSavePerTick() {
|
||||
public int configMaxAutoSavePerTick(final ServerLevel world) {
|
||||
return ConfigHolder.getConfig().chunkSaving.maxAutoSaveChunksPerTick;
|
||||
}
|
||||
|
||||
@@ -205,9 +209,11 @@ public final class NeoForgeHooks implements PlatformHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag convertNBT(final DataFixTypes type, final DataFixer dataFixer, final CompoundTag nbt,
|
||||
public CompoundTag convertNBT(final DSL.TypeReference type, final DataFixer dataFixer, final CompoundTag nbt,
|
||||
final int fromVersion, final int toVersion) {
|
||||
return type.update(dataFixer, nbt, fromVersion, toVersion);
|
||||
return (CompoundTag)dataFixer.update(
|
||||
type, new Dynamic<>(NbtOps.INSTANCE, nbt), fromVersion, toVersion
|
||||
).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package ca.spottedleaf.moonrise.common;
|
||||
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
||||
import com.mojang.datafixers.DSL;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.GenerationChunkHolder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -44,7 +45,7 @@ public interface PlatformHooks {
|
||||
|
||||
public boolean allowAsyncTicketUpdates();
|
||||
|
||||
public void onChunkHolderTicketChange(final ServerLevel world, final NewChunkHolder holder, final int oldLevel, final int newLevel);
|
||||
public void onChunkHolderTicketChange(final ServerLevel world, final ChunkHolder holder, final int oldLevel, final int newLevel);
|
||||
|
||||
public void chunkUnloadFromWorld(final LevelChunk chunk);
|
||||
|
||||
@@ -79,16 +80,16 @@ public interface PlatformHooks {
|
||||
|
||||
public int configPlayerMaxConcurrentGens();
|
||||
|
||||
public long configAutoSaveInterval();
|
||||
public long configAutoSaveInterval(final ServerLevel world);
|
||||
|
||||
public int configMaxAutoSavePerTick();
|
||||
public int configMaxAutoSavePerTick(final ServerLevel world);
|
||||
|
||||
public boolean configFixMC159283();
|
||||
|
||||
// support for CB chunk mustNotSave
|
||||
public boolean forceNoSave(final ChunkAccess chunk);
|
||||
|
||||
public CompoundTag convertNBT(final DataFixTypes type, final DataFixer dataFixer, final CompoundTag nbt,
|
||||
public CompoundTag convertNBT(final DSL.TypeReference type, final DataFixer dataFixer, final CompoundTag nbt,
|
||||
final int fromVersion, final int toVersion);
|
||||
|
||||
public boolean hasMainChunkLoadHook();
|
||||
|
||||
@@ -2,6 +2,7 @@ package ca.spottedleaf.moonrise.common.misc;
|
||||
|
||||
import ca.spottedleaf.concurrentutil.util.IntPairUtil;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceSet;
|
||||
|
||||
@@ -14,6 +15,10 @@ public final class PositionCountingAreaMap<T> {
|
||||
return this.counters.keySet();
|
||||
}
|
||||
|
||||
public LongSet getPositions() {
|
||||
return this.positions.keySet();
|
||||
}
|
||||
|
||||
public int getTotalPositions() {
|
||||
return this.positions.size();
|
||||
}
|
||||
|
||||
@@ -538,6 +538,21 @@ abstract class ChunkMapMixin extends ChunkStorage implements ChunkSystemChunkMap
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Route to new chunk system
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Redirect(
|
||||
method = "forEachSpawnCandidateChunk",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lit/unimi/dsi/fastutil/longs/Long2ObjectLinkedOpenHashMap;get(J)Ljava/lang/Object;"
|
||||
)
|
||||
)
|
||||
private <V> V redirectChunkHolderGet(final Long2ObjectLinkedOpenHashMap<V> instance, final long key) {
|
||||
return (V)this.getVisibleChunkIfPresent(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Optional<CompoundTag>> read(final ChunkPos pos) {
|
||||
final CompletableFuture<Optional<CompoundTag>> ret = new CompletableFuture<>();
|
||||
|
||||
@@ -315,6 +315,15 @@ abstract class DistanceManagerMixin implements ChunkSystemDistanceManager {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Remove old chunk system hooks
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public LongSet getTickingChunks() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason This hack is not required anymore, see {@link MinecraftServerMixin}
|
||||
* @author Spottedleaf
|
||||
|
||||
@@ -266,20 +266,4 @@ public abstract class PoiManagerMixin extends SectionStorage<Object, Object> imp
|
||||
private <T> Stream<T> skipLoadedSet(final Stream<T> instance, final Predicate<? super T> predicate) {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void moonrise$close() throws IOException {}
|
||||
|
||||
@Override
|
||||
public final CompoundTag moonrise$read(final int chunkX, final int chunkZ) throws IOException {
|
||||
return MoonriseRegionFileIO.loadData(
|
||||
this.world, chunkX, chunkZ, MoonriseRegionFileIO.RegionFileType.POI_DATA,
|
||||
MoonriseRegionFileIO.getIOBlockingPriorityForCurrentThread()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void moonrise$write(final int chunkX, final int chunkZ, final CompoundTag data) throws IOException {
|
||||
MoonriseRegionFileIO.scheduleSave(this.world, chunkX, chunkZ, data, MoonriseRegionFileIO.RegionFileType.POI_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,6 @@ abstract class SectionStorageMixin<R, P> implements ChunkSystemSectionStorage, A
|
||||
@Shadow
|
||||
private SimpleRegionStorage simpleRegionStorage;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
static Logger LOGGER;
|
||||
|
||||
|
||||
@Unique
|
||||
private RegionFileStorage storage;
|
||||
@@ -39,6 +35,9 @@ abstract class SectionStorageMixin<R, P> implements ChunkSystemSectionStorage, A
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moonrise$close() throws IOException {}
|
||||
|
||||
/**
|
||||
* @reason Retrieve storage from IOWorker, and then nuke it
|
||||
* @author Spottedleaf
|
||||
@@ -59,12 +58,8 @@ abstract class SectionStorageMixin<R, P> implements ChunkSystemSectionStorage, A
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public final CompletableFuture<Optional<CompoundTag>> tryRead(final ChunkPos pos) {
|
||||
try {
|
||||
return CompletableFuture.completedFuture(Optional.ofNullable(this.moonrise$read(pos.x, pos.z)));
|
||||
} catch (final Throwable thr) {
|
||||
return CompletableFuture.failedFuture(thr);
|
||||
}
|
||||
public final CompletableFuture<Optional<SectionStorage.PackedChunk<P>>> tryRead(final ChunkPos pos) {
|
||||
throw new IllegalStateException("Only chunk system can write state, offending class:" + this.getClass().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,24 +72,12 @@ abstract class SectionStorageMixin<R, P> implements ChunkSystemSectionStorage, A
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Route to new chunk system hook
|
||||
* @reason Destroy old chunk system hook
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Redirect(
|
||||
method = "writeChunk(Lnet/minecraft/world/level/ChunkPos;)V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/chunk/storage/SimpleRegionStorage;write(Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/nbt/CompoundTag;)Ljava/util/concurrent/CompletableFuture;"
|
||||
)
|
||||
)
|
||||
private CompletableFuture<Void> redirectWrite(final SimpleRegionStorage instance, final ChunkPos pos,
|
||||
final CompoundTag tag) {
|
||||
try {
|
||||
this.moonrise$write(pos.x, pos.z, tag);
|
||||
} catch (final IOException ex) {
|
||||
LOGGER.error("Error writing poi chunk data to disk for chunk " + pos, ex);
|
||||
}
|
||||
return null;
|
||||
@Overwrite
|
||||
private void writeChunk(final ChunkPos chunkPos) {
|
||||
throw new IllegalStateException("Only chunk system can write state, offending class:" + this.getClass().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.world.level.chunk.ChunkSource;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LightChunk;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.level.storage.DimensionDataStorage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
@@ -51,6 +52,10 @@ abstract class ServerChunkCacheMixin extends ChunkSource implements ChunkSystemS
|
||||
@Final
|
||||
public ServerLevel level;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private DimensionDataStorage dataStorage;
|
||||
|
||||
@Unique
|
||||
private final ConcurrentLong2ReferenceChainedHashTable<LevelChunk> fullChunks = new ConcurrentLong2ReferenceChainedHashTable<>();
|
||||
|
||||
@@ -261,6 +266,7 @@ abstract class ServerChunkCacheMixin extends ChunkSource implements ChunkSystemS
|
||||
@Override
|
||||
@Overwrite
|
||||
public void close() throws IOException {
|
||||
this.dataStorage.close();
|
||||
((ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.close(true, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,11 +85,20 @@ abstract class ChunkMapMixin {
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Use nearby players to avoid iterating over all online players
|
||||
* @reason Avoid checking first if there are nearby players, as we make internal perform this implicitly.
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean anyPlayerCloseEnoughForSpawning(final ChunkPos pos) {
|
||||
return this.anyPlayerCloseEnoughForSpawningInternal(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Use nearby players to avoid iterating over all online players
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean anyPlayerCloseEnoughForSpawningInternal(final ChunkPos pos) {
|
||||
final ReferenceList<ServerPlayer> players = ((ChunkSystemServerLevel)this.level).moonrise$getNearbyPlayers().getPlayers(
|
||||
pos, NearbyPlayers.NearbyMapType.SPAWN_RANGE
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@ import ca.spottedleaf.moonrise.common.misc.PositionCountingAreaMap;
|
||||
import ca.spottedleaf.moonrise.common.util.CoordinateUtils;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickConstants;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickDistanceManager;
|
||||
import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.server.level.DistanceManager;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -106,4 +107,13 @@ abstract class DistanceManagerMixin implements ChunkTickDistanceManager {
|
||||
public boolean hasPlayersNearby(final long pos) {
|
||||
return this.spawnChunkTracker.hasObjectsNear(CoordinateUtils.getChunkX(pos), CoordinateUtils.getChunkZ(pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* @reason Use spawnChunkTracker instead
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public LongIterator getSpawnCandidateChunks() {
|
||||
return this.spawnChunkTracker.getPositions().iterator();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerExplosion;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.SharedConstants;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.datafix.DataFixTypes;
|
||||
import net.minecraft.util.datafix.fixes.References;
|
||||
|
||||
public final class ChunkSystemConverters {
|
||||
|
||||
@@ -26,13 +26,13 @@ public final class ChunkSystemConverters {
|
||||
public static CompoundTag convertPoiCompoundTag(final CompoundTag data, final ServerLevel world) {
|
||||
final int dataVersion = getDataVersion(data, DEFAULT_POI_DATA_VERSION);
|
||||
|
||||
return PlatformHooks.get().convertNBT(DataFixTypes.POI_CHUNK, world.getServer().getFixerUpper(), data, dataVersion, getCurrentVersion());
|
||||
return PlatformHooks.get().convertNBT(References.POI_CHUNK, world.getServer().getFixerUpper(), data, dataVersion, getCurrentVersion());
|
||||
}
|
||||
|
||||
public static CompoundTag convertEntityChunkCompoundTag(final CompoundTag data, final ServerLevel world) {
|
||||
final int dataVersion = getDataVersion(data, DEFAULT_ENTITY_CHUNK_DATA_VERSION);
|
||||
|
||||
return PlatformHooks.get().convertNBT(DataFixTypes.ENTITY_CHUNK, world.getServer().getFixerUpper(), data, dataVersion, getCurrentVersion());
|
||||
return PlatformHooks.get().convertNBT(References.ENTITY_CHUNK, world.getServer().getFixerUpper(), data, dataVersion, getCurrentVersion());
|
||||
}
|
||||
|
||||
private ChunkSystemConverters() {}
|
||||
|
||||
@@ -165,7 +165,7 @@ public final class ChunkEntitySlices {
|
||||
return this.entities.size() != 0;
|
||||
}
|
||||
|
||||
private List<Entity> getAllEntities() {
|
||||
public List<Entity> getAllEntities() {
|
||||
final int len = this.entities.size();
|
||||
if (len == 0) {
|
||||
return new ArrayList<>();
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package ca.spottedleaf.moonrise.patches.chunk_system.level.storage;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.chunk.storage.RegionFileStorage;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface ChunkSystemSectionStorage {
|
||||
|
||||
public CompoundTag moonrise$read(final int chunkX, final int chunkZ) throws IOException;
|
||||
|
||||
public void moonrise$write(final int chunkX, final int chunkZ, final CompoundTag data) throws IOException;
|
||||
|
||||
public RegionFileStorage moonrise$getRegionStorage();
|
||||
|
||||
public void moonrise$close() throws IOException;
|
||||
|
||||
@@ -231,8 +231,8 @@ public final class ChunkHolderManager {
|
||||
public void autoSave() {
|
||||
final List<NewChunkHolder> reschedule = new ArrayList<>();
|
||||
final long currentTick = this.currentTick;
|
||||
final long maxSaveTime = currentTick - Math.max(1L, PlatformHooks.get().configAutoSaveInterval());
|
||||
final int maxToSave = PlatformHooks.get().configMaxAutoSavePerTick();
|
||||
final long maxSaveTime = currentTick - Math.max(1L, PlatformHooks.get().configAutoSaveInterval(this.world));
|
||||
final int maxToSave = PlatformHooks.get().configMaxAutoSavePerTick(this.world);
|
||||
for (int autoSaved = 0; autoSaved < maxToSave && !this.autoSaveQueue.isEmpty();) {
|
||||
final NewChunkHolder holder = this.autoSaveQueue.first();
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import ca.spottedleaf.concurrentutil.executor.thread.PrioritisedThreadPool;
|
||||
import ca.spottedleaf.concurrentutil.lock.ReentrantAreaLock;
|
||||
import ca.spottedleaf.concurrentutil.util.ConcurrentUtil;
|
||||
import ca.spottedleaf.concurrentutil.util.Priority;
|
||||
import ca.spottedleaf.moonrise.common.config.moonrise.MoonriseConfig;
|
||||
import ca.spottedleaf.moonrise.common.util.CoordinateUtils;
|
||||
import ca.spottedleaf.moonrise.common.util.JsonUtil;
|
||||
import ca.spottedleaf.moonrise.common.util.MoonriseCommon;
|
||||
|
||||
@@ -1078,7 +1078,7 @@ public final class NewChunkHolder {
|
||||
}
|
||||
|
||||
// Don't really have a choice but to place this hook here
|
||||
PlatformHooks.get().onChunkHolderTicketChange(this.world, this, oldLevel, newLevel);
|
||||
PlatformHooks.get().onChunkHolderTicketChange(this.world, this.vanillaChunkHolder, oldLevel, newLevel);
|
||||
}
|
||||
|
||||
static final int NEIGHBOUR_RADIUS = 2;
|
||||
|
||||
Reference in New Issue
Block a user