|
7 | 7 | import com.google.common.collect.Sets; |
8 | 8 | import com.mojang.logging.LogUtils; |
9 | 9 | import net.minecraft.client.particle.*; |
| 10 | +import net.minecraft.client.renderer.texture.TextureAtlas; |
10 | 11 | import org.jspecify.annotations.Nullable; |
11 | 12 |
|
12 | 13 | import java.util.HashSet; |
@@ -92,8 +93,8 @@ public enum TakeOver implements ITranslatable { |
92 | 93 | private static final HashSet<Class<? extends Particle>> RENDER_BLACKLIST = Sets.newHashSet( |
93 | 94 | ); |
94 | 95 |
|
| 96 | + @SuppressWarnings("unchecked") |
95 | 97 | private static final HashSet<Class<? extends SingleQuadParticle>> ITEM_ATLAS = Sets.newHashSet( |
96 | | - BlockMarker.class, |
97 | 98 | BreakingItemParticle.class |
98 | 99 | ); |
99 | 100 | @SuppressWarnings("unchecked") |
@@ -156,41 +157,57 @@ public String translateKey() { |
156 | 157 | return translateKey; |
157 | 158 | } |
158 | 159 |
|
| 160 | + @SuppressWarnings("deprecation") |
159 | 161 | public static ParticleRenderType map(Particle particle) { |
160 | 162 | var originalType = particle.getGroup(); |
161 | 163 | if (!(particle instanceof SingleQuadParticle)) { |
162 | 164 | return originalType; |
163 | 165 | } |
| 166 | + var takeOverRendering = ConfigHelper.getConfigRead(MadParticleConfig.class).takeOverRendering; |
| 167 | + if (particle instanceof BlockMarker blockMarker) { |
| 168 | + var layer = blockMarker.getLayer().textureAtlasLocation(); |
| 169 | + if (layer == TextureAtlas.LOCATION_PARTICLES) { |
| 170 | + return takeOverRendering == NONE ? originalType : ModParticleRenderTypes.INSTANCED; |
| 171 | + } else if (layer == TextureAtlas.LOCATION_BLOCKS) { |
| 172 | + return takeOverRendering == NONE ? originalType : ModParticleRenderTypes.INSTANCED_TERRAIN; |
| 173 | + } else if (layer == TextureAtlas.LOCATION_ITEMS) { |
| 174 | + return takeOverRendering == NONE ? originalType : ModParticleRenderTypes.INSTANCED_ITEM; |
| 175 | + } else { |
| 176 | + return originalType; |
| 177 | + } |
| 178 | + } |
164 | 179 | if (originalType == ModParticleRenderTypes.INSTANCED || originalType == ModParticleRenderTypes.INSTANCED_TERRAIN || originalType == ModParticleRenderTypes.INSTANCED_ITEM) { |
165 | 180 | return originalType; |
166 | 181 | } |
167 | 182 | return switch (originalType.name()) { |
168 | 183 | case "INSTANCED" -> ModParticleRenderTypes.INSTANCED; |
169 | 184 | case "INSTANCED_TERRAIN" -> ModParticleRenderTypes.INSTANCED_TERRAIN; |
170 | 185 | case "INSTANCED_ITEM" -> ModParticleRenderTypes.INSTANCED_ITEM; |
171 | | - case "SINGLE_QUADS" -> switch (ConfigHelper.getConfigRead(MadParticleConfig.class).takeOverRendering) { |
172 | | - case NONE -> originalType; |
173 | | - case ALL -> { |
174 | | - if (RENDER_BLACKLIST.contains(particle.getClass())) { |
175 | | - yield ParticleRenderType.SINGLE_QUADS; |
176 | | - } else if (particle instanceof TerrainParticle) { |
177 | | - yield ModParticleRenderTypes.INSTANCED_TERRAIN; |
178 | | - } else if (ITEM_ATLAS.contains(particle.getClass())) { |
179 | | - yield ModParticleRenderTypes.INSTANCED_ITEM; |
180 | | - } |
181 | | - yield ModParticleRenderTypes.INSTANCED; |
182 | | - } |
183 | | - case VANILLA -> { |
184 | | - if (particle instanceof TerrainParticle) { |
185 | | - 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())) { |
| 186 | + case "SINGLE_QUADS" -> { |
| 187 | + yield switch (takeOverRendering) { |
| 188 | + case NONE -> originalType; |
| 189 | + case ALL -> { |
| 190 | + if (RENDER_BLACKLIST.contains(particle.getClass())) { |
| 191 | + yield ParticleRenderType.SINGLE_QUADS; |
| 192 | + } else if (particle instanceof TerrainParticle) { |
| 193 | + yield ModParticleRenderTypes.INSTANCED_TERRAIN; |
| 194 | + } else if (ITEM_ATLAS.contains(particle.getClass())) { |
| 195 | + yield ModParticleRenderTypes.INSTANCED_ITEM; |
| 196 | + } |
189 | 197 | yield ModParticleRenderTypes.INSTANCED; |
190 | 198 | } |
191 | | - yield originalType; |
192 | | - } |
193 | | - }; |
| 199 | + case VANILLA -> { |
| 200 | + if (particle instanceof TerrainParticle) { |
| 201 | + yield ModParticleRenderTypes.INSTANCED_TERRAIN; |
| 202 | + } else if (ITEM_ATLAS.contains(particle.getClass())) { |
| 203 | + yield ModParticleRenderTypes.INSTANCED_ITEM; |
| 204 | + } else if (PARTICLE_ATLAS.contains(particle.getClass())) { |
| 205 | + yield ModParticleRenderTypes.INSTANCED; |
| 206 | + } |
| 207 | + yield originalType; |
| 208 | + } |
| 209 | + }; |
| 210 | + } |
194 | 211 | default -> originalType; |
195 | 212 | }; |
196 | 213 | } |
|
0 commit comments