aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java
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/MapProcessor.java
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/MapProcessor.java')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java63
1 files changed, 53 insertions, 10 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java
index 5f4f06db..5d04b720 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java
@@ -1,15 +1,24 @@
package kr.syeyoung.dungeonsguide.dungeon;
+import com.google.common.base.Predicate;
import com.google.common.collect.Sets;
+import kr.syeyoung.dungeonsguide.DungeonsGuide;
+import kr.syeyoung.dungeonsguide.SkyblockStatus;
+import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DoorFinderRegistry;
+import kr.syeyoung.dungeonsguide.dungeon.doorfinder.StartDoorFinder;
import kr.syeyoung.dungeonsguide.utils.MapUtils;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityOtherPlayerMP;
+import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.item.ItemMap;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.storage.MapData;
import javax.vecmath.Vector2d;
import java.awt.*;
+import java.util.Collection;
import java.util.Set;
public class MapProcessor {
@@ -43,37 +52,37 @@ public class MapProcessor {
int height = MapUtils.getHeightOfColorAt(mapData, (byte) 30, startroom);
unitRoomDimension = new Dimension(width, height);
}
+ Vector2d doorDir = null;
// determine the gap
{
Point midStartRoom = new Point(startroom.x + unitRoomDimension.width / 2, startroom.y +unitRoomDimension.height / 2);
final int halfWidth = unitRoomDimension.width / 2 + 2;
- Vector2d dir = null;
for (Vector2d v:directions) {
byte color = MapUtils.getMapColorAt(mapData, (int)(v.x * halfWidth +midStartRoom.x), (int)(v.y *halfWidth +midStartRoom.y));
if (color != 0) {
- dir = v;
+ doorDir = v;
break;
}
}
- if (dir == null) {
+ if (doorDir == null) {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("BUGGED MAP, no connected door found"));
bugged = true;
return;
}
Point basePoint = new Point(startroom.x, startroom.y);
- if (dir.x > 0) basePoint.x += unitRoomDimension.width;
- if (dir.x < 0) basePoint.x += -1;
- if (dir.y > 0) basePoint.y += unitRoomDimension.height;
- if (dir.y < 0) basePoint.y += -1;
- int gap = MapUtils.getLengthOfColorExtending(mapData, (byte) 0, basePoint, dir);
- Point pt = MapUtils.findFirstColorWithInNegate(mapData, (byte)0, new Rectangle(basePoint.x, basePoint.y, (int)Math.abs(dir.y) * unitRoomDimension.width + 1, (int)Math.abs(dir.x) * unitRoomDimension.height + 1));
+ if (doorDir.x > 0) basePoint.x += unitRoomDimension.width;
+ if (doorDir.x < 0) basePoint.x += -1;
+ if (doorDir.y > 0) basePoint.y += unitRoomDimension.height;
+ if (doorDir.y < 0) basePoint.y += -1;
+ int gap = MapUtils.getLengthOfColorExtending(mapData, (byte) 0, basePoint, doorDir);
+ Point pt = MapUtils.findFirstColorWithInNegate(mapData, (byte)0, new Rectangle(basePoint.x, basePoint.y, (int)Math.abs(doorDir.y) * unitRoomDimension.width + 1, (int)Math.abs(doorDir.x) * unitRoomDimension.height + 1));
if (pt == null) {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("BUGGED MAP, can't find door"));
bugged = true;
return;
}
- int doorWidth = MapUtils.getLengthOfColorExtending(mapData, MapUtils.getMapColorAt(mapData, pt.x, pt.y), pt, new Vector2d((int)Math.abs(dir.y), (int)Math.abs(dir.x)));
+ int doorWidth = MapUtils.getLengthOfColorExtending(mapData, MapUtils.getMapColorAt(mapData, pt.x, pt.y), pt, new Vector2d((int)Math.abs(doorDir.y), (int)Math.abs(doorDir.x)));
doorDimension = new Dimension(doorWidth, gap);
}
// Determine Top Left
@@ -84,12 +93,46 @@ public class MapProcessor {
while (y >= unitRoomDimension.height + doorDimension.height) y -= unitRoomDimension.height + doorDimension.height;
topLeftMapPoint = new Point(x, y);
}
+ // determine door location based on npc, and determine map min from there
+ {
+ StartDoorFinder doorFinder = DoorFinderRegistry.getDoorFinder(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName());
+ if (doorFinder == null) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Couldn't find door finder for :: "+DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()));
+ bugged = true;
+ return;
+ }
+ BlockPos door = doorFinder.find(context.getWorld());
+ if (door == null) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Couldn't find door :: "+DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()));
+ bugged = true;
+ return;
+ }
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("door Pos:"+door));
+
+ Point unitPoint = mapPointToRoomPoint(startroom);
+ unitPoint.translate(unitPoint.x + 1, unitPoint.y + 1);
+ unitPoint.translate((int)doorDir.x, (int)doorDir.y);
+
+ int worldX = unitPoint.x * 16;
+ int worldY = unitPoint.y * 16;
+ BlockPos worldMin = door.add(-worldX, 0, -worldY);
+ context.setDungeonMin(worldMin);
+
+ }
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Found Green room:"+startroom));
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Dimension:"+unitRoomDimension));
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("top Left:"+topLeftMapPoint));
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("door dimension:"+doorDimension));
}
+
+ private Point mapPointToRoomPoint(Point mapPoint) {
+ int x = (int)((mapPoint.x - topLeftMapPoint.x) / ((double)unitRoomDimension.width + doorDimension.height));
+ int y = (int)((mapPoint.y - topLeftMapPoint.y) / ((double)unitRoomDimension.height + doorDimension.height));
+ return new Point(x,y);
+ }
+
private void processMap(byte[] mapData) {
}