|
7 | 7 | import net.minecraft.client.particle.ParticleManager; |
8 | 8 | import net.minecraft.client.particle.ParticleTextureSheet; |
9 | 9 | import org.spongepowered.asm.mixin.Mixin; |
10 | | -import org.spongepowered.asm.mixin.gen.Accessor; |
| 10 | +import org.spongepowered.asm.mixin.Shadow; |
11 | 11 | import org.spongepowered.asm.mixin.injection.At; |
12 | 12 | import org.spongepowered.asm.mixin.injection.Redirect; |
13 | 13 |
|
|
16 | 16 |
|
17 | 17 | @Mixin(ParticleManager.class) |
18 | 18 | public abstract class ParticleManagerMixin { |
19 | | - @Accessor("newParticles") |
20 | | - public abstract Queue<Particle> getNewParticles(); |
| 19 | + @Shadow |
| 20 | + private Map<ParticleTextureSheet, Queue<Particle>> particles; |
21 | 21 |
|
22 | | - @Accessor("particles") |
23 | | - public abstract Map<ParticleTextureSheet, Queue<Particle>> getParticles(); |
| 22 | + @Shadow |
| 23 | + private Queue<Particle> newParticles; |
24 | 24 |
|
25 | 25 | @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Ljava/util/Queue;poll()Ljava/lang/Object;")) |
26 | 26 | public Object changeMaxParticles(Queue<Object> queue) { |
27 | 27 | // 不需要判断 EnabledParticleCountInject 了,已在注入时判断,关这个一般都是因为会注入失败,所以不用担心 |
28 | 28 | Particle particle; |
29 | 29 | int limit = APIConfigManager.getConfig().getParticleCountLimit(); |
30 | | - while ((particle = this.getNewParticles().poll()) != null) { |
31 | | - Map<ParticleTextureSheet, Queue<Particle>> particles = this.getParticles(); |
| 30 | + while ((particle = newParticles.poll()) != null) { |
32 | 31 | Queue<Particle> queue1 = particles.computeIfAbsent(particle.getType(), |
33 | | - sheet -> EvictingQueue.create(limit)); |
34 | | - // limit 不会改变,这里可以直接判断 |
| 32 | + sheet -> EvictingQueue.create(limit)); |
| 33 | + // limit 在程序生命周期内不会改变,这里可以直接判断 |
35 | 34 | if (queue1.size() < limit) { |
36 | 35 | queue1.add(particle); |
37 | 36 | } else { |
|
0 commit comments