Jump to content

Recommended Posts

Posted (edited)

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)

 

Posted
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.

Posted
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)

 

Posted
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)

 

Posted
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)

 

Posted
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)

 

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

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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