Jump to content

Custom Rain Effect? (Visual Only)


bradsk88

Recommended Posts

Hello,

For my mod, I'm interested in adding a custom type of "storm".  It would purely be a visual effect and does not need to impose any of the other effects that come from rain (e.g. putting out fires).

What would be the best option? I haven't found any other examples of this online.

My current approach is to spawn a bunch of Minecraft "RAIN" particle in a radius around the player - but to create an effective result I feel I will need to add a large number of particles and worry that would introduce lag.

Thanks for any help.

 

My current experimental implementation piggybacks off one of my crop entities to spawn particles around each player in the world - but I'm still just testing things out.

 


    @Override
    public void animateTick(BlockState p_180655_1_, World world, BlockPos p_180655_3_, Random p_180655_4_) {
        super.animateTick(p_180655_1_, world, p_180655_3_, p_180655_4_);
        for (PlayerEntity p : world.players()) {
            Vector3d position = p.getPosition(0);
            BlockPos blockPos = new BlockPos(position);
            // Instead of using directions, randomly spawn particles in a zone around the player
            for (Direction dir : Direction.values()) {
                BlockPos bpO = blockPos.relative(dir);
                for (Direction d2 : Direction.values()) {
                    BlockPos bp = bpO.relative(d2);
                    world.addParticle(ParticleTypes.RAIN, bp.getX(), bp.getY() + 1, bp.getZ(), 0.0D, 0.0D, 0.0D);
                }
            }
        }
    }

151856845-dce5f4e6-e449-4976-aa3a-81932f151856938-5430d258-e29c-4325-a0f2-f87f49

Edited by bradsk88
Link to comment
Share on other sites

  • 2 weeks later...

Figured it out.

 153699589-f774e340-cfcd-44a1-a279-d46e2d

TLDR

  • Enqueue work in FMLClientSetupEvent
  • In that work, grab the Overworld's DimensionRenderInfo and call setWeatherRenderHandler on it with your custom renderer.
  • In the renderer, copy the minecraft rain code and:
    • Provide your own ResourceLocation for RAIN_LOCATION
    • Remove the "-" from f3 value (I also multiplied it by 0.2 to slow down the rain)

Source

https://github.com/bradsk88/EurekaCraft/compare/4cfd071e8f5079184fb9be6a69b4316ce76c2d46...d13be10e423955eb4341f05ec94d46865adb1436

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