aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/rosegoldaddons/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/rosegoldaddons/utils')
-rw-r--r--src/main/java/rosegoldaddons/utils/PlayerUtils.java17
-rw-r--r--src/main/java/rosegoldaddons/utils/RenderUtils.java31
-rw-r--r--src/main/java/rosegoldaddons/utils/ScoreboardUtils.java48
-rw-r--r--src/main/java/rosegoldaddons/utils/ShadyRotation.java8
4 files changed, 80 insertions, 24 deletions
diff --git a/src/main/java/rosegoldaddons/utils/PlayerUtils.java b/src/main/java/rosegoldaddons/utils/PlayerUtils.java
index f0662c0..7411660 100644
--- a/src/main/java/rosegoldaddons/utils/PlayerUtils.java
+++ b/src/main/java/rosegoldaddons/utils/PlayerUtils.java
@@ -25,12 +25,17 @@ public class PlayerUtils {
@SubscribeEvent
public void chat(ClientChatReceivedEvent event) {
- String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
- if (message.contains(":") || message.contains(">")) return;
- if(message.startsWith("You used your")) {
- pickaxeAbilityReady = false;
- } else if(message.endsWith("is now available!")) {
- pickaxeAbilityReady = true;
+ try {
+ String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
+ if (message.contains(":") || message.contains(">")) return;
+ if(message.startsWith("You used your")) {
+ pickaxeAbilityReady = false;
+ } else if(message.endsWith("is now available!")) {
+ pickaxeAbilityReady = true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
+
}
}
diff --git a/src/main/java/rosegoldaddons/utils/RenderUtils.java b/src/main/java/rosegoldaddons/utils/RenderUtils.java
index cf83c28..d6a7f8f 100644
--- a/src/main/java/rosegoldaddons/utils/RenderUtils.java
+++ b/src/main/java/rosegoldaddons/utils/RenderUtils.java
@@ -72,7 +72,8 @@ public class RenderUtils {
glEndList();
}
- public static void drawBlockBox(final BlockPos blockPos, final Color color, final boolean outline, float partialTicks) {
+ public static void drawBlockBox(final BlockPos blockPos, final Color color, final int width, float partialTicks) {
+ if(width == 0) return;
final RenderManager renderManager = mc.getRenderManager();
final double x = blockPos.getX() - renderManager.viewerPosX;
@@ -101,16 +102,15 @@ public class RenderUtils {
disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST);
glDepthMask(false);
- glColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() != 255 ? color.getAlpha() : outline ? 26 : 35);
+ glColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() != 255 ? color.getAlpha() : 26);
//drawFilledBox(axisAlignedBB);
- if (outline) {
- glLineWidth(3F);
- enableGlCap(GL_LINE_SMOOTH);
- glColor(color);
+ glLineWidth((float) width);
+ enableGlCap(GL_LINE_SMOOTH);
+ glColor(color);
+
+ drawSelectionBoundingBox(axisAlignedBB);
- drawSelectionBoundingBox(axisAlignedBB);
- }
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glDepthMask(true);
@@ -178,7 +178,8 @@ public class RenderUtils {
tessellator.draw();
}
- public static void drawEntityBox(final Entity entity, final Color color, final boolean outline, float partialTicks) {
+ public static void drawEntityBox(final Entity entity, final Color color, final int width, float partialTicks) {
+ if(width == 0) return;
final RenderManager renderManager = mc.getRenderManager();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -203,14 +204,12 @@ public class RenderUtils {
entityBox.maxZ - entity.posZ + z + 0.05D
);
- if (outline) {
- glLineWidth(3F);
- enableGlCap(GL_LINE_SMOOTH);
- glColor(color.getRed(), color.getGreen(), color.getBlue(), 95);
- drawSelectionBoundingBox(axisAlignedBB);
- }
+ glLineWidth((float) width);
+ enableGlCap(GL_LINE_SMOOTH);
+ glColor(color.getRed(), color.getGreen(), color.getBlue(), 95);
+ drawSelectionBoundingBox(axisAlignedBB);
- glColor(color.getRed(), color.getGreen(), color.getBlue(), outline ? 26 : 35);
+ glColor(color.getRed(), color.getGreen(), color.getBlue(), 26);
//drawFilledBox(axisAlignedBB);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glDepthMask(true);
diff --git a/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java b/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java
index a9d7d63..d3a8463 100644
--- a/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java
+++ b/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java
@@ -23,6 +23,8 @@ import java.util.stream.Collectors;
public class ScoreboardUtils {
public static boolean inSkyblock = false;
+ public static boolean inDungeon = false;
+
public static String cleanSB(String scoreboard) {
char[] nvString = StringUtils.stripControlCodes(scoreboard).toCharArray();
StringBuilder cleaned = new StringBuilder();
@@ -65,11 +67,56 @@ public class ScoreboardUtils {
return lines;
}
+ @SuppressWarnings({"ExecutionException", "IllegalArgumentException"})
+ public static List<String> getScoreboard() {
+ List<String> lines = new ArrayList<>();
+ if (Minecraft.getMinecraft().theWorld == null) return lines;
+ Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard();
+ if (scoreboard == null) return lines;
+
+ ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1);
+ if (objective == null) return lines;
+
+ Collection<Score> scores = scoreboard.getSortedScores(objective);
+ List<Score> list = scores.stream()
+ .filter(input -> input != null && input.getPlayerName() != null && !input.getPlayerName()
+ .startsWith("#"))
+ .collect(Collectors.toList());
+
+ if (list.size() > 15) {
+ scores = Lists.newArrayList(Iterables.skip(list, scores.size() - 15));
+ } else {
+ scores = list;
+ }
+
+ for (Score score : scores) {
+ ScorePlayerTeam team = scoreboard.getPlayersTeam(score.getPlayerName());
+ lines.add(ScorePlayerTeam.formatPlayerName(team, score.getPlayerName()));
+ }
+
+ return lines;
+ }
+
+ public static boolean scoreboardContains(String string) {
+ boolean result = false;
+ List<String> scoreboard = getScoreboard();
+ for (String line : scoreboard) {
+ line = cleanSB(line);
+ line = removeFormatting(line);
+ if(line.contains(string)) {
+ result = true;
+ break;
+ }
+ }
+ return result;
+ }
+
public static String removeFormatting(String input) {
return input.replaceAll("ยง[0-9a-fk-or]", "");
}
private int ticks = 0;
+
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if(ticks % 20 == 0) {
@@ -78,6 +125,7 @@ public class ScoreboardUtils {
if(scoreboardObj != null) {
inSkyblock = removeFormatting(scoreboardObj.getDisplayName()).contains("SKYBLOCK");
}
+ inDungeon = inSkyblock && ScoreboardUtils.scoreboardContains("The Catacombs");
}
ticks = 0;
}
diff --git a/src/main/java/rosegoldaddons/utils/ShadyRotation.java b/src/main/java/rosegoldaddons/utils/ShadyRotation.java
index fdacc59..111ea6e 100644
--- a/src/main/java/rosegoldaddons/utils/ShadyRotation.java
+++ b/src/main/java/rosegoldaddons/utils/ShadyRotation.java
@@ -30,6 +30,10 @@ public class ShadyRotation {
return angle - Math.floor(angle / 360 + 0.5) * 360;
}
+ private static float wrapAngleTo180(float angle) {
+ return (float) (angle - Math.floor(angle / 360 + 0.5) * 360);
+ }
+
public static Rotation getRotationToBlock(BlockPos block) {
double diffX = block.getX() - Main.mc.thePlayer.posX + 0.5;
double diffY = block.getY() - Main.mc.thePlayer.posY + 0.5 - Main.mc.thePlayer.getEyeHeight();
@@ -81,8 +85,8 @@ public class ShadyRotation {
ShadyRotation.callback = callback;
- pitchDifference = rotation.pitch - Main.mc.thePlayer.rotationPitch;
- yawDifference = rotation.yaw - Main.mc.thePlayer.rotationYaw;
+ pitchDifference = wrapAngleTo180(rotation.pitch - Main.mc.thePlayer.rotationPitch);
+ yawDifference = wrapAngleTo180(rotation.yaw - Main.mc.thePlayer.rotationYaw);
ShadyRotation.ticks = ticks * 20;
ShadyRotation.tickCounter = 0;