dynmap/fabric-1.18.2/src/main/java/org/dynmap/fabric_1_18/mixin/ServerPlayerEntityMixin.java

31 lines
1.3 KiB
Java

package org.dynmap.fabric_1_18.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import org.dynmap.fabric_1_18.event.PlayerEvents;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ServerPlayerEntity.class)
public class ServerPlayerEntityMixin {
@Inject(method = "teleport", at = @At("RETURN"))
public void teleport(ServerWorld targetWorld, double x, double y, double z, float yaw, float pitch, CallbackInfo info) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
if (targetWorld != player.world) {
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
}
}
@Inject(method = "moveToWorld", at = @At("RETURN"))
public void moveToWorld(ServerWorld destination, CallbackInfoReturnable<Entity> info) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
if (player.getRemovalReason() == null) {
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
}
}
}