fix gui rendering, fix sounds being null, reimplement crosshair rendering
This commit is contained in:
parent
42421a031a
commit
95dc94d108
11
README.md
11
README.md
|
|
@ -1,15 +1,16 @@
|
|||
# WebDisplays for Minecraft 1.19.2
|
||||
This is a fork of the Web Displays mod from 1.12, updated to work on 1.19, and with some bug fixes and reworking.
|
||||
This is a fork of the Web Displays mod from 1.12, updated to work in newer versions, and with some bug fixes and reworking.
|
||||
|
||||
### Wiki
|
||||
* The Wiki that details all blocks/items can be found on my website https://montoyo.net/wdwiki/
|
||||
|
||||
### Delayed things
|
||||
* Plugin API
|
||||
* The Shop
|
||||
* CC Interface, if CC gets updated...
|
||||
* The Shop (what)
|
||||
* Center camera to screen when using keyboard
|
||||
* minePad management: check GuiContainer.draggedStack for minePad
|
||||
* In-game command to add/remove blacklisted domains
|
||||
* Config: RPMP (Real pixels per Minecraft pixels)
|
||||
* Disable miniserv in solo
|
||||
* Config: RPMP (Real pixels per Minecraft pixels) (what)
|
||||
* CC Interface (for when it's actually possible, since the screens are client only currently, but a config option is planned to change that)
|
||||
* Redstone controls (same reason as CC interface)
|
||||
* Redo minisrv logic?
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -169,12 +169,12 @@ public class WebDisplays {
|
|||
}
|
||||
|
||||
public void onRegisterSounds() {
|
||||
registerSound("keyboard_type");
|
||||
registerSound( "upgrade_add");
|
||||
registerSound( "upgrade_del");
|
||||
registerSound("screencfg_open");
|
||||
registerSound("server");
|
||||
registerSound("ironic");
|
||||
soundTyping = registerSound("keyboard_type");
|
||||
soundUpgradeAdd = registerSound( "upgrade_add");
|
||||
soundUpgradeDel = registerSound( "upgrade_del");
|
||||
soundScreenCfg = registerSound("screencfg_open");
|
||||
soundServer = registerSound("server");
|
||||
soundIronic = registerSound("ironic");
|
||||
}
|
||||
|
||||
ArrayList<ResourceKey<Level>> serverStartedDimensions = new ArrayList<>();
|
||||
|
|
@ -377,11 +377,12 @@ public class WebDisplays {
|
|||
|
||||
public static DeferredRegister<SoundEvent> SOUNDS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, "webdisplays");
|
||||
|
||||
private static void registerSound(String resName) {
|
||||
private static SoundEvent registerSound(String resName) {
|
||||
ResourceLocation resLoc = new ResourceLocation("webdisplays", resName);
|
||||
SoundEvent ret = SoundEvent.createVariableRangeEvent(resLoc);
|
||||
|
||||
SOUNDS.register(resName, () -> ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static void registerTrigger(Criterion ... criteria) {
|
||||
|
|
|
|||
|
|
@ -138,12 +138,11 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
|||
return;
|
||||
|
||||
if (!LaserPointerRenderer.isOn()) {
|
||||
RenderSystem.setShaderTexture(0, new ResourceLocation(
|
||||
"webdisplays:textures/gui/cursors.png"
|
||||
));
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
|
||||
// blit(poseStack, (screenWidth - 15) / 2, (screenHeight - 15) / 2, 240, 240, 15, 15, offset);
|
||||
|
||||
poseStack.blit(new ResourceLocation(
|
||||
"webdisplays:textures/gui/cursors.png"
|
||||
), (screenWidth - 15) / 2, (screenHeight - 15) / 2, offset, 240, 240, 15, 15, 256, 256);
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
|
@ -154,9 +153,16 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
|||
|
||||
BlockPos bpos = result.getBlockPos();
|
||||
|
||||
if (result.getType() != HitResult.Type.BLOCK || mc.level.getBlockState(bpos).getBlock() != BlockInit.blockScreen.get())
|
||||
if (result.getType() != HitResult.Type.BLOCK || mc.level.getBlockState(bpos).getBlock() != BlockInit.blockScreen.get()) {
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
|
||||
poseStack.blit(new ResourceLocation(
|
||||
"webdisplays:textures/gui/cursors.png"
|
||||
), (screenWidth - 15) / 2, (screenHeight - 15) / 2, offset, 240, 240, 15, 15, 256, 256);
|
||||
ci.cancel();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Vector3i pos = new Vector3i(result.getBlockPos());
|
||||
BlockSide side = BlockSide.values()[result.getDirection().ordinal()];
|
||||
|
||||
|
|
@ -166,19 +172,17 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
|||
TileEntityScreen.Screen sc = te.getScreen(side);
|
||||
|
||||
if (sc == null) return;
|
||||
// if (sc.mouseType == 1) return;
|
||||
|
||||
|
||||
int coordX = sc.mouseType * 15;
|
||||
int coordY = coordX / 256;
|
||||
coordX -= coordY * 256;
|
||||
|
||||
RenderSystem.setShaderTexture(0, new ResourceLocation(
|
||||
"webdisplays:textures/gui/cursors.png"
|
||||
));
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
|
||||
// blit(poseStack, (screenWidth - 15) / 2, (screenHeight - 15) / 2, coordX, coordY, 15, 15, offset);
|
||||
|
||||
|
||||
poseStack.blit(new ResourceLocation(
|
||||
"webdisplays:textures/gui/cursors.png"
|
||||
), (screenWidth - 15) / 2, (screenHeight - 15) / 2, offset, coordX, coordY, 15, 15, 256, 256);
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ public class GuiServer extends WDScreen {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
|
||||
super.render(poseStack, mouseX, mouseY, ptt);
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float ptt) {
|
||||
super.render(graphics, mouseX, mouseY, ptt);
|
||||
|
||||
int x = (width - 256) / 2;
|
||||
int y = (height - 176) / 2;
|
||||
|
|
@ -105,27 +105,27 @@ public class GuiServer extends WDScreen {
|
|||
// RenderSystem.enableTexture();
|
||||
RenderSystem.setShaderTexture(0, BG_IMAGE);
|
||||
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
// blit(poseStack, x, y, 0, 0, 256, 176);
|
||||
|
||||
graphics.blit(BG_IMAGE, x, y, 0, 0, 256, 256);
|
||||
|
||||
x += 18;
|
||||
y += 18;
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
if (selectedLine == i) {
|
||||
drawWhiteQuad(x - 1, y - 2, font.width(lines.get(i)) + 1, 12);
|
||||
poseStack.drawString(Minecraft.getInstance().font, lines.get(i), x, y, 0xFF129700, false);
|
||||
graphics.drawString(Minecraft.getInstance().font, lines.get(i), x, y, 0xFF129700, false);
|
||||
} else
|
||||
poseStack.drawString(Minecraft.getInstance().font, lines.get(i), x, y, 0xFFFFFFFF, false);
|
||||
graphics.drawString(Minecraft.getInstance().font, lines.get(i), x, y, 0xFFFFFFFF, false);
|
||||
|
||||
y += 12;
|
||||
}
|
||||
|
||||
if (!promptLocked) {
|
||||
if (queue.isEmpty()) {
|
||||
x = poseStack.drawString(Minecraft.getInstance().font, userPrompt, x, y, 0xFFFFFFFF, false);
|
||||
x = poseStack.drawString(Minecraft.getInstance().font, prompt, x, y, 0xFFFFFFFF, false);
|
||||
x = graphics.drawString(Minecraft.getInstance().font, userPrompt, x, y, 0xFFFFFFFF, false);
|
||||
x = graphics.drawString(Minecraft.getInstance().font, prompt, x, y, 0xFFFFFFFF, false);
|
||||
} else {
|
||||
x = poseStack.drawString(Minecraft.getInstance().font, tr("press_for_more"), x, y, 0xFFFFFFFF, false);
|
||||
x = graphics.drawString(Minecraft.getInstance().font, tr("press_for_more"), x, y, 0xFFFFFFFF, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ public class GuiServer extends WDScreen {
|
|||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.setShaderTexture(0, FG_IMAGE);
|
||||
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
// blit(poseStack,(width - 256) / 2, (height - 176) / 2, 0, 0, 256, 176);
|
||||
// blit(graphics,(width - 256) / 2, (height - 176) / 2, 0, 0, 256, 176);
|
||||
}
|
||||
|
||||
private void drawWhiteQuad(int x, int y, int w, int h) {
|
||||
|
|
|
|||
|
|
@ -100,15 +100,15 @@ public class RenderRecipe extends Screen {
|
|||
int x = this.x + 30 + sx * 18;
|
||||
int y = this.y + 17 + sy * 18;
|
||||
|
||||
// renderItem.renderAndDecorateItem(minecraft.player, is, x, y, 0);
|
||||
// renderItem.renderGuiItemDecorations(font, is, x, y, null);
|
||||
context.renderItem(is, x, y);
|
||||
context.renderItemDecorations(font, is, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(recipeResult != null) {
|
||||
// renderItem.renderAndDecorateItem(minecraft.player, recipeResult, x + 124, y + 35, 0);
|
||||
// renderItem.renderGuiItemDecorations(font, recipeResult, x + 124, y + 35, null);
|
||||
context.renderItem(recipeResult, x, y);
|
||||
context.renderItemDecorations(font, recipeResult, x, y);
|
||||
}
|
||||
|
||||
// GlStateManager.enableLighting();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package net.montoyo.wd.client.gui;
|
|||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
|
@ -116,6 +117,8 @@ public abstract class WDScreen extends Screen {
|
|||
if(defaultBackground)
|
||||
renderBackground(poseStack);
|
||||
|
||||
RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f);
|
||||
|
||||
for(Control ctrl: controls)
|
||||
ctrl.draw(poseStack, mouseX, mouseY, ptt);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
|
|
@ -81,12 +82,11 @@ public class CheckBox extends BasicControl {
|
|||
if(visible) {
|
||||
// GlStateManager.disableAlpha();
|
||||
poseStack.pose().pushPose();
|
||||
RenderSystem.setShaderTexture(2, checked ? texChecked : texUnchecked);
|
||||
RenderSystem.bindTexture(2);
|
||||
RenderSystem.enableBlend();
|
||||
fillTexturedRect(poseStack.pose(), x, y, WIDTH, HEIGHT, 0.0, 0.0, 1.0, 1.0);
|
||||
poseStack.blit(
|
||||
checked ? texChecked : texUnchecked, x, y, 0, 0, 0, WIDTH, HEIGHT, WIDTH, HEIGHT
|
||||
);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.bindTexture(-1);
|
||||
|
||||
poseStack.pose().popPose();
|
||||
boolean inside = (!disabled && mouseX >= x && mouseX <= x + WIDTH + 2 + labelW && mouseY >= y && mouseY < y + HEIGHT);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ import com.mojang.blaze3d.vertex.*;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
|
@ -20,6 +24,9 @@ import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
|||
import net.montoyo.wd.utilities.Bounds;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.mojang.math.Axis.XP;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
@ -109,7 +116,7 @@ public abstract class Control {
|
|||
public abstract int getHeight();
|
||||
public abstract void setPos(int x, int y);
|
||||
|
||||
public void fillRect(int x, double y, int w, int h, int color) {
|
||||
public void fillRect(MultiBufferSource.BufferSource source, int x, double y, int w, int h, int color) {
|
||||
double x1 = (double) x;
|
||||
double y1 = (double) y;
|
||||
double x2 = (double) (x + w);
|
||||
|
|
@ -119,34 +126,38 @@ public abstract class Control {
|
|||
int g = (color >> 8 ) & 0xFF;
|
||||
int b = color & 0xFF;
|
||||
|
||||
RenderSystem.setShaderColor(((float) r) / 255.f, ((float) g) / 255.f, ((float) b) / 255.f, ((float) a) / 255.f);
|
||||
float[] sdrCol = Arrays.copyOf(RenderSystem.getShaderColor(), 4);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1f);
|
||||
// RenderSystem.disableTexture();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
vBuffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
|
||||
vBuffer.vertex(x1, y2, 0.0).endVertex();
|
||||
vBuffer.vertex(x2, y2, 0.0).endVertex();
|
||||
vBuffer.vertex(x2, y1, 0.0).endVertex();
|
||||
vBuffer.vertex(x1, y1, 0.0).endVertex();
|
||||
tessellator.end();
|
||||
VertexConsumer consumer = source.getBuffer(RenderType.gui());
|
||||
consumer.vertex(x1, y2, 0.0).color(r, g, b, a).endVertex();
|
||||
consumer.vertex(x2, y2, 0.0).color(r, g, b, a).endVertex();
|
||||
consumer.vertex(x2, y1, 0.0).color(r, g, b, a).endVertex();
|
||||
consumer.vertex(x1, y1, 0.0).color(r, g, b, a).endVertex();
|
||||
|
||||
RenderSystem.setShaderColor(sdrCol[0], sdrCol[1], sdrCol[2], sdrCol[3]);
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
// RenderSystem.enableTexture();
|
||||
}
|
||||
|
||||
public void fillTexturedRect(PoseStack poseStack, int x, int y, int w, int h, double u1, double v1, double u2, double v2) {
|
||||
double x1 = (double) x;
|
||||
double y1 = (double) y;
|
||||
double x2 = (double) (x + w);
|
||||
double y2 = (double) (y + h);
|
||||
float x1 = x;
|
||||
float y1 = y;
|
||||
float x2 = (x + w);
|
||||
float y2 = (y + h);
|
||||
|
||||
vBuffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
vBuffer.vertex(x1, y2, 0.0).uv((float) u1, (float) v2).color(255, 255, 255, 255).endVertex();
|
||||
vBuffer.vertex(x2, y2, 0.0).uv((float) u2, (float) v2).color(255, 255, 255, 255).endVertex();
|
||||
vBuffer.vertex(x2, y1, 0.0).uv((float) u2, (float) v1).color(255, 255, 255, 255).endVertex();
|
||||
vBuffer.vertex(x1, y1, 0.0).uv((float) u1, (float) v1).color(255, 255, 255, 255).endVertex();
|
||||
tessellator.end();
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorTexShader);
|
||||
Matrix4f p = poseStack.last().pose();
|
||||
vBuffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
|
||||
vBuffer.vertex(p, x1, y2, 0.0f).color(255, 255, 255, 255).uv((float) u1, (float) v2).endVertex();
|
||||
vBuffer.vertex(p, x2, y2, 0.0f).color(255, 255, 255, 255).uv((float) u2, (float) v2).endVertex();
|
||||
vBuffer.vertex(p, x2, y1, 0.0f).color(255, 255, 255, 255).uv((float) u2, (float) v1).endVertex();
|
||||
vBuffer.vertex(p, x1, y1, 0.0f).color(255, 255, 255, 255).uv((float) u1, (float) v1).endVertex();
|
||||
BufferUploader.drawWithShader(vBuffer.end());
|
||||
}
|
||||
|
||||
public static void blend(boolean enable) {
|
||||
|
|
@ -178,6 +189,7 @@ public abstract class Control {
|
|||
int g = (color >> 8 ) & 0xFF;
|
||||
int b = color & 0xFF;
|
||||
|
||||
float[] sdrCol = Arrays.copyOf(RenderSystem.getShaderColor(), 4);
|
||||
RenderSystem.setShaderColor(((float) r) / 255.f, ((float) g) / 255.f, ((float) b) / 255.f, ((float) a) / 255.f);
|
||||
// RenderSystem.enableTexture();
|
||||
RenderSystem.enableBlend();
|
||||
|
|
@ -209,13 +221,15 @@ public abstract class Control {
|
|||
vBuffer.vertex(x2 - sz, y1, 0.0).endVertex();
|
||||
tessellator.end();
|
||||
|
||||
RenderSystem.setShaderColor(sdrCol[0], sdrCol[1], sdrCol[2], sdrCol[3]);
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
// RenderSystem.enableTexture();
|
||||
}
|
||||
|
||||
public GuiGraphics beginFramebuffer(RenderTarget fbo, float vpW, float vpH) {
|
||||
GuiGraphics tmpGraphics = new GuiGraphics(Minecraft.getInstance(), Minecraft.getInstance().renderBuffers().bufferSource());
|
||||
|
||||
|
||||
fbo.bindWrite(true);
|
||||
|
||||
RenderSystem.backupProjectionMatrix();
|
||||
|
|
@ -226,7 +240,10 @@ public abstract class Control {
|
|||
PoseStack poseStack = tmpGraphics.pose();
|
||||
poseStack.pushPose();
|
||||
poseStack.setIdentity();
|
||||
// poseStack.mulPose(Vector3f.XP.rotationDegrees(180.0f));
|
||||
poseStack.mulPose(XP.rotationDegrees(180.0f));
|
||||
RenderSystem.getModelViewStack().pushPose();
|
||||
RenderSystem.getModelViewStack().last().pose().set(poseStack.last().pose());
|
||||
RenderSystem.getModelViewStack().last().normal().set(poseStack.last().normal());
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
|
||||
if(!fbo.useDepth)
|
||||
|
|
@ -243,6 +260,7 @@ public abstract class Control {
|
|||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.restoreProjectionMatrix();
|
||||
poseStack.pose().popPose();
|
||||
RenderSystem.getModelViewStack().popPose();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
fbo.unbindWrite();
|
||||
mc.getMainRenderTarget().bindWrite(true);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
|||
import net.montoyo.wd.utilities.Bounds;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class ControlGroup extends Container {
|
||||
|
|
@ -102,6 +104,7 @@ public class ControlGroup extends Container {
|
|||
|
||||
if(visible) {
|
||||
poseStack.pose().pushPose();
|
||||
float[] sdrCol = Arrays.copyOf(RenderSystem.getShaderColor(), 4);
|
||||
RenderSystem.setShaderColor(0.5f, 0.5f, 0.5f, 1.f);
|
||||
// RenderSystem.disableTexture();
|
||||
RenderSystem.enableBlend();
|
||||
|
|
@ -161,6 +164,8 @@ public class ControlGroup extends Container {
|
|||
vBuffer.vertex(x2 - 1.0, y1, 0.0).endVertex();
|
||||
tessellator.end();
|
||||
|
||||
RenderSystem.setShaderColor(sdrCol[0], sdrCol[1], sdrCol[2], sdrCol[3]);
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
// RenderSystem.enableTexture();
|
||||
poseStack.pose().popPose();
|
||||
|
|
|
|||
|
|
@ -10,12 +10,16 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.GL_NEAREST;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class List extends BasicControl {
|
||||
|
||||
|
|
@ -97,19 +101,20 @@ public class List extends BasicControl {
|
|||
if(fbo != null)
|
||||
fbo.destroyBuffers();
|
||||
|
||||
fbo = new TextureTarget(parent.screen2DisplayX(width), parent.screen2DisplayY(height), false, Minecraft.ON_OSX);
|
||||
fbo = new TextureTarget(parent.screen2DisplayX(width), parent.screen2DisplayY(height), true, Minecraft.ON_OSX);
|
||||
fbo.setFilterMode(GL_NEAREST);
|
||||
fbo.bindWrite(false);
|
||||
fbo.bindWrite(true);
|
||||
RenderSystem.clearColor(0.0f, 0.0f, 0.0f, 1.f); //Set alpha to 1
|
||||
RenderSystem.clearDepth(GL_COLOR_BUFFER_BIT);
|
||||
fbo.unbindWrite();
|
||||
update = true;
|
||||
}
|
||||
|
||||
private void renderToFBO() {
|
||||
GuiGraphics poseStack = beginFramebuffer(fbo, width, height);
|
||||
poseStack.pose().pushPose();
|
||||
fillRect(0, 0, width, height, COLOR_BLACK);
|
||||
private void renderToFBO(MultiBufferSource.BufferSource source) {
|
||||
GuiGraphics graphics = beginFramebuffer(fbo, width, height);
|
||||
GL11.glColorMask(true, true, true, true);
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
graphics.fill(0, 0, width, height, COLOR_BLACK);
|
||||
RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f);
|
||||
|
||||
int offset = 4 - getYOffset();
|
||||
|
|
@ -121,13 +126,15 @@ public class List extends BasicControl {
|
|||
break;
|
||||
|
||||
int color = (i == selected) ? selColor : COLOR_WHITE;
|
||||
poseStack.drawString(font, content.get(i).text, 4, i * 12 + offset, color);
|
||||
graphics.drawString(font, content.get(i).text, 4, i * 12 + offset, color);
|
||||
}
|
||||
}
|
||||
|
||||
drawBorder(poseStack, 0, 0, width, height, 0xFF808080);
|
||||
endFramebuffer(poseStack, fbo);
|
||||
poseStack.pose().popPose();
|
||||
graphics.renderOutline(0, 0, width, height, 0xFF808080);
|
||||
RenderSystem.clearColor(0.0f, 0.0f, 0.0f, 1.f); //Set alpha to 1
|
||||
RenderSystem.clearDepth(GL_COLOR_BUFFER_BIT);
|
||||
graphics.flush();
|
||||
endFramebuffer(graphics, fbo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -312,19 +319,18 @@ public class List extends BasicControl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiGraphics poseStack, int mouseX, int mouseY, float ptt) {
|
||||
public void draw(GuiGraphics graphics, int mouseX, int mouseY, float ptt) {
|
||||
if(visible) {
|
||||
if(update) {
|
||||
renderToFBO();
|
||||
// if(update) {
|
||||
renderToFBO(graphics.bufferSource());
|
||||
update = false;
|
||||
}
|
||||
// }
|
||||
|
||||
fbo.bindRead(); //TODO: Make sure is right
|
||||
RenderSystem.setShaderTexture(0, fbo.getColorTextureId());
|
||||
RenderSystem.setShaderColor(1.f, 1.f, 1.f, 1.f);
|
||||
fillTexturedRect(poseStack.pose(), x, y, width, height, 0.0, 1.0, 1.0, 0.0);
|
||||
fbo.unbindRead();
|
||||
fillTexturedRect(graphics.pose(), x, y, width, height, 0.0, 1.0, 1.0, 0.0);
|
||||
|
||||
fillRect(x + width - 5, y + 1 + scrollPos, 4, scrollSize, (scrolling || isInScrollbar(mouseX, mouseY)) ? 0xFF202020 : 0xFF404040);
|
||||
fillRect(graphics.bufferSource(), x + width - 5, y + 1 + scrollPos, 4, scrollSize, (scrolling || isInScrollbar(mouseX, mouseY)) ? 0xFF202020 : 0xFF404040);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ package net.montoyo.wd.client.gui.controls;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||
|
|
@ -33,10 +34,10 @@ public class UpgradeGroup extends BasicControl {
|
|||
|
||||
for(ItemStack is: upgrades) {
|
||||
if(is == overStack && !disabled)
|
||||
fillRect(x, y, 16, 16, 0x80FF0000);
|
||||
fillRect(poseStack.bufferSource(), x, y, 16, 16, 0x80FF0000);
|
||||
|
||||
// renderItem.renderAndDecorateItem(mc.player, is, x, y, 0);
|
||||
// renderItem.renderAndDecorateItem(is, font.lineHeight, x, y); //TODO is lineHeight right?
|
||||
poseStack.renderItem(is, x, y);
|
||||
poseStack.renderItemDecorations(font, is, x, y);
|
||||
x += 18;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package net.montoyo.wd.entity;
|
|||
|
||||
import com.cinemamod.mcef.MCEF;
|
||||
import com.cinemamod.mcef.MCEFBrowser;
|
||||
import com.cinemamod.mcef.MCEFCursorChangeListener;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
|
@ -233,7 +234,7 @@ public class TileEntityScreen extends BlockEntity {
|
|||
else
|
||||
mcefBrowser.resize(resolution.x, resolution.y);
|
||||
|
||||
mcefBrowser.setCursorChangeListener((type) -> mouseType = type);
|
||||
mcefBrowser.setCursorChangeListener((MCEFCursorChangeListener) (type) -> mouseType = type);
|
||||
}
|
||||
|
||||
doTurnOnAnim = doAnim;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user