aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-22 18:22:10 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-11-22 18:22:10 +0900
commit527732c2242d1dc0556c6a6cd49f4847b1f9c716 (patch)
tree30b18c31ef5565ef8e346416b563355d09b6a36c /src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder
parent38c3841567f188626cf37ab02893eb29d304c21d (diff)
downloadSkyblock-Dungeons-Guide-527732c2242d1dc0556c6a6cd49f4847b1f9c716.tar.gz
Skyblock-Dungeons-Guide-527732c2242d1dc0556c6a6cd49f4847b1f9c716.tar.bz2
Skyblock-Dungeons-Guide-527732c2242d1dc0556c6a6cd49f4847b1f9c716.zip
door determination
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDoorFinder.java45
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DoorFinderRegistry.java20
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/StartDoorFinder.java8
3 files changed, 73 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDoorFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDoorFinder.java
new file mode 100644
index 00000000..c3b67d9e
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDoorFinder.java
@@ -0,0 +1,45 @@
+package kr.syeyoung.dungeonsguide.dungeon.doorfinder;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Sets;
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.item.EntityArmorStand;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.world.World;
+
+import javax.vecmath.Vector2d;
+import java.util.Collection;
+import java.util.Set;
+
+public class CatacombDoorFinder implements StartDoorFinder {
+
+ private static final Set<Vector2d> directions = Sets.newHashSet(new Vector2d(0,1), new Vector2d(0, -1), new Vector2d(1, 0), new Vector2d(-1 , 0));
+
+ @Override
+ public BlockPos find(World w) {
+ Collection<EntityArmorStand> armorStand = w.getEntities(EntityArmorStand.class, new Predicate<EntityArmorStand>() {
+ @Override
+ public boolean apply(EntityArmorStand input) {
+ System.out.println(input.getName());
+ return input.getName().equals("§bMort");
+ }
+ });
+
+ if (armorStand.size() != 0) {
+ EntityArmorStand mort = armorStand.iterator().next();
+ BlockPos pos = mort.getPosition();
+ pos = pos.add(0, 3, 0);
+ for (int i = 0; i < 5; i++) {
+ for (Vector2d vector2d:directions) {
+ BlockPos test = pos.add(vector2d.x * i, 0, vector2d.y * i);
+ if (w.getChunkFromBlockCoords(test).getBlock(test) == Blocks.iron_bars) {
+ return pos.add(vector2d.x * (i + 2), -2, vector2d.y * (i+2));
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DoorFinderRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DoorFinderRegistry.java
new file mode 100644
index 00000000..306b1993
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DoorFinderRegistry.java
@@ -0,0 +1,20 @@
+package kr.syeyoung.dungeonsguide.dungeon.doorfinder;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class DoorFinderRegistry {
+ private static final Map<Pattern, StartDoorFinder> doorFinders = new HashMap<Pattern, StartDoorFinder>();
+
+ static {
+ doorFinders.put(Pattern.compile("The Catacombs F[0-9]"), new CatacombDoorFinder());
+ }
+
+ public static StartDoorFinder getDoorFinder(String dungeonName) {
+ for (Map.Entry<Pattern, StartDoorFinder> doorFinderEntry :doorFinders.entrySet()){
+ if (doorFinderEntry.getKey().matcher(dungeonName).matches()) return doorFinderEntry.getValue();
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/StartDoorFinder.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/StartDoorFinder.java
new file mode 100644
index 00000000..5096fe7b
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/StartDoorFinder.java
@@ -0,0 +1,8 @@
+package kr.syeyoung.dungeonsguide.dungeon.doorfinder;
+
+import net.minecraft.util.BlockPos;
+import net.minecraft.world.World;
+
+public interface StartDoorFinder {
+ BlockPos find(World w);
+}