diff --git a/src/main/java/cc/reconnected/server/mixin/ServerPlayerEntityMixin.java b/src/main/java/cc/reconnected/server/mixin/ServerPlayerEntityMixin.java index 05248d1..ca7a43d 100644 --- a/src/main/java/cc/reconnected/server/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/cc/reconnected/server/mixin/ServerPlayerEntityMixin.java @@ -1,13 +1,18 @@ package cc.reconnected.server.mixin; import cc.reconnected.server.RccServer; +import cc.reconnected.server.core.BackTracker; import cc.reconnected.server.core.customChat.CustomDeathMessage; +import cc.reconnected.server.struct.ServerPosition; import eu.pb4.placeholders.api.PlaceholderContext; import eu.pb4.placeholders.api.Placeholders; import eu.pb4.placeholders.api.parsers.NodeParser; import eu.pb4.placeholders.api.parsers.TextParserV1; import net.minecraft.entity.damage.DamageTracker; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.packet.s2c.play.PositionFlag; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -16,6 +21,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.Set; + @Mixin(ServerPlayerEntity.class) public class ServerPlayerEntityMixin { @Unique @@ -36,4 +43,10 @@ public class ServerPlayerEntityMixin { var player = (ServerPlayerEntity) (Object) this; return CustomDeathMessage.onDeath(player, instance); } + + @Inject(method = "teleport(Lnet/minecraft/server/world/ServerWorld;DDDLjava/util/Set;FF)Z", at = @At("HEAD")) + public void rccServer$requestTeleport(ServerWorld world, double destX, double destY, double destZ, Set flags, float yaw, float pitch, CallbackInfoReturnable cir) { + var player = (ServerPlayerEntity) (Object) this; + BackTracker.lastPlayerPositions.put(player.getUuid(), new ServerPosition(player)); + } }