Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement NH Mixin and another safety net #4

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package me.voidxwalker.worldpreview.mixin.server;

import net.minecraft.world.level.storage.LevelStorage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(LevelStorage.Session.class)
public abstract class LevelStorage$SessionMixin {
/**
* @author tildejustin
*/
@Redirect(method = "getIconFile", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/LevelStorage$Session;checkValid()V"))
private void ignoreCheckValid(LevelStorage.Session instance) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public MinecraftServerMixin(String string) {

@Shadow @Final private static Logger LOGGER;

@Shadow private volatile boolean running;

@Shadow public abstract @Nullable ServerNetworkIo getNetworkIo();

@Shadow public abstract Thread getThread();
Expand Down Expand Up @@ -184,4 +186,11 @@ public void worldpreview_kill(WorldGenerationProgressListener worldGenerationPro
ci.cancel();
}
}

@Inject(method = "runServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V", shift = At.Shift.AFTER))
private void worldpreview_cancelRunServer(CallbackInfo ci) {
if (!this.session.lock.isValid()) {
this.running = false;
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/worldpreview.accesswidener
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
accessWidener v1 named
accessible class net/minecraft/client/world/ClientChunkManager$ClientChunkMap
accessible class net/minecraft/client/render/WorldRenderer$ChunkInfo
accessible method net/minecraft/client/render/WorldRenderer$ChunkInfo <init> (Lnet/minecraft/client/render/WorldRenderer;Lnet/minecraft/client/render/chunk/ChunkBuilder$BuiltChunk;Lnet/minecraft/util/math/Direction;I)V
accessible method net/minecraft/client/render/WorldRenderer$ChunkInfo <init> (Lnet/minecraft/client/render/WorldRenderer;Lnet/minecraft/client/render/chunk/ChunkBuilder$BuiltChunk;Lnet/minecraft/util/math/Direction;I)V
accessible field net/minecraft/world/level/storage/LevelStorage$Session lock Lnet/minecraft/world/level/storage/SessionLock;
1 change: 1 addition & 0 deletions src/main/resources/worldpreview.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"server.MinecraftServerMixin",
"server.ServerChunkManagerMixin",
"server.ServerPlayerEntityMixin",
"server.LevelStorage$SessionMixin",

"server.shutdown.StorageIOWorkerMixin",
"server.shutdown.ThreadedAnvilChunkStorageMixin"
Expand Down