Jump to content

1.11.2 Custom Crafting Table


Socratic_Phoenix

Recommended Posts

Okay, this should be fairly simple, but the research I've done so far hasn't been hugely helpful, and I see some things that say "always use this class" and then some tutorials implement other classes, so I'm not exactly sure what convention is here. I'm new-ish to forge modding as well, and this is my first project were I do anything more than generate a few ores (in this mod, I'll generate about 16 million of them). In short, I need to create a crafting table. Nothing fancy, in fact, it shouldn't be different than vanilla, other than gui name and block texture (and, of course, my custom recipes). I know that once I get the block actually in the world, with a gui and inventory, I can implement the recipe mechanic, so I'm going to focus on the first thing first.

 

So, my question is, how do I crafting table?

 

Does it need to be a TileEntity? If so, what kind? Just TileEntity? TileEntityLockable?

How do I provide the container (or gui screen or whatever it is)? I have an empty gui hander, but that's about it. (Also, what is the difference between Container and GuiScreen, how do they relate?)

How do I make the inventory work? How do I position the slots properly on the inventory when it's drawn (How does one even draw an inventory)?

How do I change set the title of the inventory ("Crafting Table" is vanilla, I want "Craftinium Table").

How do I open this inventory when the block is clicked?

How do I listen to the events from the inventory to check if the player has done recipe stuff?

Exactly what classes do I actually have to extend?

What. in. the. world. is. a. capability. (and how do I use it?) (Forge docs provided some context, but not much).

 

I understand that a lot of these questions could be answered with tutorials, but so far, I haven't found a single tut using capabilities, despite those being explicitly suggested in many of the forum topics I found, so I'm not sure what a "proper" implementation would look like. There's also the fact that I have no idea where I should start...

 

Thanks for any replies!

 

(I am using 1.11.2, Forge build #2228)

 

(For anyone who wants it, this is the github link to the package I'm putting all this code in, but at the moment there isn't anything for the table there yet...)

 

(Also, thanks for all the help I've received from the community so far! Very helpful! (also, also, I'm a forge noob, not a java noob, use whatever java lingo you deem necessary, but don't mention the evil that is bytecode instrumentation (which, side note, is surprisingly not difficult)))

Edited by Socratic_Phoenix

Developer of Randores (adds 256^3 ores to the game) and Arcane Bags (adds ridiculous storage with ridiculous crafting recipes).

I know Java pretty well... So yeah...

Quote

This is where I'd put an inspirational and/or clever quote, but I can't think of one right now...

This is the output of the totally, 100% working compiler for my programming language, Planet9:

Beginning Compilation...
Failed compilation!
planet9.compiler.error.CompilationException: Compiler not yet implemented
	at planet9.compiler.Compiler.compile(Compiler.java:39)
	at planet9.compiler.app.CompilerApp.main(CompilerApp.java:147)

 

Link to comment
Share on other sites

1 minute ago, Socratic_Phoenix said:

Does it need to be a TileEntity? If so, what kind? Just TileEntity? TileEntityLockable?

No it does not need a TileEntity. You only need a TileEntity if you want to save the slots.

2 minutes ago, Socratic_Phoenix said:

How do I provide the container (or gui screen or whatever it is)? I have an empty gui hander, but that's about it. (Also, what is the difference between Container and GuiScreen, how do they relate?)

You return a Container in getServerGuiElement and a Gui in getClientGuiElement. The container is the Server sided object of a Gui and the Gui is the Client sided one GuiScreen extends Gui.

3 minutes ago, Socratic_Phoenix said:

How do I make the inventory work? How do I position the slots properly on the inventory when it's drawn (How does one even draw an inventory)?

You add slots to it. When you add the Slots to the Container it will have it's position automatically made relative to the Gui and it will be measured in pixels. You use the Gui methods drawTexturedModelRect... to draw images on to the screen.

5 minutes ago, Socratic_Phoenix said:

How do I change set the title of the inventory ("Crafting Table" is vanilla, I want "Craftinium Table").

You should draw that using Minecraft#fontRenderer or this.fontRenderer in your Gui in the method drawGuiContainerForeground, and you should be using GuiContainer as your super class for your Gui.

6 minutes ago, Socratic_Phoenix said:

How do I open this inventory when the block is clicked?

Use EntityPlayer#openGui in Block#onBlockActivated

6 minutes ago, Socratic_Phoenix said:

How do I listen to the events from the inventory to check if the player has done recipe stuff?

This would take way to long for me to explain, but I suggest looking in the vanilla Crafting Table Container.

7 minutes ago, Socratic_Phoenix said:

What. in. the. world. is. a. capability. (and how do I use it?)

Capabilities are basically does this Object have an Inventory or IItemHandler Capability? If so give it to me and let me access it from a particular direction.

8 minutes ago, Socratic_Phoenix said:

Exactly what classes do I actually have to extend?

As stated above GuiContainer or the Crafting Tables Gui if you can salvage some of it's methods and Container or the Crafting Tables Container once again if you can salvage anything from it.

  • Like 2

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 hour ago, Animefan8888 said:

No it does not need a TileEntity. You only need a TileEntity if you want to save the slots.

I don't (at least, not until I make the furnace), so should the crafting table just extend Block and override the onclick/interact/whatever method?

Developer of Randores (adds 256^3 ores to the game) and Arcane Bags (adds ridiculous storage with ridiculous crafting recipes).

I know Java pretty well... So yeah...

Quote

This is where I'd put an inspirational and/or clever quote, but I can't think of one right now...

This is the output of the totally, 100% working compiler for my programming language, Planet9:

Beginning Compilation...
Failed compilation!
planet9.compiler.error.CompilationException: Compiler not yet implemented
	at planet9.compiler.Compiler.compile(Compiler.java:39)
	at planet9.compiler.app.CompilerApp.main(CompilerApp.java:147)

 

Link to comment
Share on other sites

Extend Block and override Block#onBlockActivated

Edited by Animefan8888
Typo

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

2 hours ago, Animefan8888 said:

You add slots to it.

Slot takes an inventory... do I have to implement an IInventory for the crafting grid?

Developer of Randores (adds 256^3 ores to the game) and Arcane Bags (adds ridiculous storage with ridiculous crafting recipes).

I know Java pretty well... So yeah...

Quote

This is where I'd put an inspirational and/or clever quote, but I can't think of one right now...

This is the output of the totally, 100% working compiler for my programming language, Planet9:

Beginning Compilation...
Failed compilation!
planet9.compiler.error.CompilationException: Compiler not yet implemented
	at planet9.compiler.Compiler.compile(Compiler.java:39)
	at planet9.compiler.app.CompilerApp.main(CompilerApp.java:147)

 

Link to comment
Share on other sites

13 minutes ago, Animefan8888 said:

You should use a InventoryCrafting look in ContainerWorkbench.

K got it, it's coming along! Thanks for all the help so far

Developer of Randores (adds 256^3 ores to the game) and Arcane Bags (adds ridiculous storage with ridiculous crafting recipes).

I know Java pretty well... So yeah...

Quote

This is where I'd put an inspirational and/or clever quote, but I can't think of one right now...

This is the output of the totally, 100% working compiler for my programming language, Planet9:

Beginning Compilation...
Failed compilation!
planet9.compiler.error.CompilationException: Compiler not yet implemented
	at planet9.compiler.Compiler.compile(Compiler.java:39)
	at planet9.compiler.app.CompilerApp.main(CompilerApp.java:147)

 

Link to comment
Share on other sites

2 hours ago, Animefan8888 said:

No it does not need a TileEntity. You only need a TileEntity if you want to save the slots.

You return a Container in getServerGuiElement and a Gui in getClientGuiElement. The container is the Server sided object of a Gui and the Gui is the Client sided one GuiScreen extends Gui.

You add slots to it. When you add the Slots to the Container it will have it's position automatically made relative to the Gui and it will be measured in pixels. You use the Gui methods drawTexturedModelRect... to draw images on to the screen.

You should draw that using Minecraft#fontRenderer or this.fontRenderer in your Gui in the method drawGuiContainerForeground, and you should be using GuiContainer as your super class for your Gui.

Use EntityPlayer#openGui in Block#onBlockActivated

This would take way to long for me to explain, but I suggest looking in the vanilla Crafting Table Container.

Capabilities are basically does this Object have an Inventory or IItemHandler Capability? If so give it to me and let me access it from a particular direction.

As stated above GuiContainer or the Crafting Tables Gui if you can salvage some of it's methods and Container or the Crafting Tables Container once again if you can salvage anything from it.

Thanks so much for your help! It works perfectly! Now, should I create a separate thread with similar questions about furnaces (and tile entities and capabilities)? Or should I continue the discussion here? (Probably a new thread...)

Developer of Randores (adds 256^3 ores to the game) and Arcane Bags (adds ridiculous storage with ridiculous crafting recipes).

I know Java pretty well... So yeah...

Quote

This is where I'd put an inspirational and/or clever quote, but I can't think of one right now...

This is the output of the totally, 100% working compiler for my programming language, Planet9:

Beginning Compilation...
Failed compilation!
planet9.compiler.error.CompilationException: Compiler not yet implemented
	at planet9.compiler.Compiler.compile(Compiler.java:39)
	at planet9.compiler.app.CompilerApp.main(CompilerApp.java:147)

 

Link to comment
Share on other sites

It should be a new Thread as it is a completely different subject than what the title suggests.

  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

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.