mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 13:09:59 +00:00
43 lines
2.6 KiB
Diff
43 lines
2.6 KiB
Diff
--- a/net/minecraft/client/particle/ParticleEngine.java
|
|
+++ b/net/minecraft/client/particle/ParticleEngine.java
|
|
@@ -63,7 +_,7 @@
|
|
private <T extends ParticleOptions> @Nullable Particle makeParticle(
|
|
final T options, final double x, final double y, final double z, final double xa, final double ya, final double za
|
|
) {
|
|
- ParticleProvider<T> provider = (ParticleProvider<T>)this.resourceManager.getProviders().get(BuiltInRegistries.PARTICLE_TYPE.getId(options.getType()));
|
|
+ ParticleProvider<T> provider = (ParticleProvider<T>)this.resourceManager.getProvider(options.getType());
|
|
return provider == null ? null : provider.createParticle(options, this.level, x, y, z, xa, ya, za, this.random);
|
|
}
|
|
|
|
@@ -111,6 +_,8 @@
|
|
return new ItemPickupParticleGroup(this);
|
|
} else if (type == ParticleRenderType.ELDER_GUARDIANS) {
|
|
return new ElderGuardianParticleGroup(this);
|
|
+ } else if (factories.containsKey(type)) {
|
|
+ return factories.get(type).apply(this);
|
|
} else {
|
|
return (ParticleGroup<?>)(type == ParticleRenderType.NO_RENDER ? new NoRenderParticleGroup(this) : new QuadParticleGroup(this, type));
|
|
}
|
|
@@ -120,8 +_,20 @@
|
|
this.trackedParticleCounts.addTo(limit, change);
|
|
}
|
|
|
|
+
|
|
+ private static final Map<ParticleRenderType, java.util.function.Function<ParticleEngine, ParticleGroup<?>>> factories = new java.util.HashMap<>();
|
|
+ private static final List<ParticleRenderType> particleRenderOrder = new java.util.ArrayList<>(RENDER_ORDER);
|
|
+
|
|
+ // Forge: allow custom particle groups
|
|
+ public static void registerParticleGroup(ParticleRenderType type, java.util.function.Function<ParticleEngine, ParticleGroup<?>> factory) {
|
|
+ if (factories.putIfAbsent(type, factory) != null) {
|
|
+ throw new IllegalArgumentException(type.name() + " already has a factory registered. Previous factory was " + factories.get(type) + ". This factory was " + factory);
|
|
+ }
|
|
+ particleRenderOrder.add(type);
|
|
+ }
|
|
+
|
|
public void extract(final ParticlesRenderState particlesRenderState, final Frustum frustum, final Camera camera, final float partialTickTime) {
|
|
- for (ParticleRenderType particleType : RENDER_ORDER) {
|
|
+ for (ParticleRenderType particleType : particleRenderOrder) { // Forge: allow custom ParticleRenderType's
|
|
ParticleGroup<?> particles = this.particles.get(particleType);
|
|
if (particles != null && !particles.isEmpty()) {
|
|
particlesRenderState.add(particles.extractRenderState(frustum, camera, partialTickTime));
|