The Meaning of Life, the Universe, and Everything.
Location:
Vancouver, WA USA
Join Date:
1/21/2014
Posts:
73
Member Details
Good job on these! You pack a lot of useful info into a well organized space. Unlike video tuts that consume lots of my time with their hunt-and-peck typing, I can quickly find what I need and then copy-paste code words from text. I can't copy text from videos
Some notes that may or may not improve your lessons further:
In your textures lesson, you wrote: "create a new package in src/main/java called assets." I think you meant to put that in "src/main/resources".
The placement of texture files deserves a few more words of clarification. In order for the setTextureName (modID:itemName) to do its job, the folder structure needs to follow a precise pattern, and each texture needs to be placed in exactly the right folder (e.g. ...Forge\src\main\resources\assets\<modID>\textures\items or ...Forge\src\main\resources\assets\<modID>\textures\blocks etc}.
Armor is special because each piece has two textures, one for the inventory/dropped item, and a 3D skin for wearing. The drop textures are items put into the items subfolder, but the skins belong in a models/armor subfolder. This and other peculiarities about armor make it worth an entire lesson by itself.
In general, I just mimic whatever the vanilla resources are doing under ...Forge\build\tmp\recompSrc\assets\minecraft. That's also where one can find PNG files to copy over to my own textures for recoloring.
You might want to refer to your package setup (or move it near the top) so people can "see it". I recommend expanding all of the mod resources then crop around the package explorer and zoom in. Another good pic would be the corresponding file-system tree.
Regarding void: It's used in place of a return type for methods that don't return anything (such as the event handlers), because Java syntax requires something where a type would go. Here's an example:
// Forge event handlers (pre, init & post)
@EventHandler
public void preInit(FMLPreInitializationEvent e) { // Instantiate blocks and items
System.out.println("Preinit " + MODID);
blockRubyOre = new classRubyOre("ruby_ore"); // Naming is so critical that
blockRubyBlock = new classRubyBlock("ruby_block"); // I chose to force it via my constructors
}
As you can see, I also chose to leave out the settings. As a matter of style, I prefer to encapsulate each new element's settings within a dedicated subclass, so I call methods like setTextureName from inside its constructor. YMMV
BTW, Don't confuse event handlers with constructors (The ore lesson uses the word "constructor" when it means event handler). Some folks may show up here new to Java, and we wouldn't want them to misunderstand the special meaning of "constructor" in the Java language.
The Meaning of Life, the Universe, and Everything.
Join Date:
6/11/2014
Posts:
59
Member Details
I really appreciate these tutorials. Some thoughts and questions.
How does the mod ID differ from the mod name? I'm not sure I understand where to export a custom texture to exactly. My workspace is setup according to the Modding with Forge #1 - JDK, Eclipse, Forge and Gradle tutorial, thus my 'Package Explorer' directory structure is a little different.
Some food for thought: avoid anonymous classes and method cascading. While these provide syntactic sugar, they can be confusing to the less experienced.
Thank you for your work. I hope to see more of it.
This is really helpful... I am having the same problem mentioned before with trying to get the block to set itself to air then replace with another block... I'll post here if I figure it out
When attempting to make an instant structure, I place the block(I haven't made a texture for it yet) and nothing happens. There aren't any errors or anything the console. Here is my file:
package coo.moddingtutorial.block;
import java.util.Random;
import coo.moddingtutorial.ModdingMain;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class SwimmingPool extends Block
{
Blocks b;
public SwimmingPool(Material material)
{
super(material);
}
public void onBlockPlacedBy(World world, Random random, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack)
{
//Super
super.onBlockPlacedBy(world, x, y, z, entity, itemstack);
//Sets the block to air on the x, y, and z coords from where you placed the block
world.setBlockToAir(x, y, z);
//Sets the block on the x, y, and z coords starting from where you placed the block
world.setBlock(x+1, y, z, b.stonebrick);
world.setBlock(x-1, y, z, b.stonebrick);
world.setBlock(x, y, z+1, b.stonebrick);
world.setBlock(x, y, z-1, b.stonebrick);
world.setBlock(x+1, y, z+1, b.stonebrick);
world.setBlock(x+1, y, z-1, b.stonebrick);
world.setBlock(x-1, y, z-1, b.stonebrick);
world.setBlock(x-1, y, z+1, b.stonebrick);
world.setBlock(x, y+1, z, b.water);
world.setBlock(x+1, y+1, z, b.water);
world.setBlock(x-1, y+1, z, b.water);
world.setBlock(x, y+1, z+1, b.water);
world.setBlock(x, y+1, z-1, b.water);
world.setBlock(x+1, y+1, z+1, b.water);
world.setBlock(x+1, y+1, z-1, b.water);
world.setBlock(x-1, y+1, z-1, b.water);
world.setBlock(x-1, y+1, z+1, b.water);
world.setBlock(x, y+2, z, b.water);
world.setBlock(x+1, y+2, z, b.water);
world.setBlock(x-1, y+2, z, b.water);
world.setBlock(x, y+2, z+1, b.water);
world.setBlock(x, y+2, z-1, b.water);
world.setBlock(x+1, y+2, z+1, b.water);
world.setBlock(x+1, y+2, z-1, b.water);
world.setBlock(x-1, y+2, z-1, b.water);
world.setBlock(x-1, y+2, z+1, b.water);
world.setBlock(x+2, y, z, b.stonebrick);
world.setBlock(x-2, y, z, b.stonebrick);
world.setBlock(x, y, z+2, b.stonebrick);
world.setBlock(x, y, z-2, b.stonebrick);
world.setBlock(x+2, y, z+1, b.stonebrick);
world.setBlock(x+2, y, z+2, b.stonebrick);
world.setBlock(x+1, y, z+2, b.stonebrick);
world.setBlock(x+2, y, z-1, b.stonebrick);
world.setBlock(x+2, y, z-2, b.stonebrick);
world.setBlock(x+1, y, z-2, b.stonebrick);
world.setBlock(x-2, y, z+1, b.stonebrick);
world.setBlock(x-2, y, z+2, b.stonebrick);
world.setBlock(x-1, y, z+2, b.stonebrick);
world.setBlock(x-2, y, z-1, b.stonebrick);
world.setBlock(x-2, y, z-2, b.stonebrick);
world.setBlock(x-1, y, z-2, b.stonebrick);
world.setBlock(x+2, y+1, z, b.stonebrick);
world.setBlock(x-2, y+1, z, b.stonebrick);
world.setBlock(x, y+1, z+2, b.stonebrick);
world.setBlock(x, y+1, z-2, b.stonebrick);
world.setBlock(x+2, y+1, z+1, b.stonebrick);
world.setBlock(x+2, y+1, z+2, b.stonebrick);
world.setBlock(x+1, y+1, z+2, b.stonebrick);
world.setBlock(x+2, y+1, z-1, b.stonebrick);
world.setBlock(x+2, y+1, z-2, b.stonebrick);
world.setBlock(x+1, y+1, z-2, b.stonebrick);
world.setBlock(x-2, y+1, z+1, b.stonebrick);
world.setBlock(x-2, y+1, z+2, b.stonebrick);
world.setBlock(x-1, y+1, z+2, b.stonebrick);
world.setBlock(x-2, y+1, z-1, b.stonebrick);
world.setBlock(x-2, y+1, z-2, b.stonebrick);
world.setBlock(x-1, y+1, z-2, b.stonebrick);
world.setBlock(x+2, y+2, z, b.stonebrick);
world.setBlock(x-2, y+2, z, b.stonebrick);
world.setBlock(x, y+2, z+2, b.stonebrick);
world.setBlock(x, y+2, z-2, b.stonebrick);
world.setBlock(x+2, y+2, z+1, b.stonebrick);
world.setBlock(x+2, y+2, z+2, b.stonebrick);
world.setBlock(x+1, y+2, z+2, b.stonebrick);
world.setBlock(x+2, y+2, z-1, b.stonebrick);
world.setBlock(x+2, y+2, z-2, b.stonebrick);
world.setBlock(x+1, y+2, z-2, b.stonebrick);
world.setBlock(x-2, y+2, z+1, b.stonebrick);
world.setBlock(x-2, y+2, z+2, b.stonebrick);
world.setBlock(x-1, y+2, z+2, b.stonebrick);
world.setBlock(x-2, y+2, z-1, b.stonebrick);
world.setBlock(x-2, y+2, z-2, b.stonebrick);
world.setBlock(x-1, y+2, z-2, b.stonebrick);
//Sets the block(with set metadata) on the x, y, and z coords from where you placed the block
//world.setBlock(x, y, z, b.planks, 2, 2); //This is for birch planks, if you want other planks, search 'Minecraft Block Metadata' in google or find it on the MinecraftWiki
}
}
ebonyOre = new BlockEbonyOre(Material.rock) <--- Right here, so that it'll look like this
ebonyOre = new BlockEbonyOre(Material.rock).setBlockName("this is the name you use in the lang file").setBlockaTextureName(Reference.MODID + ":" + "the name of your image").setCreativeTab(CreativeTabs.tabBlock);
oh, and dont put your assets packages under src/main/resources put them under src/main/java
if it still wont work then, send me the error logs again!
nice guides, im reading through them to refresh my memory and maybe learn something new, i did spot a typo though
event.entityLiving.entityDropItem(new ItemStack(Item.apple), dropped); Should be:
event.entityLiving.entityDropItem(new ItemStack(Items.apple), dropped);
Thats in the drop handler
I notice your missing a sounds tutorial,i wrote this back in january (before my long time away from modding made me rusty...hay not my fault forge mods have taken so long to update lol!) http://www.minecraft..._sound_tutorial
i did 2 more advanced tutorials as well (one on adding a chat bot to a mod and one on adding true multisystem speech synth, both are on the wiki)
feel free to use them on here as you see fit, either as is or reworded, i wrote them to help people after all
I must also say a huge congrats and thank you for taking the time to make these guides, they are appreciated
When attempting to make an instant structure, I place the block(I haven't made a texture for it yet) and nothing happens. There aren't any errors or anything the console. Here is my file:
package coo.moddingtutorial.block;
import java.util.Random;
import coo.moddingtutorial.ModdingMain;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class SwimmingPool extends Block
{
Blocks b;
public SwimmingPool(Material material)
{
super(material);
}
public void onBlockPlacedBy(World world, Random random, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack)
{
//Super
super.onBlockPlacedBy(world, x, y, z, entity, itemstack);
//Sets the block to air on the x, y, and z coords from where you placed the block
world.setBlockToAir(x, y, z);
//Sets the block on the x, y, and z coords starting from where you placed the block
world.setBlock(x+1, y, z, b.stonebrick);
world.setBlock(x-1, y, z, b.stonebrick);
world.setBlock(x, y, z+1, b.stonebrick);
world.setBlock(x, y, z-1, b.stonebrick);
world.setBlock(x+1, y, z+1, b.stonebrick);
world.setBlock(x+1, y, z-1, b.stonebrick);
world.setBlock(x-1, y, z-1, b.stonebrick);
world.setBlock(x-1, y, z+1, b.stonebrick);
world.setBlock(x, y+1, z, b.water);
world.setBlock(x+1, y+1, z, b.water);
world.setBlock(x-1, y+1, z, b.water);
world.setBlock(x, y+1, z+1, b.water);
world.setBlock(x, y+1, z-1, b.water);
world.setBlock(x+1, y+1, z+1, b.water);
world.setBlock(x+1, y+1, z-1, b.water);
world.setBlock(x-1, y+1, z-1, b.water);
world.setBlock(x-1, y+1, z+1, b.water);
world.setBlock(x, y+2, z, b.water);
world.setBlock(x+1, y+2, z, b.water);
world.setBlock(x-1, y+2, z, b.water);
world.setBlock(x, y+2, z+1, b.water);
world.setBlock(x, y+2, z-1, b.water);
world.setBlock(x+1, y+2, z+1, b.water);
world.setBlock(x+1, y+2, z-1, b.water);
world.setBlock(x-1, y+2, z-1, b.water);
world.setBlock(x-1, y+2, z+1, b.water);
world.setBlock(x+2, y, z, b.stonebrick);
world.setBlock(x-2, y, z, b.stonebrick);
world.setBlock(x, y, z+2, b.stonebrick);
world.setBlock(x, y, z-2, b.stonebrick);
world.setBlock(x+2, y, z+1, b.stonebrick);
world.setBlock(x+2, y, z+2, b.stonebrick);
world.setBlock(x+1, y, z+2, b.stonebrick);
world.setBlock(x+2, y, z-1, b.stonebrick);
world.setBlock(x+2, y, z-2, b.stonebrick);
world.setBlock(x+1, y, z-2, b.stonebrick);
world.setBlock(x-2, y, z+1, b.stonebrick);
world.setBlock(x-2, y, z+2, b.stonebrick);
world.setBlock(x-1, y, z+2, b.stonebrick);
world.setBlock(x-2, y, z-1, b.stonebrick);
world.setBlock(x-2, y, z-2, b.stonebrick);
world.setBlock(x-1, y, z-2, b.stonebrick);
world.setBlock(x+2, y+1, z, b.stonebrick);
world.setBlock(x-2, y+1, z, b.stonebrick);
world.setBlock(x, y+1, z+2, b.stonebrick);
world.setBlock(x, y+1, z-2, b.stonebrick);
world.setBlock(x+2, y+1, z+1, b.stonebrick);
world.setBlock(x+2, y+1, z+2, b.stonebrick);
world.setBlock(x+1, y+1, z+2, b.stonebrick);
world.setBlock(x+2, y+1, z-1, b.stonebrick);
world.setBlock(x+2, y+1, z-2, b.stonebrick);
world.setBlock(x+1, y+1, z-2, b.stonebrick);
world.setBlock(x-2, y+1, z+1, b.stonebrick);
world.setBlock(x-2, y+1, z+2, b.stonebrick);
world.setBlock(x-1, y+1, z+2, b.stonebrick);
world.setBlock(x-2, y+1, z-1, b.stonebrick);
world.setBlock(x-2, y+1, z-2, b.stonebrick);
world.setBlock(x-1, y+1, z-2, b.stonebrick);
world.setBlock(x+2, y+2, z, b.stonebrick);
world.setBlock(x-2, y+2, z, b.stonebrick);
world.setBlock(x, y+2, z+2, b.stonebrick);
world.setBlock(x, y+2, z-2, b.stonebrick);
world.setBlock(x+2, y+2, z+1, b.stonebrick);
world.setBlock(x+2, y+2, z+2, b.stonebrick);
world.setBlock(x+1, y+2, z+2, b.stonebrick);
world.setBlock(x+2, y+2, z-1, b.stonebrick);
world.setBlock(x+2, y+2, z-2, b.stonebrick);
world.setBlock(x+1, y+2, z-2, b.stonebrick);
world.setBlock(x-2, y+2, z+1, b.stonebrick);
world.setBlock(x-2, y+2, z+2, b.stonebrick);
world.setBlock(x-1, y+2, z+2, b.stonebrick);
world.setBlock(x-2, y+2, z-1, b.stonebrick);
world.setBlock(x-2, y+2, z-2, b.stonebrick);
world.setBlock(x-1, y+2, z-2, b.stonebrick);
//Sets the block(with set metadata) on the x, y, and z coords from where you placed the block
//world.setBlock(x, y, z, b.planks, 2, 2); //This is for birch planks, if you want other planks, search 'Minecraft Block Metadata' in google or find it on the MinecraftWiki
}
}
Try getting rid of the super constructor, it may not need to be there, i'll look into this more though
No, i mean a picture of the actual class, so i can see the code and look for errors
yeah, just get rid of the void modifier, so it's public testBlock(Material material)
and you don't put quotation marks around Test Block in the en_US.lang file
You're welcome!
Some notes that may or may not improve your lessons further:
In your textures lesson, you wrote: "create a new package in src/main/java called assets." I think you meant to put that in "src/main/resources".
The placement of texture files deserves a few more words of clarification. In order for the setTextureName (modID:itemName) to do its job, the folder structure needs to follow a precise pattern, and each texture needs to be placed in exactly the right folder (e.g. ...Forge\src\main\resources\assets\<modID>\textures\items or ...Forge\src\main\resources\assets\<modID>\textures\blocks etc}.
Armor is special because each piece has two textures, one for the inventory/dropped item, and a 3D skin for wearing. The drop textures are items put into the items subfolder, but the skins belong in a models/armor subfolder. This and other peculiarities about armor make it worth an entire lesson by itself.
In general, I just mimic whatever the vanilla resources are doing under ...Forge\build\tmp\recompSrc\assets\minecraft. That's also where one can find PNG files to copy over to my own textures for recoloring.
You might want to refer to your package setup (or move it near the top) so people can "see it". I recommend expanding all of the mod resources then crop around the package explorer and zoom in. Another good pic would be the corresponding file-system tree.
Regarding void: It's used in place of a return type for methods that don't return anything (such as the event handlers), because Java syntax requires something where a type would go. Here's an example:
As you can see, I also chose to leave out the settings. As a matter of style, I prefer to encapsulate each new element's settings within a dedicated subclass, so I call methods like setTextureName from inside its constructor. YMMV
BTW, Don't confuse event handlers with constructors (The ore lesson uses the word "constructor" when it means event handler). Some folks may show up here new to Java, and we wouldn't want them to misunderstand the special meaning of "constructor" in the Java language.
I have been trying to figure out fluids since 1.2.5, but ive had no luck, theyre elusive...but ill try harder and ill post a tut asap
it will really help thank for making this tuts
How does the mod ID differ from the mod name? I'm not sure I understand where to export a custom texture to exactly. My workspace is setup according to the Modding with Forge #1 - JDK, Eclipse, Forge and Gradle tutorial, thus my 'Package Explorer' directory structure is a little different.
Some food for thought: avoid anonymous classes and method cascading. While these provide syntactic sugar, they can be confusing to the less experienced.
Thank you for your work. I hope to see more of it.
See that up arrow?
https://gist.github.com/KaminoCoding/9a71b02ab6e8cdf6b525
I haven't Creative Tab and can't find my items!
You have to use the
in side each class file for your items... an example would be...
NOTE: don't copy and paste this... it probably isn't correct i'm just using it as a demonstration
Thanks dude! i'll add that to my tut asap!
I took screenshots of everything which can be found here: http://thexfactor117.imgur.com/
Thanks in advance!
in your BlockEbonyOre.class you should put these...
setBlockName();
setBlockTextureName();
setCreativeTab();
after this...
ebonyOre = new BlockEbonyOre(Material.rock) <--- Right here, so that it'll look like this
ebonyOre = new BlockEbonyOre(Material.rock).setBlockName("this is the name you use in the lang file").setBlockaTextureName(Reference.MODID + ":" + "the name of your image").setCreativeTab(CreativeTabs.tabBlock);
oh, and dont put your assets packages under src/main/resources put them under src/main/java
if it still wont work then, send me the error logs again!
Thank you for your help! i'll add look into it!
Try getting rid of the super constructor, it may not need to be there, i'll look into this more though