From 519e968743e29e32afa760a15e3b3fac8c635b06 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sat, 27 Feb 2021 01:20:27 +0900 Subject: fix streams i guess --- .../features/impl/dungeon/FeatureDungeonMap.java | 151 +++++++++++++-------- 1 file changed, 97 insertions(+), 54 deletions(-) (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features/impl') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java index 357c5636..e378fadd 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java @@ -11,10 +11,7 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.GuiFeature; -import kr.syeyoung.dungeonsguide.features.listener.BossroomEnterListener; -import kr.syeyoung.dungeonsguide.features.listener.ChatListener; -import kr.syeyoung.dungeonsguide.features.listener.DungeonEndListener; -import kr.syeyoung.dungeonsguide.features.listener.DungeonStartListener; +import kr.syeyoung.dungeonsguide.features.listener.*; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.block.material.MapColor; @@ -59,6 +56,7 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, parameters.put("playerCenter", new FeatureParameter("playerCenter", "Center map at player", "Render you in the center", false, "boolean")); parameters.put("rotate", new FeatureParameter("rotate", "Rotate map centered at player", "Only works with Center map at player enabled", false, "boolean")); parameters.put("postScale", new FeatureParameter("postScale", "Scale factor of map", "Only works with Center map at player enabled", 1.0f, "float")); + parameters.put("useplayerheads", new FeatureParameter("useplayerheads", "Use player heads instead of arrows", "Option to use player heads instead of arrows", true, "boolean")); parameters.put("showotherplayers", new FeatureParameter("showotherplayers", "Show other players", "Option to show other players in map", true, "boolean")); parameters.put("showtotalsecrets", new FeatureParameter("showtotalsecrets", "Show Total secrets in the room", "Option to overlay total secrets in the specific room", true, "boolean")); parameters.put("playerheadscale", new FeatureParameter("playerheadscale", "Player head scale", "Scale factor of player heads, defaults to 1", 1.0f, "float")); @@ -163,58 +161,13 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(1, 771, 0, 1); + if (this.getParameter("useplayerheads").getValue()) { + renderHeads(mapProcessor, mapData, scale, postScale, partialTicks); + } else { + renderArrows(mapProcessor, mapData, scale, postScale, partialTicks); + } - List list = field_175252_a.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); - if (list.size() < 40) return; - for (int i = 1; i < 20; i++) { - NetworkPlayerInfo networkPlayerInfo = list.get(i); - String name = networkPlayerInfo.getDisplayName() != null ? networkPlayerInfo.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfo.getPlayerTeam(), networkPlayerInfo.getGameProfile().getName()); - if (name.trim().equals("§r") || name.startsWith("§r ")) continue; - String actual = TextUtils.stripColor(name).trim().split(" ")[0]; - EntityPlayer entityplayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(actual); - if (TextUtils.stripColor(name).endsWith("(DEAD)") && entityplayer != Minecraft.getMinecraft().thePlayer) { - continue; - } - Point pt2; - double yaw2; - - if (entityplayer != null && (!entityplayer.isInvisible() || entityplayer == Minecraft.getMinecraft().thePlayer)) { - pt2 = mapProcessor.worldPointToMapPoint(entityplayer.getPositionEyes(partialTicks)); - yaw2 = entityplayer.prevRotationYawHead + (entityplayer.rotationYawHead - entityplayer.prevRotationYawHead) * partialTicks; - } else { - String iconName = mapProcessor.getMapIconToPlayerMap().get(actual); - if (iconName == null) continue; - Vec4b vec = mapData.mapDecorations.get(iconName); - if (vec == null) { - continue; - } else { - pt2 = new Point(vec.func_176112_b() / 2 + 64, vec.func_176113_c() / 2 + 64); - yaw2 = vec.func_176111_d() * 360 / 16.0f ; - } - } - GlStateManager.pushMatrix(); - if (entityplayer == Minecraft.getMinecraft().thePlayer || this.getParameter("showotherplayers").getValue()) - { - boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE); - GlStateManager.enableTexture2D(); - Minecraft.getMinecraft().getTextureManager().bindTexture(networkPlayerInfo.getLocationSkin()); - int l2 = 8 + (flag1 ? 8 : 0); - int i3 = 8 * (flag1 ? -1 : 1); - - GlStateManager.translate(pt2.x, pt2.y, 0); - GlStateManager.rotate((float) (yaw2 - 180), 0, 0, 1); - - GlStateManager.scale(1 / scale, 1 / scale, 0); - GlStateManager.scale(1 / postScale, 1 / postScale, 0); - float s = this.getParameter("playerheadscale").getValue(); - GlStateManager.scale(s,s,0); - Gui.drawScaledCustomSizeModalRect(-4, -4, 8.0F, (float) l2, 8, i3, 8, 8, 64.0F, 64.0F); - GL11.glLineWidth(1); - RenderUtils.drawUnfilledBox(-4,-4,4, 4, this.getParameter("player_color").getValue()); - } - GlStateManager.popMatrix(); - } FontRenderer fr = getFontRenderer(); if (this.getParameter("showtotalsecrets").getValue()) { for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { @@ -293,6 +246,96 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, this.mapTexture.updateDynamicTexture(); } + private void renderHeads(MapProcessor mapProcessor, MapData mapData, float scale, float postScale, float partialTicks) { + List list = field_175252_a.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); + if (list.size() < 40) return; + for (int i = 1; i < 20; i++) { + NetworkPlayerInfo networkPlayerInfo = list.get(i); + String name = networkPlayerInfo.getDisplayName() != null ? networkPlayerInfo.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfo.getPlayerTeam(), networkPlayerInfo.getGameProfile().getName()); + if (name.trim().equals("§r") || name.startsWith("§r ")) continue; + String actual = TextUtils.stripColor(name).trim().split(" ")[0]; + EntityPlayer entityplayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(actual); + if (TextUtils.stripColor(name).endsWith("(DEAD)") && entityplayer != Minecraft.getMinecraft().thePlayer) { + continue; + } + Point pt2; + double yaw2; + + if (entityplayer != null && (!entityplayer.isInvisible() || entityplayer == Minecraft.getMinecraft().thePlayer)) { + pt2 = mapProcessor.worldPointToMapPoint(entityplayer.getPositionEyes(partialTicks)); + yaw2 = entityplayer.prevRotationYawHead + (entityplayer.rotationYawHead - entityplayer.prevRotationYawHead) * partialTicks; + } else { + String iconName = mapProcessor.getMapIconToPlayerMap().get(actual); + if (iconName == null) continue; + Vec4b vec = mapData.mapDecorations.get(iconName); + if (vec == null) { + continue; + } else { + pt2 = new Point(vec.func_176112_b() / 2 + 64, vec.func_176113_c() / 2 + 64); + yaw2 = vec.func_176111_d() * 360 / 16.0f ; + } + } + GlStateManager.pushMatrix(); + if (entityplayer == Minecraft.getMinecraft().thePlayer || this.getParameter("showotherplayers").getValue()) + { + boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE); + GlStateManager.enableTexture2D(); + Minecraft.getMinecraft().getTextureManager().bindTexture(networkPlayerInfo.getLocationSkin()); + int l2 = 8 + (flag1 ? 8 : 0); + int i3 = 8 * (flag1 ? -1 : 1); + + GlStateManager.translate(pt2.x, pt2.y, 0); + GlStateManager.rotate((float) (yaw2 - 180), 0, 0, 1); + + GlStateManager.scale(1 / scale, 1 / scale, 0); + GlStateManager.scale(1 / postScale, 1 / postScale, 0); + float s = this.getParameter("playerheadscale").getValue(); + GlStateManager.scale(s,s,0); + Gui.drawScaledCustomSizeModalRect(-4, -4, 8.0F, (float) l2, 8, i3, 8, 8, 64.0F, 64.0F); + GL11.glLineWidth(1); + RenderUtils.drawUnfilledBox(-4,-4,4, 4, this.getParameter("player_color").getValue()); + } + GlStateManager.popMatrix(); + } + } + private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png"); + + private void renderArrows(MapProcessor mapProcessor, MapData mapData, float scale, float postScale, float partialTicks) { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + int k = 0; + Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons); + for (Vec4b vec4b : mapData.mapDecorations.values()) { + if (vec4b.func_176110_a() == 1 || this.getParameter("showotherplayers").getValue()) { + GlStateManager.pushMatrix(); + GlStateManager.translate((float)vec4b.func_176112_b() / 2.0F + 64.0F, (float)vec4b.func_176113_c() / 2.0F + 64.0F, -0.02F); + GlStateManager.rotate((float)(vec4b.func_176111_d() * 360) / 16.0F, 0.0F, 0.0F, 1.0F); + + GlStateManager.scale(1 / scale, 1 / scale, 0); + GlStateManager.scale(1 / postScale, 1 / postScale, 0); + float s = this.getParameter("playerheadscale").getValue(); + GlStateManager.scale(s,s,0); + + GlStateManager.translate(-0.125F, 0.125F, 0.0F); + byte b0 = vec4b.func_176110_a(); + float f1 = (float)(b0 % 4) / 4.0F; + float f2 = (float)(b0 / 4) / 4.0F; + float f3 = (float)(b0 % 4 + 1) / 4.0F; + float f4 = (float)(b0 / 4 + 1) / 4.0F; + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + float f5 = -0.001F; + worldrenderer.pos(-1.0D, 1.0D, (double)((float)k * -0.001F)).tex((double)f1, (double)f2).endVertex(); + worldrenderer.pos(1.0D, 1.0D, (double)((float)k * -0.001F)).tex((double)f3, (double)f2).endVertex(); + worldrenderer.pos(1.0D, -1.0D, (double)((float)k * -0.001F)).tex((double)f3, (double)f4).endVertex(); + worldrenderer.pos(-1.0D, -1.0D, (double)((float)k * -0.001F)).tex((double)f1, (double)f4).endVertex(); + tessellator.draw(); + GlStateManager.popMatrix(); + ++k; + } + GlStateManager.popMatrix(); + } + } + private void render(MapData mapData, boolean noOverlayRendering) { int i = 0; int j = 0; -- cgit