fix mod menu background transparency

This commit is contained in:
janeptrv 2020-10-05 17:35:52 -04:00
parent 6acc2de314
commit cafd3700aa
2 changed files with 13 additions and 10 deletions

View File

@ -18,7 +18,6 @@ public class PModMenuScreen extends Screen {
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
System.out.println("MENU ACTIVATED");
this.client.textRenderer.drawWithShadow(matrices, new LiteralText("Menu Open"), 10, 50, -1);
this.renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
@ -26,7 +25,7 @@ public class PModMenuScreen extends Screen {
@Override
protected void init() {
this.addButton(new PMovableButton(10, 10, 40, 10, PetroleumMod.getActiveMods().get(0)));
this.addButton(new PMovableButton(10, 10, PetroleumMod.getActiveMods().get(0)));
}
@Override
@ -39,12 +38,13 @@ public class PModMenuScreen extends Screen {
public void renderBackground(MatrixStack matrices) {
Tessellator t_1 = Tessellator.getInstance();
BufferBuilder buffer = t_1.getBuffer();
RenderSystem.color4f(0.0F, 0.0F, 0.0F, 0.1F);
RenderSystem.enableBlend();
buffer.begin(7, VertexFormats.POSITION_COLOR);
buffer.vertex(0,this.height, 0.0D).color(0.0F, 0.0F, 0.0F, 0.1F).next();
buffer.vertex(this.width, this.height, 0.0D).color(0.0F, 0.0F, 0.0F, 0.1F).next();
buffer.vertex(this.width, 0, 0.0D).color(0.0F, 0.0F, 0.0F, 0.1F).next();
buffer.vertex(0,0,0.0D).color(0.0F, 0.0F, 0.0F, 0.1F).next();
buffer.vertex(0,this.height, 0.0D).color(0.1F, 0.1F, 0.1F, 0.3F).next();
buffer.vertex(this.width, this.height, 0.0D).color(0.1F, 0.1F, 0.1F, 0.3F).next();
buffer.vertex(this.width, 0, 0.0D).color(0.1F, 0.1F, 0.1F, 0.3F).next();
buffer.vertex(0,0,0.0D).color(0.1F, 0.1F, 0.1F, 0.3F).next();
t_1.draw();
RenderSystem.disableBlend();
}
}

View File

@ -10,13 +10,16 @@ import net.minecraft.util.math.MathHelper;
import pm.j4.petroleum.modules.base.ModuleBase;
public class PMovableButton extends AbstractButtonWidget {
public PMovableButton(int x, int y, int width, int height, ModuleBase module) {
super(x, y, width, height, module.getReadableName());
public PMovableButton(int x, int y, ModuleBase module) {
super(x, y, 0, 0, module.getReadableName());
int w = MinecraftClient.getInstance().textRenderer.getWidth(module.getReadableName()) + 8;
int h = MinecraftClient.getInstance().textRenderer.fontHeight + 8;
this.width = w;
this.height = h;
}
@Override
protected void onDrag(double mouseX, double mouseY, double deltaX, double deltaY) {
System.out.println(mouseX + "/" + mouseY + "/" + deltaX + "/" + deltaY);
this.x += (int)deltaX;
this.y += (int)deltaY;
}