Skip to content

Commit

Permalink
Ported to 1.15.1
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Dec 23, 2019
1 parent 357087b commit 50722f1
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 119 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
minecraft_version=1.14.4
forge_version=28.0.45
mappings=20190807-1.14.3
mod_version=1.8.2
minecraft_version=1.15.1
forge_version=30.0.15
mappings=20191221-1.14.3
mod_version=1.8.3

org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=false
16 changes: 8 additions & 8 deletions src/main/java/dmillerw/menu/gui/menu/PickIconScreen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dmillerw.menu.gui.menu;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import dmillerw.menu.data.session.EditSessionData;
import dmillerw.menu.gui.ScreenStack;
import dmillerw.menu.helper.GuiRenderHelper;
Expand Down Expand Up @@ -129,7 +129,7 @@ public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPre
public boolean mouseClicked(double mouseX, double mouseY, int button) {
super.mouseClicked(mouseX, mouseY, button);

ItemStack clicked = getClickedStack(this.width / 2, this.height - (Minecraft.getInstance().mainWindow.getScaledHeight() - 80), mouseX, mouseY);
ItemStack clicked = getClickedStack(this.width / 2, this.height - (Minecraft.getInstance().func_228018_at_().getScaledHeight() - 80), mouseX, mouseY);

if (!clicked.isEmpty()) {
EditSessionData.icon = clicked;
Expand Down Expand Up @@ -170,7 +170,7 @@ public void render(int mouseX, int mouseY, float partial) {

GuiRenderHelper.renderHeaderAndFooter(this, 25, 20, 5, "Select an Icon:");

drawList(this.width / 2, this.height - (Minecraft.getInstance().mainWindow.getScaledHeight() - 80), mouseX, mouseY);
drawList(this.width / 2, this.height - (Minecraft.getInstance().func_228018_at_().getScaledHeight() - 80), mouseX, mouseY);
}

private void drawList(int x, int y, int mx, int my) {
Expand All @@ -183,7 +183,7 @@ private void drawList(int x, int y, int mx, int my) {
int drawY = i / MAX_COLUMN;

if (((i - 14 * listScrollIndex) / MAX_COLUMN) <= MAX_ROW) {
GlStateManager.pushMatrix();
RenderSystem.pushMatrix();

boolean scaled = false;
int actualDrawX = (x + drawX * 20) - (7 * 20) + 10;
Expand All @@ -201,17 +201,17 @@ private void drawList(int x, int y, int mx, int my) {
ItemRenderHelper.renderItem(actualDrawX, actualDrawY, stacks.get(i));
}

GlStateManager.popMatrix();
RenderSystem.popMatrix();
} else {
break;
}
}

if (!highlighted.isEmpty()) {
GlStateManager.pushMatrix();
GlStateManager.scaled(2, 2, 2);
RenderSystem.pushMatrix();
RenderSystem.scaled(2, 2, 2);
ItemRenderHelper.renderItem(highlightedX, highlightedY, highlighted);
GlStateManager.popMatrix();
RenderSystem.popMatrix();
}
}

Expand Down
53 changes: 27 additions & 26 deletions src/main/java/dmillerw/menu/gui/menu/PickItemScreen.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dmillerw.menu.gui.menu;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.datafixers.util.Pair;
import dmillerw.menu.gui.ScreenStack;
import dmillerw.menu.helper.GuiRenderHelper;
import dmillerw.menu.helper.ItemRenderHelper;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -41,59 +41,60 @@ public void render(int mouseX, int mouseY, float partialTicks) {
Slot mousedOver = null;

// Draw inventory contents
GlStateManager.pushMatrix();
for (int i1 = 0; i1 < this.getMinecraft().player.container.inventorySlots.size(); ++i1) {
Slot slot = this.getMinecraft().player.container.inventorySlots.get(i1);
if (mouseX - guiLeft >= slot.xPos && mouseX - guiLeft <= slot.xPos + 16 && mouseY - guiTop >= slot.yPos && mouseY - guiTop <= slot.yPos + 16) {
mousedOver = slot;
} else {
this.drawSlot(slot, false);
if (this.getMinecraft().player != null) {
RenderSystem.pushMatrix();
for (int i1 = 0; i1 < this.getMinecraft().player.container.inventorySlots.size(); ++i1) {
Slot slot = this.getMinecraft().player.container.inventorySlots.get(i1);
if (mouseX - guiLeft >= slot.xPos && mouseX - guiLeft <= slot.xPos + 16 && mouseY - guiTop >= slot.yPos && mouseY - guiTop <= slot.yPos + 16) {
mousedOver = slot;
} else {
this.drawSlot(slot, false);
}
}
if (mousedOver != null && !mousedOver.getStack().isEmpty()) {
RenderSystem.pushMatrix();
drawSlot(mousedOver, true);
RenderSystem.popMatrix();
renderTooltip(mousedOver.getStack(), mouseX, mouseY);
}
RenderSystem.popMatrix();
}
if (mousedOver != null && !mousedOver.getStack().isEmpty()) {
GlStateManager.pushMatrix();
drawSlot(mousedOver, true);
GlStateManager.popMatrix();
renderTooltip(mousedOver.getStack(), mouseX, mouseY);
}
GlStateManager.popMatrix();
}

private void drawSlot(Slot slot, boolean scale) {
int x = slot.xPos;
int y = slot.yPos;
ItemStack stack = slot.getStack();

this.blitOffset = 100;
this.setBlitOffset(100);
itemRenderer.zLevel = 100.0F;

if (stack.isEmpty()) {
TextureAtlasSprite sprite = slot.getBackgroundSprite();
Pair<ResourceLocation, ResourceLocation> pair = slot.func_225517_c_();

if (sprite != null) {
GlStateManager.disableLighting();
this.getMinecraft().getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
blit(this.guiLeft + x, this.guiTop + y, this.blitOffset, 16, 16, sprite);
GlStateManager.enableLighting();
if (pair != null) {
TextureAtlasSprite sprite = this.getMinecraft().func_228015_a_(pair.getFirst()).apply(pair.getSecond());
this.getMinecraft().getTextureManager().bindTexture(sprite.func_229241_m_().func_229223_g_());
blit(this.guiLeft + x, this.guiTop + y, this.getBlitOffset(), 16, 16, sprite);
}
}

if (!stack.isEmpty()) {
if (scale) {
GlStateManager.scaled(2, 2, 2);
RenderSystem.scaled(2, 2, 2);
ItemRenderHelper.renderItem((this.guiLeft + x + 8) / 2, (this.guiTop + y + 8) / 2, stack);
} else {
ItemRenderHelper.renderItem(this.guiLeft + x + 8, this.guiTop + y + 8, stack);
}
}

itemRenderer.zLevel = 0.0F;
this.blitOffset = 0;
this.setBlitOffset(0);
}

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (button == 0) {
if (button == 0 && this.getMinecraft().player != null) {
for (int i1 = 0; i1 < this.getMinecraft().player.container.inventorySlots.size(); ++i1) {
Slot slot = this.getMinecraft().player.container.inventorySlots.get(i1);
if (mouseX - guiLeft >= slot.xPos && mouseX - guiLeft <= slot.xPos + 16 && mouseY - guiTop >= slot.yPos && mouseY - guiTop <= slot.yPos + 16) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/dmillerw/menu/gui/menu/button/ItemButton.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dmillerw.menu.gui.menu.button;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import dmillerw.menu.helper.ItemRenderHelper;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
Expand All @@ -24,15 +24,15 @@ public void render(int mouseX, int mouseY, float partial) {
if (this.visible) {
this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int k = this.getYImage(this.isHovered);
GuiUtils.drawContinuousTexturedBox(WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.blitOffset);
GuiUtils.drawContinuousTexturedBox(WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
this.renderBg(Minecraft.getInstance(), mouseX, mouseY);

GlStateManager.pushMatrix();
RenderSystem.pushMatrix();
if (this.icon.isEmpty()) {
this.icon = new ItemStack(Blocks.STONE);
}
ItemRenderHelper.renderItem(this.x + this.width / 2, this.y + this.height / 2, icon);
GlStateManager.popMatrix();
RenderSystem.popMatrix();
}
}
}
75 changes: 36 additions & 39 deletions src/main/java/dmillerw/menu/handler/ClientTickHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dmillerw.menu.handler;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import dmillerw.menu.MineMenu;
import dmillerw.menu.data.menu.MenuItem;
import dmillerw.menu.data.menu.RadialMenu;
Expand All @@ -11,7 +11,6 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -77,20 +76,20 @@ public static void onRenderOverlay(RenderGameOverlayEvent event) {

private static void renderGui() {
Minecraft mc = Minecraft.getInstance();
GlStateManager.pushMatrix();
RenderSystem.pushMatrix();

GlStateManager.disableTexture();
RenderSystem.disableTexture();

GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
RenderSystem.matrixMode(GL11.GL_MODELVIEW);
RenderSystem.pushMatrix();
RenderSystem.loadIdentity();

GlStateManager.matrixMode(GL11.GL_PROJECTION);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
RenderSystem.matrixMode(GL11.GL_PROJECTION);
RenderSystem.pushMatrix();
RenderSystem.loadIdentity();

Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
Expand All @@ -110,8 +109,8 @@ private static void renderGui() {
currAngle = Math.toRadians(currAngle);
nextAngle = Math.toRadians(nextAngle);

double innerRadius = ((INNER_RADIUS - RadialMenu.animationTimer - (mouseIn ? 2 : 0)) / 100F) * (257F / (float) mc.mainWindow.getScaledHeight());
double outerRadius = ((OUTER_RADIUS - RadialMenu.animationTimer + (mouseIn ? 2 : 0)) / 100F) * (257F / (float) mc.mainWindow.getScaledHeight());
double innerRadius = ((INNER_RADIUS - RadialMenu.animationTimer - (mouseIn ? 2 : 0)) / 100F) * (257F / (float) mc.func_228018_at_().getScaledHeight());
double outerRadius = ((OUTER_RADIUS - RadialMenu.animationTimer + (mouseIn ? 2 : 0)) / 100F) * (257F / (float) mc.func_228018_at_().getScaledHeight());

bufferBuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);

Expand All @@ -129,29 +128,28 @@ private static void renderGui() {
alpha = (float) ConfigHandler.VISUAL.menuAlpha.get() / (float) 255;
}

bufferBuilder.pos(Math.cos(currAngle) * mc.mainWindow.getScaledHeight() / mc.mainWindow.getScaledWidth() * innerRadius, Math.sin(currAngle) * innerRadius, 0).color(r, g, b, alpha).endVertex();
bufferBuilder.pos(Math.cos(currAngle) * mc.mainWindow.getScaledHeight() / mc.mainWindow.getScaledWidth() * outerRadius, Math.sin(currAngle) * outerRadius, 0).color(r, g, b, alpha).endVertex();
bufferBuilder.pos(Math.cos(nextAngle) * mc.mainWindow.getScaledHeight() / mc.mainWindow.getScaledWidth() * outerRadius, Math.sin(nextAngle) * outerRadius, 0).color(r, g, b, alpha).endVertex();
bufferBuilder.pos(Math.cos(nextAngle) * mc.mainWindow.getScaledHeight() / mc.mainWindow.getScaledWidth() * innerRadius, Math.sin(nextAngle) * innerRadius, 0).color(r, g, b, alpha).endVertex();
bufferBuilder.func_225582_a_(Math.cos(currAngle) * mc.func_228018_at_().getScaledHeight() / mc.func_228018_at_().getScaledWidth() * innerRadius, Math.sin(currAngle) * innerRadius, 0).func_227885_a_(r, g, b, alpha).endVertex();
bufferBuilder.func_225582_a_(Math.cos(currAngle) * mc.func_228018_at_().getScaledHeight() / mc.func_228018_at_().getScaledWidth() * outerRadius, Math.sin(currAngle) * outerRadius, 0).func_227885_a_(r, g, b, alpha).endVertex();
bufferBuilder.func_225582_a_(Math.cos(nextAngle) * mc.func_228018_at_().getScaledHeight() / mc.func_228018_at_().getScaledWidth() * outerRadius, Math.sin(nextAngle) * outerRadius, 0).func_227885_a_(r, g, b, alpha).endVertex();
bufferBuilder.func_225582_a_(Math.cos(nextAngle) * mc.func_228018_at_().getScaledHeight() / mc.func_228018_at_().getScaledWidth() * innerRadius, Math.sin(nextAngle) * innerRadius, 0).func_227885_a_(r, g, b, alpha).endVertex();

tessellator.draw();
}

GlStateManager.popMatrix();
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GlStateManager.popMatrix();
RenderSystem.popMatrix();
RenderSystem.matrixMode(GL11.GL_MODELVIEW);
RenderSystem.popMatrix();

GlStateManager.disableBlend();
GlStateManager.enableTexture();
RenderSystem.disableBlend();
RenderSystem.enableTexture();

GlStateManager.popMatrix();
RenderSystem.popMatrix();
}

private static void renderItems() {
Minecraft mc = Minecraft.getInstance();
GlStateManager.pushMatrix();
GlStateManager.translated(mc.mainWindow.getScaledWidth() * 0.5D, mc.mainWindow.getScaledHeight() * 0.5D, 0);
RenderHelper.enableGUIStandardItemLighting();
RenderSystem.pushMatrix();
RenderSystem.translated(mc.func_228018_at_().getScaledWidth() * 0.5D, mc.func_228018_at_().getScaledHeight() * 0.5D, 0);

for (int i = 0; i < RadialMenu.MAX_ITEMS; i++) {
MenuItem item = RadialMenu.getActiveArray()[i];
Expand All @@ -171,13 +169,12 @@ private static void renderItems() {
ItemRenderHelper.renderItem((int) drawX, (int) drawY, stack);
}

RenderHelper.disableStandardItemLighting();
GlStateManager.popMatrix();
RenderSystem.popMatrix();
}

private static void renderText() {
Minecraft mc = Minecraft.getInstance();
MainWindow window = mc.mainWindow;
MainWindow window = mc.func_228018_at_();
FontRenderer fontRenderer = mc.fontRenderer;
double mouseAngle = AngleHelper.getMouseAngle();
mouseAngle -= ClientTickHandler.ANGLE_PER_ITEM / 2;
Expand Down Expand Up @@ -208,10 +205,10 @@ private static void renderText() {
float padding = 5F;

// Background
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

GlStateManager.disableTexture();
RenderSystem.disableTexture();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(7, DefaultVertexFormats.POSITION_COLOR);
Expand All @@ -221,14 +218,14 @@ private static void renderText() {
float b = (float) ConfigHandler.VISUAL.menuBlue.get() / (float) 255;
float alpha = (float) ConfigHandler.VISUAL.menuAlpha.get() / (float) 255;

bufferBuilder.pos(drawX - padding, drawY + drawHeight + padding, 0).color(r, g, b, alpha).endVertex();
bufferBuilder.pos(drawX + drawWidth + padding, drawY + drawHeight + padding, 0).color(r, g, b, alpha).endVertex();
bufferBuilder.pos(drawX + drawWidth + padding, drawY - padding, 0).color(r, g, b, alpha).endVertex();
bufferBuilder.pos(drawX - padding, drawY - padding, 0).color(r, g, b, alpha).endVertex();
bufferBuilder.func_225582_a_(drawX - padding, drawY + drawHeight + padding, 0).func_227885_a_(r, g, b, alpha).endVertex();
bufferBuilder.func_225582_a_(drawX + drawWidth + padding, drawY + drawHeight + padding, 0).func_227885_a_(r, g, b, alpha).endVertex();
bufferBuilder.func_225582_a_(drawX + drawWidth + padding, drawY - padding, 0).func_227885_a_(r, g, b, alpha).endVertex();
bufferBuilder.func_225582_a_(drawX - padding, drawY - padding, 0).func_227885_a_(r, g, b, alpha).endVertex();

tessellator.draw();
GlStateManager.enableTexture();
GlStateManager.disableBlend();
RenderSystem.enableTexture();
RenderSystem.disableBlend();

// Text
fontRenderer.drawStringWithShadow(string, drawX, drawY, 0xFFFFFF);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dmillerw/menu/handler/KeyboardHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static void onClientTick(TickEvent.ClientTickEvent event) {
return;
}

long handle = Minecraft.getInstance().mainWindow.getHandle();
long handle = Minecraft.getInstance().func_228018_at_().getHandle();
boolean wheelKeyPressed = WHEEL.getKey().getKeyCode() >= 0 ? InputMappings.isKeyDown(handle, WHEEL.getKey().getKeyCode()) : InputMappings.isKeyDown(handle, WHEEL.getKey().getKeyCode() + 100);

if (wheelKeyPressed != lastWheelState) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dmillerw/menu/helper/AngleHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class AngleHelper {

public static double getMouseAngle() {
Minecraft mc = Minecraft.getInstance();
return getRelativeAngle(mc.mainWindow.getWidth() * 0.5D, mc.mainWindow.getHeight() * 0.5D, mc.mouseHelper.getMouseX(), mc.mouseHelper.getMouseY());
return getRelativeAngle(mc.func_228018_at_().getWidth() * 0.5D, mc.func_228018_at_().getHeight() * 0.5D, mc.mouseHelper.getMouseX(), mc.mouseHelper.getMouseY());
}

private static double getRelativeAngle(double originX, double originY, double x, double y) {
Expand Down

0 comments on commit 50722f1

Please sign in to comment.