Skip to content

Commit d9a44ee

Browse files
committed
Merge 1.18 into 1.19.2
2 parents 2e8c003 + 1ce7647 commit d9a44ee

File tree

3 files changed

+173
-1
lines changed

3 files changed

+173
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.embeddedt.modernfix.common.mixin.perf.remove_spawn_chunks;
2+
3+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
4+
import net.minecraft.core.BlockPos;
5+
import net.minecraft.server.level.ServerLevel;
6+
import net.minecraft.server.level.TicketType;
7+
import net.minecraft.world.entity.Entity;
8+
import net.minecraft.world.level.ChunkPos;
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
12+
@Mixin(Entity.class)
13+
public class EntityMixin {
14+
/**
15+
* @author embeddedt
16+
* @reason If the spawn chunks are not loaded, end portals linking to the overworld will teleport entities into
17+
* the void at the spawn position, which is not ideal. To solve this, we create a PORTAL ticket if the expected
18+
* overworld chunk is missing.
19+
*/
20+
@ModifyExpressionValue(method = "findDimensionEntryPoint", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;getSharedSpawnPos()Lnet/minecraft/core/BlockPos;"), require = 0)
21+
private BlockPos mfix$triggerChunkloadAtSpawnPos(BlockPos spawnPos, ServerLevel destination) {
22+
// Only apply this change if the overworld is the destination
23+
if (destination.dimension() == ServerLevel.OVERWORLD) {
24+
// No ticket is required if the chunk happens to already be loaded
25+
if(!destination.hasChunk(spawnPos.getX() >> 4, spawnPos.getZ() >> 4)) {
26+
// Create a portal ticket. While we could just load the chunk once, it would immediately unload on the
27+
// next tick, causing churn. The ticket will keep it loaded for a few seconds which should give high
28+
// performance for farms pumping things through portals frequently.
29+
BlockPos key = spawnPos.immutable();
30+
destination.getChunkSource().addRegionTicket(TicketType.PORTAL, new ChunkPos(key), 3, key);
31+
// Wait for the chunk to be loaded, as adding the ticket is asynchronous
32+
destination.getChunk(key);
33+
}
34+
}
35+
return spawnPos;
36+
}
37+
}

common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ private ModernFixEarlyConfig(File file) {
229229
disableIfModPresent("mixin.perf.faster_texture_stitching", "optifine");
230230
disableIfModPresent("mixin.bugfix.entity_pose_stack", "optifine");
231231
disableIfModPresent("mixin.perf.datapack_reload_exceptions", "cyanide");
232-
disableIfModPresent("mixin.bugfix.buffer_builder_leak", "isometric-renders");
232+
disableIfModPresent("mixin.bugfix.buffer_builder_leak", "isometric-renders", "witherstormmod");
233233
disableIfModPresent("mixin.feature.remove_chat_signing", "nochatreports");
234234
disableIfModPresent("mixin.perf.faster_texture_loading", "stitch", "optifine", "changed");
235235
if(isFabric) {

0 commit comments

Comments
 (0)