當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。