本文整理匯總了Java中net.minecraft.util.IThreadListener.isCallingFromMinecraftThread方法的典型用法代碼示例。如果您正苦於以下問題:Java IThreadListener.isCallingFromMinecraftThread方法的具體用法?Java IThreadListener.isCallingFromMinecraftThread怎麽用?Java IThreadListener.isCallingFromMinecraftThread使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.IThreadListener
的用法示例。
在下文中一共展示了IThreadListener.isCallingFromMinecraftThread方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: channelRead0
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, final OpenGui msg) throws Exception
{
IThreadListener thread = FMLCommonHandler.instance().getWorldThread(ctx.channel().attr(NetworkRegistry.NET_HANDLER).get());
if (thread.isCallingFromMinecraftThread())
{
process(msg);
}
else
{
thread.addScheduledTask(new Runnable()
{
public void run()
{
OpenGuiHandler.this.process(msg);
}
});
}
}
示例2: channelRead0
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, final EntityMessage msg) throws Exception
{
IThreadListener thread = FMLCommonHandler.instance().getWorldThread(ctx.channel().attr(NetworkRegistry.NET_HANDLER).get());
if (thread.isCallingFromMinecraftThread())
{
process(msg);
}
else
{
thread.addScheduledTask(new Runnable()
{
public void run()
{
EntitySpawnHandler.this.process(msg);
}
});
}
}
示例3: onMessage
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
@Override
@Nullable
public IMessage onMessage(final T message, final MessageContext context) {
final IThreadListener thread = FMLCommonHandler.instance().getWorldThread(context.netHandler);
if (thread.isCallingFromMinecraftThread()) {
onMessageSynchronized(message, context);
} else {
thread.addScheduledTask(() -> onMessageSynchronized(message, context));
}
return null;
}
示例4: checkThreadAndEnqueue
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
public static <T extends INetHandler> void checkThreadAndEnqueue(final Packet<T> p_180031_0_, final T p_180031_1_, IThreadListener p_180031_2_) throws ThreadQuickExitException
{
if (!p_180031_2_.isCallingFromMinecraftThread())
{
p_180031_2_.addScheduledTask(new Runnable()
{
public void run()
{
p_180031_0_.processPacket(p_180031_1_);
}
});
throw ThreadQuickExitException.field_179886_a;
}
}
示例5: HandleDataMismatch
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
private void HandleDataMismatch(OpenGuiWrapper msg, RemoteGuiPlayerData data, EntityPlayerMP player, ChannelHandlerContext ctx)
{
// sometimes multiblocks trigger UI from another position!
// time to re-issue with the correct information
// however we could be on the networking thread!
IThreadListener scheduler = FMLCommonHandler.instance().getWorldThread(ctx.channel().attr(NetworkRegistry.NET_HANDLER).get());
if (!scheduler.isCallingFromMinecraftThread())
{
Util.logger.warn("HandleDataMismatch scheduling PrepareReissueRequest!");
scheduler.addScheduledTask(new Runnable()
{
@Override
public void run()
{
PrepareReissueRequest(msg, data, player);
}
});
} else {
PrepareReissueRequest(msg, data, player);
}
}
示例6: checkThreadAndEnqueue
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
public static <T extends IMessage> boolean checkThreadAndEnqueue(final T message, final IMessageHandler<T, IMessage> handler, final MessageContext ctx, IThreadListener listener)
{
if (!listener.isCallingFromMinecraftThread())
{
listener.addScheduledTask(() -> handler.onMessage(message, ctx));
return true;
}
return false;
}
示例7: checkThreadAndEnqueue
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
public static <T extends INetHandler> void checkThreadAndEnqueue(final Packet<T> packetIn, final T processor, IThreadListener scheduler) throws ThreadQuickExitException
{
if (!scheduler.isCallingFromMinecraftThread())
{
scheduler.addScheduledTask(new Runnable()
{
public void run()
{
packetIn.processPacket(processor);
}
});
throw ThreadQuickExitException.INSTANCE;
}
}
示例8: checkThreadAndEnqueue
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
/**
* 1.8 ONLY: Ensures that the message is being handled on the main thread
*/
private static final <T extends AbstractMessage<T>> void checkThreadAndEnqueue (final AbstractMessage<T> msg, final MessageContext ctx) {
IThreadListener thread = KingdomKeys.proxy.getThreadFromContext(ctx);
if (!thread.isCallingFromMinecraftThread()) thread.addScheduledTask(new Runnable() {
@Override
public void run () {
msg.process(KingdomKeys.proxy.getPlayerEntity(ctx), ctx.side);
}
});
}
示例9: checkThreadAndEnqueue
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
/**
* 1.8 ONLY: Ensures that the message is being handled on the main thread
*/
private static final <T extends AbstractMessage<T>> void checkThreadAndEnqueue(final AbstractMessage<T> msg, final MessageContext ctx) {
IThreadListener thread = Skillz.proxy.getThreadFromContext(ctx);
// pretty much copied straight from vanilla code, see {@link PacketThreadUtil#checkThreadAndEnqueue}
if (!thread.isCallingFromMinecraftThread()) {
thread.addScheduledTask(new Runnable() {
public void run() {
msg.process(Skillz.proxy.getPlayerEntity(ctx), ctx.side);
}
});
}
}
示例10: executeSynchronized
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
public static void executeSynchronized(ChannelHandlerContext ctx, Runnable runnable) {
final IThreadListener thread = FMLCommonHandler.instance().getWorldThread(ctx.channel().attr(NetworkRegistry.NET_HANDLER).get());
if (!thread.isCallingFromMinecraftThread()) {
thread.addScheduledTask(runnable);
} else {
runnable.run();
}
}
示例11: onClientDisconnect
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
@SubscribeEvent
public void onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event)
{
IThreadListener thread = Minecraft.getMinecraft();
if(thread.isCallingFromMinecraftThread())
{
onClientDisconnect();
}
else
{
thread.addScheduledTask(this::onClientDisconnect);
}
}
示例12: channelRead0
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
@Override
protected void channelRead0(final ChannelHandlerContext ctx, final REQ msg) throws Exception
{
EntityPlayer player;
if(side.isServer())
{
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
player = ((NetHandlerPlayServer)netHandler).player;
}
else
{
player = this.getClientPlayer();
}
if(!msg.requiresMainThread())
{
executeMessage(msg, player, side, ctx);
}
else
{
IThreadListener thread = FMLCommonHandler.instance().getWorldThread(ctx.channel().attr(NetworkRegistry.NET_HANDLER).get());
if(thread.isCallingFromMinecraftThread())
{
executeMessage(msg, player, side, ctx);
}
else
{
thread.addScheduledTask(() -> executeMessage(msg, player, side, ctx));
}
}
}
示例13: checkThreadAndEnqueue
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
/**
* 1.8 ONLY: Ensures that the message is being handled on the main thread
*/
private static <T extends AbstractMessage<T>> void checkThreadAndEnqueue (final AbstractMessage<T> msg, final MessageContext ctx) {
IThreadListener thread = Bonfires.proxy.getThreadFromContext(ctx);
if (!thread.isCallingFromMinecraftThread()) thread.addScheduledTask(() -> msg.process(Bonfires.proxy.getPlayerEntity(ctx), ctx.side));
}
示例14: checkThreadAndEnqueue
import net.minecraft.util.IThreadListener; //導入方法依賴的package包/類
/**
* Ensures that the message is being handled on the main thread
*/
private static final <T extends AbstractMessage<T>> void checkThreadAndEnqueue(final AbstractMessage<T> msg, final MessageContext ctx) {
IThreadListener thread = AbyssalCraft.proxy.getThreadFromContext(ctx);
if (!thread.isCallingFromMinecraftThread())
thread.addScheduledTask(() -> msg.process(AbyssalCraft.proxy.getPlayerEntity(ctx), ctx.side));
}