• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GuiMerchant类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onClientUpdate

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
@SubscribeEvent
public static void onClientUpdate(TickEvent.ClientTickEvent event)
{
    if(event.side == Side.CLIENT && event.phase == TickEvent.Phase.END)
    {
        GuiScreen gui = Minecraft.getMinecraft().currentScreen;
        if (gui instanceof GuiMerchant) {
            //IMerchant merchant = ((GuiMerchant) gui).getMerchant();
            ContainerMerchant container = (ContainerMerchant) ((GuiMerchant) gui).inventorySlots;
            if (container != null && (clientContainer == null || clientContainer.container != container)) {
                clientContainer = new ContainerWrapper(container);
            }
            clientContainer.update();
        }
        else
        {
            clientContainer = null;
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:21,代码来源:VillagerAntimonyHandler.java


示例2: guiPostInit

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
@SubscribeEvent
public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) {
	if (Minecraft.getMinecraft().player != null) {
		if ((event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiContainerCreative || event.getGui() instanceof GuiWearables)
				&& !Minecraft.getMinecraft().player.getCapability(TF2weapons.INVENTORY_CAP, null).isEmpty()) {
			// GuiContainer gui = (GuiContainer) event.getGui();
			event.getButtonList().add(new GuiButton(97535627, event.getGui().width / 2 - 10, event.getGui().height / 2 + 95, 20, 20, "W"));
		}

		if (event.getGui() instanceof GuiMerchant)
			if (((GuiMerchant) event.getGui()).getMerchant().getDisplayName().getUnformattedText().equals(I18n.format("entity.hale.name"))) {
				event.getButtonList().add(new GuiButton(7578, event.getGui().width / 2 - 100, event.getGui().height / 2 - 110, 100, 20, "Change Team"));
				event.getButtonList().add(new GuiButton(7579, event.getGui().width / 2, event.getGui().height / 2 - 110, 100, 20, "Recover Lost Items"));
			}
		Minecraft.getMinecraft().player.getCapability(TF2weapons.WEAPONS_CAP, null).state &= 8;
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:18,代码来源:TF2EventsClient.java


示例3: guiPostAction

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
@SubscribeEvent
public void guiPostAction(GuiScreenEvent.ActionPerformedEvent.Post event) {

	if (event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiContainerCreative)
		if (event.getButton().id == 97535627) {
			// Minecraft.getMinecraft().displayGuiScreen(null);
			TF2weapons.network.sendToServer(new TF2Message.ShowGuiMessage(0));
		}

	if (event.getGui() instanceof GuiWearables)
		if (event.getButton().id == 97535627) {
			event.getGui().mc.displayGuiScreen(new GuiInventory(event.getGui().mc.player));
		}
	// PacketHandler.INSTANCE.sendToServer(new
	// PacketOpenNormalInventory(event.getGui().mc.player));
	if (event.getGui() instanceof GuiMerchant && event.getButton().id == 7578) {
		ClientProxy.displayScreenJoinTeam();
	}
	else if (event.getGui() instanceof GuiMerchant && event.getButton().id == 7579) {
		TF2weapons.network.sendToServer(new TF2Message.ActionMessage(18));
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:23,代码来源:TF2EventsClient.java


示例4: func_72501_a

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void func_72501_a(Packet250CustomPayload p_72501_1_) {
   if("MC|TrList".equals(p_72501_1_.field_73630_a)) {
      DataInputStream var2 = new DataInputStream(new ByteArrayInputStream(p_72501_1_.field_73629_c));

      try {
         int var3 = var2.readInt();
         GuiScreen var4 = this.field_72563_h.field_71462_r;
         if(var4 != null && var4 instanceof GuiMerchant && var3 == this.field_72563_h.field_71439_g.field_71070_bA.field_75152_c) {
            IMerchant var5 = ((GuiMerchant)var4).func_74199_h();
            MerchantRecipeList var6 = MerchantRecipeList.func_77204_a(var2);
            var5.func_70930_a(var6);
         }
      } catch (IOException var7) {
         var7.printStackTrace();
      }
   } else if("MC|Brand".equals(p_72501_1_.field_73630_a)) {
      this.field_72563_h.field_71439_g.func_142020_c(new String(p_72501_1_.field_73629_c, Charsets.UTF_8));
   }

}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:21,代码来源:NetClientHandler.java


示例5: func_73737_a

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void func_73737_a(Minecraft p_73737_1_, int p_73737_2_, int p_73737_3_) {
   if(this.field_73748_h) {
      p_73737_1_.func_110434_K().func_110577_a(GuiMerchant.func_110417_h());
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      boolean var4 = p_73737_2_ >= this.field_73746_c && p_73737_3_ >= this.field_73743_d && p_73737_2_ < this.field_73746_c + this.field_73747_a && p_73737_3_ < this.field_73743_d + this.field_73745_b;
      int var5 = 0;
      int var6 = 176;
      if(!this.field_73742_g) {
         var6 += this.field_73747_a * 2;
      } else if(var4) {
         var6 += this.field_73747_a;
      }

      if(!this.field_73749_j) {
         var5 += this.field_73745_b;
      }

      this.func_73729_b(this.field_73746_c, this.field_73743_d, var6, var5, this.field_73747_a, this.field_73745_b);
   }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:21,代码来源:GuiButtonMerchant.java


示例6: handleCustomPayload

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
/**
 * Handles packets that have room for a channel specification. Vanilla
 * implemented channels are "MC|TrList" to acquire a MerchantRecipeList trades
 * for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate
 * the identifier of the default server resourcepack for the client to load.
 */
public void handleCustomPayload(S3FPacketCustomPayload packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

	if ("MC|TrList".equals(packetIn.getChannelName())) {
		PacketBuffer packetbuffer = packetIn.getBufferData();

		try {
			int i = packetbuffer.readInt();
			GuiScreen guiscreen = this.gameController.currentScreen;

			if (guiscreen != null && guiscreen instanceof GuiMerchant
					&& i == this.gameController.thePlayer.openContainer.windowId) {
				IMerchant imerchant = ((GuiMerchant) guiscreen).getMerchant();
				MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
				imerchant.setRecipes(merchantrecipelist);
			}
		} catch (IOException ioexception) {
			logger.error((String) "Couldn\'t load trade info", (Throwable) ioexception);
		} finally {
			packetbuffer.release();
		}
	} else if ("MC|Brand".equals(packetIn.getChannelName())) {
		this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
	} else if ("MC|BOpen".equals(packetIn.getChannelName())) {
		ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();

		if (itemstack != null && itemstack.getItem() == Items.written_book) {
			this.gameController
					.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
		}
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:40,代码来源:NetHandlerPlayClient.java


示例7: tryMoveItemsVillager

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public static boolean tryMoveItemsVillager(GuiMerchant gui, Slot slot, boolean moveToOtherInventory, boolean isShiftDown)
{
    if (isShiftDown)
    {
        // Try to fill the merchant's buy slots from the player inventory
        if (moveToOtherInventory == false)
        {
            tryMoveItemsToMerchantBuySlots(gui, true);
        }
        // Move items from sell slot to player inventory
        else if (slot.getHasStack())
        {
            tryMoveStacks(slot, gui, true, true, true);
        }
        // Scrolling over an empty output slot, clear the buy slots
        else
        {
            tryMoveStacks(slot, gui, false, true, false);
        }
    }
    else
    {
        // Scrolling items from player inventory into merchant buy slots
        if (moveToOtherInventory == false)
        {
            tryMoveItemsToMerchantBuySlots(gui, false);
        }
        // Scrolling items from this slot/inventory into the other inventory
        else if (slot.getHasStack())
        {
            moveOneSetOfItemsFromSlotToOtherInventory(gui, slot);
        }
    }

    return false;
}
 
开发者ID:maruohon,项目名称:itemscroller,代码行数:37,代码来源:InventoryUtils.java


示例8: tryMoveItemsToMerchantBuySlots

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
private static void tryMoveItemsToMerchantBuySlots(GuiMerchant gui, boolean fillStacks)
{
    MerchantRecipeList list = gui.getMerchant().getRecipes(gui.mc.player);
    int index = 0;

    try
    {
        index = fieldSelectedMerchantRecipe.getInt(gui);
    }
    catch (IllegalAccessException e)
    {
        ItemScroller.logger.warn("Failed to get the value of GuiMerchant.selectedMerchantRecipe");
    }

    if (list == null || list.size() <= index)
    {
        return;
    }

    MerchantRecipe recipe = list.get(index);
    if (recipe == null)
    {
        return;
    }

    ItemStack buy1 = recipe.getItemToBuy();
    ItemStack buy2 = recipe.getSecondItemToBuy();

    if (isStackEmpty(buy1) == false)
    {
        fillBuySlot(gui, 0, buy1, fillStacks);
    }

    if (isStackEmpty(buy2) == false)
    {
        fillBuySlot(gui, 1, buy2, fillStacks);
    }
}
 
开发者ID:maruohon,项目名称:itemscroller,代码行数:39,代码来源:InventoryUtils.java


示例9: npcTradeOpen

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
@SubscribeEvent
public void npcTradeOpen(GuiOpenEvent event){
	if(event.getGui() instanceof GuiMerchant){
		if(((GuiMerchant) event.getGui()).getMerchant() instanceof NPCShop){
			lastOpened = (NPCShop) ((GuiMerchant) event.getGui()).getMerchant();
		}else{
			Minecraft mc = Minecraft.getMinecraft();
			event.setGui(new GuiNPCMerchant(mc.player.inventory, lastOpened, mc.world));
		}
	}
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:12,代码来源:ClientProxy.java


示例10: handleVanilla250Packet

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void handleVanilla250Packet(Packet250CustomPayload par1Packet250CustomPayload)
{
    if ("MC|TrList".equals(par1Packet250CustomPayload.channel))
    {
        DataInputStream datainputstream = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data));

        try
        {
            int i = datainputstream.readInt();
            GuiScreen guiscreen = this.mc.currentScreen;

            if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.mc.thePlayer.openContainer.windowId)
            {
                IMerchant imerchant = ((GuiMerchant)guiscreen).getIMerchant();
                MerchantRecipeList merchantrecipelist = MerchantRecipeList.readRecipiesFromStream(datainputstream);
                imerchant.setRecipes(merchantrecipelist);
            }
        }
        catch (IOException ioexception)
        {
            ioexception.printStackTrace();
        }
    }
    else if ("MC|Brand".equals(par1Packet250CustomPayload.channel))
    {
        this.mc.thePlayer.func_142020_c(new String(par1Packet250CustomPayload.data, Charsets.UTF_8));
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:29,代码来源:NetClientHandler.java


示例11: drawButton

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
/**
 * Draws this button to the screen.
 */
@Override
public void drawButton(Minecraft mc, int xCursor, int yCursor, float tick)
{
	if(this.visible)
	{
		mc.getTextureManager().bindTexture(GuiMerchant.MERCHANT_GUI_TEXTURE);

		GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
		GL11.glColor4f(1F, 1F, 1F, 1F);

		boolean flag = (xCursor >= this.x) && (yCursor >= this.y) && (xCursor < this.x + this.width) && (yCursor < this.y + this.height);
		int yTexturePos = 0;
		int xTexturePos = 176;

		if(!this.enabled)
		{
			xTexturePos += this.width * 2;
		}
		else if(flag)
		{
			xTexturePos += this.width;
		}

		if(!this.isNextButton)
		{
			yTexturePos += this.height;
		}

		this.drawTexturedModalRect(this.x, this.y, xTexturePos, yTexturePos, this.width, this.height);

		GL11.glPopAttrib();
	}
}
 
开发者ID:a1lic,项目名称:McMod-CubicVillager,代码行数:37,代码来源:MerchantButton.java


示例12: displayVillagerTradeGui

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
    this.mc.displayGuiScreen(new GuiMerchant(this.inventory, villager, this.worldObj));
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:5,代码来源:EntityPlayerSP.java


示例13: handleCustomPayload

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
public void handleCustomPayload(S3FPacketCustomPayload packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if ("MC|TrList".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer = packetIn.getBufferData();

        try
        {
            int i = packetbuffer.readInt();
            GuiScreen guiscreen = this.gameController.currentScreen;

            if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
            {
                IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
                MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
                imerchant.setRecipes(merchantrecipelist);
            }
        }
        catch (IOException ioexception)
        {
            logger.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
        }
        finally
        {
            packetbuffer.release();
        }
    }
    else if ("MC|Brand".equals(packetIn.getChannelName()))
    {
        this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
    }
    else if ("MC|BOpen".equals(packetIn.getChannelName()))
    {
        ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();

        if (itemstack != null && itemstack.getItem() == Items.written_book)
        {
            this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:50,代码来源:NetHandlerPlayClient.java


示例14: displayVillagerTradeGui

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager) {
	this.mc.displayGuiScreen(new GuiMerchant(this.inventory, villager, this.worldObj));
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:4,代码来源:EntityPlayerSP.java


示例15: displayVillagerTradeGui

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
    this.mc.displayGuiScreen(new GuiMerchant(this.inventory, villager, this.world));
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:5,代码来源:EntityPlayerSP.java


示例16: handleCustomPayload

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
public void handleCustomPayload(SPacketCustomPayload packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if ("MC|TrList".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer = packetIn.getBufferData();

        try
        {
            int i = packetbuffer.readInt();
            GuiScreen guiscreen = this.gameController.currentScreen;

            if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.player.openContainer.windowId)
            {
                IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
                MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
                imerchant.setRecipes(merchantrecipelist);
            }
        }
        catch (IOException ioexception)
        {
            LOGGER.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
        }
        finally
        {
            packetbuffer.release();
        }
    }
    else if ("MC|Brand".equals(packetIn.getChannelName()))
    {
        this.gameController.player.setServerBrand(packetIn.getBufferData().readStringFromBuffer(32767));
    }
    else if ("MC|BOpen".equals(packetIn.getChannelName()))
    {
        EnumHand enumhand = (EnumHand)packetIn.getBufferData().readEnumValue(EnumHand.class);
        ItemStack itemstack = enumhand == EnumHand.OFF_HAND ? this.gameController.player.getHeldItemOffhand() : this.gameController.player.getHeldItemMainhand();

        if (itemstack.getItem() == Items.WRITTEN_BOOK)
        {
            this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.player, itemstack, false));
        }
    }
    else if ("MC|DebugPath".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer1 = packetIn.getBufferData();
        int j = packetbuffer1.readInt();
        float f = packetbuffer1.readFloat();
        Path path = Path.read(packetbuffer1);
        ((DebugRendererPathfinding)this.gameController.debugRenderer.debugRendererPathfinding).addPath(j, path, f);
    }
    else if ("MC|StopSound".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer2 = packetIn.getBufferData();
        String s = packetbuffer2.readStringFromBuffer(32767);
        String s1 = packetbuffer2.readStringFromBuffer(256);
        this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s));
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:66,代码来源:NetHandlerPlayClient.java


示例17: handleCustomPayload

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
public void handleCustomPayload(SPacketCustomPayload packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if ("MC|TrList".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer = packetIn.getBufferData();

        try
        {
            int i = packetbuffer.readInt();
            GuiScreen guiscreen = this.gameController.currentScreen;

            if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.player.openContainer.windowId)
            {
                IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
                MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
                imerchant.setRecipes(merchantrecipelist);
            }
        }
        catch (IOException ioexception)
        {
            LOGGER.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
        }
        finally
        {
            packetbuffer.release();
        }
    }
    else if ("MC|Brand".equals(packetIn.getChannelName()))
    {
        this.gameController.player.setServerBrand(packetIn.getBufferData().readStringFromBuffer(32767));
    }
    else if ("MC|BOpen".equals(packetIn.getChannelName()))
    {
        EnumHand enumhand = (EnumHand)packetIn.getBufferData().readEnumValue(EnumHand.class);
        ItemStack itemstack = enumhand == EnumHand.OFF_HAND ? this.gameController.player.getHeldItemOffhand() : this.gameController.player.getHeldItemMainhand();

        if (itemstack.getItem() == Items.WRITTEN_BOOK)
        {
            this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.player, itemstack, false));
        }
    }
    else if ("MC|DebugPath".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer1 = packetIn.getBufferData();
        int j = packetbuffer1.readInt();
        float f = packetbuffer1.readFloat();
        Path path = Path.read(packetbuffer1);
        ((DebugRendererPathfinding)this.gameController.debugRenderer.debugRendererPathfinding).addPath(j, path, f);
    }
    else if ("MC|DebugNeighborsUpdate".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer2 = packetIn.getBufferData();
        long k = packetbuffer2.readVarLong();
        BlockPos blockpos = packetbuffer2.readBlockPos();
        ((DebugRendererNeighborsUpdate)this.gameController.debugRenderer.field_191557_f).func_191553_a(k, blockpos);
    }
    else if ("MC|StopSound".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer3 = packetIn.getBufferData();
        String s = packetbuffer3.readStringFromBuffer(32767);
        String s1 = packetbuffer3.readStringFromBuffer(256);
        this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:73,代码来源:NetHandlerPlayClient.java


示例18: handleCustomPayload

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
public void handleCustomPayload(SPacketCustomPayload packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if ("MC|TrList".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer = packetIn.getBufferData();

        try
        {
            int i = packetbuffer.readInt();
            GuiScreen guiscreen = this.gameController.currentScreen;

            if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
            {
                IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
                MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
                imerchant.setRecipes(merchantrecipelist);
            }
        }
        catch (IOException ioexception)
        {
            LOGGER.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
        }
        finally
        {
            packetbuffer.release();
        }
    }
    else if ("MC|Brand".equals(packetIn.getChannelName()))
    {
        this.gameController.thePlayer.setServerBrand(packetIn.getBufferData().readStringFromBuffer(32767));
    }
    else if ("MC|BOpen".equals(packetIn.getChannelName()))
    {
        EnumHand enumhand = (EnumHand)packetIn.getBufferData().readEnumValue(EnumHand.class);
        ItemStack itemstack = enumhand == EnumHand.OFF_HAND ? this.gameController.thePlayer.getHeldItemOffhand() : this.gameController.thePlayer.getHeldItemMainhand();

        if (itemstack != null && itemstack.getItem() == Items.WRITTEN_BOOK)
        {
            this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
        }
    }
    else if ("MC|DebugPath".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer1 = packetIn.getBufferData();
        int j = packetbuffer1.readInt();
        float f = packetbuffer1.readFloat();
        Path path = Path.read(packetbuffer1);
        ((DebugRendererPathfinding)this.gameController.debugRenderer.debugRendererPathfinding).addPath(j, path, f);
    }
    else if ("MC|StopSound".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer2 = packetIn.getBufferData();
        String s = packetbuffer2.readStringFromBuffer(32767);
        String s1 = packetbuffer2.readStringFromBuffer(256);
        this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:66,代码来源:NetHandlerPlayClient.java


示例19: displayGUIMerchant

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
public void displayGUIMerchant(IMerchant par1IMerchant, String par2Str)
{
    this.mc.displayGuiScreen(new GuiMerchant(this.inventory, par1IMerchant, this.worldObj, par2Str));
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:5,代码来源:EntityPlayerSP.java


示例20: handleCustomPayload

import net.minecraft.client.gui.GuiMerchant; //导入依赖的package包/类
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
public void handleCustomPayload(S3FPacketCustomPayload p_147240_1_)
{
    if ("MC|TrList".equals(p_147240_1_.func_149169_c()))
    {
        ByteBuf var2 = Unpooled.wrappedBuffer(p_147240_1_.func_149168_d());

        try
        {
            int var3 = var2.readInt();
            GuiScreen var4 = this.gameController.currentScreen;

            if (var4 != null && var4 instanceof GuiMerchant && var3 == this.gameController.thePlayer.openContainer.windowId)
            {
                IMerchant var5 = ((GuiMerchant)var4).func_147035_g();
                MerchantRecipeList var6 = MerchantRecipeList.func_151390_b(new PacketBuffer(var2));
                var5.setRecipes(var6);
            }
        }
        catch (IOException var7)
        {
            logger.error("Couldn\'t load trade info", var7);
        }
    }
    else if ("MC|Brand".equals(p_147240_1_.func_149169_c()))
    {
        this.gameController.thePlayer.func_142020_c(new String(p_147240_1_.func_149168_d(), Charsets.UTF_8));
    }
    else if ("MC|RPack".equals(p_147240_1_.func_149169_c()))
    {
        final String var8 = new String(p_147240_1_.func_149168_d(), Charsets.UTF_8);

        if (this.gameController.gameSettings.serverTextures)
        {
            if (this.gameController.func_147104_D() != null && this.gameController.func_147104_D().func_147408_b())
            {
                this.gameController.getResourcePackRepository().func_148526_a(var8);
            }
            else if (this.gameController.func_147104_D() == null || this.gameController.func_147104_D().func_147410_c())
            {
                this.gameController.displayGuiScreen(new GuiYesNo(new GuiScreen()
                {
                    private static final String __OBFID = "CL_00000879";
                    public void confirmClicked(boolean par1, int par2)
                    {
                        this.mc = Minecraft.getMinecraft();

                        if (this.mc.func_147104_D() != null)
                        {
                            this.mc.func_147104_D().setAcceptsTextures(par1);
                            ServerList.func_147414_b(this.mc.func_147104_D());
                        }

                        if (par1)
                        {
                            this.mc.getResourcePackRepository().func_148526_a(var8);
                        }

                        this.mc.displayGuiScreen((GuiScreen)null);
                    }
                }, I18n.format("multiplayer.texturePrompt.line1", new Object[0]), I18n.format("multiplayer.texturePrompt.line2", new Object[0]), 0));
            }
        }
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:71,代码来源:NetHandlerPlayClient.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ImagingOpException类代码示例发布时间:2022-05-21
下一篇:
Java ResourcesMgr类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap