diff options
author | syeyoung <cyong06@naver.com> | 2021-01-09 17:08:19 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-09 17:08:19 +0900 |
commit | 1dd4751514a05e493683f4bba7f9dcd94ba5f438 (patch) | |
tree | 9a784c9b7bd987dd8333ba0bc9fca4b149814078 /src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java | |
parent | 3513364b2177cb88c57284c113b367000e93f2e5 (diff) | |
download | Skyblock-Dungeons-Guide-1dd4751514a05e493683f4bba7f9dcd94ba5f438.tar.gz Skyblock-Dungeons-Guide-1dd4751514a05e493683f4bba7f9dcd94ba5f438.tar.bz2 Skyblock-Dungeons-Guide-1dd4751514a05e493683f4bba7f9dcd94ba5f438.zip |
maybe better
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java')
-rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java index 893bcda8..ed66ab00 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java @@ -13,11 +13,13 @@ import kr.syeyoung.dungeonsguide.events.DungeonContextInitializationEvent; import kr.syeyoung.dungeonsguide.utils.MapUtils; import lombok.Getter; import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.Vec3; +import net.minecraft.util.Vec4b; import net.minecraft.world.storage.MapData; import net.minecraftforge.common.MinecraftForge; @@ -35,6 +37,7 @@ public class MapProcessor { @Getter private MapData lastMapData2; + @Getter private BiMap<String, String> mapIconToPlayerMap = HashBiMap.create(); @Getter @@ -163,6 +166,11 @@ public class MapProcessor { int y = (int)((mapPoint.y - topLeftMapPoint.y) / ((double)unitRoomDimension.height + doorDimension.height)); return new Point(x,y); } + public BlockPos mapPointToWorldPoint(Point mapPoint) { + int x = (int)((mapPoint.x - topLeftMapPoint.x) / ((double)unitRoomDimension.width + doorDimension.height) * 32 + context.getDungeonMin().getX()); + int y = (int)((mapPoint.y - topLeftMapPoint.y) / ((double)unitRoomDimension.height + doorDimension.height) * 32 + context.getDungeonMin().getZ()); + return new BlockPos(x,70,y); + } public Point roomPointToMapPoint(Point roomPoint) { return new Point(roomPoint.x * (unitRoomDimension.width +doorDimension.height) + topLeftMapPoint.x, roomPoint.y *(unitRoomDimension.height + doorDimension.height) + topLeftMapPoint.y); @@ -322,9 +330,38 @@ public class MapProcessor { else if (mapData != null) processMap(mapData); if (lastMapData2 != null && mapIconToPlayerMap.size() < context.getPlayers().size()) { - - for (String player : context.getPlayers()) { - + label: for (Map.Entry<String, Vec4b> stringVec4bEntry : lastMapData2.mapDecorations.entrySet()) { + if (mapIconToPlayerMap.containsValue(stringVec4bEntry.getKey())) continue; + int x = stringVec4bEntry.getValue().func_176112_b() /2 + 64; + int y = stringVec4bEntry.getValue().func_176113_c() /2 + 64; + BlockPos mapPos = mapPointToWorldPoint(new Point(x, y)); + String potentialPlayer = null; + for (String player : context.getPlayers()) { // check nearby players + if (mapIconToPlayerMap.containsKey(player)) continue; + EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(player); + if (entityPlayer == null) continue; + BlockPos pos = entityPlayer.getPosition(); + int dx = mapPos.getX() - pos.getX(); + int dz = mapPos.getZ() - pos.getZ(); + if (dx * dx + dz * dz < 81) { + if (potentialPlayer != null) continue label; + potentialPlayer = player; + } + } + if (potentialPlayer == null) continue; + + for (Map.Entry<String, Vec4b> stringVec4bEntry2 : lastMapData2.mapDecorations.entrySet()) { // check nearby markers + if (mapIconToPlayerMap.containsValue(stringVec4bEntry.getKey())) continue; + if (stringVec4bEntry.getKey().equals(stringVec4bEntry2.getKey())) continue; + int x2 = stringVec4bEntry2.getValue().func_176112_b() /2 + 64; + int y2 = stringVec4bEntry2.getValue().func_176113_c() /2 + 64; + int dx = x2 - x; + int dy = y2 - y; + if (dx * dx + dy * dy < 81) { + continue label; + } + } + mapIconToPlayerMap.put(potentialPlayer, stringVec4bEntry.getKey()); } } |