Jump to content

Recommended Posts

Posted

Bukkit has an event which can be used to modify the result of mixing lava and water. I'm wondering if Forge has something similar. I don't see anything in net.minecraft,block.BlockLiquid.checkForMixing, but I thought I'd double check here before I try anything too complex.

 

My intention is to modify minecraft's behavior such that you can get granite etc. from a cobblestone generator.

 

Posted (edited)

Would this not be possible (but ugly) with an IWorldEventListener & overriding IWorldEventListener::notifyBlockUpdate? Would require some guess-work to make sure it was indeed placed by BlockLiquid::checkForMixing, but should be viable.

Edited by Matryoshika
  • Like 1

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted

It is possible; I've confirmed that this code has the desired effect:

public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, IBlockState newState, int flags){
    if (oldState.getBlock() != Blocks.FLOWING_LAVA) return;
    if (newState.getBlock() != Blocks.COBBLESTONE) return;

    boolean adjacentToWater = false;
    if (worldIn.getBlockState(pos.north()).getMaterial() == Material.WATER) adjacentToWater = true;
    if (worldIn.getBlockState(pos.south()).getMaterial() == Material.WATER) adjacentToWater = true;
    if (worldIn.getBlockState(pos.east() ).getMaterial() == Material.WATER) adjacentToWater = true;
    if (worldIn.getBlockState(pos.west() ).getMaterial() == Material.WATER) adjacentToWater = true;
    if (worldIn.getBlockState(pos.down() ).getMaterial() == Material.WATER) adjacentToWater = true;
    if (worldIn.getBlockState(pos.up()   ).getMaterial() == Material.WATER) adjacentToWater = true;
    if(!adjacentToWater) return;

    worldIn.setBlockState(pos, Blocks.DIAMOND_BLOCK.getDefaultState());
}

But like you said, I'm using guess-work.

 

I would still be interested in submitting a PR - if my technical knowledge extended to all that "@@ -452,4 +452,29 @@" stuff in BlockLiquid.java.patch. I don't suppose anyone has suggestions for topics to google?

 

Posted

You don't write the patches yourself, you set up a Forge workspace, make your changes to the appropriate Vanilla classes and then run the genPatches Gradle task to re-generate the patches with your changes.

 

Forge's documentation explains how to contribute to Forge here and here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.