当前位置: 首页>>代码示例>>Java>>正文


Java IThreadListener类代码示例

本文整理汇总了Java中net.minecraft.util.IThreadListener的典型用法代码示例。如果您正苦于以下问题:Java IThreadListener类的具体用法?Java IThreadListener怎么用?Java IThreadListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IThreadListener类属于net.minecraft.util包,在下文中一共展示了IThreadListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
@Override
public IMessage onMessage(final PacketClassGui message, final MessageContext ctx) 
{			
	IThreadListener mainThread = Minecraft.getMinecraft();
	mainThread.addScheduledTask(new Runnable()
	{
		@Override
		public void run() 
		{
			EntityPlayer player = Minecraft.getMinecraft().player;
			PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
			
			if (playerInfo != null && playerInfo.getPlayerClass() == 0)
			{
				player.openGui(LootSlashConquer.instance, GuiHandler.CLASS_SELECTION, player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
			}
		}
	});
	
	return null;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:22,代码来源:PacketClassGui.java

示例2: onMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
@Override
public IMessage onMessage(final PacketUpdateChunkLevel message, final MessageContext ctx) 
{			
	IThreadListener mainThread = Minecraft.getMinecraft();
	mainThread.addScheduledTask(new Runnable()
	{
		@Override
		public void run() 
		{
			World world = Minecraft.getMinecraft().world;
			ChunkPos chunkPos = new ChunkPos(message.chunkX, message.chunkZ);
			
			IChunkLevelHolder chunkLevelHolder = CapabilityChunkLevel.getChunkLevelHolder(world);
			
			if (chunkLevelHolder.getChunkLevel(chunkPos) != null) return;
			
			IChunkLevel chunkLevel = new ChunkLevel(world, chunkPos, message.level);
			chunkLevelHolder.setChunkLevel(chunkPos, chunkLevel);
		}
	});
	
	return null;
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:24,代码来源:PacketUpdateChunkLevel.java

示例3: onMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
@Override
public IMessage onMessage(final ConfigSyncMessage message, MessageContext ctx)
{
	IThreadListener threadListener = this.getThreadListener(ctx);
	threadListener.addScheduledTask(new Runnable()
	{

		@Override
		public void run()
		{
			ModConfiguration.enableInventoryGui = message.enableInventoryGui;
			ModConfiguration.enableDeathDrops = message.enableDeathDrops;
			ModConfiguration.requireEmptyHand = message.requireEmptyHand;
		}
	});

	return null;
}
 
开发者ID:crazysnailboy,项目名称:VillagerInventory,代码行数:19,代码来源:ConfigSyncMessage.java

示例4: processMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
/** IMPORTANT: Call this from the onMessage method in the subclass. */
public IMessage processMessage(final ObservationRequestMessage message, final MessageContext ctx)
{
	IThreadListener mainThread = (WorldServer)ctx.getServerHandler().playerEntity.worldObj;
	mainThread.addScheduledTask(new Runnable() {
		@Override
		public void run() {
			EntityPlayerMP player = ctx.getServerHandler().playerEntity;
			JsonObject json = new JsonObject();
			buildJson(json, player, message, ctx);
			// Send this message back again now we've filled in the json stats.
			Map<String, String> returnData = new HashMap<String, String>();
			returnData.put("json", json.toString());
			message.addReturnData(returnData);
			MalmoMod.network.sendTo(new MalmoMod.MalmoMessage(MalmoMessageType.SERVER_OBSERVATIONSREADY, message.id, returnData), player);
		}
	});
	return null; // no response in this case
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:20,代码来源:ObservationFromServer.java

示例5: 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);
            }
        });
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:OpenGuiHandler.java

示例6: 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);
            }
        });
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:EntitySpawnHandler.java

示例7: onMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
@Override
public IMessage onMessage(final MessageLegalMovesResponse message, MessageContext ctx) {

  if (message.legalPositions == null || message.controlBlockPos == null) {
    return null;
  }

  IThreadListener mainThread = Minecraft.getMinecraft();

  mainThread.addScheduledTask(new Runnable() {
    @Override
    public void run() {
      CheckerBoardOverlay.INSTANCE.setValidMoves(message.legalPositions);
    }
  });

  return null;
}
 
开发者ID:ToroCraft,项目名称:ToroChess,代码行数:19,代码来源:MessageLegalMovesResponse.java

示例8: onMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
@Override
public IMessage onMessage(final MessageUpdateControlBlock message, MessageContext ctx) {

  if (message.controlBlockPos == null) {
    return null;
  }

  final IThreadListener mainThread = Minecraft.getMinecraft();
  final EntityPlayerSP player = Minecraft.getMinecraft().player;

  mainThread.addScheduledTask(new Runnable() {
    @Override
    public void run() {
      TileEntityChessControl control = ItemChessControlWand.getChessControlAt(player.world, message.controlBlockPos);
      if (control == null) {
        System.out.println("control block not found");
        return;
      }
      control.readFromNBT(message.data);
    }
  });

  return null;
}
 
开发者ID:ToroCraft,项目名称:ToroChess,代码行数:25,代码来源:MessageUpdateControlBlock.java

示例9: reloadResources

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
public static void reloadResources(@Nonnull final Side side) {
	// Reload can be called on either side so make sure we queue
	// up a scheduled task appropriately.
	if (managers.hasValue(side)) {
		final IThreadListener tl = side == Side.SERVER ? FMLCommonHandler.instance().getMinecraftServerInstance()
				: Minecraft.getMinecraft();
		if (tl == null)
			managers.clear(side);
		else
			tl.addScheduledTask(new Runnable() {
				public void run() {
					managers.get().reload();
				}
			});
	}
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:17,代码来源:RegistryManager.java

示例10: onMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
@Override
public InventoryChangeMessage onMessage(final InventoryMessage message, MessageContext ctx)
{
    final EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    IThreadListener mainThread = (WorldServer)ctx.getServerHandler().playerEntity.world;
    mainThread.addScheduledTask(new Runnable()
    {
        @Override
        public void run()
        {
            ItemStack[] changes = null;
            if (message.combine)
                changes = combineSlots(player, message.invA, message.slotA, message.invB, message.slotB, message.containerPos);
            else
                changes = swapSlots(player, message.invA, message.slotA, message.invB, message.slotB, message.containerPos);
            if (changes != null)
                MalmoMod.network.sendTo(new InventoryChangeMessage(changes[0], changes[1]), player);
        }
    });
    return null;
}
 
开发者ID:Microsoft,项目名称:malmo,代码行数:22,代码来源:InventoryCommandsImplementation.java

示例11: processMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
/** IMPORTANT: Call this from the onMessage method in the subclass. */
public IMessage processMessage(ObservationRequestMessage message, MessageContext ctx)
{
    IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.world;
    final EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    final ObservationRequestMessage mess = message;
    mainThread.addScheduledTask(new Runnable()
    {
        @Override
        public void run()
        {
            JsonObject json = new JsonObject();
            buildJson(json, player, mess);
            // Send this message back again now we've filled in the json stats.
            Map<String, String> returnData = new HashMap<String, String>();
            returnData.put("json", json.toString());
            mess.addReturnData(returnData);
            MalmoMod.network.sendTo(new MalmoMod.MalmoMessage(MalmoMessageType.SERVER_OBSERVATIONSREADY, mess.id, returnData), player);
        }
    });
    return null; // no response in this case
}
 
开发者ID:Microsoft,项目名称:malmo,代码行数:23,代码来源:ObservationFromServer.java

示例12: onMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
@Override
public IMessage onMessage(final RecipeNavigationMessage message, MessageContext ctx)
{
	final EntityPlayerMP player = ctx.getServerHandler().player;

	IThreadListener threadListener = (WorldServer)player.world;
	threadListener.addScheduledTask(new Runnable()
	{
		@Override
		public void run()
		{
			Container container = player.openContainer;
			if (container instanceof ContainerUncraftingTable)
			{
				ContainerUncraftingTable uncraftingContainer = (ContainerUncraftingTable)container;
				uncraftingContainer.uncraftingResult.selectedCraftingGrid = message.recipeIndex;
				uncraftingContainer.switchRecipe();
			}
		}
	});

	return null;
}
 
开发者ID:crazysnailboy,项目名称:UncraftingTable,代码行数:24,代码来源:RecipeNavigationMessage.java

示例13: onMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
@Override
public IMessage onMessage(final ConfigSyncMessage message, MessageContext ctx)
{
	IThreadListener threadListener = getThreadListener(ctx);
	threadListener.addScheduledTask(new Runnable()
	{
		@Override
		public void run()
		{
			ModConfiguration.maxUsedLevel = message.maxUsedLevel;
			ModConfiguration.standardLevel = message.standardLevel;
			ModConfiguration.enchantmentCost = message.enchantmentCost;
			ModConfiguration.uncraftMethod = message.uncraftMethod;
			ModConfiguration.excludedItems = message.excludedItems;
			ModConfiguration.useNuggets = message.useNuggets;
			ModConfiguration.registerNuggets = message.registerNuggets;
			ModConfiguration.useRabbitHide = message.useRabbitHide;
			ModConfiguration.ensureReturn = message.ensureReturn;
		}
	});

	return null;
}
 
开发者ID:crazysnailboy,项目名称:UncraftingTable,代码行数:24,代码来源:ConfigSyncMessage.java

示例14: onMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
@Override
public IMessage onMessage(final StructureTagMessage message, final MessageContext ctx) 
{
	// Or Minecraft.getMinecraft() on the client.
	IThreadListener mainThread = (WorldServer) ctx.getServerHandler().player.world; 

	mainThread.addScheduledTask(new Runnable()
	{
		@Override
		public void run() 
		{
			// This is server side. Build the structure.
			EnumStructureConfiguration structureConfig = message.getStructureConfig();
			
			StructureConfiguration configuration = structureConfig.structureConfig.ReadFromNBTTagCompound(message.getMessageTag());
			configuration.BuildStructure(ctx.getServerHandler().player, ctx.getServerHandler().player.world);
		}
	});

	// no response in this case
	return null;
}
 
开发者ID:Brian-Wuest,项目名称:MC-Prefab,代码行数:23,代码来源:StructureHandler.java

示例15: onMessage

import net.minecraft.util.IThreadListener; //导入依赖的package包/类
@Override
public IMessage onMessage(final PlayerEntityTagMessage message, final MessageContext ctx) 
{
	// Or Minecraft.getMinecraft() on the client.
	IThreadListener mainThread = Minecraft.getMinecraft();

	mainThread.addScheduledTask(new Runnable()
	{
		@Override
		public void run() 
		{
			// This is client side.
			NBTTagCompound newPlayerTag = Minecraft.getMinecraft().player.getEntityData();
			newPlayerTag.setTag(EntityPlayerConfiguration.PLAYER_ENTITY_TAG, message.getMessageTag());
			ClientEventHandler.playerConfig.loadFromNBTTagCompound(message.getMessageTag());
		}
	});

	// no response in this case
	return null;
}
 
开发者ID:Brian-Wuest,项目名称:MC-Prefab,代码行数:22,代码来源:PlayerEntityHandler.java


注:本文中的net.minecraft.util.IThreadListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。