Posted April 27, 201411 yr I would like to be able to cancel the crafting event providing certain conditions have been met, however the event is not cancel-able. Am I able to change this, if so how? What else can I do to achieve the same thing, (close the gui before the resources are consumed for example) if so how? Or is this only achievable by reflection/coremodding/ASM (which I am not %100 on what it is)
April 27, 201411 yr Can't you use the ItemCraftedEvent? My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
April 27, 201411 yr Author I just find it hard to believe that is all I could do. How would I go about the coremod method?
April 27, 201411 yr I think it possible to cancel the mouse click when the crafting container is opened for the player. The trickiest part would probably be to compute the mouse screen position and check against the result slot. You can't prevent the recipe from being displayed without removing it entirely, though.
April 27, 201411 yr Author I think it possible to cancel the mouse click when the crafting container is opened for the player. The trickiest part would probably be to compute the mouse screen position and check against the result slot. You can't prevent the recipe from being displayed without removing it entirely, though. Ultimately as long as the player doesn't get a hold of what they crafted I would be happy, if I could delete the item from their cursor then that would ultimately achieve the same thing but I don't know how those objects are treated (or even where to begin to figure it out)
April 29, 201411 yr Author Okay I managed to figure this out @SubscribeEvent public void onPlayerOpenContainer(PlayerOpenContainerEvent event){ //System.out.println("open container :"+event.entityPlayer.openContainer.getClass().toString()); if (event.entityPlayer.openContainer.getClass().toString().equals("class net.minecraft.inventory.ContainerWorkbench")){ //System.out.println(""); System.out.println(event.entityPlayer.openContainer.inventoryItemStacks.get(0)); if (event.entityPlayer.openContainer.inventoryItemStacks.get(0) != null){ event.entityPlayer.displayGUIWorkbench(0, 0, 0); System.out.println("Blocking Crafting"); } //} } it is very messy but I hope someone can learn from this
April 29, 201411 yr Okay I managed to figure this out @SubscribeEvent public void onPlayerOpenContainer(PlayerOpenContainerEvent event){ //System.out.println("open container :"+event.entityPlayer.openContainer.getClass().toString()); if (event.entityPlayer.openContainer.getClass().toString().equals("class net.minecraft.inventory.ContainerWorkbench")){ //System.out.println(""); System.out.println(event.entityPlayer.openContainer.inventoryItemStacks.get(0)); if (event.entityPlayer.openContainer.inventoryItemStacks.get(0) != null){ event.entityPlayer.displayGUIWorkbench(0, 0, 0); System.out.println("Blocking Crafting"); } //} } it is very messy but I hope someone can learn from this event.entityPlayer.openContainer.getClass().toString().equals("class net.minecraft.inventory.ContainerWorkbench") Use container.getClass().equals(ContainerWorkbench.class) instead of this mess. It checks if the class of the instance is the same as the class you've provided event.entityPlayer.displayGUIWorkbench(0, 0, 0); Use event.entityPlayer.closeScreen(); as this is the proper way to close a GUI. Also are you intending on removing the System.out.println's? Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
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.