public void openTrade(IMerchant imerchant) { // CraftBukkit start - inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent( this, new ContainerMerchant(this.inventory, imerchant, this.world)); if (container == null) return; // CraftBukkit end this.nextContainerCounter(); this.activeContainer = container; // CraftBukkit - Use container passed to event this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).getMerchantInventory(); this.playerConnection.sendPacket( new Packet100OpenWindow( this.containerCounter, 6, inventorymerchant.getName(), inventorymerchant.getSize())); MerchantRecipeList merchantrecipelist = imerchant.getOffers(this); if (merchantrecipelist != null) { try { ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream); dataoutputstream.writeInt(this.containerCounter); merchantrecipelist.a(dataoutputstream); this.playerConnection.sendPacket( new Packet250CustomPayload("MC|TrList", bytearrayoutputstream.toByteArray())); } catch (IOException ioexception) { ioexception.printStackTrace(); } } }
public void a(IMerchant imerchant, String s0) { this.ct(); this.bM = new ContainerMerchant(this.bK, imerchant, this.q); this.bM.d = this.cu; this.bM.a((ICrafting) this); InventoryMerchant inventorymerchant = ((ContainerMerchant) this.bM).e(); this.a.b( new Packet100OpenWindow( this.cu, 6, s0 == null ? "" : s0, inventorymerchant.j_(), s0 != null)); MerchantRecipeList merchantrecipelist = imerchant.b(this); if (merchantrecipelist != null) { try { ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream); dataoutputstream.writeInt(this.cu); merchantrecipelist.a(dataoutputstream); this.a.b(new Packet250CustomPayload("MC|TrList", bytearrayoutputstream.toByteArray())); } catch (IOException ioexception) { ioexception.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 var3 = ((ContainerMerchant) this.openContainer).getMerchantInventory(); this.playerNetServerHandler.sendPacketToPlayer( new Packet100OpenWindow( this.currentWindowId, 6, par2Str == null ? "" : par2Str, var3.getSizeInventory(), par2Str != null)); MerchantRecipeList var4 = par1IMerchant.getRecipes(this); if (var4 != null) { try { ByteArrayOutputStream var5 = new ByteArrayOutputStream(); DataOutputStream var6 = new DataOutputStream(var5); var6.writeInt(this.currentWindowId); var4.writeRecipiesToStream(var6); this.playerNetServerHandler.sendPacketToPlayer( new Packet250CustomPayload("MC|TrList", var5.toByteArray())); } catch (IOException var7) { var7.printStackTrace(); } } }