diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon')
-rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java | 21 | ||||
-rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java | 43 |
2 files changed, 51 insertions, 13 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java index e58416ec..b80813b4 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java @@ -53,21 +53,13 @@ public class DungeonContext { private int BossRoomEnterSeconds = -1; @Getter - private List<String> players = new ArrayList<String>(); + private Set<String> players = new HashSet<String>(); public DungeonContext(World world) { this.world = world; mapProcessor = new MapProcessor(this); - List<NetworkPlayerInfo> list = FeatureDungeonMap.field_175252_a.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); - for (int i = 1; i < 10; i++) { - NetworkPlayerInfo networkPlayerInfo = list.get(i); - String name = networkPlayerInfo.getDisplayName() != null ? networkPlayerInfo.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfo.getPlayerTeam(), networkPlayerInfo.getGameProfile().getName()); - if (name.trim().equals("§r") || name.startsWith("§r ")) continue; - EntityPlayer entityplayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(TextUtils.stripColor(name).trim().split(" ")[0]); - if (entityplayer == null) continue; - players.add(entityplayer.getName()); - } + } @@ -79,6 +71,15 @@ public class DungeonContext { BossRoomEnterSeconds = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed() / 1000; MinecraftForge.EVENT_BUS.post(new BossroomEnterEvent()); } + List<NetworkPlayerInfo> list = FeatureDungeonMap.field_175252_a.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); + try { + for (int i = 1; i < 20; i++) { + NetworkPlayerInfo networkPlayerInfo = list.get(i); + String name = networkPlayerInfo.getDisplayName() != null ? networkPlayerInfo.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfo.getPlayerTeam(), networkPlayerInfo.getGameProfile().getName()); + if (name.trim().equals("§r") || name.startsWith("§r ")) continue; + players.add(TextUtils.stripColor(name).trim().split(" ")[0]); + } + } catch (Exception e) {} } public void onChat(ClientChatReceivedEvent event) { 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()); } } |