/* * Decompiled with CFR 0.152. * * Could not load the following classes: * it.unimi.dsi.fastutil.objects.ObjectOpenHashSet */ package net.minecraft.client.renderer.feature; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.SubmitNodeCollection; import net.minecraft.client.renderer.SubmitNodeCollector; import net.minecraft.client.renderer.SubmitNodeStorage; import net.minecraft.client.renderer.rendertype.RenderType; public class CustomFeatureRenderer { public void render(SubmitNodeCollection nodeCollection, MultiBufferSource.BufferSource bufferSource) { Storage storage = nodeCollection.getCustomGeometrySubmits(); for (Map.Entry> entry : storage.customGeometrySubmits.entrySet()) { VertexConsumer buffer = bufferSource.getBuffer(entry.getKey()); for (SubmitNodeStorage.CustomGeometrySubmit customGeometrySubmit : entry.getValue()) { customGeometrySubmit.customGeometryRenderer().render(customGeometrySubmit.pose(), buffer); } } } public static class Storage { private final Map> customGeometrySubmits = new HashMap>(); private final Set customGeometrySubmitsUsage = new ObjectOpenHashSet(); public void add(PoseStack poseStack, RenderType renderType, SubmitNodeCollector.CustomGeometryRenderer customGeometryRenderer) { List submits = this.customGeometrySubmits.computeIfAbsent(renderType, rt -> new ArrayList()); submits.add(new SubmitNodeStorage.CustomGeometrySubmit(poseStack.last().copy(), customGeometryRenderer)); } public void clear() { for (Map.Entry> entry : this.customGeometrySubmits.entrySet()) { if (entry.getValue().isEmpty()) continue; this.customGeometrySubmitsUsage.add(entry.getKey()); entry.getValue().clear(); } } public void endFrame() { this.customGeometrySubmits.keySet().removeIf(renderType -> !this.customGeometrySubmitsUsage.contains(renderType)); this.customGeometrySubmitsUsage.clear(); } } }