Compare commits

..

3 Commits

Author SHA1 Message Date
Jason Penilla
500c0777f8 Raise priority of occlusion task
Having this at a higher priority than section render tasks seems to give better results anecdotally
2024-10-23 15:38:59 -07:00
Jason Penilla
b5b6e38cb7 attempt to execute task on #get to minimize blocking 2024-10-23 10:35:35 -07:00
Jason Penilla
e69eeba47c Use Moonrise executor for section occlusion tasks 2024-10-23 10:35:35 -07:00
30 changed files with 180 additions and 198 deletions

View File

@@ -12,19 +12,19 @@ Fabric/NeoForge mod for optimising performance of the integrated (singleplayer/L
Moonrise aims to optimise the game *without changing Vanilla behavior*. If you find that there are changes to Vanilla behavior, Moonrise aims to optimise the game *without changing Vanilla behavior*. If you find that there are changes to Vanilla behavior,
please open an issue. please open an issue.
Moonrise is an official port of several important [Paper](https://github.com/PaperMC/Paper/) Moonrise ports several important [Paper](https://github.com/PaperMC/Paper/)
patches. Listed below are notable patches: patches. Listed below are notable patches:
- [Starlight](https://github.com/PaperMC/Starlight/)
- Chunk system rewrite - Chunk system rewrite
- Collision optimisations - Collision optimisations
- Entity tracker optimisations - Entity tracker optimisations
- Random ticking optimisations - Random ticking optimisations
- [Starlight](https://github.com/PaperMC/Starlight/)
## Known Compatibility Issues ## Known Compatibility Issues
| Mod | Status | | Mod | Status |
|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Lithium | <details><summary>✅ compatible</summary>Lithium optimises many of the same parts of the game as Moonrise, for example the chunk system. Moonrise will automatically disable conflicting parts of Lithium. This mechanism needs to be manually validated for each Moonrise and Lithium release.</details> | | Lithium | <details><summary>✅ compatible</summary>Lithium optimises many of the same parts of the game as Moonrise, for example the chunk system. Moonrise will automatically disable conflicting parts of Lithium. This mechanism needs to be manually validated for each Moonrise and Lithium release.</details> |
| FerriteCore | <details><summary>✅ compatible</summary>FerriteCore optimises some of the same parts of the game as Moonrise. Moonrise will automatically disable conflicting parts of FerriteCore. This mechanism needs to be manually validated for each Moonrise and FerriteCore release.</details> | | FerriteCore | <details><summary>📝 requires config changes</summary>In `config/ferritecore-mixin.toml`:<br/>Set `replaceNeighborLookup` and `replacePropertyMap` to `false`</details> |
| C2ME | <details><summary>❌ incompatible</summary>C2ME is based around modifications to the chunk system, which Moonrise replaces wholesale. This makes them fundamentally incompatible.</details> | | C2ME | <details><summary>❌ incompatible</summary>C2ME is based around modifications to the chunk system, which Moonrise replaces wholesale. This makes them fundamentally incompatible.</details> |
## Configuration ## Configuration

View File

@@ -24,8 +24,7 @@ dependencies {
include "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}" include "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}"
modImplementation "com.terraformersmc:modmenu:${rootProject.modmenu_version}" modImplementation "com.terraformersmc:modmenu:${rootProject.modmenu_version}"
modImplementation fabricApiLibs.command.api.v2 modImplementation fabricApiLibs.fabric.api
modImplementation fabricApiLibs.lifecycle.events.v1
include fabricApiLibs.command.api.v2 include fabricApiLibs.command.api.v2
include fabricApiLibs.base include fabricApiLibs.base
} }
@@ -60,7 +59,7 @@ publishMods {
incompatible( incompatible(
"not-enough-crashes", "not-enough-crashes",
"starlight", "starlight",
"c2me" "c2me-fabric"
) )
} }
} }

View File

@@ -2,25 +2,21 @@ package ca.spottedleaf.moonrise.fabric;
import ca.spottedleaf.moonrise.common.PlatformHooks; import ca.spottedleaf.moonrise.common.PlatformHooks;
import ca.spottedleaf.moonrise.common.util.ConfigHolder; import ca.spottedleaf.moonrise.common.util.ConfigHolder;
import com.mojang.datafixers.DSL; import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
import com.mojang.datafixers.DataFixer; import com.mojang.datafixers.DataFixer;
import com.mojang.serialization.Dynamic;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; 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.GenerationChunkHolder;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.datafix.DataFixTypes;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess; 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.LevelChunk;
import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.chunk.ProtoChunk;
import net.minecraft.world.level.chunk.status.ChunkStatusTasks; import net.minecraft.world.level.chunk.status.ChunkStatusTasks;
@@ -32,8 +28,6 @@ import java.util.function.Predicate;
public final class FabricHooks implements PlatformHooks { public final class FabricHooks implements PlatformHooks {
private static final boolean HAS_FABRIC_LIFECYCLE_EVENTS = FabricLoader.getInstance().isModLoaded("fabric-lifecycle-events-v1");
@Override @Override
public String getBrand() { public String getBrand() {
return "Moonrise"; return "Moonrise";
@@ -68,12 +62,7 @@ public final class FabricHooks implements PlatformHooks {
@Override @Override
public void chunkFullStatusComplete(final LevelChunk newChunk, final ProtoChunk original) { public void chunkFullStatusComplete(final LevelChunk newChunk, final ProtoChunk original) {
if (HAS_FABRIC_LIFECYCLE_EVENTS) {
ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad((ServerLevel)newChunk.getLevel(), newChunk); ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad((ServerLevel)newChunk.getLevel(), newChunk);
if (!(original instanceof ImposterProtoChunk)) {
ServerChunkEvents.CHUNK_GENERATE.invoker().onChunkGenerate((ServerLevel)newChunk.getLevel(), newChunk);
}
}
} }
@Override @Override
@@ -82,16 +71,14 @@ public final class FabricHooks implements PlatformHooks {
} }
@Override @Override
public void onChunkHolderTicketChange(final ServerLevel world, final ChunkHolder holder, final int oldLevel, final int newLevel) { public void onChunkHolderTicketChange(final ServerLevel world, final NewChunkHolder holder, final int oldLevel, final int newLevel) {
} }
@Override @Override
public void chunkUnloadFromWorld(final LevelChunk chunk) { public void chunkUnloadFromWorld(final LevelChunk chunk) {
if (HAS_FABRIC_LIFECYCLE_EVENTS) {
ServerChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload((ServerLevel)chunk.getLevel(), chunk); ServerChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload((ServerLevel)chunk.getLevel(), chunk);
} }
}
@Override @Override
public void chunkSyncSave(final ServerLevel world, final ChunkAccess chunk, final SerializableChunkData data) { public void chunkSyncSave(final ServerLevel world, final ChunkAccess chunk, final SerializableChunkData data) {
@@ -166,12 +153,12 @@ public final class FabricHooks implements PlatformHooks {
} }
@Override @Override
public long configAutoSaveInterval(final ServerLevel world) { public long configAutoSaveInterval() {
return ConfigHolder.getConfig().chunkSaving.autoSaveInterval.getTimeTicks(); return ConfigHolder.getConfig().chunkSaving.autoSaveInterval.getTimeTicks();
} }
@Override @Override
public int configMaxAutoSavePerTick(final ServerLevel world) { public int configMaxAutoSavePerTick() {
return ConfigHolder.getConfig().chunkSaving.maxAutoSaveChunksPerTick; return ConfigHolder.getConfig().chunkSaving.maxAutoSaveChunksPerTick;
} }
@@ -186,11 +173,9 @@ public final class FabricHooks implements PlatformHooks {
} }
@Override @Override
public CompoundTag convertNBT(final DSL.TypeReference type, final DataFixer dataFixer, final CompoundTag nbt, public CompoundTag convertNBT(final DataFixTypes type, final DataFixer dataFixer, final CompoundTag nbt,
final int fromVersion, final int toVersion) { final int fromVersion, final int toVersion) {
return (CompoundTag)dataFixer.update( return type.update(dataFixer, nbt, fromVersion, toVersion);
type, new Dynamic<>(NbtOps.INSTANCE, nbt), fromVersion, toVersion
).getValue();
} }
@Override @Override

View File

@@ -42,6 +42,7 @@
"custom": { "custom": {
"lithium:options": { "lithium:options": {
"mixin.ai.poi": false, "mixin.ai.poi": false,
"mixin.alloc.chunk_ticking": false,
"mixin.alloc.deep_passengers": false, "mixin.alloc.deep_passengers": false,
"mixin.alloc.entity_tracker": false, "mixin.alloc.entity_tracker": false,
"mixin.block.flatten_states": false, "mixin.block.flatten_states": false,
@@ -65,12 +66,9 @@
"mixin.world.block_entity_ticking": false, "mixin.world.block_entity_ticking": false,
"mixin.world.chunk_access": false, "mixin.world.chunk_access": false,
"mixin.world.explosions.block_raycast": false, "mixin.world.explosions.block_raycast": false,
"mixin.world.explosions.cache_exposure": false,
"mixin.world.temperature_cache": false, "mixin.world.temperature_cache": false,
"mixin.world.tick_scheduler": false "mixin.world.tick_scheduler": false
}, }
"ferritecore:disabled_options": [
"replaceNeighborLookup",
"replacePropertyMap"
]
} }
} }

View File

@@ -6,16 +6,16 @@ org.gradle.daemon=false
minecraft_version=1.21.3 minecraft_version=1.21.3
loader_version=0.16.7 loader_version=0.16.7
supported_minecraft_versions=1.21.3 supported_minecraft_versions=1.21.3
neoforge_version=21.3.31-beta neoforge_version=21.3.0-beta
fabric_api_version=0.107.0+1.21.3 fabric_api_version=0.106.1+1.21.3
snakeyaml_version=2.2 snakeyaml_version=2.2
concurrentutil_version=0.0.2-SNAPSHOT concurrentutil_version=0.0.2-SNAPSHOT
cloth_version=16.0.141 cloth_version=16.0.141
modmenu_version=12.0.0-beta.1 modmenu_version=12.0.0-beta.1
# version ids from modrinth # version ids from modrinth
fabric_lithium_version=QhCwdt4l fabric_lithium_version=mc1.21.1-0.14.0-beta.1
neo_lithium_version=wDD955sb neo_lithium_version=BrMIoIMv
# Mod Properties # Mod Properties
mod_version=0.2.0-beta.4 mod_version=0.2.0-SNAPSHOT
maven_group=ca.spottedleaf.moonrise maven_group=ca.spottedleaf.moonrise
archives_base_name=moonrise archives_base_name=moonrise

View File

@@ -3,16 +3,14 @@ package ca.spottedleaf.moonrise.neoforge;
import ca.spottedleaf.moonrise.common.PlatformHooks; import ca.spottedleaf.moonrise.common.PlatformHooks;
import ca.spottedleaf.moonrise.common.util.ConfigHolder; import ca.spottedleaf.moonrise.common.util.ConfigHolder;
import ca.spottedleaf.moonrise.common.util.CoordinateUtils; import ca.spottedleaf.moonrise.common.util.CoordinateUtils;
import com.mojang.datafixers.DSL; import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
import com.mojang.datafixers.DataFixer; import com.mojang.datafixers.DataFixer;
import com.mojang.serialization.Dynamic;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; 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.GenerationChunkHolder;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.datafix.DataFixTypes;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
@@ -82,12 +80,10 @@ public final class NeoForgeHooks implements PlatformHooks {
} }
@Override @Override
public void onChunkHolderTicketChange(final ServerLevel world, final ChunkHolder holder, final int oldLevel, final int newLevel) { public void onChunkHolderTicketChange(final ServerLevel world, final NewChunkHolder holder, final int oldLevel, final int newLevel) {
final ChunkPos pos = holder.getPos();
EventHooks.fireChunkTicketLevelUpdated( EventHooks.fireChunkTicketLevelUpdated(
world, CoordinateUtils.getChunkKey(pos.x, pos.z), world, CoordinateUtils.getChunkKey(holder.chunkX, holder.chunkZ),
oldLevel, newLevel, holder oldLevel, newLevel, holder.vanillaChunkHolder
); );
} }
@@ -189,12 +185,12 @@ public final class NeoForgeHooks implements PlatformHooks {
} }
@Override @Override
public long configAutoSaveInterval(final ServerLevel world) { public long configAutoSaveInterval() {
return ConfigHolder.getConfig().chunkSaving.autoSaveInterval.getTimeTicks(); return ConfigHolder.getConfig().chunkSaving.autoSaveInterval.getTimeTicks();
} }
@Override @Override
public int configMaxAutoSavePerTick(final ServerLevel world) { public int configMaxAutoSavePerTick() {
return ConfigHolder.getConfig().chunkSaving.maxAutoSaveChunksPerTick; return ConfigHolder.getConfig().chunkSaving.maxAutoSaveChunksPerTick;
} }
@@ -209,11 +205,9 @@ public final class NeoForgeHooks implements PlatformHooks {
} }
@Override @Override
public CompoundTag convertNBT(final DSL.TypeReference type, final DataFixer dataFixer, final CompoundTag nbt, public CompoundTag convertNBT(final DataFixTypes type, final DataFixer dataFixer, final CompoundTag nbt,
final int fromVersion, final int toVersion) { final int fromVersion, final int toVersion) {
return (CompoundTag)dataFixer.update( return type.update(dataFixer, nbt, fromVersion, toVersion);
type, new Dynamic<>(NbtOps.INSTANCE, nbt), fromVersion, toVersion
).getValue();
} }
@Override @Override

View File

@@ -13,10 +13,6 @@ displayURL = "https://github.com/Tuinity/Moonrise"
authors = "Spottedleaf" authors = "Spottedleaf"
description = "Optimisation mod for the dedicated and integrated server." description = "Optimisation mod for the dedicated and integrated server."
displayTest = "IGNORE_ALL_VERSION" displayTest = "IGNORE_ALL_VERSION"
"ferritecore:disabled_options" = [
"replaceNeighborLookup",
"replacePropertyMap"
]
[[dependencies.moonrise]] [[dependencies.moonrise]]
modId = "neoforge" modId = "neoforge"
@@ -55,8 +51,9 @@ config = "moonrise.mixins.json"
[[mixins]] [[mixins]]
config = "moonrise-neoforge.mixins.json" config = "moonrise-neoforge.mixins.json"
["lithium:options"] [mods."lithium:options"]
"mixin.ai.poi" = false "mixin.ai.poi" = false
"mixin.alloc.chunk_ticking" = false
"mixin.alloc.deep_passengers" = false "mixin.alloc.deep_passengers" = false
"mixin.alloc.entity_tracker" = false "mixin.alloc.entity_tracker" = false
"mixin.block.flatten_states" = false "mixin.block.flatten_states" = false
@@ -80,5 +77,6 @@ config = "moonrise-neoforge.mixins.json"
"mixin.world.block_entity_ticking" = false "mixin.world.block_entity_ticking" = false
"mixin.world.chunk_access" = false "mixin.world.chunk_access" = false
"mixin.world.explosions.block_raycast" = false "mixin.world.explosions.block_raycast" = false
"mixin.world.explosions.cache_exposure" = false
"mixin.world.temperature_cache" = false "mixin.world.temperature_cache" = false
"mixin.world.tick_scheduler" = false "mixin.world.tick_scheduler" = false

View File

@@ -24,7 +24,7 @@ pluginManagement {
plugins { plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
id("xyz.jpenilla.quiet-architectury-loom") version "1.7.300" apply false id("xyz.jpenilla.quiet-architectury-loom") version "1.7.297" apply false
id 'com.gradleup.shadow' version '8.3.0' apply false id 'com.gradleup.shadow' version '8.3.0' apply false
} }

View File

@@ -1,10 +1,9 @@
package ca.spottedleaf.moonrise.common; package ca.spottedleaf.moonrise.common;
import com.mojang.datafixers.DSL; import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
import com.mojang.datafixers.DataFixer; import com.mojang.datafixers.DataFixer;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.GenerationChunkHolder; import net.minecraft.server.level.GenerationChunkHolder;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
@@ -45,7 +44,7 @@ public interface PlatformHooks {
public boolean allowAsyncTicketUpdates(); public boolean allowAsyncTicketUpdates();
public void onChunkHolderTicketChange(final ServerLevel world, final ChunkHolder holder, final int oldLevel, final int newLevel); public void onChunkHolderTicketChange(final ServerLevel world, final NewChunkHolder holder, final int oldLevel, final int newLevel);
public void chunkUnloadFromWorld(final LevelChunk chunk); public void chunkUnloadFromWorld(final LevelChunk chunk);
@@ -80,16 +79,16 @@ public interface PlatformHooks {
public int configPlayerMaxConcurrentGens(); public int configPlayerMaxConcurrentGens();
public long configAutoSaveInterval(final ServerLevel world); public long configAutoSaveInterval();
public int configMaxAutoSavePerTick(final ServerLevel world); public int configMaxAutoSavePerTick();
public boolean configFixMC159283(); public boolean configFixMC159283();
// support for CB chunk mustNotSave // support for CB chunk mustNotSave
public boolean forceNoSave(final ChunkAccess chunk); public boolean forceNoSave(final ChunkAccess chunk);
public CompoundTag convertNBT(final DSL.TypeReference type, final DataFixer dataFixer, final CompoundTag nbt, public CompoundTag convertNBT(final DataFixTypes type, final DataFixer dataFixer, final CompoundTag nbt,
final int fromVersion, final int toVersion); final int fromVersion, final int toVersion);
public boolean hasMainChunkLoadHook(); public boolean hasMainChunkLoadHook();

View File

@@ -2,7 +2,6 @@ package ca.spottedleaf.moonrise.common.misc;
import ca.spottedleaf.concurrentutil.util.IntPairUtil; import ca.spottedleaf.concurrentutil.util.IntPairUtil;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; 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.Reference2ReferenceOpenHashMap;
import it.unimi.dsi.fastutil.objects.ReferenceSet; import it.unimi.dsi.fastutil.objects.ReferenceSet;
@@ -15,10 +14,6 @@ public final class PositionCountingAreaMap<T> {
return this.counters.keySet(); return this.counters.keySet();
} }
public LongSet getPositions() {
return this.positions.keySet();
}
public int getTotalPositions() { public int getTotalPositions() {
return this.positions.size(); return this.positions.size();
} }

View File

@@ -32,6 +32,7 @@ public final class MoonriseCommon {
public static final long WORKER_QUEUE_HOLD_TIME = (long)(20.0e6); // 20ms public static final long WORKER_QUEUE_HOLD_TIME = (long)(20.0e6); // 20ms
public static final int CLIENT_DIVISION = 0; public static final int CLIENT_DIVISION = 0;
public static final PrioritisedThreadPool.ExecutorGroup RENDER_EXECUTOR_GROUP = MoonriseCommon.WORKER_POOL.createExecutorGroup(CLIENT_DIVISION, 0); public static final PrioritisedThreadPool.ExecutorGroup RENDER_EXECUTOR_GROUP = MoonriseCommon.WORKER_POOL.createExecutorGroup(CLIENT_DIVISION, 0);
public static final PrioritisedThreadPool.ExecutorGroup SECTION_OCCLUSION_EXECUTOR_GROUP = MoonriseCommon.WORKER_POOL.createExecutorGroup(CLIENT_DIVISION, 0);
public static final int SERVER_DIVISION = 1; public static final int SERVER_DIVISION = 1;
public static final PrioritisedThreadPool.ExecutorGroup PARALLEL_GEN_GROUP = MoonriseCommon.WORKER_POOL.createExecutorGroup(SERVER_DIVISION, 0); public static final PrioritisedThreadPool.ExecutorGroup PARALLEL_GEN_GROUP = MoonriseCommon.WORKER_POOL.createExecutorGroup(SERVER_DIVISION, 0);
public static final PrioritisedThreadPool.ExecutorGroup RADIUS_AWARE_GROUP = MoonriseCommon.WORKER_POOL.createExecutorGroup(SERVER_DIVISION, 0); public static final PrioritisedThreadPool.ExecutorGroup RADIUS_AWARE_GROUP = MoonriseCommon.WORKER_POOL.createExecutorGroup(SERVER_DIVISION, 0);

View File

@@ -538,21 +538,6 @@ abstract class ChunkMapMixin extends ChunkStorage implements ChunkSystemChunkMap
throw new UnsupportedOperationException(); 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 @Override
public CompletableFuture<Optional<CompoundTag>> read(final ChunkPos pos) { public CompletableFuture<Optional<CompoundTag>> read(final ChunkPos pos) {
final CompletableFuture<Optional<CompoundTag>> ret = new CompletableFuture<>(); final CompletableFuture<Optional<CompoundTag>> ret = new CompletableFuture<>();

View File

@@ -315,15 +315,6 @@ abstract class DistanceManagerMixin implements ChunkSystemDistanceManager {
throw new UnsupportedOperationException(); 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} * @reason This hack is not required anymore, see {@link MinecraftServerMixin}
* @author Spottedleaf * @author Spottedleaf

View File

@@ -266,4 +266,20 @@ public abstract class PoiManagerMixin extends SectionStorage<Object, Object> imp
private <T> Stream<T> skipLoadedSet(final Stream<T> instance, final Predicate<? super T> predicate) { private <T> Stream<T> skipLoadedSet(final Stream<T> instance, final Predicate<? super T> predicate) {
return instance; 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);
}
} }

View File

@@ -26,6 +26,10 @@ abstract class SectionStorageMixin<R, P> implements ChunkSystemSectionStorage, A
@Shadow @Shadow
private SimpleRegionStorage simpleRegionStorage; private SimpleRegionStorage simpleRegionStorage;
@Shadow
@Final
static Logger LOGGER;
@Unique @Unique
private RegionFileStorage storage; private RegionFileStorage storage;
@@ -35,9 +39,6 @@ abstract class SectionStorageMixin<R, P> implements ChunkSystemSectionStorage, A
return this.storage; return this.storage;
} }
@Override
public void moonrise$close() throws IOException {}
/** /**
* @reason Retrieve storage from IOWorker, and then nuke it * @reason Retrieve storage from IOWorker, and then nuke it
* @author Spottedleaf * @author Spottedleaf
@@ -58,8 +59,12 @@ abstract class SectionStorageMixin<R, P> implements ChunkSystemSectionStorage, A
* @author Spottedleaf * @author Spottedleaf
*/ */
@Overwrite @Overwrite
public final CompletableFuture<Optional<SectionStorage.PackedChunk<P>>> tryRead(final ChunkPos pos) { public final CompletableFuture<Optional<CompoundTag>> tryRead(final ChunkPos pos) {
throw new IllegalStateException("Only chunk system can write state, offending class:" + this.getClass().getName()); try {
return CompletableFuture.completedFuture(Optional.ofNullable(this.moonrise$read(pos.x, pos.z)));
} catch (final Throwable thr) {
return CompletableFuture.failedFuture(thr);
}
} }
/** /**
@@ -72,12 +77,24 @@ abstract class SectionStorageMixin<R, P> implements ChunkSystemSectionStorage, A
} }
/** /**
* @reason Destroy old chunk system hook * @reason Route to new chunk system hook
* @author Spottedleaf * @author Spottedleaf
*/ */
@Overwrite @Redirect(
private void writeChunk(final ChunkPos chunkPos) { method = "writeChunk(Lnet/minecraft/world/level/ChunkPos;)V",
throw new IllegalStateException("Only chunk system can write state, offending class:" + this.getClass().getName()); 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;
} }
/** /**

View File

@@ -24,7 +24,6 @@ import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LightChunk; import net.minecraft.world.level.chunk.LightChunk;
import net.minecraft.world.level.chunk.status.ChunkStatus; 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.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Overwrite;
@@ -52,10 +51,6 @@ abstract class ServerChunkCacheMixin extends ChunkSource implements ChunkSystemS
@Final @Final
public ServerLevel level; public ServerLevel level;
@Shadow
@Final
private DimensionDataStorage dataStorage;
@Unique @Unique
private final ConcurrentLong2ReferenceChainedHashTable<LevelChunk> fullChunks = new ConcurrentLong2ReferenceChainedHashTable<>(); private final ConcurrentLong2ReferenceChainedHashTable<LevelChunk> fullChunks = new ConcurrentLong2ReferenceChainedHashTable<>();
@@ -266,7 +261,6 @@ abstract class ServerChunkCacheMixin extends ChunkSource implements ChunkSystemS
@Override @Override
@Overwrite @Overwrite
public void close() throws IOException { public void close() throws IOException {
this.dataStorage.close();
((ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.close(true, true); ((ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler().chunkHolderManager.close(true, true);
} }

View File

@@ -84,21 +84,12 @@ abstract class ChunkMapMixin {
((ChunkTickDistanceManager)this.distanceManager).moonrise$removePlayer(player, SectionPos.of(player)); ((ChunkTickDistanceManager)this.distanceManager).moonrise$removePlayer(player, SectionPos.of(player));
} }
/**
* @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 * @reason Use nearby players to avoid iterating over all online players
* @author Spottedleaf * @author Spottedleaf
*/ */
@Overwrite @Overwrite
public boolean anyPlayerCloseEnoughForSpawningInternal(final ChunkPos pos) { public boolean anyPlayerCloseEnoughForSpawning(final ChunkPos pos) {
final ReferenceList<ServerPlayer> players = ((ChunkSystemServerLevel)this.level).moonrise$getNearbyPlayers().getPlayers( final ReferenceList<ServerPlayer> players = ((ChunkSystemServerLevel)this.level).moonrise$getNearbyPlayers().getPlayers(
pos, NearbyPlayers.NearbyMapType.SPAWN_RANGE pos, NearbyPlayers.NearbyMapType.SPAWN_RANGE
); );

View File

@@ -4,7 +4,6 @@ import ca.spottedleaf.moonrise.common.misc.PositionCountingAreaMap;
import ca.spottedleaf.moonrise.common.util.CoordinateUtils; import ca.spottedleaf.moonrise.common.util.CoordinateUtils;
import ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickConstants; import ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickConstants;
import ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickDistanceManager; import ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickDistanceManager;
import it.unimi.dsi.fastutil.longs.LongIterator;
import net.minecraft.core.SectionPos; import net.minecraft.core.SectionPos;
import net.minecraft.server.level.DistanceManager; import net.minecraft.server.level.DistanceManager;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
@@ -107,13 +106,4 @@ abstract class DistanceManagerMixin implements ChunkTickDistanceManager {
public boolean hasPlayersNearby(final long pos) { public boolean hasPlayersNearby(final long pos) {
return this.spawnChunkTracker.hasObjectsNear(CoordinateUtils.getChunkX(pos), CoordinateUtils.getChunkZ(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();
}
} }

View File

@@ -15,6 +15,7 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.ExplosionDamageCalculator; import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerExplosion; import net.minecraft.world.level.ServerExplosion;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
@@ -439,10 +440,7 @@ abstract class ServerExplosionMixin {
* @author Spottedleaf * @author Spottedleaf
*/ */
@Redirect( @Redirect(
method = { method = "hurtEntities",
"hurtEntities()V",
"hurtEntities(Ljava/util/List;)V" // Neo moves logic into this new method
},
at = @At( at = @At(
value = "INVOKE", value = "INVOKE",
target = "Lnet/minecraft/world/level/ServerExplosion;getSeenPercent(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/Entity;)F" target = "Lnet/minecraft/world/level/ServerExplosion;getSeenPercent(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/Entity;)F"

View File

@@ -0,0 +1,56 @@
package ca.spottedleaf.moonrise.mixin.render;
import ca.spottedleaf.concurrentutil.executor.PrioritisedExecutor;
import ca.spottedleaf.concurrentutil.executor.thread.PrioritisedThreadPool;
import ca.spottedleaf.concurrentutil.util.Priority;
import ca.spottedleaf.moonrise.common.util.MoonriseCommon;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import net.minecraft.client.renderer.SectionOcclusionGraph;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(SectionOcclusionGraph.class)
abstract class SectionOcclusionGraphMixin {
@Unique
private static final PrioritisedThreadPool.ExecutorGroup.ThreadPoolExecutor SECTION_OCCLUSION_EXECUTOR = MoonriseCommon.SECTION_OCCLUSION_EXECUTOR_GROUP.createExecutor(
-1, MoonriseCommon.WORKER_QUEUE_HOLD_TIME, 0
);
/**
* @reason Change executor to use our thread pool
* Note: even at normal priority, our worker pool will try to share resources equally rather than having it
* be a free-for-all
* @author jpenilla
*/
@Redirect(
method = "scheduleFullUpdate",
at = @At(
value = "INVOKE",
target = "Ljava/util/concurrent/CompletableFuture;runAsync(Ljava/lang/Runnable;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"
)
)
private CompletableFuture<Void> changeExecutor(final Runnable runnable, final Executor executor) {
final PrioritisedExecutor.PrioritisedTask[] prioritisedTask = new PrioritisedExecutor.PrioritisedTask[1];
final CompletableFuture<Void> future = new CompletableFuture<>() {
@Override
public Void get() throws InterruptedException, ExecutionException {
prioritisedTask[0].execute();
return super.get();
}
};
prioritisedTask[0] = SECTION_OCCLUSION_EXECUTOR.queueTask(() -> {
try {
runnable.run();
future.complete(null);
} catch (final Throwable throwable) {
future.completeExceptionally(throwable);
}
}, Priority.HIGH); // Higher than SectionRenderDispatcherMixin#changeExecutor
return future;
}
}

View File

@@ -21,7 +21,6 @@ import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.chunk.storage.RegionStorageInfo; import net.minecraft.world.level.chunk.storage.RegionStorageInfo;
import net.minecraft.world.level.chunk.storage.SerializableChunkData; import net.minecraft.world.level.chunk.storage.SerializableChunkData;
import net.minecraft.world.level.lighting.LevelLightEngine; import net.minecraft.world.level.lighting.LevelLightEngine;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@@ -47,10 +46,6 @@ abstract class SerializableChunkDataMixin {
@Final @Final
private List<SerializableChunkData.SectionData> sectionData; private List<SerializableChunkData.SectionData> sectionData;
@Shadow
@Final
private static Logger LOGGER;
/** /**
* @reason Replace light correctness check with our own * @reason Replace light correctness check with our own
* Our light check is versioned in case we change the light format OR fix a bug * Our light check is versioned in case we change the light format OR fix a bug
@@ -121,13 +116,6 @@ abstract class SerializableChunkDataMixin {
final SWMRNibbleArray[] blockNibbles = StarLightEngine.getFilledEmptyLight(world); final SWMRNibbleArray[] blockNibbles = StarLightEngine.getFilledEmptyLight(world);
final SWMRNibbleArray[] skyNibbles = StarLightEngine.getFilledEmptyLight(world); final SWMRNibbleArray[] skyNibbles = StarLightEngine.getFilledEmptyLight(world);
if (!this.lightCorrect) {
((StarlightChunk)ret).starlight$setBlockNibbles(blockNibbles);
((StarlightChunk)ret).starlight$setSkyNibbles(skyNibbles);
return;
}
try {
for (final SerializableChunkData.SectionData sectionData : this.sectionData) { for (final SerializableChunkData.SectionData sectionData : this.sectionData) {
final int y = sectionData.y(); final int y = sectionData.y();
final DataLayer blockLight = sectionData.blockLight(); final DataLayer blockLight = sectionData.blockLight();
@@ -155,11 +143,6 @@ abstract class SerializableChunkDataMixin {
((StarlightChunk)ret).starlight$setBlockNibbles(blockNibbles); ((StarlightChunk)ret).starlight$setBlockNibbles(blockNibbles);
((StarlightChunk)ret).starlight$setSkyNibbles(skyNibbles); ((StarlightChunk)ret).starlight$setSkyNibbles(skyNibbles);
} catch (final Throwable thr) {
ret.setLightCorrect(false);
LOGGER.error("Failed to parse light data for chunk " + ret.getPos() + " in world '" + WorldUtil.getWorldName(world) + "'", thr);
}
} }
/** /**

View File

@@ -9,7 +9,7 @@ import it.unimi.dsi.fastutil.objects.AbstractReference2ObjectMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator; import it.unimi.dsi.fastutil.objects.ObjectIterator;
import it.unimi.dsi.fastutil.objects.ObjectSet; import it.unimi.dsi.fastutil.objects.ObjectSet;
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap; import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import it.unimi.dsi.fastutil.objects.ReferenceArrayList; import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@@ -27,7 +27,7 @@ public final class ZeroCollidingReferenceStateTable<O, S> {
public ZeroCollidingReferenceStateTable(final Collection<Property<?>> properties) { public ZeroCollidingReferenceStateTable(final Collection<Property<?>> properties) {
this.propertyToIndexer = new Int2ObjectOpenHashMap<>(properties.size()); this.propertyToIndexer = new Int2ObjectOpenHashMap<>(properties.size());
this.properties = new ReferenceArrayList<>(properties); this.properties = new ReferenceOpenHashSet<>(properties);
final List<Property<?>> sortedProperties = new ArrayList<>(properties); final List<Property<?>> sortedProperties = new ArrayList<>(properties);

View File

@@ -5,7 +5,7 @@ import net.minecraft.SharedConstants;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.datafix.fixes.References; import net.minecraft.util.datafix.DataFixTypes;
public final class ChunkSystemConverters { public final class ChunkSystemConverters {
@@ -26,13 +26,13 @@ public final class ChunkSystemConverters {
public static CompoundTag convertPoiCompoundTag(final CompoundTag data, final ServerLevel world) { public static CompoundTag convertPoiCompoundTag(final CompoundTag data, final ServerLevel world) {
final int dataVersion = getDataVersion(data, DEFAULT_POI_DATA_VERSION); final int dataVersion = getDataVersion(data, DEFAULT_POI_DATA_VERSION);
return PlatformHooks.get().convertNBT(References.POI_CHUNK, world.getServer().getFixerUpper(), data, dataVersion, getCurrentVersion()); return PlatformHooks.get().convertNBT(DataFixTypes.POI_CHUNK, world.getServer().getFixerUpper(), data, dataVersion, getCurrentVersion());
} }
public static CompoundTag convertEntityChunkCompoundTag(final CompoundTag data, final ServerLevel world) { public static CompoundTag convertEntityChunkCompoundTag(final CompoundTag data, final ServerLevel world) {
final int dataVersion = getDataVersion(data, DEFAULT_ENTITY_CHUNK_DATA_VERSION); final int dataVersion = getDataVersion(data, DEFAULT_ENTITY_CHUNK_DATA_VERSION);
return PlatformHooks.get().convertNBT(References.ENTITY_CHUNK, world.getServer().getFixerUpper(), data, dataVersion, getCurrentVersion()); return PlatformHooks.get().convertNBT(DataFixTypes.ENTITY_CHUNK, world.getServer().getFixerUpper(), data, dataVersion, getCurrentVersion());
} }
private ChunkSystemConverters() {} private ChunkSystemConverters() {}

View File

@@ -165,7 +165,7 @@ public final class ChunkEntitySlices {
return this.entities.size() != 0; return this.entities.size() != 0;
} }
public List<Entity> getAllEntities() { private List<Entity> getAllEntities() {
final int len = this.entities.size(); final int len = this.entities.size();
if (len == 0) { if (len == 0) {
return new ArrayList<>(); return new ArrayList<>();

View File

@@ -1,10 +1,15 @@
package ca.spottedleaf.moonrise.patches.chunk_system.level.storage; package ca.spottedleaf.moonrise.patches.chunk_system.level.storage;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.chunk.storage.RegionFileStorage; import net.minecraft.world.level.chunk.storage.RegionFileStorage;
import java.io.IOException; import java.io.IOException;
public interface ChunkSystemSectionStorage { 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 RegionFileStorage moonrise$getRegionStorage();
public void moonrise$close() throws IOException; public void moonrise$close() throws IOException;

View File

@@ -231,8 +231,8 @@ public final class ChunkHolderManager {
public void autoSave() { public void autoSave() {
final List<NewChunkHolder> reschedule = new ArrayList<>(); final List<NewChunkHolder> reschedule = new ArrayList<>();
final long currentTick = this.currentTick; final long currentTick = this.currentTick;
final long maxSaveTime = currentTick - Math.max(1L, PlatformHooks.get().configAutoSaveInterval(this.world)); final long maxSaveTime = currentTick - Math.max(1L, PlatformHooks.get().configAutoSaveInterval());
final int maxToSave = PlatformHooks.get().configMaxAutoSavePerTick(this.world); final int maxToSave = PlatformHooks.get().configMaxAutoSavePerTick();
for (int autoSaved = 0; autoSaved < maxToSave && !this.autoSaveQueue.isEmpty();) { for (int autoSaved = 0; autoSaved < maxToSave && !this.autoSaveQueue.isEmpty();) {
final NewChunkHolder holder = this.autoSaveQueue.first(); final NewChunkHolder holder = this.autoSaveQueue.first();

View File

@@ -6,6 +6,7 @@ import ca.spottedleaf.concurrentutil.executor.thread.PrioritisedThreadPool;
import ca.spottedleaf.concurrentutil.lock.ReentrantAreaLock; import ca.spottedleaf.concurrentutil.lock.ReentrantAreaLock;
import ca.spottedleaf.concurrentutil.util.ConcurrentUtil; import ca.spottedleaf.concurrentutil.util.ConcurrentUtil;
import ca.spottedleaf.concurrentutil.util.Priority; 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.CoordinateUtils;
import ca.spottedleaf.moonrise.common.util.JsonUtil; import ca.spottedleaf.moonrise.common.util.JsonUtil;
import ca.spottedleaf.moonrise.common.util.MoonriseCommon; import ca.spottedleaf.moonrise.common.util.MoonriseCommon;

View File

@@ -1078,7 +1078,7 @@ public final class NewChunkHolder {
} }
// Don't really have a choice but to place this hook here // Don't really have a choice but to place this hook here
PlatformHooks.get().onChunkHolderTicketChange(this.world, this.vanillaChunkHolder, oldLevel, newLevel); PlatformHooks.get().onChunkHolderTicketChange(this.world, this, oldLevel, newLevel);
} }
static final int NEIGHBOUR_RADIUS = 2; static final int NEIGHBOUR_RADIUS = 2;

View File

@@ -14,9 +14,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.CollisionGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@@ -1945,7 +1943,6 @@ public final class CollisionUtil {
final BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); final BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();
final CollisionContext collisionShape = new LazyEntityCollisionContext(entity); final CollisionContext collisionShape = new LazyEntityCollisionContext(entity);
final boolean useEntityCollisionShape = LazyEntityCollisionContext.useEntityCollisionShape(world, entity);
// special cases: // special cases:
if (minBlockY > maxBlockY) { if (minBlockY > maxBlockY) {
@@ -2031,10 +2028,7 @@ public final class CollisionUtil {
VoxelShape blockCollision = ((CollisionBlockState)blockData).moonrise$getConstantContextCollisionShape(); VoxelShape blockCollision = ((CollisionBlockState)blockData).moonrise$getConstantContextCollisionShape();
if (edgeCount == 0 || ((edgeCount != 1 || blockData.hasLargeCollisionShape()) && (edgeCount != 2 || blockData.getBlock() == Blocks.MOVING_PISTON))) { if (edgeCount == 0 || ((edgeCount != 1 || blockData.hasLargeCollisionShape()) && (edgeCount != 2 || blockData.getBlock() == Blocks.MOVING_PISTON))) {
if (useEntityCollisionShape) { if (blockCollision == null) {
mutablePos.set(blockX, blockY, blockZ);
blockCollision = collisionShape.getCollisionShape(blockData, world, mutablePos);
} else if (blockCollision == null) {
mutablePos.set(blockX, blockY, blockZ); mutablePos.set(blockX, blockY, blockZ);
blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape); blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape);
} }
@@ -2156,10 +2150,6 @@ public final class CollisionUtil {
super(false, 0.0, null, null, entity); super(false, 0.0, null, null, entity);
} }
public static boolean useEntityCollisionShape(final Level world, final Entity entity) {
return entity instanceof AbstractMinecart && AbstractMinecart.useExperimentalMovement(world);
}
public boolean isDelegated() { public boolean isDelegated() {
final boolean delegated = this.delegated; final boolean delegated = this.delegated;
this.delegated = false; this.delegated = false;
@@ -2191,11 +2181,6 @@ public final class CollisionUtil {
public boolean canStandOnFluid(final FluidState state, final FluidState fluidState) { public boolean canStandOnFluid(final FluidState state, final FluidState fluidState) {
return this.getDelegate().canStandOnFluid(state, fluidState); return this.getDelegate().canStandOnFluid(state, fluidState);
} }
@Override
public VoxelShape getCollisionShape(final BlockState blockState, final CollisionGetter collisionGetter, final BlockPos blockPos) {
return this.getDelegate().getCollisionShape(blockState, collisionGetter, blockPos);
}
} }
private CollisionUtil() { private CollisionUtil() {

View File

@@ -128,6 +128,7 @@
"config.MinecraftMixin", "config.MinecraftMixin",
"loading_screen.LevelLoadStatusManagerMixin", "loading_screen.LevelLoadStatusManagerMixin",
"profiler.MinecraftMixin", "profiler.MinecraftMixin",
"render.SectionOcclusionGraphMixin",
"render.SectionRenderDispatcherMixin", "render.SectionRenderDispatcherMixin",
"serverlist.ClientConnectionMixin", "serverlist.ClientConnectionMixin",
"serverlist.ServerAddressResolverMixin", "serverlist.ServerAddressResolverMixin",