I have just recently taken up modding on (yes, believe it or not) Minecraft v1.8! So far, most everything is fairly basic, and there are plenty of tutorials out there, too!
One thing puzzles me, though, and maybe someone could shine some light on it for me...
I created a new block which I sub-classed from the BlockGlass class, and it renders perfectly (both item and block in-world). However, when I BREAK this block, I get the "default" stone block-break sound effect, instead of the "breaking glass" effect. Since I have seen NO tutorials on how to make your custom blocks work with Minecraft's existing sounds, I just assumed that a block sub-classed from GLASS would play that "breaking" sound "automagically", but I guess that I was wrong there!
i don't know if they changed it in 1.8, but in 1.7 i would use Material.glass and setStepSound(soundTypeGlass)
public class GlassBlock extends Block {
protected GlassBlock(String unlocalizedName, Material material) {
super(material);
this.setBlockName(unlocalizedName);
this.setBlockTextureName(Main.modid + ":" + unlocalizedName);
this.setStepSound(soundTypeGlass);
}
}
please only copy-paste the relevant stuff (the material argument and the setStepSound method), as most of this won't work in 1.8 afaik. now in my ModBlocks class' init() method (or wherever you register your Blocks), use
GameRegistry.registerBlock(glassBlock = new GlassBlock("glassBlock", Material.glass), "glassBlock");
again, the only important thing is that you use the Material.glass argument when creating the new block. to clarify this, you could also write it a bit longer, but with more overview:
public static final glassBlock; //declare your block<br /><br />public void init() {<br />glassBlock = new GlassBlock("glassBlock", Material.glass), //create your blockGameRegistry.registerBlock(glassBlock "glassBlock"); //register your block<br />}
That reply, although at first it sounded a bit "dodgy", as I was LOOKING for the "Block Break" sound effect (not the "stepping" sound, as the name of the method you suggested implies that it relates to), but I tried that, and it worked! In the constructor, for my sub-class of the BlockGlass class, exactly as you provided it. I was somewhat surprised, as I really don't know HOW anyone is supposed to intuitively know that this poorly-named method actually sets up ALL sounds for the block (I'm assuming that is does, as it certainly sets up the sounds for "stepping on" AND "breaking" the blocks...). But, hey, now that I know, all is good!
The following is my MC 1.8 class definition and constructor for the block I was referring to (a "tnt-proof" form of glass I liked that came as a
part of the Mystic mods (last seen in 1.7.10, sadly :-{ ). I am currently working to "port" the Mystic Mods to 1.8 (I need to discuss with the original author what to do about the NAME I'll provide for MY version of the mod; I'm not using ANY of the original code, just some (a lot) of the textures...). I'll call it something like "Mystic Revisited", or something, if he / she will let me ...).
public class TemperedGlassBlock extends BlockGlass {
// My constructor...
public TemperedGlassBlock(String unlocalizedName, Material material, boolean shouldSidesBeRendered, float hardness, float resistance) {
super(material, shouldSidesBeRendered);
this.setUnlocalizedName(unLocalizedName);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setHardness(hardness);
this.setResistance(resistance);
// Set up sound-FX for block...
// (Thanks to MCOfficer!)
this.setStepSound(soundTypeGlass);
}
...
}
I was already using Material.glass when I registered the block, but thanks for mentioning that for completeness!
Hello again!
I have just recently taken up modding on (yes, believe it or not) Minecraft v1.8! So far, most everything is fairly basic, and there are plenty of tutorials out there, too!
One thing puzzles me, though, and maybe someone could shine some light on it for me...
I created a new block which I sub-classed from the BlockGlass class, and it renders perfectly (both item and block in-world). However, when I BREAK this block, I get the "default" stone block-break sound effect, instead of the "breaking glass" effect. Since I have seen NO tutorials on how to make your custom blocks work with Minecraft's existing sounds, I just assumed that a block sub-classed from GLASS would play that "breaking" sound "automagically", but I guess that I was wrong there!
What do I need to do to fix this?
Thanks in advance from a modding "noob" :-}
i don't know if they changed it in 1.8, but in 1.7 i would use Material.glass and setStepSound(soundTypeGlass)
please only copy-paste the relevant stuff (the material argument and the setStepSound method), as most of this won't work in 1.8 afaik. now in my ModBlocks class' init() method (or wherever you register your Blocks), use
again, the only important thing is that you use the Material.glass argument when creating the new block. to clarify this, you could also write it a bit longer, but with more overview:
(i cant fix that f*cking codeblock... here's a link to the code: https://www.hastebin.com/tudaxafeze.scala )
oh, and if i were you, i would ask at minecraftforum -> mapping and modding -> mod development or at the forge forums instead.
hope that helped ;)
Thank you once again, MCOfficer!!!
That reply, although at first it sounded a bit "dodgy", as I was LOOKING for the "Block Break" sound effect (not the "stepping" sound, as the name of the method you suggested implies that it relates to), but I tried that, and it worked! In the constructor, for my sub-class of the BlockGlass class, exactly as you provided it. I was somewhat surprised, as I really don't know HOW anyone is supposed to intuitively know that this poorly-named method actually sets up ALL sounds for the block (I'm assuming that is does, as it certainly sets up the sounds for "stepping on" AND "breaking" the blocks...). But, hey, now that I know, all is good!
The following is my MC 1.8 class definition and constructor for the block I was referring to (a "tnt-proof" form of glass I liked that came as a
part of the Mystic mods (last seen in 1.7.10, sadly :-{ ). I am currently working to "port" the Mystic Mods to 1.8 (I need to discuss with the original author what to do about the NAME I'll provide for MY version of the mod; I'm not using ANY of the original code, just some (a lot) of the textures...). I'll call it something like "Mystic Revisited", or something, if he / she will let me ...).
I was already using Material.glass when I registered the block, but thanks for mentioning that for completeness!
Works like a champ!
Your my hero :-}
Thanks again!
ZTagre.