Skip to content

Commit f566ad2

Browse files
authored
Merge pull request #8 from tildejustin/1.19-1.20.4
re-add global shouldModifySpawn to fix spawn being set on death respawn on 1.20.5
2 parents a04098a + 72fe0cc commit f566ad2

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ org.gradle.jvmargs=-Xmx1G
55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
77
mod_id=setspawnmod
8-
mod_version=1.0.0
9-
target_version=1.19-1.20.4
8+
mod_version=1.0.1
9+
target_version=1.19-1.20.6
1010
minecraft_version=23w13a_or_b
1111
yarn_mappings=23w13a_or_b+build.5
1212
loader_version=0.14.22

src/main/java/net/set/spawn/mod/SetSpawn.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class SetSpawn implements ClientModInitializer {
1616
public static final String MOD_ID = "setspawnmod";
1717
public static final String subDir = SetSpawn.MOD_ID + "_global";
1818
public static Logger LOGGER = LogManager.getLogger();
19+
public static boolean shouldModifySpawn;
1920
public static boolean shouldSendErrorMessage;
2021
public static String errorMessage;
2122
public static File localConfigFile;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package net.set.spawn.mod.mixin;
2+
3+
import net.minecraft.server.MinecraftServer;
4+
import net.minecraft.server.WorldGenerationProgressListener;
5+
import net.set.spawn.mod.SetSpawn;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.injection.At;
8+
import org.spongepowered.asm.mixin.injection.Inject;
9+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
10+
11+
@Mixin(MinecraftServer.class)
12+
public abstract class MinecraftServerMixin{
13+
14+
@Inject(method = "prepareStartRegion", at = @At(value = "HEAD"))
15+
public void setspawnmod_startedWorldGen(WorldGenerationProgressListener worldGenerationProgressListener, CallbackInfo ci){
16+
if (SetSpawn.config.isEnabled()) {
17+
SetSpawn.shouldModifySpawn = true;
18+
}
19+
}
20+
}

src/main/java/net/set/spawn/mod/mixin/ServerPlayerEntityMixin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile
2424
}
2525
@Inject(method = "moveToSpawn", at = @At("HEAD"), cancellable = true)
2626
public void setspawnmod_setSpawn(ServerWorld world, CallbackInfo ci) {
27-
if (SetSpawn.config.isEnabled() && this.server.getSaveProperties().getPlayerData() == null) {
27+
if (SetSpawn.config.isEnabled() && SetSpawn.shouldModifySpawn) {
28+
SetSpawn.shouldModifySpawn = false;
2829
Seed seedObject = SetSpawn.findSeedObjectFromLong(world.getSeed());
2930
String response;
3031
if (seedObject != null ) {

src/main/resources/setspawnmod.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"package": "net.set.spawn.mod.mixin",
55
"compatibilityLevel": "JAVA_17",
66
"mixins": [
7+
"MinecraftServerMixin",
78
"PlayerManagerMixin",
89
"ServerPlayerEntityMixin",
910
"SpawnLocatingAccessor"

0 commit comments

Comments
 (0)