Spaces:
Build error
Build error
File size: 2,768 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
package net.minecraft.client.renderer.debug;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.vertex.PoseStack;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.Util;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.core.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class GameTestDebugRenderer implements DebugRenderer.SimpleDebugRenderer {
private static final float PADDING = 0.02F;
private final Map<BlockPos, GameTestDebugRenderer.Marker> markers = Maps.newHashMap();
public void addMarker(BlockPos p_113525_, int p_113526_, String p_113527_, int p_113528_) {
this.markers.put(p_113525_, new GameTestDebugRenderer.Marker(p_113526_, p_113527_, Util.getMillis() + (long)p_113528_));
}
@Override
public void clear() {
this.markers.clear();
}
@Override
public void render(PoseStack p_113519_, MultiBufferSource p_113520_, double p_113521_, double p_113522_, double p_113523_) {
long i = Util.getMillis();
this.markers.entrySet().removeIf(p_113517_ -> i > p_113517_.getValue().removeAtTime);
this.markers.forEach((p_269737_, p_269738_) -> this.renderMarker(p_113519_, p_113520_, p_269737_, p_269738_));
}
private void renderMarker(PoseStack p_270274_, MultiBufferSource p_271018_, BlockPos p_270918_, GameTestDebugRenderer.Marker p_270827_) {
DebugRenderer.renderFilledBox(
p_270274_, p_271018_, p_270918_, 0.02F, p_270827_.getR(), p_270827_.getG(), p_270827_.getB(), p_270827_.getA() * 0.75F
);
if (!p_270827_.text.isEmpty()) {
double d0 = (double)p_270918_.getX() + 0.5;
double d1 = (double)p_270918_.getY() + 1.2;
double d2 = (double)p_270918_.getZ() + 0.5;
DebugRenderer.renderFloatingText(p_270274_, p_271018_, p_270827_.text, d0, d1, d2, -1, 0.01F, true, 0.0F, true);
}
}
@OnlyIn(Dist.CLIENT)
static class Marker {
public int color;
public String text;
public long removeAtTime;
public Marker(int p_113536_, String p_113537_, long p_113538_) {
this.color = p_113536_;
this.text = p_113537_;
this.removeAtTime = p_113538_;
}
public float getR() {
return (float)(this.color >> 16 & 0xFF) / 255.0F;
}
public float getG() {
return (float)(this.color >> 8 & 0xFF) / 255.0F;
}
public float getB() {
return (float)(this.color & 0xFF) / 255.0F;
}
public float getA() {
return (float)(this.color >> 24 & 0xFF) / 255.0F;
}
}
} |