Since high school, I've made a few attempts at learning to mod Minecraft, which all end up with me quickly giving up because of the overwhelming amount of new information to take in. It doesn't help that most "beginner friendly" tutorials basically just give you code templates to plug things into, and my mind instinctively wants to figure out what everything is, and what it's doing. A year and a half though, I followed some free online courses to teach myself beginner Java, and while I'm undoubtedly still a beginner and don't understand jack about user interfaces, I'm really good at writing and structuring code and can make almost any text box-based program you want me to lol. But that still hasn't alleviated my main anxiety about learning to mod Minecraft. I feel like I need to somehow learn how Minecraft works in order to mod Minecraft beyond following the templates to add custom blocks and stuff. But that seems like such an enormous task that I don't even know how to approach it, even though I understand a lot of Java. Any thoughts/suggestions?
You don't need to know how the entire Minecraft code works, the basics are enough. I think the best way to learn modding in Minecraft is to first learn the basics like creating "inert" blocks and items and then learn more and more advanced functions you can add to your creations. While learning those functions, you will also probably start understanding the principle of the vanilla Minecraft code over time. If you need to know how to program any particular function, just google it. And if you find nothing, write on the forum. Someone might know the answer. At least I personally do it that way.
And when learning more advanced funcions, it is allways important to know what exactly you want to make. There are simply too many options to learn all of them.
I pretty much taught myself how to mod entirely by looking at the source code and how vanilla did things, including using the source as a template, if not just directly modifying it (I started with, and still make, "jar" mods, without using Forge or another mod API); my first mods were pretty basic, just changing some values within the cave generation code, then I later figured out exactly how it works and was able to make more significant changes. Likewise, many of the other things that I've added on my own are based on various vanilla features; for example, my "mega trees" are based on the code that generates big jungle trees, modified to be taller and have more branches and leaves.
Since high school, I've made a few attempts at learning to mod Minecraft, which all end up with me quickly giving up because of the overwhelming amount of new information to take in. It doesn't help that most "beginner friendly" tutorials basically just give you code templates to plug things into, and my mind instinctively wants to figure out what everything is, and what it's doing. A year and a half though, I followed some free online courses to teach myself beginner Java, and while I'm undoubtedly still a beginner and don't understand jack about user interfaces, I'm really good at writing and structuring code and can make almost any text box-based program you want me to lol. But that still hasn't alleviated my main anxiety about learning to mod Minecraft. I feel like I need to somehow learn how Minecraft works in order to mod Minecraft beyond following the templates to add custom blocks and stuff. But that seems like such an enormous task that I don't even know how to approach it, even though I understand a lot of Java. Any thoughts/suggestions?
minecraft isn't open source
also I'm a programming noob and made several hacked clients for minecraft.
also I'm a programming noob and made several hacked clients for minecraft.
You can easily access the source though; most mod development environments will give you access to the decompiled and deobfuscated source and some, at least MCP (Mod Coder Pack), let you directly modify it (in the case of e.g. Forge you'll need to copy the code to your own class and use hooks/events/reflection to plug into the vanilla code (this tutorial probably doesn't work anymore for newer versions but "coremods" are still used) or register it as a new block/biome/entity/etc, all way more complicated and resource-hungry at the benefit of mod compatibility). You can even find GitHub repositories that (illegally) uploaded the source, albeit it seems only up to 1.12, and it isn't as easy to navigate as having it all on your computer (I use a "grep" tool to quickly search through the code); of course, there are also open-source mods that let you view their source code and even use it in your own mods (be sure to read the license first).
@jstastny Yeah, that's one of the issues I'm having with getting into modding. I imagine it's probably easier to get into modding the newer versions since the tutorials are more up to date and there are more convenient features. But if I eventually want to learn how to make large-scale changes to Minecraft, I'm not sure if it's worth it to learn how the newer versions work if it ends up being too hard to change the game's systems in them, and I'll just have to end up learning how the earlier versions work from scratch.
I imagine it's probably easier to get into modding the newer versions since the tutorials are more up to date and there are more convenient features.
I'd say the opposite - for example, to add a basic block to 1.6.4 using MCP all I need to do is this:
public static final Block rubyBlock = new BlockOreStorage(BlockStates.rubyBlock).setHardness(5.0F).setResistance(6.0F).setStepSound(soundMetalFootstep).setUnlocalizedName("rubyBlock").setTextureName("ruby_block");
par1CraftingManager.addRecipe(new ItemStack(Block.rubyBlock), new Object[] {"###", "###", "###", '#', Item.ruby});
No messing around with model jsons or anything of that sort (the only asset I needed was a texture); every block also automatically has a valid item form (even blocks like water) and there are no "illegal" block states (e.g. stone:1 in vanilla 1.6.4 simply appears as normal stone).
Also, using MCP offers some significant advantages at the cost of mod compatibility besides being able to directly work with the code; for example, Forge mods that backport the 1.8 stone variants to 1.7.10 or earlier do so by adding a new block but I did it by adding new variants to the stone block, same for the vast majority of the 250+ blocks that I've added, such that I'd actually only used around 30 new IDs:
// Original definition for coal blocks in vanilla (uses a default Block instance, no subclass)
public static final Block coalBlock = (new Block(173, Material.rock)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundStoneFootstep).setUnlocalizedName("blockCoal").setCreativeTab(CreativeTabs.tabBlock).setTextureName("coal_block");
// Replaced with my own custom class
public static final Block coalBlock = new BlockCoalBlock(BlockStates.coalBlock);
package net.minecraft.src;
import java.util.List;
public class BlockCoalBlock extends Block
{
// Added charcoal variant of coal blocks
public static final int COAL_BLOCK = 0;
public static final int CHARCOAL_BLOCK = 1;
public static final String[] VARIANTS = new String[] {"coal", "charcoal"};
private Icon charcoalBlockIcon;
public BlockCoalBlock(int par1)
{
super(par1, Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setHardness(5.0F);
this.setResistance(6.0F);
this.setStepSound(soundStoneFootstep);
this.setUnlocalizedName("blockCoal");
}
public int damageDropped(int meta)
{
return meta == CHARCOAL_BLOCK ? CHARCOAL_BLOCK : COAL_BLOCK;
}
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(par1, 1, COAL_BLOCK));
par3List.add(new ItemStack(par1, 1, CHARCOAL_BLOCK));
}
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon("coal_block");
this.charcoalBlockIcon = par1IconRegister.registerIcon("charcoal_block");
}
public Icon getIcon(int side, int meta)
{
return meta == CHARCOAL_BLOCK ? this.charcoalBlockIcon : this.blockIcon;
}
}
Note that the code shown here was basically copied from vanilla; all the methods shown are in the Block base class and you can see how they are used in subclasses if they aren't used by default (for example, "getIcon" defaults to returning "blockIcon", while it can return separate icons for each side and each data value).
Of course, I've made many of my own changes to the vanilla code to make it easier to mod, such as adding a custom render type to render blocks with non-vanilla models; the huge advantage that pre-1.8 versions have is that block models could easily be dynamically rendered in-code (I recall that some mods needed thousands of model jsons for a single block, which is also one reason why 1.8+ requires 5-10x more memory than older versions):
// partial code shown
public class BlockWaterPlant extends Block
{
// Formerly used by ladders, now used to render custom blocks
public int getRenderType()
{
return 8;
}
// Renders on both opaque (0) and translucent (1) passes
public int getRenderBlockPass()
{
return 2;
}
public boolean renderBlock(CustomBlockRenderer blockRenderer, int x, int y, int z)
{
// Renders water around block
if (blockRenderer.renderPass == 1) return blockRenderer.renderBlockFluids(Block.waterStill, x, y, z);
IBlockAccess blockAccess = blockRenderer.blockAccess;
int meta = blockAccess.getBlockMetadata(x, y, z);
// Double plants renders entire block based on lower block; blocks only render if the block below
// is the ground
if (this.isDoubleBlock(meta) && !canRenderDoublePlant(blockAccess.getBlockId(x, y - 1, z))) return false;
Tessellator tess = Tessellator.instance;
tess.setBrightness(blockAccess.getMixedBrightnessForBlock(x, y, z));
tess.setColorOpaque_I(this.getColorMultiplier(blockAccess, x, y, z, meta));
// Applies a random offset; double blocks do not use y
int lcg = (this.isDoubleBlock(meta) ? this.getRandomValue(x, z) : this.getRandomValue(x, y, z));
float minX = (float)((double)x + tess.xOffset) + this.getBlockXOffset(lcg) + 0.05F;
float minY = (float)((double)y + tess.yOffset) + this.getBlockYOffset(lcg);
float minZ = (float)((double)z + tess.zOffset) + this.getBlockZOffset(lcg) + 0.05F;
float maxX = minX + 0.9F;
float maxY = minY + 1.0F;
float maxZ = minZ + 0.9F;
Icon icon = this.getIcon(0, meta);
float minU;
float maxU;
float minV = icon.getMinV();
float maxV = icon.getMaxV();
// Randomly flips texture from left-right
lcg = ((lcg * 1664525 + 1013904223) >>> 31) & ((x + z) & 1);
if (lcg == 0)
{
minU = icon.getMinU();
maxU = icon.getMaxU();
}
else
{
minU = icon.getMaxU();
maxU = icon.getMinU();
}
// Second pass renders top half of double blocks
for (int i = 0; i < 2; ++i)
{
if (i == 1)
{
minY += 1.0F;
maxY += 1.0F;
icon = this.getIcon(0, this.getTopIconIndex(meta));
minV = icon.getMinV();
maxV = icon.getMaxV();
if (lcg == 0)
{
minU = icon.getMinU();
maxU = icon.getMaxU();
}
else
{
minU = icon.getMaxU();
maxU = icon.getMinU();
}
// Sets flag to increase bounds of frustrum culling bounding box to ensure that top half
// isn't culled
if ((y & 15) == 15) ChunkRenderer.hasDoubleBlocksUp = true;
}
}
tess.addBlockVertex(minX, maxY, minZ, minU, minV);
tess.addBlockVertex(minX, minY, minZ, minU, maxV);
tess.addBlockVertex(maxX, minY, maxZ, maxU, maxV);
tess.addBlockVertex(maxX, maxY, maxZ, maxU, minV);
tess.addBlockVertex(maxX, maxY, maxZ, minU, minV);
tess.addBlockVertex(maxX, minY, maxZ, minU, maxV);
tess.addBlockVertex(minX, minY, minZ, maxU, maxV);
tess.addBlockVertex(minX, maxY, minZ, maxU, minV);
tess.addBlockVertex(minX, maxY, maxZ, minU, minV);
tess.addBlockVertex(minX, minY, maxZ, minU, maxV);
tess.addBlockVertex(maxX, minY, minZ, maxU, maxV);
tess.addBlockVertex(maxX, maxY, minZ, maxU, minV);
tess.addBlockVertex(maxX, maxY, minZ, minU, minV);
tess.addBlockVertex(maxX, minY, minZ, minU, maxV);
tess.addBlockVertex(minX, minY, maxZ, maxU, maxV);
tess.addBlockVertex(minX, maxY, maxZ, maxU, minV);
if (!this.isDoubleBlock(meta)) break;
}
return true;
}
Since high school, I've made a few attempts at learning to mod Minecraft, which all end up with me quickly giving up because of the overwhelming amount of new information to take in. It doesn't help that most "beginner friendly" tutorials basically just give you code templates to plug things into, and my mind instinctively wants to figure out what everything is, and what it's doing. A year and a half though, I followed some free online courses to teach myself beginner Java, and while I'm undoubtedly still a beginner and don't understand jack about user interfaces, I'm really good at writing and structuring code and can make almost any text box-based program you want me to lol. But that still hasn't alleviated my main anxiety about learning to mod Minecraft. I feel like I need to somehow learn how Minecraft works in order to mod Minecraft beyond following the templates to add custom blocks and stuff. But that seems like such an enormous task that I don't even know how to approach it, even though I understand a lot of Java. Any thoughts/suggestions?
You don't need to know how the entire Minecraft code works, the basics are enough. I think the best way to learn modding in Minecraft is to first learn the basics like creating "inert" blocks and items and then learn more and more advanced functions you can add to your creations. While learning those functions, you will also probably start understanding the principle of the vanilla Minecraft code over time. If you need to know how to program any particular function, just google it. And if you find nothing, write on the forum. Someone might know the answer. At least I personally do it that way.
And when learning more advanced funcions, it is allways important to know what exactly you want to make. There are simply too many options to learn all of them.
Good luck programing your first mod!
Thanks for the reply! And if you have any links to any of the resources you used to start learning, I'd appreciate if you could share!
It depends what Minecraft version do you want to make mod for. Each version differs a bit and the tutorials are usually for defined version.
I pretty much taught myself how to mod entirely by looking at the source code and how vanilla did things, including using the source as a template, if not just directly modifying it (I started with, and still make, "jar" mods, without using Forge or another mod API); my first mods were pretty basic, just changing some values within the cave generation code, then I later figured out exactly how it works and was able to make more significant changes. Likewise, many of the other things that I've added on my own are based on various vanilla features; for example, my "mega trees" are based on the code that generates big jungle trees, modified to be taller and have more branches and leaves.
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
minecraft isn't open source
also I'm a programming noob and made several hacked clients for minecraft.
Thanks.
You can easily access the source though; most mod development environments will give you access to the decompiled and deobfuscated source and some, at least MCP (Mod Coder Pack), let you directly modify it (in the case of e.g. Forge you'll need to copy the code to your own class and use hooks/events/reflection to plug into the vanilla code (this tutorial probably doesn't work anymore for newer versions but "coremods" are still used) or register it as a new block/biome/entity/etc, all way more complicated and resource-hungry at the benefit of mod compatibility). You can even find GitHub repositories that (illegally) uploaded the source, albeit it seems only up to 1.12, and it isn't as easy to navigate as having it all on your computer (I use a "grep" tool to quickly search through the code); of course, there are also open-source mods that let you view their source code and even use it in your own mods (be sure to read the license first).
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
@jstastny Yeah, that's one of the issues I'm having with getting into modding. I imagine it's probably easier to get into modding the newer versions since the tutorials are more up to date and there are more convenient features. But if I eventually want to learn how to make large-scale changes to Minecraft, I'm not sure if it's worth it to learn how the newer versions work if it ends up being too hard to change the game's systems in them, and I'll just have to end up learning how the earlier versions work from scratch.
I'd say the opposite - for example, to add a basic block to 1.6.4 using MCP all I need to do is this:
No messing around with model jsons or anything of that sort (the only asset I needed was a texture); every block also automatically has a valid item form (even blocks like water) and there are no "illegal" block states (e.g. stone:1 in vanilla 1.6.4 simply appears as normal stone).
Also, using MCP offers some significant advantages at the cost of mod compatibility besides being able to directly work with the code; for example, Forge mods that backport the 1.8 stone variants to 1.7.10 or earlier do so by adding a new block but I did it by adding new variants to the stone block, same for the vast majority of the 250+ blocks that I've added, such that I'd actually only used around 30 new IDs:
Note that the code shown here was basically copied from vanilla; all the methods shown are in the Block base class and you can see how they are used in subclasses if they aren't used by default (for example, "getIcon" defaults to returning "blockIcon", while it can return separate icons for each side and each data value).
Of course, I've made many of my own changes to the vanilla code to make it easier to mod, such as adding a custom render type to render blocks with non-vanilla models; the huge advantage that pre-1.8 versions have is that block models could easily be dynamically rendered in-code (I recall that some mods needed thousands of model jsons for a single block, which is also one reason why 1.8+ requires 5-10x more memory than older versions):
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?