Jump to content

Recommended Posts

Posted

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)

 

 

Posted

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.

Posted

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)

Posted

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

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.