Java Code Examples for net.minecraft.client.Minecraft#isCallingFromMinecraftThread()

The following examples show how to use net.minecraft.client.Minecraft#isCallingFromMinecraftThread() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchematicProject.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onTaskCompleted()
{
    Minecraft mc = Minecraft.getMinecraft();

    if (mc.isCallingFromMinecraftThread())
    {
        this.saveVersion();
    }
    else
    {
        mc.addScheduledTask(new Runnable()
        {
            @Override
            public void run()
            {
                SaveCompletionListener.this.saveVersion();
            }
        });
    }
}
 
Example 2
Source File: PacketCustom.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void handle(final INetHandler netHandler, final String channel, final PacketCustom packet) {
    if (netHandler instanceof INetHandlerPlayClient) {
        Minecraft mc = Minecraft.getMinecraft();
        if (!mc.isCallingFromMinecraftThread())
            mc.addScheduledTask(new Runnable() {
                public void run() {
                    handle(netHandler, channel, packet);
                }
            });
        else
            handler.handlePacket(packet, mc, (INetHandlerPlayClient) netHandler);
    } else
        System.err.println("Invalid INetHandler for PacketCustom on channel: " + channel);
}