@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; } } }
public void displayVillagerTradeGui(IMerchant villager) { this.getNextWindowId(); this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj); this.openContainer.windowId = this.currentWindowId; this.openContainer.onCraftGuiOpened(this); IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory(); IChatComponent ichatcomponent = villager.getDisplayName(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:villager", ichatcomponent, iinventory.getSizeInventory())); MerchantRecipeList merchantrecipelist = villager.getRecipes(this); if (merchantrecipelist != null) { PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(this.currentWindowId); merchantrecipelist.writeToBuf(packetbuffer); this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer)); } }
public void displayVillagerTradeGui(IMerchant villager) { this.getNextWindowId(); this.openContainer = new ContainerMerchant(this.inventory, villager, this.world); this.openContainer.windowId = this.currentWindowId; this.openContainer.addListener(this); IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory(); ITextComponent itextcomponent = villager.getDisplayName(); this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory())); MerchantRecipeList merchantrecipelist = villager.getRecipes(this); if (merchantrecipelist != null) { PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(this.currentWindowId); merchantrecipelist.writeToBuf(packetbuffer); this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer)); } }
@SubscribeEvent public void containerOpen(PlayerContainerEvent.Open event) { if(!event.getEntityPlayer().world.isRemote && event.getContainer() instanceof ContainerMercenary) { IInventory iinventory = ((ContainerMerchant) event.getContainer()).getMerchantInventory(); ITextComponent itextcomponent = ((ContainerMercenary) event.getContainer()).mercenary.getDisplayName(); MerchantRecipeList merchantrecipelist =((ContainerMercenary) event.getContainer()).mercenary.getRecipes(event.getEntityPlayer()); if (merchantrecipelist != null) { PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(event.getContainer().windowId); merchantrecipelist.writeToBuf(packetbuffer); ((EntityPlayerMP)event.getEntityPlayer()).connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer)); } } }
public void displayVillagerTradeGui(IMerchant villager) { this.getNextWindowId(); this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj); this.openContainer.windowId = this.currentWindowId; this.openContainer.addListener(this); net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer)); IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory(); ITextComponent itextcomponent = villager.getDisplayName(); this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory())); MerchantRecipeList merchantrecipelist = villager.getRecipes(this); if (merchantrecipelist != null) { PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(this.currentWindowId); merchantrecipelist.writeToBuf(packetbuffer); this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer)); } }
public void displayGUIMerchant(IMerchant par1IMerchant, String par2Str) { this.getNextWindowId(); this.openContainer = new ContainerMerchant(this.inventory, par1IMerchant, this.worldObj); this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); InventoryMerchant var3 = ((ContainerMerchant)this.openContainer).getMerchantInventory(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 6, par2Str == null ? "" : par2Str, var3.getSizeInventory(), par2Str != null)); MerchantRecipeList var4 = par1IMerchant.getRecipes(this); if (var4 != null) { try { PacketBuffer var5 = new PacketBuffer(Unpooled.buffer()); var5.writeInt(this.currentWindowId); var4.func_151391_a(var5); this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", var5)); } catch (IOException var6) { logger.error("Couldn\'t send trade list", var6); } } }
public void func_71030_a(IMerchant p_71030_1_, String p_71030_2_) { this.func_71117_bO(); this.field_71070_bA = new ContainerMerchant(this.field_71071_by, p_71030_1_, this.field_70170_p); this.field_71070_bA.field_75152_c = this.field_71139_cq; this.field_71070_bA.func_75132_a(this); InventoryMerchant var3 = ((ContainerMerchant)this.field_71070_bA).func_75174_d(); this.field_71135_a.func_72567_b(new Packet100OpenWindow(this.field_71139_cq, 6, p_71030_2_ == null?"":p_71030_2_, var3.func_70302_i_(), p_71030_2_ != null)); MerchantRecipeList var4 = p_71030_1_.func_70934_b(this); if(var4 != null) { try { ByteArrayOutputStream var5 = new ByteArrayOutputStream(); DataOutputStream var6 = new DataOutputStream(var5); var6.writeInt(this.field_71139_cq); var4.func_77200_a(var6); this.field_71135_a.func_72567_b(new Packet250CustomPayload("MC|TrList", var5.toByteArray())); } catch (IOException var7) { var7.printStackTrace(); } } }
protected void func_73875_a(GuiButton p_73875_1_) { boolean var2 = false; if(p_73875_1_ == this.field_74202_p) { ++this.field_74200_r; var2 = true; } else if(p_73875_1_ == this.field_74201_q) { --this.field_74200_r; var2 = true; } if(var2) { ((ContainerMerchant)this.field_74193_d).func_75175_c(this.field_74200_r); ByteArrayOutputStream var3 = new ByteArrayOutputStream(); DataOutputStream var4 = new DataOutputStream(var3); try { var4.writeInt(this.field_74200_r); this.field_73882_e.func_71391_r().func_72552_c(new Packet250CustomPayload("MC|TrSel", var3.toByteArray())); } catch (Exception var6) { var6.printStackTrace(); } } }
public void displayGUIMerchant(IMerchant par1IMerchant, String par2Str) { this.incrementWindowID(); this.openContainer = new ContainerMerchant(this.inventory, par1IMerchant, this.worldObj); this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); InventoryMerchant inventorymerchant = ((ContainerMerchant)this.openContainer).getMerchantInventory(); this.playerNetServerHandler.sendPacketToPlayer(new Packet100OpenWindow(this.currentWindowId, 6, par2Str == null ? "" : par2Str, inventorymerchant.getSizeInventory(), par2Str != null)); MerchantRecipeList merchantrecipelist = par1IMerchant.getRecipes(this); if (merchantrecipelist != null) { try { ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream); dataoutputstream.writeInt(this.currentWindowId); merchantrecipelist.writeRecipiesToStream(dataoutputstream); this.playerNetServerHandler.sendPacketToPlayer(new Packet250CustomPayload("MC|TrList", bytearrayoutputstream.toByteArray())); } catch (IOException ioexception) { ioexception.printStackTrace(); } } }
/** * Fired when a control is clicked. This is the equivalent of * ActionListener.actionPerformed(ActionEvent e). */ @Override protected void actionPerformed(GuiButton par1GuiButton) { boolean flag = false; if (par1GuiButton == this.nextRecipeButtonIndex) { ++this.currentRecipeIndex; flag = true; } else if (par1GuiButton == this.previousRecipeButtonIndex) { --this.currentRecipeIndex; flag = true; } if (flag) { ((ContainerMerchant) this.inventorySlots).setCurrentRecipeIndex(this.currentRecipeIndex); ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream); try { dataoutputstream.writeInt(this.currentRecipeIndex); this.mc.getNetHandler().addToSendQueue(new Packet250CustomPayload("MC|TrSel", bytearrayoutputstream.toByteArray())); } catch (Exception exception) { exception.printStackTrace(); } } }
@SubscribeEvent public static void onContainerOpen(PlayerContainerEvent.Open event) { Container container = event.getContainer(); if(container instanceof ContainerMerchant) { if(!openContainers.containsKey(container)) openContainers.put((ContainerMerchant) container, new ContainerWrapper((ContainerMerchant) container)); } }
@SubscribeEvent public static void onContainerClose(PlayerContainerEvent.Close event) { Container container = event.getContainer(); if(container instanceof ContainerMerchant) { if(openContainers.containsKey(container)) { openContainers.get(container).resetList(); openContainers.remove(container); } } }
/** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) */ protected void actionPerformed(GuiButton button) throws IOException { boolean flag = false; if (button == this.nextButton) { ++this.selectedMerchantRecipe; MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.mc.thePlayer); if (merchantrecipelist != null && this.selectedMerchantRecipe >= merchantrecipelist.size()) { this.selectedMerchantRecipe = merchantrecipelist.size() - 1; } flag = true; } else if (button == this.previousButton) { --this.selectedMerchantRecipe; if (this.selectedMerchantRecipe < 0) { this.selectedMerchantRecipe = 0; } flag = true; } if (flag) { ((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.selectedMerchantRecipe); PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(this.selectedMerchantRecipe); this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|TrSel", packetbuffer)); } }
/** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) */ protected void actionPerformed(GuiButton button) throws IOException { boolean flag = false; if (button == this.nextButton) { ++this.selectedMerchantRecipe; MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.mc.player); if (merchantrecipelist != null && this.selectedMerchantRecipe >= merchantrecipelist.size()) { this.selectedMerchantRecipe = merchantrecipelist.size() - 1; } flag = true; } else if (button == this.previousButton) { --this.selectedMerchantRecipe; if (this.selectedMerchantRecipe < 0) { this.selectedMerchantRecipe = 0; } flag = true; } if (flag) { ((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.selectedMerchantRecipe); PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(this.selectedMerchantRecipe); this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|TrSel", packetbuffer)); } }
/** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) */ protected void actionPerformed(GuiButton button) throws IOException { boolean flag = false; if (button == this.nextButton) { ++this.selectedMerchantRecipe; MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.mc.thePlayer); if (merchantrecipelist != null && this.selectedMerchantRecipe >= merchantrecipelist.size()) { this.selectedMerchantRecipe = merchantrecipelist.size() - 1; } flag = true; } else if (button == this.previousButton) { --this.selectedMerchantRecipe; if (this.selectedMerchantRecipe < 0) { this.selectedMerchantRecipe = 0; } flag = true; } if (flag) { ((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.selectedMerchantRecipe); PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(this.selectedMerchantRecipe); this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|TrSel", packetbuffer)); } }
protected void actionPerformed(GuiButton p_146284_1_) { boolean var2 = false; if (p_146284_1_ == this.field_147043_x) { ++this.field_147041_z; var2 = true; } else if (p_146284_1_ == this.field_147042_y) { --this.field_147041_z; var2 = true; } if (var2) { ((ContainerMerchant)this.field_147002_h).setCurrentRecipeIndex(this.field_147041_z); ByteBuf var3 = Unpooled.buffer(); try { var3.writeInt(this.field_147041_z); this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|TrSel", var3)); } catch (Exception var8) { logger.error("Couldn\'t send trade info", var8); } finally { var3.release(); } } }
public void displayGUIMerchant(IMerchant p_71030_1_, String p_71030_2_) { // CraftBukkit start - Inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerMerchant(this.inventory, p_71030_1_, this.worldObj)); if (container == null) { return; } // CraftBukkit end this.getNextWindowId(); this.openContainer = container; // CraftBukkit - Use container we passed to event this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); InventoryMerchant inventorymerchant = ((ContainerMerchant)this.openContainer).getMerchantInventory(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 6, p_71030_2_ == null ? "" : p_71030_2_, inventorymerchant.getSizeInventory(), p_71030_2_ != null)); MerchantRecipeList merchantrecipelist = p_71030_1_.getRecipes(this); if (merchantrecipelist != null) { PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); try { packetbuffer.writeInt(this.currentWindowId); merchantrecipelist.func_151391_a(packetbuffer); this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer)); } catch (Exception ioexception) // CraftBukkit - IOException -> Exception { logger.error("Couldn\'t send trade list", ioexception); } finally { packetbuffer.release(); } } }
protected void actionPerformed(GuiButton p_146284_1_) { boolean flag = false; if (p_146284_1_ == this.field_147043_x) { ++this.field_147041_z; flag = true; } else if (p_146284_1_ == this.field_147042_y) { --this.field_147041_z; flag = true; } if (flag) { ((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.field_147041_z); ByteBuf bytebuf = Unpooled.buffer(); try { bytebuf.writeInt(this.field_147041_z); this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|TrSel", bytebuf)); } catch (Exception exception) { logger.error("Couldn\'t send trade info", exception); } finally { bytebuf.release(); } } }
public void displayGUIMerchant(IMerchant p_71030_1_, String p_71030_2_) { this.getNextWindowId(); this.openContainer = new ContainerMerchant(this.inventory, p_71030_1_, this.worldObj); this.openContainer.windowId = this.currentWindowId; this.openContainer.addCraftingToCrafters(this); InventoryMerchant inventorymerchant = ((ContainerMerchant)this.openContainer).getMerchantInventory(); this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 6, p_71030_2_ == null ? "" : p_71030_2_, inventorymerchant.getSizeInventory(), p_71030_2_ != null)); MerchantRecipeList merchantrecipelist = p_71030_1_.getRecipes(this); if (merchantrecipelist != null) { PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); try { packetbuffer.writeInt(this.currentWindowId); merchantrecipelist.func_151391_a(packetbuffer); this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer)); } catch (IOException ioexception) { logger.error("Couldn\'t send trade list", ioexception); } finally { packetbuffer.release(); } } }
/** * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e). */ protected void actionPerformed(GuiButton par1GuiButton) { boolean flag = false; if (par1GuiButton == this.nextRecipeButtonIndex) { ++this.currentRecipeIndex; flag = true; } else if (par1GuiButton == this.previousRecipeButtonIndex) { --this.currentRecipeIndex; flag = true; } if (flag) { ((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.currentRecipeIndex); ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream); try { dataoutputstream.writeInt(this.currentRecipeIndex); this.mc.getNetHandler().addToSendQueue(new Packet250CustomPayload("MC|TrSel", bytearrayoutputstream.toByteArray())); } catch (Exception exception) { exception.printStackTrace(); } } }
public GuiPrice(InventoryPlayer par1, IMerchant par2, World par3World) { super(new ContainerMerchant(par1, par2, par3World)); this.theIMerchant = par2; this.field_94082_v = StatCollector.translateToLocal("entity.Price.name"); // this.field_94082_v = par4 != null && par4.length() >= 1 ? par4 : // StatCollector.translateToLocal("entity.Villager.name"); }
public ContainerWrapper(ContainerMerchant container) { this.container = container; this.merchant = getContainerMerchant(container); }
public GuiMerchant(InventoryPlayer p_i45500_1_, IMerchant p_i45500_2_, World worldIn) { super(new ContainerMerchant(p_i45500_1_, p_i45500_2_, worldIn)); this.merchant = p_i45500_2_; this.chatComponent = p_i45500_2_.getDisplayName(); }
public GuiMerchant(InventoryPlayer par1InventoryPlayer, IMerchant par2IMerchant, World par3World, String par4Str) { super(new ContainerMerchant(par1InventoryPlayer, par2IMerchant, par3World)); this.field_147037_w = par2IMerchant; this.field_147040_A = par4Str != null && par4Str.length() >= 1 ? par4Str : I18n.format("entity.Villager.name", new Object[0]); }