Search in sources :

Example 1 with PacketUnconsciousAwaken

use of com.lying.variousoddities.network.PacketUnconsciousAwaken in project VariousOddities by Lyinginbedmon.

the class MinecraftMixin method processKeyBinds.

@Inject(method = "processKeyBinds()V", at = @At("HEAD"), cancellable = true)
public void processKeyBinds(final CallbackInfo ci) {
    PlayerEntity player = ((Minecraft) (Object) this).player;
    if (player == null)
        return;
    PlayerData data = PlayerData.forPlayer(player);
    if (data == null)
        return;
    Minecraft mc = Minecraft.getInstance();
    if (PlayerData.isPlayerNormalFunction(player) || VOHelper.isCreativeOrSpectator(player))
        return;
    else
        ci.cancel();
    while (mc.gameSettings.keyBindInventory.isPressed()) {
        switch(data.getBodyCondition()) {
            case DEAD:
                // Send respawn packet if delay completed
                if (data.timeToRespawnable() == 0F)
                    PacketHandler.sendToServer(new PacketDeadDeath());
            case UNCONSCIOUS:
                // Send wakeup packet if no longer unconscious
                if (!LivingData.forEntity(player).isUnconscious() && data.getSoulCondition() == SoulCondition.ALIVE)
                    PacketHandler.sendToServer(new PacketUnconsciousAwaken());
            default:
                ;
        }
    }
    processVitalKeys(mc);
    if (this.player.isHandActive())
        this.playerController.onStoppedUsingItem(this.player);
    this.sendClickBlockToController(false);
}
Also used : PacketDeadDeath(com.lying.variousoddities.network.PacketDeadDeath) PacketUnconsciousAwaken(com.lying.variousoddities.network.PacketUnconsciousAwaken) Minecraft(net.minecraft.client.Minecraft) PlayerData(com.lying.variousoddities.capabilities.PlayerData) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

PlayerData (com.lying.variousoddities.capabilities.PlayerData)1 PacketDeadDeath (com.lying.variousoddities.network.PacketDeadDeath)1 PacketUnconsciousAwaken (com.lying.variousoddities.network.PacketUnconsciousAwaken)1 Minecraft (net.minecraft.client.Minecraft)1 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1