Unicopia/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java

32 lines
1.3 KiB
Java
Raw Normal View History

package com.minelittlepony.unicopia.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.unicopia.entity.PonyContainer;
import com.minelittlepony.unicopia.entity.MotionChecker;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.player.PlayerEntity;
2020-06-26 11:44:47 +02:00
import net.minecraft.screen.ScreenHandlerListener;
import net.minecraft.server.network.ServerPlayerEntity;
@Mixin(ServerPlayerEntity.class)
abstract class MixinServerPlayerEntity extends PlayerEntity implements ScreenHandlerListener, PonyContainer<Pony>, MotionChecker {
2022-06-25 00:19:55 +02:00
MixinServerPlayerEntity() {super(null, null, 0, null, null);}
@Override
@Accessor("inTeleportationState")
public abstract void setPreventMotionChecks(boolean enabled);
@SuppressWarnings("unchecked")
@Inject(method = "copyFrom(Lnet/minecraft/server/network/ServerPlayerEntity;Z)V", at = @At("HEAD"))
private void onCopyFrom(ServerPlayerEntity oldPlayer, boolean alive, CallbackInfo info) {
get().copyFrom(((PonyContainer<Pony>)oldPlayer).get());
}
}