Bedrock...

  • 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

ILoveGregTech

New Member
Jul 29, 2019
788
0
0
So if I edit bedrock in the block.Block classfile of Vanilla minecraft would that cause it become incompatible with other mods? Is it ill advised? I know it may break that balance of other mods but if I were to edit:
Code:
public static final Block bedrock = (new Block(7, Material.rock)).setBlockUnbreakable().setResistance(6000000.0F).setStepSound(soundStoneFootstep).setUnlocalizedName("bedrock").disableStats().setCreativeTab(CreativeTabs.tabBlock);
to
Code:
public static final Block bedrock = (new Block(7, Material.rock)).setHardnes(_____.F).setResistance(6000000.0F).setStepSound(soundStoneFootstep).setUnlocalizedName("bedrock").disableStats().setCreativeTab(CreativeTabs.tabBlock);
would it cause any major errors?

edit so in my baseclass file where I register everything would this work?
Code:
public static final Block bedrock = (new Block(7, Material.rock)).setHardness(100.0F).setResistance(5000.0F).setUnlocalizedName("bedrock").setCreativeTab(CreativeTabs.tabBlock);
 

CrafterOfMines57

New Member
Jul 29, 2019
275
0
0
I believe Reflection can do what you want without having to screw with actual values, thus leaving no question as to whether your mod would be Forge Compatible or not.
 

ILoveGregTech

New Member
Jul 29, 2019
788
0
0
I believe Reflection can do what you want without having to screw with actual values, thus leaving no question as to whether your mod would be Forge Compatible or not.
First off how come it is every time I have a code question I can count on you lol?
Also how would I do that?
 

CrafterOfMines57

New Member
Jul 29, 2019
275
0
0
Also how would I do that?
TO THE TUTORIALS/APIS OF COURSE! :D (specifically the classes and members sections of those tutorials, and most likely the .set(Obj o, Obj value) method of the field class, I think)

EDIT: You might also want to get the Field first, and use .setAccessible(true) on it, if necessary.

EDIT2: Upon further examination, use of .set (at least how I was doing it) screws with FML's state, .get(Object obj) is your friend.
 

CrafterOfMines57

New Member
Jul 29, 2019
275
0
0
Mother of god English please!! :p
How's Java?

try{
Field fi = null;

for(Field f : Block.class.getDeclaredFields())
{
if(f.getName().equals("bedrock"))
{
fi = f;
}
}

Object o = fi.get(DGlass); //DGlass being an object of Block type
Block bedrock = (Block) o; //Casting o to a block so you can screw with its fields
bedrock.setHardness(1); // 1 being your number here, because all setBlockUnbreakable() does is makes the hardness = -1

}catch(Exception e)
{
System.err.println(e.getClass().getName());
}

As a side note, you might want to understand how this code works, it is a very good idea to have a solid understanding of Reflection in modding.
 

ILoveGregTech

New Member
Jul 29, 2019
788
0
0
How's Java?

try{
Field fi = null;

for(Field f : Block.class.getDeclaredFields())
{
if(f.getName().equals("bedrock"))
{
fi = f;
}
}

Object o = fi.get(DGlass); //DGlass being an object of Block type
Block bedrock = (Block) o; //Casting o to a block so you can screw with its fields
bedrock.setHardness(1); // 1 being your number here, because all setBlockUnbreakable() does is makes the hardness = -1

}catch(Exception e)
{
System.err.println(e.getClass().getName());
}

As a side note, you might want to understand how this code works, it is a very good idea to have a solid understanding of Reflection in modding.
OK I'll look into it more. Right now it's close to my sleepy sleep time and I don't feel like getting a headache(which is what watching/reading java tutorials usually does) thanks for the code also btw :)
and for the .setHardness wouldn't that be a float and also would I be able to put anything in there? to make it hard but breakable?
 

CrafterOfMines57

New Member
Jul 29, 2019
275
0
0

Attachments

  • 2013-05-16_21.20.58.png
    2013-05-16_21.20.58.png
    143.9 KB · Views: 85