Jump to content

[1.8] setHardness, setResistance, setStepSound are "protected"!?


MrJPGames

Recommended Posts

So I was trying to update my mod to 1.8 (and yes I know it's in it's early stages right now). But it seems like these three functions (setHardness, setResistance, setStepSound) are protected in the Block class of Minecraft. Is there a workaround or do I just wait for the next update of FML for 1.8?

I try not to be mean about your english (as my own isn't the best either) but sometimes I can't help myself!

If you get mad at me for this or any other reason, please look at the profile picture so you'll feel better (and pretier) than me!

Thanks.

Link to comment
Share on other sites

Well, you would only call them from your Block class anyways, so there is no problem.

I don't quite understand what you mean. I could add them to my own block class but I think that wouldn't work correctly, if that is the way could you try to be a little more specific on how to do so!

 

Here is the code I use for the adding the block:

public static final Block SapphireBlock = new MT_Block (235, 7).setHardness(2F).setResistance(4F).setStepSound(Block.soundTypeStone).setUnlocalizedName("SapphireBlock").setBlockTextureName("moretools:SapphireBlock");

Here is the MT_Block file:

package MoreTools;

import java.util.Random;

import net.minecraftforge.*;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
public class MT_Block extends Block
{
    public MT_Block(int par1, int par2)
    {
        super(Material.iron);
        this.setCreativeTab(CreativeTabs.tabBlock);
    }
    

}

I try not to be mean about your english (as my own isn't the best either) but sometimes I can't help myself!

If you get mad at me for this or any other reason, please look at the profile picture so you'll feel better (and pretier) than me!

Thanks.

Link to comment
Share on other sites

Call them from the Block's constructor.

 

public final class SomeBlock extends Block
{
    public SomeBlock()
    {
        super(Material.rock);
        setHardness(1.0F);
    }
}

 

To be honest, the block class shouldn't be treated as a 'Builder' class, and those methods should be void rather than 'chaining'.

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

Link to comment
Share on other sites

Its about time... I always thought that was odd about most people's 1.7 code. I feel like one tutorial chained the calls that way to keep all the code in the main mod file and then many modders/newer programmers just thought that was how it worked!

I'll need help, and I'll give help. Just ask, you know I will!

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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