forked from Minecraft-Java-Edition-Speedrunning/set-spawn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinecraftClientMixin.java
More file actions
26 lines (23 loc) · 1.28 KB
/
MinecraftClientMixin.java
File metadata and controls
26 lines (23 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package net.set.spawn.mod.mixin;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef;
import net.minecraft.client.MinecraftClient;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.world.level.LevelInfo;
import net.set.spawn.mod.interfaces.MinecraftServerExtended;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MinecraftClient.class)
public abstract class MinecraftClientMixin {
@Inject(method = "startIntegratedServer", at = @At("HEAD"))
private void markIfNewWorld(String worldName, String levelName, LevelInfo levelInfo, CallbackInfo ci, @Share("newWorld") LocalBooleanRef newWorld) {
newWorld.set(levelInfo != null);
}
@ModifyExpressionValue(method = "startIntegratedServer", at = @At(value = "NEW", target = "net/minecraft/server/integrated/IntegratedServer"))
private IntegratedServer createIntegratedServer(IntegratedServer original, @Share("newWorld") LocalBooleanRef newWorld) {
((MinecraftServerExtended) original).setspawnmod$setShouldModifySpawn(newWorld.get());
return original;
}
}