Skip to content

Commit

Permalink
Fix duplicate VertexConsumer exception
Browse files Browse the repository at this point in the history
  • Loading branch information
soir20 committed Nov 14, 2024
1 parent a96d8e5 commit 484ded7
Showing 1 changed file with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,14 @@
@MethodsReturnNonnullByDefault
public class EmptyVertexConsumer implements VertexConsumer {
private static final Supplier<EmptyVertexConsumer> FACTORY;
private static final ThreadLocal<EmptyVertexConsumer> instance = new ThreadLocal<>();
static {
Supplier<EmptyVertexConsumer> factory;
try {
// Check whether the Sodium 0.6+ buffer interface is present before attempting to load the class
Class.forName("net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter");
factory = () -> {
if (instance.get() == null) {
instance.set(new SodiumEmptyVertexConsumer());
}
return instance.get();
};
factory = SodiumEmptyVertexConsumer::new;
} catch (ClassNotFoundException err) {
factory = () -> {
if (instance.get() == null) {
instance.set(new EmptyVertexConsumer());
}
return instance.get();
};
factory = EmptyVertexConsumer::new;
}
FACTORY = factory;
}
Expand Down

0 comments on commit 484ded7

Please sign in to comment.