Jump to content

Recommended Posts

Posted

I'm creating a server-side mod that would allow one to use the command /craft and the crafting gui opens.

In old versions (1.12.2) it would be done with this code.

EntityPlayerMP player = someMethod(args)
player.displayGui(new BlockWorkbench.InterfaceCraftingTable(player.world, player.getPosition()));

In 1.18.2, I can cause the crafting gui/menu to open for a brief second with this code.

if (commandContext.getSource().getEntity() instanceof Player) {
		ServerPlayer player = (ServerPlayer)commandContext.getSource().getEntity();
		player.sendMessage(new TextComponent("Opening Crafting table"), player.getUUID());

		CraftingTableBlock craftingTableBlock = new CraftingTableBlock(BlockBehaviour.Properties.of(Material.WOOD).strength(2.5F).sound(SoundType.WOOD));
		player.openMenu(craftingTableBlock.getMenuProvider(craftingTableBlock.defaultBlockState(), player.getLevel(), player.blockPosition()));
		return Command.SINGLE_SUCCESS;
}

How do i stop it from closing? I'm probably calling the wrong methods.

Posted

The crafting table doesn't have an internal inventory.

Instead the server keeps track of whether the block is still valid and returns the crafting inventory to the player when it is not.

Unlike for example the furnace where the items are assigned to its internal inventory.

 

That is why it is closing your screen,.The block does not exist at the position you specified.

See for example:

https://forums.minecraftforge.net/topic/114789-best-way-to-create-a-custom-crafting-table-in-119/?do=findComment&comment=508881

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted (edited)
  Quote

CraftingTableBlock craftingTableBlock = new CraftingTableBlock(BlockBehaviour.Properties.of(Material.WOOD).strength(2.5F).sound(SoundType.WOOD));

Expand  

By the way, it wouldn't suprise if doing things like that causes memory leaks and other issues in modern minecraft versions due to the way "intrinsic holders" work.

You shouldn't be creating objects that are mean to go in registries unless you actually intend to register them.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
  On 1/19/2023 at 11:15 PM, warjort said:

By the way, it wouldn't suprise if doing things like that causes memory leaks and other issues in modern minecraft versions due to the way "intrinsic holders" work.

You shouldn't be creating objects that are mean to go in registries unless you actually intend to register them.

Expand  

Ok, I kinda new that wouldn't be ideal 😥

 

  On 1/19/2023 at 10:57 PM, warjort said:

The crafting table doesn't have an internal inventory.

Instead the server keeps track of whether the block is still valid and returns the crafting inventory to the player when it is not.

Unlike for example the furnace where the items are assigned to its internal inventory.

 

That is why it is closing your screen, The block does not exist at the position you specified.

See for example:

https://forums.minecraftforge.net/topic/114789-best-way-to-create-a-custom-crafting-table-in-119/?do=findComment&comment=508881

Expand  

Thanks so much! I will try and implement that and will get back to you :)

Posted

I have extended the crafting menu

public class VirtualCraftingMenu extends CraftingMenu {

    private final ContainerLevelAccess access;

    public VirtualCraftingMenu(int p_39356_, Inventory p_39357_, ContainerLevelAccess p_39358_) {
        super(p_39356_, p_39357_, p_39358_);
        this.access = p_39358_;
    }

    public VirtualCraftingMenu(int p_39353_, Inventory p_39354_) {
        this(p_39353_, p_39354_, ContainerLevelAccess.NULL);
    }

    // Override to return your menu type that identifies the screen to use
    @Override
    public MenuType<?> getType() {
        return MenuType.CRAFTING;
    }

    // Override to identify the block instance (used to force the user out of the screen if the block is destroyed)
    @Override
    public boolean stillValid(Player p_39368_) {
        //return stillValid(this.access, p_39368_, MY_CRAFTING_BLOCK.get());
    	return true;
    }
}

How would i now open it with player.openMenu() it is asking for a MenuProvider.

Posted

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted

Using this code:

player.openMenu(getMenuProvider(player.level, player.blockPosition()));

public MenuProvider getMenuProvider(Level p_52241_, BlockPos p_52242_) {
		return new SimpleMenuProvider((p_52229_, p_52230_, p_52231_) -> {
		return new VirtualCraftingMenu(p_52229_, p_52230_);
		}, CONTAINER_TITLE);
 }

I get the crafting gui to fully open stay open, but putting items into the crafting gid will not show an output item

Posted

Using:

NetworkHooks.openGui(Splayer, new SimpleMenuProvider(
    				  (containerId, playerInventory, player) -> new VirtualCraftingMenu(containerId, playerInventory),
    				  CONTAINER_TITLE
    				));

to open the menu results in the same problem

Posted

People that only post snippets of code and then say "it doesn't work" will usually just be ignored.

That is unless the bug is trivially obvious from the small amount of code posted.

This is especially if they spent less than 15 minutes trying to debug it for themselves.

You need to put your code on github where we can see all relevant code in context and try it for ourselves if needed.

 

On the trivially obvious:

  Quote

// Override to return your menu type that identifies the screen to use

@Override public MenuType<?> getType() {

return MenuType.CRAFTING;

}

Expand  

That is the vanilla MenuType pointing at the vanilla CraftingMenu, not your overridden menu.

You need your own MenuType that creates your implementation with a screen registered against it

https://docs.minecraftforge.net/en/latest/gui/screens/#registering-an-abstractcontainerscreen

You should be able to reuse the vanilla CraftingScreen for that?

 

I suggest you read the whole of those links I posted above.

And try implementing your own simple test menu and screen from scratch to get a better understanding how the menu system works.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
  On 1/20/2023 at 8:17 PM, warjort said:

People that only post snippets of code and then say "it doesn't work" will usually just be ignored.

That is unless the bug is trivially obvious from the small amount of code posted.

This is especially if they spent less than 15 minutes trying to debug it for themselves.

You need to put your code on github where we can see all relevant code in context and try it for ourselves if needed.

 

On the trivially obvious:

That is the vanilla MenuType pointing at the vanilla CraftingMenu, not your overridden menu.

You need your own MenuType that creates your implementation with a screen registered against it

https://docs.minecraftforge.net/en/latest/gui/screens/#registering-an-abstractcontainerscreen

You should be able to reuse the vanilla CraftingScreen for that?

 

I suggest you read the whole of those links I posted above.

And try implementing your own simple test menu and screen from scratch to get a better understanding how the menu system works.

Expand  

Understood.

Just to clarify, the client doesn't need to be modded?

I just want to have a vanilla client use the crafting gui without a physical table, or mods.

Posted

The vanilla crafting menu needs to be associated with a physical block and that is what will be used in a vanilla client.

Short of major hacks to do something like rewrite the network packets to pretend your menu is the vanilla menu to clients I don't know how you achieve what you are trying to do?

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I should have specified in my last post, the current build is the latest that Ars Nouvaeu supports. Sorry for the trouble!
    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
    • Try other builds: https://www.curseforge.com/minecraft/mc-mods/geckolib/files/all?page=1&pageSize=20&version=1.16.5&gameVersionTypeId=1 Currently, you are using build 96 - the latest one that I linked is build 106 So try 97 to 105  
    • New users at Temu receive a $100 discount on orders over $100 Use the code [aci789589] during checkout to get Temu Coupon Code $100 off For New Users. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. Temu 100% Off coupon code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers $100 off coupon code “aci789589” for first-time users. You can get a$100 bonus plus 30% off any purchase at Temu with the$100 Coupon Bundle at Temu if you sign up with the referral code [aci789589] and make a first purchase of$50 or more. The Temu $100 Off coupon code (aci789589) will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Yes Temu offers $100 Off Coupon Code “aci789589” for First Time Users. Yes, Temu offers $100 off coupon code {aci789589} for first-time users. You can get a $100 bonus plus 100% off any purchase at Temu with the $100 Coupon Bundle if you sign up with the referral code [aci789589] and make a first purchase of $100 or more. If you are who wish to join Temu, then you should use this exclusive Temu coupon code $100 off (aci789589) and get $100 off on your purchase with Temu. You can get a $100 discount with Temu coupon code {aci789589}. This exclusive offer is for existing customers and can be used for a $100 reduction on your total purchase. Enter coupon code {aci789589} at checkout to avail of the discount. You can use the code {aci789589} to get a $100 off Temu coupon as a new customer. Apply this Temu coupon code $100 off (aci789589) to get a $100 discount on your shopping with Temu. If you’re a first-time user and looking for a Temu coupon code $100 first time user(aci789589) then using this code will give you a flat $100 Off and a 90% discount on your Temu shopping. Temu $100% Off Coupon Code "aci789589" will save you $100 on your order. To get a discount, click on the item to purchase and enter the code. Temu coupon code$100off-{aci789589} Temu coupon code -{aci789589} Temu coupon code$50 off-{aci789589} Temu Coupon code [aci789589] for existing users can get up to 50% discount on product during checkout. Temu Coupon Codes for Existing Customers-aci789589 Temu values its loyal customers and offers various promo codes, including the Legit Temu Coupon Code (aci789589]) or (aci789589), which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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