aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkingstefan26 <eryk.ruta1@gmail.com>2022-10-04 16:43:40 +0200
committerkingstefan26 <eryk.ruta1@gmail.com>2022-10-04 16:43:40 +0200
commit0eded8ba2270b9cd49db6527978567d69ce7c32b (patch)
tree72c3a5fac7f72980dee3526366bf3ecc37c99a7d /src
parent0769dd5ff85fda912a52f8cc602bc484d85165c8 (diff)
downloadSkyblock-Dungeons-Guide-0eded8ba2270b9cd49db6527978567d69ce7c32b.tar.gz
Skyblock-Dungeons-Guide-0eded8ba2270b9cd49db6527978567d69ce7c32b.tar.bz2
Skyblock-Dungeons-Guide-0eded8ba2270b9cd49db6527978567d69ce7c32b.zip
fix the code not checking if player is not dead
Diffstat (limited to 'src')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonMap.java193
1 files changed, 108 insertions, 85 deletions
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 d9cb27a1..39fde917 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
@@ -51,6 +51,7 @@ import net.minecraft.world.WorldSettings;
import net.minecraft.world.storage.MapData;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
@@ -62,7 +63,7 @@ import java.util.regex.Pattern;
public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener, DungeonStartListener, BossroomEnterListener {
public FeatureDungeonMap() {
- super("Dungeon", "Dungeon Map", "Display dungeon map!", "dungeon.map", true, 128,128);
+ super("Dungeon", "Dungeon Map", "Display dungeon map!", "dungeon.map", true, 128, 128);
this.setEnabled(false);
parameters.put("scale", new FeatureParameter<Boolean>("scale", "Scale map", "Whether to scale map to fit screen", true, "boolean"));
parameters.put("playerCenter", new FeatureParameter<Boolean>("playerCenter", "Center map at player", "Render you in the center", false, "boolean"));
@@ -74,9 +75,9 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
parameters.put("playerheadscale", new FeatureParameter<Float>("playerheadscale", "Player head scale", "Scale factor of player heads, defaults to 1", 1.0f, "float"));
parameters.put("textScale", new FeatureParameter<Float>("textScale", "Text scale", "Scale factor of texts on map, defaults to 1", 1.0f, "float"));
- parameters.put("border_color", new FeatureParameter<AColor>("border_color", "Color of the border", "Same as name", new AColor(255,255,255,255), "acolor"));
+ parameters.put("border_color", new FeatureParameter<AColor>("border_color", "Color of the border", "Same as name", new AColor(255, 255, 255, 255), "acolor"));
parameters.put("background_color", new FeatureParameter<AColor>("background_color", "Color of the background", "Same as name", new AColor(0x22000000, true), "acolor"));
- parameters.put("player_color", new FeatureParameter<AColor>("player_color", "Color of the player border", "Same as name", new AColor(255,255,255,0), "acolor"));
+ parameters.put("player_color", new FeatureParameter<AColor>("player_color", "Color of the player border", "Same as name", new AColor(255, 255, 255, 0), "acolor"));
}
SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus();
@@ -100,40 +101,39 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
}
@SideOnly(Side.CLIENT)
- static class PlayerComparator implements Comparator<NetworkPlayerInfo>
- {
- private PlayerComparator()
- {
+ static class PlayerComparator implements Comparator<NetworkPlayerInfo> {
+ private PlayerComparator() {
}
- public int compare(NetworkPlayerInfo p_compare_1_, NetworkPlayerInfo p_compare_2_)
- {
+ public int compare(NetworkPlayerInfo p_compare_1_, NetworkPlayerInfo p_compare_2_) {
ScorePlayerTeam scoreplayerteam = p_compare_1_.getPlayerTeam();
ScorePlayerTeam scoreplayerteam1 = p_compare_2_.getPlayerTeam();
return ComparisonChain.start().compareTrueFirst(p_compare_1_.getGameType() != WorldSettings.GameType.SPECTATOR, p_compare_2_.getGameType() != WorldSettings.GameType.SPECTATOR).compare(scoreplayerteam != null ? scoreplayerteam.getRegisteredName() : "", scoreplayerteam1 != null ? scoreplayerteam1.getRegisteredName() : "").compare(p_compare_1_.getGameProfile().getName(), p_compare_2_.getGameProfile().getName()).result();
}
}
+
@Override
public void drawHUD(float partialTicks) {
if (!skyblockStatus.isOnDungeon()) return;
- if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return;
+ if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized())
+ return;
if (!on) return;
DungeonContext context = skyblockStatus.getContext();
MapProcessor mapProcessor = context.getMapProcessor();
MapData mapData = mapProcessor.getLastMapData2();
- Rectangle featureRect =getFeatureRect().getRectangle();
- Gui.drawRect(0,0,featureRect.width, featureRect.height, RenderUtils.getColorAt(featureRect.x, featureRect.y, this.<AColor>getParameter("background_color").getValue()));
- GlStateManager.color(1,1,1,1);
+ Rectangle featureRect = getFeatureRect().getRectangle();
+ Gui.drawRect(0, 0, featureRect.width, featureRect.height, RenderUtils.getColorAt(featureRect.x, featureRect.y, this.<AColor>getParameter("background_color").getValue()));
+ GlStateManager.color(1, 1, 1, 1);
GlStateManager.pushMatrix();
if (mapData == null) {
- Gui.drawRect(0,0,featureRect.width, featureRect.height, 0xFFFF0000);
+ Gui.drawRect(0, 0, featureRect.width, featureRect.height, 0xFFFF0000);
} else {
- renderMap(partialTicks,mapProcessor,mapData,context);
+ renderMap(partialTicks, mapProcessor, mapData, context);
}
GlStateManager.popMatrix();
GL11.glLineWidth(2);
- RenderUtils.drawUnfilledBox(0,0,featureRect.width, featureRect.height, this.<AColor>getParameter("border_color").getValue());
+ RenderUtils.drawUnfilledBox(0, 0, featureRect.width, featureRect.height, this.<AColor>getParameter("border_color").getValue());
}
@Override
@@ -142,8 +142,8 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
drawHUD(partialTicks);
return;
}
- Rectangle featureRect =getFeatureRect().getRectangle();
- Gui.drawRect(0,0,featureRect.width, featureRect.height, RenderUtils.getColorAt(featureRect.x, featureRect.y, this.<AColor>getParameter("background_color").getValue()));
+ Rectangle featureRect = getFeatureRect().getRectangle();
+ Gui.drawRect(0, 0, featureRect.width, featureRect.height, RenderUtils.getColorAt(featureRect.x, featureRect.y, this.<AColor>getParameter("background_color").getValue()));
FontRenderer fr = getFontRenderer();
GlStateManager.enableBlend();
@@ -151,27 +151,27 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
fr.drawString("Please join a dungeon to see preview", featureRect.width / 2 - fr.getStringWidth("Please join a dungeon to see preview") / 2, featureRect.height / 2 - fr.FONT_HEIGHT / 2, 0xFFFFFFFF);
GL11.glLineWidth(2);
- RenderUtils.drawUnfilledBox(0,0,featureRect.width, featureRect.height, this.<AColor>getParameter("border_color").getValue());
+ RenderUtils.drawUnfilledBox(0, 0, featureRect.width, featureRect.height, this.<AColor>getParameter("border_color").getValue());
}
- public void renderMap(float partialTicks, MapProcessor mapProcessor, MapData mapData, DungeonContext context){
+ public void renderMap(float partialTicks, MapProcessor mapProcessor, MapData mapData, DungeonContext context) {
float postScale = this.<Boolean>getParameter("playerCenter").getValue() ? this.<Float>getParameter("postScale").getValue() : 1;
- Rectangle featureRect =getFeatureRect().getRectangle();
+ Rectangle featureRect = getFeatureRect().getRectangle();
int width = featureRect.width;
float scale = (this.<Boolean>getParameter("scale").getValue() ? width / 128.0f : 1);
GlStateManager.translate(width / 2, width / 2, 0);
GlStateManager.scale(scale, scale, 0);
- GlStateManager.scale(postScale, postScale,0);
+ GlStateManager.scale(postScale, postScale, 0);
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
Point pt = mapProcessor.worldPointToMapPoint(p.getPositionEyes(partialTicks));
double yaw = p.prevRotationYawHead + (p.rotationYaw - p.prevRotationYawHead) * partialTicks;
if (this.<Boolean>getParameter("playerCenter").getValue()) {
if (this.<Boolean>getParameter("rotate").getValue()) {
- GlStateManager.rotate((float) (180.0 - yaw), 0,0,1);
+ GlStateManager.rotate((float) (180.0 - yaw), 0, 0, 1);
}
- GlStateManager.translate( -pt.x, -pt.y, 0);
+ GlStateManager.translate(-pt.x, -pt.y, 0);
} else {
- GlStateManager.translate( -64, -64, 0);
+ GlStateManager.translate(-64, -64, 0);
}
updateMapTexture(mapData.colors, mapProcessor, context.getDungeonRoomList());
render(mapData, false);
@@ -201,7 +201,7 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
GlStateManager.scale(1 / scale, 1 / scale, 0);
GlStateManager.scale(1 / postScale, 1 / postScale, 0);
float s = this.<Float>getParameter("textScale").getValue();
- GlStateManager.scale(s,s,0);
+ GlStateManager.scale(s, s, 0);
String str = "";
str += dungeonRoom.getTotalSecrets() == -1 ? "?" : String.valueOf(dungeonRoom.getTotalSecrets());
str += " ";
@@ -228,7 +228,6 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
}
-
private final DynamicTexture mapTexture = new DynamicTexture(128, 128);
private final ResourceLocation location = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("dungeonmap/map", mapTexture);
private final int[] mapTextureData = mapTexture.getTextureData();
@@ -269,40 +268,23 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
this.mapTexture.updateDynamicTexture();
}
- final Pattern pattern = Pattern.compile("\\*[a-zA-Z0-9_]{2,16}\\*", Pattern.MULTILINE);
-
-
private void renderHeads(MapProcessor mapProcessor, MapData mapData, float scale, float postScale, float partialTicks) {
List<NetworkPlayerInfo> list = field_175252_a.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap());
if (list.size() < 40) return;
+
+ // 19 iterations bc we only want to scan the player part of tab list
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;
-
- name = TextUtils.stripColor(name);
-
- name = name.replaceAll(" ", "*");
-
- Matcher matcher = pattern.matcher(name);
-
- if(!matcher.find()) continue;
-
- name = matcher.group(0);
-
- name = name.substring(0, name.length() - 1);
-
- name = name.substring(1);
+ String name = getPlayerName(networkPlayerInfo);
+ if (name == null) continue;
EntityPlayer entityplayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(name);
- if (TextUtils.stripColor(name).endsWith("(DEAD)") && entityplayer != Minecraft.getMinecraft().thePlayer) {
- continue;
- }
+ if (entityplayer != Minecraft.getMinecraft().thePlayer) continue;
+
Point pt2;
double yaw2;
@@ -317,12 +299,15 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
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 ;
+ yaw2 = vec.func_176111_d() * 360 / 16.0f;
}
}
+
GlStateManager.pushMatrix();
- if (entityplayer == Minecraft.getMinecraft().thePlayer || this.<Boolean>getParameter("showotherplayers").getValue())
- {
+
+ boolean showOtherPlayers = this.<Boolean>getParameter("showotherplayers").getValue();
+
+ if (entityplayer == Minecraft.getMinecraft().thePlayer || showOtherPlayers) {
boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE);
GlStateManager.enableTexture2D();
Minecraft.getMinecraft().getTextureManager().bindTexture(networkPlayerInfo.getLocationSkin());
@@ -335,14 +320,52 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
GlStateManager.scale(1 / scale, 1 / scale, 0);
GlStateManager.scale(1 / postScale, 1 / postScale, 0);
float s = this.<Float>getParameter("playerheadscale").getValue();
- GlStateManager.scale(s,s,0);
+ 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.<AColor>getParameter("player_color").getValue());
+ RenderUtils.drawUnfilledBox(-4, -4, 4, 4, this.<AColor>getParameter("player_color").getValue());
}
GlStateManager.popMatrix();
}
}
+
+ final Pattern tabListRegex = Pattern.compile("\\*[a-zA-Z0-9_]{2,16}\\*", Pattern.MULTILINE);
+
+ /**
+ * We make sure that the player is alive and regex their name out
+ * @param networkPlayerInfo the network player info of player
+ * @return the username of player
+ */
+ @Nullable
+ private String getPlayerName(NetworkPlayerInfo networkPlayerInfo) {
+ String name;
+ if (networkPlayerInfo.getDisplayName() != null) {
+ name = networkPlayerInfo.getDisplayName().getFormattedText();
+ } else {
+ name = ScorePlayerTeam.formatPlayerName(
+ networkPlayerInfo.getPlayerTeam(),
+ networkPlayerInfo.getGameProfile().getName()
+ );
+ }
+
+ if (name.trim().equals("§r") || name.startsWith("§r ")) return null;
+
+ name = TextUtils.stripColor(name);
+
+ if(name.contains("(DEAD)")) return null;
+
+ name = name.replace(" ", "*");
+
+ Matcher matcher = tabListRegex.matcher(name);
+ if (!matcher.find()) return null;
+
+ name = matcher.group(0);
+ name = name.substring(0, name.length() - 1);
+ name = name.substring(1);
+ return name;
+ }
+
+
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) {
@@ -351,32 +374,32 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
int k = 0;
Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons);
for (Vec4b vec4b : mapData.mapDecorations.values()) {
- if (vec4b.func_176110_a() == 1 || this.<Boolean>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.<Float>getParameter("playerheadscale").getValue();
- GlStateManager.scale(s * 5,s * 5,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, (float)k * -0.001F).tex(f1, f2).endVertex();
- worldrenderer.pos(1.0D, 1.0D, (float)k * -0.001F).tex(f3, f2).endVertex();
- worldrenderer.pos(1.0D, -1.0D, (float)k * -0.001F).tex(f3, f4).endVertex();
- worldrenderer.pos(-1.0D, -1.0D, (float)k * -0.001F).tex(f1, f4).endVertex();
- tessellator.draw();
- GlStateManager.popMatrix();
- ++k;
- }
+ if (vec4b.func_176110_a() == 1 || this.<Boolean>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.<Float>getParameter("playerheadscale").getValue();
+ GlStateManager.scale(s * 5, s * 5, 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, (float) k * -0.001F).tex(f1, f2).endVertex();
+ worldrenderer.pos(1.0D, 1.0D, (float) k * -0.001F).tex(f3, f2).endVertex();
+ worldrenderer.pos(1.0D, -1.0D, (float) k * -0.001F).tex(f3, f4).endVertex();
+ worldrenderer.pos(-1.0D, -1.0D, (float) k * -0.001F).tex(f1, f4).endVertex();
+ tessellator.draw();
+ GlStateManager.popMatrix();
+ ++k;
+ }
}
}
@@ -391,10 +414,10 @@ public class FeatureDungeonMap extends GuiFeature implements DungeonEndListener,
GlStateManager.tryBlendFuncSeparate(1, 771, 0, 1);
GlStateManager.disableAlpha();
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer.pos((float)(i) + f, (float)(j + 128) - f, -0.009999999776482582D).tex(0.0D, 1.0D).endVertex();
- worldrenderer.pos((float)(i + 128) - f, (float)(j + 128) - f, -0.009999999776482582D).tex(1.0D, 1.0D).endVertex();
- worldrenderer.pos((float)(i + 128) - f, (float)(j) + f, -0.009999999776482582D).tex(1.0D, 0.0D).endVertex();
- worldrenderer.pos((float)(i) + f, (float)(j) + f, -0.009999999776482582D).tex(0.0D, 0.0D).endVertex();
+ worldrenderer.pos((float) (i) + f, (float) (j + 128) - f, -0.009999999776482582D).tex(0.0D, 1.0D).endVertex();
+ worldrenderer.pos((float) (i + 128) - f, (float) (j + 128) - f, -0.009999999776482582D).tex(1.0D, 1.0D).endVertex();
+ worldrenderer.pos((float) (i + 128) - f, (float) (j) + f, -0.009999999776482582D).tex(1.0D, 0.0D).endVertex();
+ worldrenderer.pos((float) (i) + f, (float) (j) + f, -0.009999999776482582D).tex(0.0D, 0.0D).endVertex();
tessellator.draw();
GlStateManager.enableAlpha();
GlStateManager.disableBlend();