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

40 lines
1.6 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;
2023-04-30 02:41:21 +02:00
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.minelittlepony.unicopia.entity.Equine;
import com.minelittlepony.unicopia.entity.duck.ServerPlayerEntityDuck;
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;
2023-04-30 02:41:21 +02:00
import net.minecraft.world.World;
@Mixin(ServerPlayerEntity.class)
abstract class MixinServerPlayerEntity extends PlayerEntity implements ScreenHandlerListener, Equine.Container<Pony>, ServerPlayerEntityDuck {
2022-12-18 22:07:24 +01:00
MixinServerPlayerEntity() {super(null, null, 0, 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(((Equine.Container<Pony>)oldPlayer).get(), alive);
}
2023-04-30 02:41:21 +02:00
@Redirect(method = "trySleep", at = @At(
value = "INVOKE",
target = "net/minecraft/world/World.isDay()Z"
))
private boolean redirectIsDay(World world) {
return get().isDaytime();
}
}