Skip to content

Commit

Permalink
fix respawn position
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkGoosik committed Mar 26, 2023
1 parent 8d6759f commit 24478bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/main/java/skylands/event/SkylandsEvents.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package skylands.event;

import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
Expand All @@ -9,10 +10,21 @@
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import skylands.logic.Skylands;

public class SkylandsEvents {

public static void init() {
ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, player, alive) -> {
var server = player.getServer();
if(server != null && server.getFile("hub_template").exists()) {
if(player.getWorld().getRegistryKey().equals(World.OVERWORLD)) {
Skylands.getInstance().hub.visit(player);
}
}
});

ServerLifecycleEvents.SERVER_STARTING.register(ServerStartEvent::onStarting);
ServerTickEvents.END_SERVER_TICK.register(ServerTickEvent::onTick);
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> PlayerConnectEvent.onJoin(server, handler.player));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/skylands/mixin/server/MinecraftServerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class MinecraftServerMixin {
@Final
private static Logger LOGGER;

@Redirect(method = "save", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V"))
@Redirect(method = "save", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false))
void info(Logger logger, String s, Object o, Object o1) {
if(o1 instanceof Identifier id) {
if(id.getNamespace().equals(SkylandsMod.MOD_ID)) {
Expand All @@ -32,7 +32,7 @@ void info(Logger logger, String s, Object o, Object o1) {
logger.info(s, o, o1);
}

@Redirect(method = "save", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;)V"))
@Redirect(method = "save", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
void info(Logger logger, String s, Object o) {
try {
if(o instanceof String) {
Expand Down

0 comments on commit 24478bd

Please sign in to comment.