Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.1]Randomly set fire to nearby wooden blocks.
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 2
PlayPrey

[1.12.1]Randomly set fire to nearby wooden blocks.

By PlayPrey, September 5, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

PlayPrey    0

PlayPrey

PlayPrey    0

  • Tree Puncher
  • PlayPrey
  • Members
  • 0
  • 26 posts
Posted September 5, 2017

Greetings,-

 

I am trying to have my block "emulate" being so hot it sets nearby wooden structure on fire.

 

I have looked trough BlockFire and BlockLiquid in attempt to figure out how it's done, but to no success.

 

Am I looking in the right classes even? 

  • Quote

Share this post


Link to post
Share on other sites

PlayPrey    0

PlayPrey

PlayPrey    0

  • Tree Puncher
  • PlayPrey
  • Members
  • 0
  • 26 posts
Posted September 5, 2017

Well I had forgotten to enable ticking on the block... Now to figure out the following error: 

Spoiler

Caused by: java.lang.IllegalArgumentException:

Cannot get property PropertyInteger{name=age, clazz=class java.lang.Integer, values=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]} as it does not exist in BlockStateContainer{block=ppextreme:tungstenlight, properties=[]}


    at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:204) ~[BlockStateContainer$StateImplementation.class:?]

 

  • Quote

Share this post


Link to post
Share on other sites

Busti    72

Busti

Busti    72

  • Dragon Slayer
  • Busti
  • Forge Modder
  • 72
  • 588 posts
Posted September 5, 2017 (edited)

Set the flag setTickRandomly(true); in your block.

 

Then Override randomTick in your block class.

Create a x,y,z for loop around your block using the givens BlockPos : pos.getX() pos.getY() and pos.getZ() as your origin.

Use worldIn.getBlockState(pos) == Blocks.AIR.getDeraultState() to check if a block is air.
You can then check the block underneath it for not being air using almost the same code in order to get blocks with air over them around your block.

Once you found such a block set it aflame using worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState())

 

BUT WAIT! That sets all blocks on fire every time a random tick happens!

 

Use the given `random` to only set a couple blocks aflame like this:

if (random.nextFloat() < 0.1f) {
    worldIn.setBlockState(pos, Blocks.FIRE.getDefaultState());
}

 

Where the floating point number is the chance of a block catching fire.

Edited September 5, 2017 by Busti
Formatting
  • Quote

Share this post


Link to post
Share on other sites

IceMetalPunk    22

IceMetalPunk

IceMetalPunk    22

  • Diamond Finder
  • IceMetalPunk
  • Members
  • 22
  • 374 posts
Posted September 5, 2017
29 minutes ago, PlayPrey said:

Well I had forgotten to enable ticking on the block... Now to figure out the following error: 

  Hide contents

Caused by: java.lang.IllegalArgumentException:

Cannot get property PropertyInteger{name=age, clazz=class java.lang.Integer, values=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]} as it does not exist in BlockStateContainer{block=ppextreme:tungstenlight, properties=[]}


    at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:204) ~[BlockStateContainer$StateImplementation.class:?]

 

As it says, the property "age" doesn't exist in the block "ppextreme:tungstenlight". Does your block have a property called "age", and are you returning the proper block state container in the block's createBlockState method?

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2090

Draco18s

Draco18s    2090

  • Reality Controller
  • Draco18s
  • Members
  • 2090
  • 14008 posts
Posted September 5, 2017
1 hour ago, Busti said:

Use worldIn.getBlockState(pos) == Blocks.AIR.getDeraultState() to check if a block is air.

Actually you use use .isAir() instead. Mods may add blocks that they wish to be treated as air (for example, Greg's Lighting's spotlight, which creates a column of blocks that are light sources, but should otherwise be treated as air).

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

Busti    72

Busti

Busti    72

  • Dragon Slayer
  • Busti
  • Forge Modder
  • 72
  • 588 posts
Posted September 5, 2017

Good point @Draco18s

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Rohman
      [1.12.2 Build 2847] Server Crash on startup

      By Rohman · Posted 26 minutes ago

      Here you go. Thanks for having a look. debug(1).log
    • diesieben07
      Server Cannot Start

      By diesieben07 · Posted 47 minutes ago

      You installed a client-only mod (Controllable) on the server. Mods have the ability to indicate their client-only-ness to Forge and it will not load the mod on a server. This mod has not done so, please report this bug to the mod author.
    • diesieben07
      [1.12.2] How do i make it so my sword renders in my mobs hand?.

      By diesieben07 · Posted 53 minutes ago

      Why would you replace them?! This is a simple method override and you are calling super. There is no need to replace anything. Again: Please learn Java basics before making a mod.
    • diesieben07
      [1.12.2 Build 2847] Server Crash on startup

      By diesieben07 · Posted 56 minutes ago

      Post the debug.log file.
    • diesieben07
      Need your help pls

      By diesieben07 · Posted 57 minutes ago

      1.8.9 is no longer supported on this forum due to it's age. Update to a modern version of Minecraft to receive support.
  • Topics

    • Rohman
      2
      [1.12.2 Build 2847] Server Crash on startup

      By Rohman
      Started 1 hour ago

    • The_Unkown675
      1
      Server Cannot Start

      By The_Unkown675
      Started 4 hours ago

    • J0WAY
      17
      [1.12.2] How do i make it so my sword renders in my mobs hand?.

      By J0WAY
      Started Thursday at 10:10 PM

    • _jiriik_
      1
      Need your help pls

      By _jiriik_
      Started 2 hours ago

    • Kuaka
      0
      My Forge 1.12 and 1.12.2 Keep Crashing when i start it up

      By Kuaka
      Started 1 hour ago

  • Who's Online (See full list)

    • Ugdhar
    • vaartis
    • HussNuss
    • AkosM
    • Gnaux
    • Ollie_Bear
    • Kuaka
    • AdieCraft
    • cookiedragon234
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.1]Randomly set fire to nearby wooden blocks.
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community