aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java')
-rw-r--r--src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java76
1 files changed, 48 insertions, 28 deletions
diff --git a/src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java b/src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java
index 8f7de95..d97509c 100644
--- a/src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java
+++ b/src/main/java/me/Danker/features/puzzlesolvers/ThreeManSolver.java
@@ -1,7 +1,9 @@
package me.Danker.features.puzzlesolvers;
+import com.google.gson.JsonArray;
import me.Danker.DankersSkyblockMod;
import me.Danker.commands.ToggleCommand;
+import me.Danker.utils.RenderUtils;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
@@ -16,6 +18,7 @@ import java.util.List;
public class ThreeManSolver {
+ // Hard coded solutions if api call fails
static String[] riddleSolutions = {"The reward is not in my chest!", "At least one of them is lying, and the reward is not in",
"My chest doesn't have the reward. We are all telling the truth", "My chest has the reward and I'm telling the truth",
"The reward isn't in any of our chests", "Both of them are telling the truth."};
@@ -32,34 +35,23 @@ public class ThreeManSolver {
if (!Utils.inDungeons) return;
- if (ToggleCommand.threeManToggled && message.contains("[NPC]")) {
- for (String solution : riddleSolutions) {
- if (message.contains(solution)) {
- Minecraft mc = Minecraft.getMinecraft();
- String npcName = message.substring(message.indexOf("]") + 2, message.indexOf(":"));
- mc.thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.ANSWER_COLOUR + EnumChatFormatting.BOLD + StringUtils.stripControlCodes(npcName) + DankersSkyblockMod.MAIN_COLOUR + " has the blessing."));
- if (riddleChest == null) {
- List<Entity> entities = mc.theWorld.getLoadedEntityList();
- for (Entity entity : entities) {
- if (entity == null || !entity.hasCustomName()) continue;
- if (entity.getCustomNameTag().contains(npcName)) {
- BlockPos npcLocation = new BlockPos(entity.posX, 69, entity.posZ);
- if (mc.theWorld.getBlockState(npcLocation.north()).getBlock() == Blocks.chest) {
- riddleChest = npcLocation.north();
- } else if (mc.theWorld.getBlockState(npcLocation.east()).getBlock() == Blocks.chest) {
- riddleChest = npcLocation.east();
- } else if (mc.theWorld.getBlockState(npcLocation.south()).getBlock() == Blocks.chest) {
- riddleChest = npcLocation.south();
- } else if (mc.theWorld.getBlockState(npcLocation.west()).getBlock() == Blocks.chest) {
- riddleChest = npcLocation.west();
- } else {
- System.out.print("Could not find correct riddle chest.");
- }
- break;
- }
- }
+ if (ToggleCommand.threeManToggled && message.startsWith("[NPC]")) {
+ if (DankersSkyblockMod.data != null && DankersSkyblockMod.data.has("threeman")) {
+ JsonArray riddleSolutions = DankersSkyblockMod.data.get("threeman").getAsJsonArray();
+
+ for (int i = 0; i < riddleSolutions.size(); i++) {
+ String solution = riddleSolutions.get(i).getAsString();
+ if (message.contains(solution)) {
+ answer(message);
+ break;
+ }
+ }
+ } else {
+ for (String solution : riddleSolutions) {
+ if (message.contains(solution)) {
+ answer(message);
+ break;
}
- break;
}
}
}
@@ -68,7 +60,35 @@ public class ThreeManSolver {
@SubscribeEvent
public void onWorldRender(RenderWorldLastEvent event) {
if (ToggleCommand.threeManToggled && riddleChest != null) {
- Utils.drawFilled3DBox(new AxisAlignedBB(riddleChest.getX() - 0.05, riddleChest.getY(), riddleChest.getZ() - 0.05, riddleChest.getX() + 1.05, riddleChest.getY() + 1, riddleChest.getZ() + 1.05), 0x197F19, true, true, event.partialTicks);
+ RenderUtils.drawFilled3DBox(new AxisAlignedBB(riddleChest.getX() - 0.05, riddleChest.getY(), riddleChest.getZ() - 0.05, riddleChest.getX() + 1.05, riddleChest.getY() + 1, riddleChest.getZ() + 1.05), 0x197F19, true, true, event.partialTicks);
+ }
+ }
+
+ public static void answer(String message) {
+ Minecraft mc = Minecraft.getMinecraft();
+ String npcName = message.substring(message.indexOf("]") + 2, message.indexOf(":"));
+ mc.thePlayer.addChatMessage(new ChatComponentText(DankersSkyblockMod.ANSWER_COLOUR + EnumChatFormatting.BOLD + StringUtils.stripControlCodes(npcName) + DankersSkyblockMod.MAIN_COLOUR + " has the blessing."));
+
+ if (riddleChest == null) {
+ List<Entity> entities = mc.theWorld.getLoadedEntityList();
+ for (Entity entity : entities) {
+ if (entity == null || !entity.hasCustomName()) continue;
+ if (entity.getCustomNameTag().contains(npcName)) {
+ BlockPos npcLocation = new BlockPos(entity.posX, 69, entity.posZ);
+ if (mc.theWorld.getBlockState(npcLocation.north()).getBlock() == Blocks.chest) {
+ riddleChest = npcLocation.north();
+ } else if (mc.theWorld.getBlockState(npcLocation.east()).getBlock() == Blocks.chest) {
+ riddleChest = npcLocation.east();
+ } else if (mc.theWorld.getBlockState(npcLocation.south()).getBlock() == Blocks.chest) {
+ riddleChest = npcLocation.south();
+ } else if (mc.theWorld.getBlockState(npcLocation.west()).getBlock() == Blocks.chest) {
+ riddleChest = npcLocation.west();
+ } else {
+ System.out.print("Could not find correct riddle chest.");
+ }
+ break;
+ }
+ }
}
}