Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new MobEffect constructor that allows specifying a particle factory #1578

Open
wants to merge 1 commit into
base: 1.21.x
Choose a base branch
from

Conversation

ChampionAsh5357
Copy link
Contributor

Closes #1558

Currently, the mob effect can specify a ParticleOptions to handle what particles should be displayed. However, as the particle options may contain modded entries that may not exist at the time of the mob effect initialization, the options need to be deferred somewhat. This is normally done with a supplier, but since there is already a factory that the option is delegated to, I opted to simply expose it as a parameter.

@ChampionAsh5357 ChampionAsh5357 added the 1.21.1 Targeted at Minecraft 1.21.1 label Oct 2, 2024
@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented Oct 2, 2024

  • Publish PR to GitHub Packages

Last commit published: 1f1fb37123677da07b215b54e5c64684af26b170.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #1578' // https://github.com/neoforged/NeoForge/pull/1578
        url 'https://prmaven.neoforged.net/NeoForge/pr1578'
        content {
            includeModule('net.neoforged', 'neoforge')
            includeModule('net.neoforged', 'testframework')
        }
    }
}

MDK installation

In order to setup a MDK using the latest PR version, run the following commands in a terminal.
The script works on both *nix and Windows as long as you have the JDK bin folder on the path.
The script will clone the MDK in a folder named NeoForge-pr1578.
On Powershell you will need to remove the -L flag from the curl invocation.

mkdir NeoForge-pr1578
cd NeoForge-pr1578
curl -L https://prmaven.neoforged.net/NeoForge/pr1578/net/neoforged/neoforge/21.1.67-pr-1578-fix-mobeffect-particleoptions/mdk-pr1578.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip

To test a production environment, you can download the installer from here.

@Shadows-of-Fire
Copy link
Contributor

Yeah I think this is the best solution. Unfortunately, ParticleOptions is a bit of a mess, since MobEffect is dependent on it, but it is natively dependent on both Item and Block. In the vanilla order, MobEffect is before both Item and Block, so trying to shuffle the registry order around for correctness would be incredibly annoying.

@Shadows-of-Fire Shadows-of-Fire changed the title Add MobEffect Constructor For Particle Factory Add new MobEffect constructor that allows specifying a particle factory Oct 8, 2024
this.particleFactory = p_333515_ -> p_333716_;
}

+ protected MobEffect(MobEffectCategory category, int color, Function<MobEffectInstance, ParticleOptions> particleFactory) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a javadoc comment to this constructor, not necessarily to inform the users of the parameters (they're pretty self-explanatory), but do to the following:

  1. Inform the user this is a patched-in ctor (i.e. add a Neo: header)
  2. Inform the user that they should use this constructor over the ParticleOptions one if using a ParticleOptions that depends on other registry entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.1 Targeted at Minecraft 1.21.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Initialize ParticleType registry before MobEffects
3 participants