Skip to content

Commit 3cd03ab

Browse files
committed
minor fix
1 parent 5898983 commit 3cd03ab

1 file changed

Lines changed: 39 additions & 22 deletions

File tree

  • src/main/java/cn/ussshenzhou/madparticle/particle/enums

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

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.google.common.collect.Sets;
88
import com.mojang.logging.LogUtils;
99
import net.minecraft.client.particle.*;
10+
import net.minecraft.client.renderer.texture.TextureAtlas;
1011
import org.jspecify.annotations.Nullable;
1112

1213
import java.util.HashSet;
@@ -92,8 +93,8 @@ public enum TakeOver implements ITranslatable {
9293
private static final HashSet<Class<? extends Particle>> RENDER_BLACKLIST = Sets.newHashSet(
9394
);
9495

96+
@SuppressWarnings("unchecked")
9597
private static final HashSet<Class<? extends SingleQuadParticle>> ITEM_ATLAS = Sets.newHashSet(
96-
BlockMarker.class,
9798
BreakingItemParticle.class
9899
);
99100
@SuppressWarnings("unchecked")
@@ -156,41 +157,57 @@ public String translateKey() {
156157
return translateKey;
157158
}
158159

160+
@SuppressWarnings("deprecation")
159161
public static ParticleRenderType map(Particle particle) {
160162
var originalType = particle.getGroup();
161163
if (!(particle instanceof SingleQuadParticle)) {
162164
return originalType;
163165
}
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+
}
164179
if (originalType == ModParticleRenderTypes.INSTANCED || originalType == ModParticleRenderTypes.INSTANCED_TERRAIN || originalType == ModParticleRenderTypes.INSTANCED_ITEM) {
165180
return originalType;
166181
}
167182
return switch (originalType.name()) {
168183
case "INSTANCED" -> ModParticleRenderTypes.INSTANCED;
169184
case "INSTANCED_TERRAIN" -> ModParticleRenderTypes.INSTANCED_TERRAIN;
170185
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+
}
189197
yield ModParticleRenderTypes.INSTANCED;
190198
}
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+
}
194211
default -> originalType;
195212
};
196213
}

0 commit comments

Comments
 (0)