Chipped away too much

- Fix formatting and tooltip depth regressions
- Fix outline rendering
This commit is contained in:
PepperBell 2021-11-07 00:26:41 -07:00
parent a8f422030c
commit ab8f6a01ce
7 changed files with 67 additions and 53 deletions

View file

@ -121,7 +121,7 @@ public class UIRenderHelper {
/**
* x and y specify the middle point of the starting edge
*
* @param angle the angle of the gradient in degrees; 0° means from left to right
* @param angle the angle of the gradient in degrees; 0° means from left to right
* @param color1 the color at the starting edge
* @param color2 the color at the ending edge
* @param breadth the total width of the gradient
@ -153,13 +153,13 @@ public class UIRenderHelper {
private static void breadcrumbArrow(PoseStack ms, int width, int height, int indent, Color c1, Color c2) {
/*
* 0,0 x1,y1 ********************* x4,y4 ***** x7,y7
* **** ****
* **** ****
* x0,y0 x2,y2 x5,y5
* **** ****
* **** ****
* x3,y3 ********************* x6,y6 ***** x8,y8
* 0,0 x1,y1 ********************* x4,y4 ***** x7,y7
* **** ****
* **** ****
* x0,y0 x2,y2 x5,y5
* **** ****
* **** ****
* x3,y3 ********************* x6,y6 ***** x8,y8
*
*/

View file

@ -429,6 +429,7 @@ public class PonderUI extends NavigatableSimiScreen {
RenderSystem.enableDepthTest();
// RenderSystem.pushMatrix();
// TODO 1.17: is the following still true?
// has to be outside of MS transforms, important for vertex sorting
// RenderSystem.translated(0, 0, 800);

View file

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Optional;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.gui.AllIcons;
@ -205,12 +206,19 @@ public class PonderTagIndexScreen extends NavigatableSimiScreen {
@Override
protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
RenderSystem.disableDepthTest();
ms.pushPose();
ms.translate(0, 0, 200);
if (hoveredItem != null) {
List<Component> list = TooltipHelper.cutStringTextComponent(hoveredItem.getDescription(),
ChatFormatting.GRAY, ChatFormatting.GRAY);
list.add(0, new TextComponent(hoveredItem.getTitle()));
renderComponentTooltip(ms, list, mouseX, mouseY);
}
ms.popPose();
RenderSystem.enableDepthTest();
}
@Override

View file

@ -5,6 +5,7 @@ import java.util.List;
import java.util.Objects;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.gui.BoxElement;
@ -293,9 +294,16 @@ public class PonderTagScreen extends NavigatableSimiScreen {
@Override
protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
RenderSystem.disableDepthTest();
ms.pushPose();
ms.translate(0, 0, 200);
if (!hoveredItem.isEmpty()) {
renderTooltip(ms, hoveredItem, mouseX, mouseY);
}
ms.popPose();
RenderSystem.enableDepthTest();
}
@Override

View file

@ -35,6 +35,7 @@ public class RenderTypes extends RenderStateShard {
.setCullState(cull ? CULL : NO_CULL)
.setLightmapState(LIGHTMAP)
.setOverlayState(OVERLAY)
.setWriteMaskState(COLOR_WRITE)
.createCompositeState(true));
}

View file

@ -15,17 +15,15 @@ import net.minecraft.client.resources.model.ModelBakery;
public class SuperRenderTypeBuffer implements MultiBufferSource {
static SuperRenderTypeBuffer instance;
private static final SuperRenderTypeBuffer INSTANCE = new SuperRenderTypeBuffer();;
public static SuperRenderTypeBuffer getInstance() {
if (instance == null)
instance = new SuperRenderTypeBuffer();
return instance;
return INSTANCE;
}
SuperRenderTypeBufferPhase earlyBuffer;
SuperRenderTypeBufferPhase defaultBuffer;
SuperRenderTypeBufferPhase lateBuffer;
private SuperRenderTypeBufferPhase earlyBuffer;
private SuperRenderTypeBufferPhase defaultBuffer;
private SuperRenderTypeBufferPhase lateBuffer;
public SuperRenderTypeBuffer() {
earlyBuffer = new SuperRenderTypeBufferPhase();
@ -34,65 +32,64 @@ public class SuperRenderTypeBuffer implements MultiBufferSource {
}
public VertexConsumer getEarlyBuffer(RenderType type) {
return earlyBuffer.getBuffer(type);
return earlyBuffer.bufferSource.getBuffer(type);
}
@Override
public VertexConsumer getBuffer(RenderType type) {
return defaultBuffer.getBuffer(type);
return defaultBuffer.bufferSource.getBuffer(type);
}
public VertexConsumer getLateBuffer(RenderType type) {
return lateBuffer.getBuffer(type);
return lateBuffer.bufferSource.getBuffer(type);
}
public void draw() {
earlyBuffer.endBatch();
defaultBuffer.endBatch();
lateBuffer.endBatch();
earlyBuffer.bufferSource.endBatch();
defaultBuffer.bufferSource.endBatch();
lateBuffer.bufferSource.endBatch();
}
public void draw(RenderType type) {
earlyBuffer.endBatch(type);
defaultBuffer.endBatch(type);
lateBuffer.endBatch(type);
earlyBuffer.bufferSource.endBatch(type);
defaultBuffer.bufferSource.endBatch(type);
lateBuffer.bufferSource.endBatch(type);
}
private static class SuperRenderTypeBufferPhase extends MultiBufferSource.BufferSource {
private static class SuperRenderTypeBufferPhase {
// Visible clones from net.minecraft.client.renderer.RenderTypeBuffers
static final ChunkBufferBuilderPack blockBuilders = new ChunkBufferBuilderPack();
static final SortedMap<RenderType, BufferBuilder> createEntityBuilders() {
return Util.make(new Object2ObjectLinkedOpenHashMap<>(), (map) -> {
map.put(Sheets.solidBlockSheet(), blockBuilders.builder(RenderType.solid()));
assign(map, RenderTypes.getOutlineSolid());
map.put(Sheets.cutoutBlockSheet(), blockBuilders.builder(RenderType.cutout()));
map.put(Sheets.bannerSheet(), blockBuilders.builder(RenderType.cutoutMipped()));
map.put(Sheets.translucentCullBlockSheet(), blockBuilders.builder(RenderType.translucent())); // FIXME new equivalent of getEntityTranslucent() ?
assign(map, Sheets.shieldSheet());
assign(map, Sheets.bedSheet());
assign(map, Sheets.shulkerBoxSheet());
assign(map, Sheets.signSheet());
assign(map, Sheets.chestSheet());
assign(map, RenderType.translucentNoCrumbling());
assign(map, RenderType.glint());
assign(map, RenderType.entityGlint());
assign(map, RenderType.waterMask());
ModelBakery.DESTROY_TYPES.forEach((p_228488_1_) -> {
assign(map, p_228488_1_);
// Visible clones from RenderBuffers
private final ChunkBufferBuilderPack fixedBufferPack = new ChunkBufferBuilderPack();
private final SortedMap<RenderType, BufferBuilder> fixedBuffers = Util.make(new Object2ObjectLinkedOpenHashMap<>(), map -> {
map.put(Sheets.solidBlockSheet(), fixedBufferPack.builder(RenderType.solid()));
map.put(Sheets.cutoutBlockSheet(), fixedBufferPack.builder(RenderType.cutout()));
map.put(Sheets.bannerSheet(), fixedBufferPack.builder(RenderType.cutoutMipped()));
map.put(Sheets.translucentCullBlockSheet(), fixedBufferPack.builder(RenderType.translucent()));
put(map, Sheets.shieldSheet());
put(map, Sheets.bedSheet());
put(map, Sheets.shulkerBoxSheet());
put(map, Sheets.signSheet());
put(map, Sheets.chestSheet());
put(map, RenderType.translucentNoCrumbling());
put(map, RenderType.armorGlint());
put(map, RenderType.armorEntityGlint());
put(map, RenderType.glint());
put(map, RenderType.glintDirect());
put(map, RenderType.glintTranslucent());
put(map, RenderType.entityGlint());
put(map, RenderType.entityGlintDirect());
put(map, RenderType.waterMask());
put(map, RenderTypes.getOutlineSolid());
ModelBakery.DESTROY_TYPES.forEach((p_173062_) -> {
put(map, p_173062_);
});
});
}
private final MultiBufferSource.BufferSource bufferSource = MultiBufferSource.immediateWithBuffers(fixedBuffers, new BufferBuilder(256));
private static void assign(Object2ObjectLinkedOpenHashMap<RenderType, BufferBuilder> map, RenderType type) {
private static void put(Object2ObjectLinkedOpenHashMap<RenderType, BufferBuilder> map, RenderType type) {
map.put(type, new BufferBuilder(type.bufferSize()));
}
protected SuperRenderTypeBufferPhase() {
super(new BufferBuilder(256), createEntityBuilders());
}
}
}

View file

@ -79,7 +79,6 @@ public class WrappedChunkProvider extends ChunkSource {
@Override
public int getLoadedChunksCount() {
// TODO Auto-generated method stub
return 0;
}
}