BLOCK_PHYSICS and melting ice

Discussion in 'Plugin Development' started by Bone008, Jun 12, 2011.

Thread Status:
Not open for further replies.
  1. I'm trying to write a plugin to prevent ice from melting (in short).
    My attempt to capture such an event is the BLOCK_PHYSICS-event. I did a lot of debugging and found out the following:
    1. When a block changes (e.g. due to block placing/destroying), the event is called for every adjacent block but NOT for the block itself!
    2. The only information about the actual changed block is event.getChangedType(), which gives you its NEW Material.
    3. You can't even get a Block-Instance of the block that changed.
    4. When ice melts, it doesn't fire an own BLOCK_PHYSICS-event. The getChangedType()-method of the fired events only returns the new water-materials.
    So when ice melts, you never receive an event containing ice (neither the actual getBlock() nor the getChangedType()).
    All you get is the adjacent blocks updating - but due to the new water-block.

    Does anyone have an idea of how to notice when an ice block melts? Maybe there is another event I didn't notice?

    Thank you.
     
  2. Offline

    Meta1203

    Couldn't you change the water block back to ice when the BLOCK_PHYSICS event fires? As of yet, i know nothing that creates water using physics. You might want to try that, but do some rigorous bug testing first.​
     
  3. That's the problem! The BLOCK_PHYSICS event isn't called for the ice-block itself but only for the surrounding ones (see 1. in the op).

    Is there noone with an idea?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  4. Maybe try checking the biome type, if it's tundra or something then change the block back to ice.
     
  5. Damn, nobody is getting my problem.
    @Adamki11s
    The problem is knowing "the block" when it's melting. As described above, the blockPhysicsEvent isn't called with the required parameters to recognize it as a melting ice block.
     
  6. @Bone008 I know but you said it calls every adjacent blocks so wouldn't that be 8 blocks called. From that you could calculate the position of the 'unknown' block. Let the 1's represent the blocks you know and the 0 the block changing.

    111
    101
    111
     
  7. @Adamki11s Well, this could probably work if it's more or less completely surrounded by blocks. But not if it's only standing on a single block or sth like that.
    However, locationg the block isn't the only problem. Since BLOCK_PHYSICS is called everytime a block state updates, you can't even know if it was an ice block melting or just a water source placed!

    To clarify this, that's what's called when ice melts in this situation
    a a a
    d i d
    d d d
    a = air; d = dirt; i = ice

    BLOCK_PHYSICS (open)

    getBlock() = the dirt-block on the left
    getChangedType() = Material.WATER

    getBlock() = the dirt-block on the right
    getChangedType() = Material.WATER

    getBlock() = the dirt-block at the bottom center
    getChangedType() = Material.WATER


    It never occurrs anything with ice ...
     
  8. Hmm, I see your problem. Are you sure there's no way to get the block changed? That seems strange.
     
  9. Offline

    Sethcran

    I had a rather similar problem attempting to prevent water from freezing, and I only succeeded in making acid that began to dissolve the land of my world, lol.

    There are some pull requests on the bukkit github of people that have implemented events for these, and I would love to see them implemented, unless someone can come up with a good way to do it with what we have now anyways.
     
  10. Offline

    rominos2

    +1

    BlockPhysics returns nothing interesting in fact ^^
    Hope it will be modified
     
Thread Status:
Not open for further replies.

Share This Page