Ask A Programmer

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

RavynousHunter

New Member
Jul 29, 2019
2,784
-3
1
Ya know, I have an idea. A lot of people out there don't really get how code and programs work, but want to learn. Why not...feed that particular beast? (And flog the bellend that made that horrid pun, lol.) Think of it like a Reddit AMA, cept the "me" in this case is anyone who writes code either for a mod, as a hobby, or as part of their profession.

So, what do you wanna know?
 

Chaka

FTB Team
Mod Developer
Retired Staff
Dec 24, 2013
928
323
103
New Jersey
What do you need to know? (Cause I'm soooo wolfy, right...)
I would like a reflections tutorial, Because I'm to lazy to learn it, And I'm to lazy to
go to youtube and look for the new boston tutorial for reflections.
 

rungok

New Member
Jul 29, 2019
173
0
0
I want to know how a moron like me can get started. There seems to be a certain "You must be this tall of a programmer to ride" need for doing any kind of modding. I really have great ideas (At least to me they're great) and I want to try to implement them because I lack the charisma and conversational prowess to convince other people to make stuff FOR me.
 

RavynousHunter

New Member
Jul 29, 2019
2,784
-3
1
I want to know how a moron like me can get started. There seems to be a certain "You must be this tall of a programmer to ride" need for doing any kind of modding. I really have great ideas (At least to me they're great) and I want to try to implement them because I lack the charisma and conversational prowess to convince other people to make stuff FOR me.
The best way to answer this is to answer this question: How do you best learn new things? Do you prefer learning by doing, or do you prefer reading? I think a good place to start in general would be a place called Dream.In.Code, since they host not only a good community, but lots of articles and tutorials in many languages.

As for starting languages, I personally suggest either Visual BASIC.Net or Python. It mostly has to do with the fact that both are more readable than languages like Java or C# that use C-style syntax, and are thus much more easy to understand.
 
  • Like
Reactions: Padfoote

TheGreatKamina

New Member
Jul 29, 2019
35
0
0
As for starting languages, I personally suggest either Visual BASIC.Net or Python. It mostly has to do with the fact that both are more readable than languages like Java or C# that use C-style syntax, and are thus much more easy to understand.
Neither of those are designed around object-oriented programming, which Java is all about. I think you can do OOP with Python, but I have little experience with it. That said, if you're looking to get a good sense for how to code, it's probably a good idea to start with procedural and functional programming before moving on to OOP.

Edit: I realize, for someone completely new to programming, the above might be a bit nebulous. Different languages tend to favor different ways of structuring code. Java is very heavily built around object oriented programming, which involves operating on custom, self-contained black boxes called objects that may internally change state. Procedural programming is simply writing a list of instructions to operate on primitive data types. Usually all the working bits of objects are procedural, which is why understanding one helps with the other.

I do have a question for the modders out there. As a guy who programs for a living, how the heck does one get into the "deep" modding that goes beyond adding cosmetic blocks? I can't seem to find any good resources on how the underlying stuff works or what hooks are available...
 
Last edited:

jordsta95

New Member
Jul 29, 2019
5,056
-4
1
I have a very simple question...
Is there any way to sort out the default minecraft/forge "code" you know like:
"p_25438_i" or "field_264_d" ( these are just random)
etc.
 

ljfa

New Member
Jul 29, 2019
2,761
-46
0
I have a very simple question...
Is there any way to sort out the default minecraft/forge "code" you know like:
"p_25438_i" or "field_264_d" ( these are just random)
etc.
Probably not. You're going to have look what these parameters or variables do. Unfortunately it's very hard to read sometimes.
 

ljfa

New Member
Jul 29, 2019
2,761
-46
0
Procedural programming is simply writing a list of instructions to operate on primitive data types. Usually all the working bits of objects are procedural, which is why understanding one helps with the other.
Although that doesn't mean it would be a good idea to e.g. learn C before Java.
 

ratchet freak

Well-Known Member
Nov 11, 2012
1,198
243
79
I have a very simple question...
Is there any way to sort out the default minecraft/forge "code" you know like:
"p_25438_i" or "field_264_d" ( these are just random)
etc.
keep updated on what MCPBot has for those mappings, You can find him on the MCP IRC chat channel, and you can add descriptive names for the functions yourself IIRC
 

TheGreatKamina

New Member
Jul 29, 2019
35
0
0
Although that doesn't mean it would be a good idea to e.g. learn C before Java.
Well, no, I wouldn't say learn C unless you're serious about computer science in general. A scripting language like Lua or Python wouldn't be a bad start, as you can play with the basic concepts without needing a ton of setup. Actually... doesn't ComputerCraft run Lua?

The best way would probably be to browse the Minecraft and Forge source. There isn't really any tutorials about more advanced stuff. You could also take a look at existing mods.
Hmm. You know, once I make some headway on an (unrelated) pet project of mine, I may just try that... I wouldn't mind trying to get Mazeworld off the ground again, but that would almost need a whole team of modders to flesh out properly. Maybe I'll just make a small potpourri mod to get some experience. Add some unique dungeon loot or something.
 

yotus

New Member
Jul 29, 2019
148
-1
0
Well, no, I wouldn't say learn C unless you're serious about computer science in general. A scripting language like Lua or Python wouldn't be a bad start, as you can play with the basic concepts without needing a ton of setup. Actually... doesn't ComputerCraft run Lua?

It does run Lua indeed, but I wouldn't recommend starting with ComputerCraft, because first, not the best text editor ever, and second, debugging is not the easiest thing to do on a CC computer..

If you want to write mods, I would recommend http://www.minecraftforge.net/wiki/Basic_Modding, it should be a good starting point and you will be able to make your very first mod pretty quickly (even if it's a 1 dirt -> 64 diamonds recipe :) )
 

yotus

New Member
Jul 29, 2019
148
-1
0
I also have a question myself.. coding in Java is what I do for a living, and I'd really like to make my own mod sometime, but I don't really know where to start. I went through the tutorials I posted above, I have some ideas for the mod, but that's it.

How do you get started for mods that are more than just new recipes or textures ? Like a basic machine, for example ?
What do you use to make new 3D models ?
Is it possible to take a screenshot from a point of view of an entity (other than the player) ?
 

Plainy

New Member
Jul 29, 2019
366
0
0
I also have a question myself.. coding in Java is what I do for a living, and I'd really like to make my own mod sometime, but I don't really know where to start. I went through the tutorials I posted above, I have some ideas for the mod, but that's it.

How do you get started for mods that are more than just new recipes or textures ? Like a basic machine, for example ?
What do you use to make new 3D models ?
Is it possible to take a screenshot from a point of view of an entity (other than the player) ?
You could use Techne
I dont like it myself since you have to keep clicking... a lot to use the damn thing around.
Still looking for a alternative.
 

ratchet freak

Well-Known Member
Nov 11, 2012
1,198
243
79
I also have a question myself.. coding in Java is what I do for a living, and I'd really like to make my own mod sometime, but I don't really know where to start. I went through the tutorials I posted above, I have some ideas for the mod, but that's it.

How do you get started for mods that are more than just new recipes or textures ? Like a basic machine, for example ?
What do you use to make new 3D models ?
Is it possible to take a screenshot from a point of view of an entity (other than the player) ?

basic machine is a Tile Entity implementing a ISidedInventory and some energy API that uses a tick handler that decrements the energy storage and time until completion, when that last one is 0 it decrements the input slots and adds an item into the output slot

It should also save and restore its state to NBT and probably have a GUI
 

yotus

New Member
Jul 29, 2019
148
-1
0
basic machine is a Tile Entity implementing a ISidedInventory and some energy API that uses a tick handler that decrements the energy storage and time until completion, when that last one is 0 it decrements the input slots and adds an item into the output slot

It should also save and restore its state to NBT and probably have a GUI

A lot of helpful information, I like it ! Thank you
 

RavynousHunter

New Member
Jul 29, 2019
2,784
-3
1
Neither of those are designed around object-oriented programming, which Java is all about. I think you can do OOP with Python, but I have little experience with it. That said, if you're looking to get a good sense for how to code, it's probably a good idea to start with procedural and functional programming before moving on to OOP.

Visual BASIC.Net's biggest thing was moving to proper OOP design, instead of the pseudo-OOP that VB6 implemented.

Also, I disagree on learning procedural and/or functional programming before learning OOP. The most-used languages for both hobbyists and professionals are object-oriented: C++, Java, C++/CLI, Python, etc. From my experience, you're also more likely to find quality tutorials and examples in the more popular object-oriented languages, meaning learning may end up taking less time, depending on the person. Personally, the greatest barrier I faced (pre-C++) when learning programming was getting a handle on control flow and structuring, something that VB.Net makes abundantly clear because of its plain-language keywords and lack of whitespace requirement. I'll even provide an example using a for loop, one of my most common loops:

C#:
Code:
for ( int i = 0; i < 5; i++ )
{
  System.Console.WriteLine( i );
}

VB.Net:
Code:
For i as Integer = 0 To 5
  System.Console.WriteLine( i )
Next

For a beginner, the latter is likely much easier to read, and thus, to understand. VB.Net also doesn't require you to start off with making classes and such, making it a good entry point for beginners, since they can progress to classes when they feel comfortable doing so without having to change language, making the transition from newbie code to object-orientation.