Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

[TUT] How to make a block flammable without altering base files

tutorial flammability modding help howto block burn flame make

  • Please log in to reply
14 replies to this topic

#1

jaredjeya
  • Location: UK or Singapore
  • Minecraft: jaredjeya
  • Xbox:jaredjeya

Posted 11 April 2012 - 01:37 PM

How to make ANY block flammable!


When I made my first real mod, BetterDyes, I realised there were no tutorial on how to make blocks flammable without editing base files.

*Requires Minecraft Forge*


Of course, you could always edit the accessibility of the 'setBurnRate' method in Block.Fire, but then your mod has to be manually installed, and cannot just be plonked inside the mods folder. On top of this, you could have compatibility problems with anyone changing the behaviour of fire.

After investigating what the methods involved did, I realised they traced back to some protected variables and a public method in Block.java, which meant they could be accessed from other classes if need be.

private void setBurnRate(int par1, int par2, int par3)
	{
		Block.setBurnProperties(par1,  par2, par3);
	}

public static void setBurnProperties(int id, int encouragement, int flammability)
	{
		blockFireSpreadSpeed[id] = encouragement; /* &--#60;---This is protected */
		blockFlammability[id] = flammability; /* &--#60;---This is protected */
	}

As a result, one could use either the arrays themselves or the method to edit flammability. Here are two possible constructors for blocks (note the method can also be called in your mod_XXX file, but not the arrays. You will need to replace 'this' with the code name of your block.):

protected BlockYYY(int i, int j)
   {
	   super(i, Material.wood);
	   j = blockIndexInTexture;
	   setBurnProperties(this.blockID, 5, 5);
   }

OR

protected BlockZZZ(int i, int j)
	{
	   super(i, Material.wood);
	   blockIndexInTexture = j;
	   blockFireSpreadSpeed[this.blockID] = 5;
	   blockFlammability[this.blockID] = 20;
   }

The first array, or second parameter, is the chance that the block will set another nearby block on fire, while the second array, or third parameter, is how likely the block is to burn, and how quickly it does so. For reference, Wool has a value of 30:60, Planks have a value of 5:20, and Logs (Wood) have a value of 5:5 (see if you can guess what mod those are from!
Spoiler:

Have fun lighting up the world, and click '+' if it helped you!
Posted Image

Register or log in to remove.

#2

alexmack929
    alexmack929

    Lapis Lazuli Collector

  • Members
  • 1117 posts
  • Location: Manchester, UK
  • Minecraft: alexmack929

Posted 11 April 2012 - 01:41 PM

Great tutorial, and this may seem like a majorly noobish question, but

View Postjaredjeya, on 11 April 2012 - 01:37 PM, said:

just be plonked inside the mods folder


REALLY!?! You can do that!?!

Could you tell me how I can make my mod into a .jar so I can do this, it seems awesome if it's possible.

Posted Image


#3

jaredjeya
  • Location: UK or Singapore
  • Minecraft: jaredjeya
  • Xbox:jaredjeya

Posted 11 April 2012 - 01:48 PM

If you put all of your .jar files (post recompilation/obfuscation),into a folder or .zip, you can add them to the Modloader mods folder AS LONG AS THEY DO NOT OVERWRITE BASE FILES. Btw, I LOVE the idea of a hunger games mod Posted Image
Posted Image

#4

alexmack929
    alexmack929

    Lapis Lazuli Collector

  • Members
  • 1117 posts
  • Location: Manchester, UK
  • Minecraft: alexmack929

Posted 11 April 2012 - 01:51 PM

View Postjaredjeya, on 11 April 2012 - 01:48 PM, said:

If you put all of your .jar files (post recompilation/obfuscation),into a folder or .zip, you can add them to the Modloader mods folder AS LONG AS THEY DO NOT OVERWRITE BASE FILES. Btw, I LOVE the idea of a hunger games mod Posted Image

Haha, thanks.

Currently having massive problems with it though. :/

The tributes are spawning inside hills and trees. Posted Image

http://www.minecraft...-simple-matter/

Posted Image


#5

jaredjeya
  • Location: UK or Singapore
  • Minecraft: jaredjeya
  • Xbox:jaredjeya

Posted 11 April 2012 - 01:54 PM

I'm not much of an entity person (yet - I want to make coloured sand, needs to obey physics) so I wouldn't know, but try making sure that the block they are on is solid, and the blocks above are air or non-solid. I know it is possible due to suitable-place checking for vanilla mobs. Do they start at spawn?
Posted Image

#6

goku454545
  • Minecraft: goku454545

Posted 15 April 2012 - 09:46 PM

View Postjaredjeya, on 11 April 2012 - 01:37 PM, said:

After investigating what the methods involved did, I realised they traced back to some protected variables and a public method in Block.java, which meant they could be accessed from other classes if need be.

i'm not quite understanding, which method allows it to be accessed?

#7

SpeedStar5
  • Location: UK
  • Minecraft: blake5961

Posted 15 April 2012 - 10:07 PM

Nice to see a new tutorial up but you posted it in the wrong section mate =p Shoulda been posted in Tutorial section
If I have been helpful then +Rep  would be nice :3  That's the button over there -->

#8

jaredjeya
  • Location: UK or Singapore
  • Minecraft: jaredjeya
  • Xbox:jaredjeya

Posted 15 April 2012 - 10:16 PM

View PostSpeedStar5, on 15 April 2012 - 10:07 PM, said:

Nice to see a new tutorial up but you posted it in the wrong section mate =p Shoulda been posted in Tutorial section

If a moderator sees this, please move the post.

View Postgoku454545, on 15 April 2012 - 09:46 PM, said:



i'm not quite understanding, which method allows it to be accessed?

The method Block.setBurnProperties can be accessed from anywhere, e.g a mod init() method, but you could set the arrays manually from a class extending block (eg BlockDirt). I prefer to put the method in my block constructor. This allows you to alter the burn rates of all blocks.

Posted Image

#9

goku454545
  • Minecraft: goku454545

Posted 15 April 2012 - 10:42 PM

seems that setBurnProperties inside of block.java doesnt exist for me....

#10

jaredjeya
  • Location: UK or Singapore
  • Minecraft: jaredjeya
  • Xbox:jaredjeya

Posted 16 April 2012 - 01:01 PM

Hmm.  I decompiled with forge, so it may have been a hook added by forge. I'll check again when I can, and if necessary alter the tutorial to say 'requires forge'. I am going to be away from a computer for a while so it might be better if you check yourself.
Posted Image

#11

goku454545
  • Minecraft: goku454545

Posted 16 April 2012 - 03:03 PM

that's probably it, i'm using modloader

#12

Casey1201
  • Location: The States
  • Minecraft: Casey1201

Posted 03 June 2012 - 05:00 PM

Thank you so much!
*tips hat
Posted Image

#13

El_Alamein

Posted 03 June 2012 - 10:44 PM

I just use flint and steel but OK

#14

POTATO321123
  • Minecraft: mr_screwy

Posted 03 June 2012 - 10:48 PM

AARRRGGG TO COMPLICATED

#15

jaredjeya
  • Location: UK or Singapore
  • Minecraft: jaredjeya
  • Xbox:jaredjeya

Posted 04 June 2012 - 01:26 AM

View PostEl_Alamein, on 03 June 2012 - 10:44 PM, said:

I just use flint and steel but OK

This is a mod tutorial! If you just want to set something alight, use flint and steel.

View PostPOTATO321123, on 03 June 2012 - 10:48 PM, said:

AARRRGGG TO COMPLICATED

Sorry about that, I've designed this for people who already have some modding experience.
Posted Image