Posted April 3, 20187 yr I added a villager, and when that villager is right clicked it should open a custom gui instead of the villager trading gui. I got as far as using AT to get the IMerchant value and now I know when its the villager I added. But the event is uncancelable and if I open my GUI first then the container of the tradegui will just open after it. Is there a way I can do this? I have already looked into GuiOpenEvent but that way I cannot get the container. If I grab either container variable from the player its a ContainerPlayer which is the inventory. Code: @SubscribeEvent public static void onOpenVillagerGUI(PlayerContainerEvent.Open event){ if(event.getContainer() instanceof ContainerMerchant){ ContainerMerchant merchantContainer = (ContainerMerchant) event.getContainer(); InventoryMerchant merchant = merchantContainer.getMerchantInventory(); if(!(merchant.merchant instanceof EntityVillager)){ return; } EntityVillager villager = (EntityVillager) merchant.merchant; if(villager.getProfessionForge().getRegistryName().toString() .equalsIgnoreCase(ModVillage.OLD_PRIEST_PROFESSION.getRegistryName().toString())){ Minecraft.getMinecraft().player.openGui(Solar.instance, GuiHandler.GUIDE_BOOK_ID_GUI, event.getEntityPlayer().getEntityWorld(), 0, 0, 0); } } } How would I stop the opening, or close it and then open my own GUI?
April 4, 20187 yr I think the gui open event should work. The gui that is passed in can be tested to see if it is a GuiMerchant and if so then you should be able to cast it as GuiMerchant and then get the container since the inventorySlots field is public. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.