本文整理汇总了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));
}