diff options
author | syeyoung <cyong06@naver.com> | 2021-05-01 01:49:21 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-05-01 01:49:21 +0900 |
commit | c60485da3704c1ac91f614f8020c79f5a92a599e (patch) | |
tree | 8f1566266dcee9057cfaf1f1b7202cfd83b66270 /src/main/java/kr | |
parent | 3759d01a54ede59da360961266c7b3cd70c99585 (diff) | |
download | Skyblock-Dungeons-Guide-c60485da3704c1ac91f614f8020c79f5a92a599e.tar.gz Skyblock-Dungeons-Guide-c60485da3704c1ac91f614f8020c79f5a92a599e.tar.bz2 Skyblock-Dungeons-Guide-c60485da3704c1ac91f614f8020c79f5a92a599e.zip |
hot bar
Diffstat (limited to 'src/main/java/kr')
4 files changed, 97 insertions, 37 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererHoverForInv.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererHoverForInv.java deleted file mode 100644 index 6360da62..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererHoverForInv.java +++ /dev/null @@ -1,32 +0,0 @@ -package kr.syeyoung.dungeonsguide.features.impl.party.playerpreview; - -import kr.syeyoung.dungeonsguide.features.impl.party.api.PlayerProfile; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; - -import java.awt.*; - -public class DataRendererHoverForInv implements DataRenderer { - @Override - public Dimension renderData(PlayerProfile playerProfile) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("§aView Inventory", 0,0,-1); - return new Dimension(100, fr.FONT_HEIGHT); - } - - @Override - public void onHover(PlayerProfile playerProfile, int mouseX, int mouseY) { - - } - - @Override - public Dimension renderDummy() { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - fr.drawString("§aView Inventory", 0,0,-1); - return new Dimension(100, fr.FONT_HEIGHT); - } - @Override - public Dimension getDimension() { - return new Dimension(100, Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT); - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java index fa23d1e7..0c1edea0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/DataRendererRegistry.java @@ -36,7 +36,6 @@ public class DataRendererRegistry { } dataRendererMap.put("fairysouls", new DataRendererFairySouls()); dataRendererMap.put("secrets", new DataRendererSecrets()); - dataRendererMap.put("hover4inv", new DataRendererHoverForInv()); dataRendererMap.put("dummy", new DataRendererSetUrOwn()); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java index 80109141..263aaf35 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/playerpreview/FeatureViewPlayerOnJoin.java @@ -35,6 +35,7 @@ import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.client.resources.SkinManager; @@ -71,6 +72,7 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen private Future<Optional<GameProfile>> gfFuture; private Future<SkinFetchur.SkinSet> skinFuture; private FakePlayer fakePlayer; + private boolean drawInv = false; @SneakyThrows @Override public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { @@ -94,6 +96,7 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen gfFuture = null; skinFuture= null; fakePlayer= null; + drawInv = false; } public void reqRender(String uid) { @@ -104,11 +107,11 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - if (!((popupRect != null && popupRect.contains(mouseX, mouseY)) || uid != null && uid.equals(lastuid))) { + if (!((popupRect != null && (popupRect.contains(mouseX, mouseY) || drawInv)) || uid != null && uid.equals(lastuid))) { cancelRender(); } - if (uid != null && !uid.equals(lastuid) && (popupRect==null || !popupRect.contains(mouseX, mouseY))) { + if (uid != null && !uid.equals(lastuid) && (popupRect==null || (!popupRect.contains(mouseX, mouseY) && !drawInv)) ) { cancelRender(); lastuid = uid; } @@ -195,7 +198,6 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen GlStateManager.translate(95, 5, 0); int culmutativeY = 5; DataRenderer dataRendererToHover = null; - System.out.println(this.<List<String>>getParameter("datarenderers").getValue()); for (String datarenderers : this.<List<String>>getParameter("datarenderers").getValue()) { DataRenderer dataRenderer = DataRendererRegistry.getDataRenderer(datarenderers); Dimension dim; @@ -219,6 +221,9 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen Gui.drawRect(0,0, 90, 170, 0xFF23272a); Gui.drawRect(2,2, 88, 168, 0xFF444444); + Gui.drawRect(80,159, 90, 170, 0xFF23272a); + Gui.drawRect(82,161, 88, 168, 0xFF444444); + fr.drawString("§eI", 83,161,-1); GlStateManager.color(1, 1, 1, 1.0F); if (fakePlayer != null) { GuiInventory.drawEntityOnScreen(45, 150, 60, -(mouseX - popupRect.x - 75), 0, fakePlayer); @@ -262,9 +267,60 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen } GL11.glDisable(GL11.GL_SCISSOR_TEST); - if (dataRendererToHover != null) { + if (dataRendererToHover != null && !drawInv) { dataRendererToHover.onHover(playerProfile.get(), relX, relY); } + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + if (drawInv) { + int startX = 81; + int startY = 86; + MPanel.clip(scaledResolution, popupRect.x+startX-1, popupRect.y+startY-1, 164, 74); + GlStateManager.translate(startX,startY,1); + Gui.drawRect(-1,-1,163,73, 0xFF000000); + GlStateManager.disableLighting(); + ItemStack toHover = null; + int rx = relX - startX; + int ry = relY - startY; + + + GlStateManager.pushAttrib(); + GlStateManager.disableRescaleNormal(); + RenderHelper.enableGUIStandardItemLighting(); + GlStateManager.disableLighting(); + for (int i = 0; i < playerProfile.get().getInventory().length; i++) { + int x = (i%9) * 18; + int y = (i/9) * 18; + if (x <= rx && rx<x+18 && y<=ry&&ry<y+18) { + toHover = playerProfile.get().getInventory()[(i+9) % 36]; + } + Gui.drawRect(x,y,x+18,y+18, 0xFF000000); + Gui.drawRect(x+1,y+1,x+17,y+17, 0xFF666666); + GlStateManager.color(1, 1, 1, 1.0F); + + Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(playerProfile.get().getInventory()[(i+9) % 36], (i%9) * 18+1,(i/9) * 18+1); + } + GlStateManager.popAttrib(); + if (toHover != null) { + List<String> list = toHover.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); + for (int i = 0; i < list.size(); ++i) { + if (i == 0) { + list.set(i, toHover.getRarity().rarityColor + (String)list.get(i)); + } else { + list.set(i, EnumChatFormatting.GRAY + (String)list.get(i)); + } + } + FontRenderer font = toHover.getItem().getFontRenderer(toHover); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + FontRenderer theRenderer = (font == null ? fr : font); + int minY = scaledResolution.getScaledHeight() - (list.size()+4) * theRenderer.FONT_HEIGHT - popupRect.y; + RenderUtils.drawHoveringText(list,rx, Math.min(minY-startY, ry), theRenderer); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + } + } + GL11.glDisable(GL11.GL_SCISSOR_TEST); + + GlStateManager.popMatrix(); // 33 66 108 130 154 // 5 75 } @Override @@ -274,6 +330,8 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen int height = scaledResolution.getScaledHeight(); int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + if (Mouse.getEventButton() != -1 && Mouse.isButtonDown(Mouse.getEventButton()) && drawInv) drawInv = false; if (popupRect == null || !popupRect.contains(mouseX, mouseY)) return; mouseInputEvent.setCanceled(true); @@ -281,6 +339,7 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen int relX = mouseX - popupRect.x; int relY = mouseY - popupRect.y; + try { PlayerProfile playerProfile = profileFuture.isDone() ? profileFuture.get().orElse(null) : null; if (playerProfile == null) return; @@ -291,6 +350,8 @@ public class FeatureViewPlayerOnJoin extends SimpleFeature implements GuiPostRen } else if (new Rectangle(2, 170, 86, 23).contains(relX, relY)) { // kick Minecraft.getMinecraft().thePlayer.sendChatMessage("/p kick " + ApiFetchur.fetchNicknameAsync(playerProfile.getMemberUID()).get().orElse("-")); + } else if (new Rectangle(80,159,10,11).contains(relX, relY)) { + drawInv = true; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index 9accdbbe..f8e05329 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -6,6 +6,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; @@ -16,6 +17,8 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.passive.EntityBat; import net.minecraft.util.*; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import javax.vecmath.Vector3f; @@ -29,6 +32,10 @@ public class RenderUtils { drawTexturedRect(x, y, width, height, 0.0F, 1.0F, 0.0F, 1.0F, filter); } private static float zLevel = 0; + public static int scrollY = 0; + public static boolean allowScrolling; + public static int scrollX = 0; + public static void drawHoveringText(List<String> textLines, int x, int y, FontRenderer font) { if (!textLines.isEmpty()) @@ -60,6 +67,30 @@ public class RenderUtils { zLevel = 300.0F; int l = -267386864; + + + if (!allowScrolling) { + scrollX = 0; + scrollY = 0; + } + allowScrolling = (i2 < 0); + GlStateManager.pushMatrix(); + if (allowScrolling) { + int eventDWheel = Mouse.getDWheel(); + if (Keyboard.isKeyDown(42)) { + if (eventDWheel < 0) { + scrollX += 10; + } else if (eventDWheel > 0) { + scrollX -= 10; + } + } else if (eventDWheel < 0) { + scrollY -= 10; + } else if (eventDWheel > 0) { + scrollY += 10; + } + } + GlStateManager.translate(scrollX, scrollY, 0.0F); + drawGradientRect(l1 - 3, i2 - 4, l1 + i + 3, i2 - 3, l, l); drawGradientRect(l1 - 3, i2 + k + 3, l1 + i + 3, i2 + k + 4, l, l); drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 + k + 3, l, l); @@ -90,6 +121,7 @@ public class RenderUtils { GlStateManager.enableDepth(); RenderHelper.enableStandardItemLighting(); GlStateManager.enableRescaleNormal(); + GlStateManager.popMatrix(); } } protected static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) |