Search in sources :

Example 1 with ARApplication

use of gregtech.api.terminal.app.ARApplication in project GregTech by GregTechCEu.

the class TerminalARRenderer method onClientTick.

public static void onClientTick(TickEvent.ClientTickEvent event) {
    if (event.phase == TickEvent.Phase.END) {
        EntityPlayer player = Minecraft.getMinecraft().player;
        if (player == null) {
            if (APP != null) {
                APP.onARClosed();
                APP = null;
            }
            return;
        }
        HELD_HAND = EnumHand.MAIN_HAND;
        NBTTagCompound tag = player.getHeldItem(EnumHand.MAIN_HAND).getSubCompound("terminal");
        if (tag == null) {
            tag = player.getHeldItem(EnumHand.OFF_HAND).getSubCompound("terminal");
            HELD_HAND = EnumHand.OFF_HAND;
        }
        if (tag != null && tag.hasKey("_ar")) {
            AbstractApplication app = TerminalRegistry.getApplication(tag.getString("_ar"));
            if (app instanceof ARApplication) {
                if (APP != app) {
                    if (APP != null) {
                        APP.onARClosed();
                    }
                    APP = (ARApplication) app;
                    APP.setAROpened(player.getHeldItem(HELD_HAND));
                    APP.onAROpened();
                }
                APP.tickAR(player);
                return;
            }
        }
        if (APP != null) {
            APP.onARClosed();
            APP = null;
        }
    }
}
Also used : ARApplication(gregtech.api.terminal.app.ARApplication) AbstractApplication(gregtech.api.terminal.app.AbstractApplication) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

ARApplication (gregtech.api.terminal.app.ARApplication)1 AbstractApplication (gregtech.api.terminal.app.AbstractApplication)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1