Skip to content

Commit 6248e86

Browse files
committed
fix
1 parent ed3a87c commit 6248e86

11 files changed

Lines changed: 40 additions & 31 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ mod_name=MadParticle
3535
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
3636
mod_license=GNU GPL 3.0
3737
# The mod version. See https://semver.org/
38-
mod_version=26.1.2-4
38+
mod_version=26.1.2-5
3939
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
4040
# This should match the base package used for the mod sources.
4141
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

src/main/java/cn/ussshenzhou/madparticle/mixin/compat/IrisFinalPassRendererMixin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public class IrisFinalPassRendererMixin {
1818
@Inject(method = "renderFinalPass", at = @At(value = "INVOKE", target = "Lnet/irisshaders/iris/gl/GLDebug;popGroup()V", shift = At.Shift.BEFORE), require = 0)
1919
private void madparticleRender(CallbackInfo ci) {
2020
if (MadParticle.irisOn) {
21-
NeoInstancedRenderManager.getInstance(ModParticleRenderTypes.INSTANCED).render();
22-
NeoInstancedRenderManager.getInstance(ModParticleRenderTypes.INSTANCED_TERRAIN).render();
21+
NeoInstancedRenderManager.forEach(NeoInstancedRenderManager::render);
2322
}
2423
}
2524
}

src/main/java/cn/ussshenzhou/madparticle/particle/enums/TakeOver.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.google.common.collect.Sets;
88
import com.mojang.logging.LogUtils;
99
import net.minecraft.client.particle.*;
10-
import net.minecraft.world.level.block.Block;
1110
import org.jspecify.annotations.Nullable;
1211

1312
import java.util.HashSet;
@@ -91,12 +90,14 @@ public enum TakeOver implements ITranslatable {
9190
);
9291
@SuppressWarnings("unchecked")
9392
private static final HashSet<Class<? extends Particle>> RENDER_BLACKLIST = Sets.newHashSet(
94-
//TODO support item atlas
93+
);
94+
95+
private static final HashSet<Class<? extends SingleQuadParticle>> ITEM_ATLAS = Sets.newHashSet(
9596
BlockMarker.class,
9697
BreakingItemParticle.class
9798
);
9899
@SuppressWarnings("unchecked")
99-
private static final HashSet<Class<? extends SingleQuadParticle>> RENDER_VANILLA = Sets.newHashSet(
100+
private static final HashSet<Class<? extends SingleQuadParticle>> PARTICLE_ATLAS = Sets.newHashSet(
100101
SnowflakeParticle.class,
101102
SpitParticle.class,
102103
SpellParticle.class,
@@ -160,25 +161,34 @@ public static ParticleRenderType map(Particle particle) {
160161
if (!(particle instanceof SingleQuadParticle)) {
161162
return originalType;
162163
}
163-
if (originalType == ModParticleRenderTypes.INSTANCED || originalType == ModParticleRenderTypes.INSTANCED_TERRAIN) {
164+
if (originalType == ModParticleRenderTypes.INSTANCED || originalType == ModParticleRenderTypes.INSTANCED_TERRAIN || originalType == ModParticleRenderTypes.INSTANCED_ITEM) {
164165
return originalType;
165166
}
166167
return switch (originalType.name()) {
167168
case "INSTANCED" -> ModParticleRenderTypes.INSTANCED;
168169
case "INSTANCED_TERRAIN" -> ModParticleRenderTypes.INSTANCED_TERRAIN;
170+
case "INSTANCED_ITEM" -> ModParticleRenderTypes.INSTANCED_ITEM;
169171
case "SINGLE_QUADS" -> switch (ConfigHelper.getConfigRead(MadParticleConfig.class).takeOverRendering) {
170172
case NONE -> originalType;
171173
case ALL -> {
172-
if (particle instanceof TerrainParticle) {
174+
if (RENDER_BLACKLIST.contains(particle.getClass())) {
175+
yield ParticleRenderType.SINGLE_QUADS;
176+
} else if (particle instanceof TerrainParticle) {
173177
yield ModParticleRenderTypes.INSTANCED_TERRAIN;
178+
} else if (ITEM_ATLAS.contains(particle.getClass())) {
179+
yield ModParticleRenderTypes.INSTANCED_ITEM;
174180
}
175-
yield RENDER_BLACKLIST.contains(particle.getClass()) ? ParticleRenderType.SINGLE_QUADS : ModParticleRenderTypes.INSTANCED;
181+
yield ModParticleRenderTypes.INSTANCED;
176182
}
177183
case VANILLA -> {
178184
if (particle instanceof TerrainParticle) {
179185
yield ModParticleRenderTypes.INSTANCED_TERRAIN;
186+
} else if (ITEM_ATLAS.contains(particle.getClass())) {
187+
yield ModParticleRenderTypes.INSTANCED_ITEM;
188+
} else if (PARTICLE_ATLAS.contains(particle.getClass())) {
189+
yield ModParticleRenderTypes.INSTANCED;
180190
}
181-
yield RENDER_VANILLA.contains(particle.getClass()) ? ModParticleRenderTypes.INSTANCED : originalType;
191+
yield originalType;
182192
}
183193
};
184194
default -> originalType;

src/main/java/cn/ussshenzhou/madparticle/particle/enums/TakeOverType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
public enum TakeOverType implements ITranslatable {
1515
INSTANCED("gui.mp.de.helper.render_type.instanced"),
1616
INSTANCED_TERRAIN("gui.mp.de.helper.render_type.terrain"),
17+
INSTANCED_ITEM("gui.mp.de.helper.render_type.item"),
1718
DEFAULT("gui.mp.de.helper.render_type.default");
1819

1920
private final String translateKey;

src/main/java/cn/ussshenzhou/madparticle/particle/enums/TakeOverTypeUtilC.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public static SingleQuadParticle.Layer getLayer(TakeOverType t) {
1010
return switch (t) {
1111
case INSTANCED, DEFAULT -> SingleQuadParticle.Layer.TRANSLUCENT;
1212
case INSTANCED_TERRAIN -> SingleQuadParticle.Layer.TRANSLUCENT_TERRAIN;
13+
case INSTANCED_ITEM -> SingleQuadParticle.Layer.TRANSLUCENT_ITEMS;
1314
};
1415
}
1516

@@ -18,6 +19,7 @@ public static ParticleRenderType getParticleRenderType(TakeOverType t) {
1819
case INSTANCED -> ModParticleRenderTypes.INSTANCED;
1920
case INSTANCED_TERRAIN -> ModParticleRenderTypes.INSTANCED_TERRAIN;
2021
case DEFAULT -> ParticleRenderType.SINGLE_QUADS;
22+
case INSTANCED_ITEM -> ModParticleRenderTypes.INSTANCED_ITEM;
2123
};
2224
}
2325
}

src/main/java/cn/ussshenzhou/madparticle/particle/render/ModParticleRenderTypes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ public class ModParticleRenderTypes {
1414
public static final ParticleRenderType INSTANCED = new ParticleRenderType("INSTANCED");
1515

1616
public static final ParticleRenderType INSTANCED_TERRAIN = new ParticleRenderType("INSTANCED_TERRAIN");
17+
18+
public static final ParticleRenderType INSTANCED_ITEM = new ParticleRenderType("INSTANCED_ITEM");
1719
}

src/main/java/cn/ussshenzhou/madparticle/particle/render/NeoInstancedRenderManager.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,16 @@ public NeoInstancedRenderManager(Identifier usingAtlas) {
5858
static final NeoInstancedRenderManager[] MANAGER_BY_RENDER_TYPE = new NeoInstancedRenderManager[]{
5959
new NeoInstancedRenderManager(TextureAtlas.LOCATION_PARTICLES),
6060
new NeoInstancedRenderManager(TextureAtlas.LOCATION_BLOCKS),
61+
new NeoInstancedRenderManager(TextureAtlas.LOCATION_ITEMS),
6162
};
6263

6364
public static NeoInstancedRenderManager getInstance(ParticleRenderType renderType) {
6465
if (renderType == ModParticleRenderTypes.INSTANCED) {
6566
return MANAGER_BY_RENDER_TYPE[0];
67+
} else if (renderType == ModParticleRenderTypes.INSTANCED_TERRAIN) {
68+
return MANAGER_BY_RENDER_TYPE[1];
6669
}
67-
return MANAGER_BY_RENDER_TYPE[1];
70+
return MANAGER_BY_RENDER_TYPE[2];
6871
}
6972

7073
public static Stream<NeoInstancedRenderManager> getAllInstances() {
@@ -74,6 +77,7 @@ public static Stream<NeoInstancedRenderManager> getAllInstances() {
7477
public static void forEach(Consumer<? super NeoInstancedRenderManager> consumer) {
7578
consumer.accept(MANAGER_BY_RENDER_TYPE[0]);
7679
consumer.accept(MANAGER_BY_RENDER_TYPE[1]);
80+
consumer.accept(MANAGER_BY_RENDER_TYPE[2]);
7781
}
7882

7983
public static void init() {
@@ -140,8 +144,7 @@ public static void renderAtLast(RenderLevelStageEvent.AfterTranslucentParticles
140144
if (cn.ussshenzhou.madparticle.MadParticle.irisOn) {
141145
return;
142146
}
143-
NeoInstancedRenderManager.getInstance(ModParticleRenderTypes.INSTANCED).render();
144-
NeoInstancedRenderManager.getInstance(ModParticleRenderTypes.INSTANCED_TERRAIN).render();
147+
forEach(NeoInstancedRenderManager::render);
145148
}
146149

147150
@SubscribeEvent

src/main/java/cn/ussshenzhou/madparticle/particle/render/ParallelTickManager.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,10 @@ public static void tick(ParticleEngine engine) {
9696
}
9797
removeAndAdd(engine);
9898
if (engine.particles.values().stream().mapToInt(ParticleGroup::size).sum() == 0) {
99-
NeoInstancedRenderManager.getInstance(ModParticleRenderTypes.INSTANCED).clear();
100-
NeoInstancedRenderManager.getInstance(ModParticleRenderTypes.INSTANCED_TERRAIN).clear();
99+
NeoInstancedRenderManager.forEach(NeoInstancedRenderManager::clear);
101100
}
102101
engine.particles.forEach((renderType, particles) -> {
103-
if (renderType == ModParticleRenderTypes.INSTANCED || renderType == ModParticleRenderTypes.INSTANCED_TERRAIN) {
102+
if (renderType == ModParticleRenderTypes.INSTANCED || renderType == ModParticleRenderTypes.INSTANCED_TERRAIN || renderType == ModParticleRenderTypes.INSTANCED_ITEM) {
104103
NeoInstancedRenderManager.getInstance(renderType).update((MultiThreadedEqualObjectLinkedOpenHashSetQueue<Particle>) particles.particles);
105104
}
106105
});
@@ -129,7 +128,7 @@ public static void tick(ParticleEngine engine) {
129128
failSafe(engine, e);
130129
}
131130
engine.particles.forEach((renderType, particleGroup) -> {
132-
if (renderType == ModParticleRenderTypes.INSTANCED || renderType == ModParticleRenderTypes.INSTANCED_TERRAIN) {
131+
if (renderType == ModParticleRenderTypes.INSTANCED || renderType == ModParticleRenderTypes.INSTANCED_TERRAIN || renderType == ModParticleRenderTypes.INSTANCED_ITEM) {
133132
NeoInstancedRenderManager.getInstance(renderType).postUpdate((MultiThreadedEqualObjectLinkedOpenHashSetQueue<Particle>) particleGroup.particles);
134133
}
135134
});

src/main/java/cn/ussshenzhou/madparticle/particle/render/UtilListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public class UtilListener {
1313

1414
@SubscribeEvent
1515
public static void onLeaveLevel(LevelEvent.Unload event) {
16-
//NeoInstancedRenderManager.getAllInstances().forEach(NeoInstancedRenderManager::clear);
16+
NeoInstancedRenderManager.forEach(NeoInstancedRenderManager::clear);
1717
}
1818
}

src/main/resources/assets/madparticle/lang/en_us.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"key.categories.madparticle": "Mad Particle",
2+
"key.category.madparticle.madparticle": "Mad Particle",
33
"key.mp.call_de": "Call out MadParticle Designer",
44
"key.mp.clear_de": "Clear MadParticle Designer",
55

0 commit comments

Comments
 (0)