From 0c787aa9e54331eb42bfb82804926df173c6f04f Mon Sep 17 00:00:00 2001 From: Dalwyn <100111505+DalwynWasTaken@users.noreply.github.com> Date: Sat, 18 Feb 2023 16:57:50 +0100 Subject: MapPlayerProcessor to use renderDistance (#322) * MapPlayerProcessor to use renderDistance If this is wrong, please do remove it. Also you will probably change this in a few weeks with map recode but thought I may as well add it. If I did something wrong please tell me * - Fix squared distance issue Signed-off-by: syeyoung --------- Signed-off-by: syeyoung Co-authored-by: syeyoung --- .../dungeonsguide/mod/dungeon/map/MapPlayerProcessor.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'mod/src/main/java/kr') diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/map/MapPlayerProcessor.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/map/MapPlayerProcessor.java index c52d3693..be387624 100755 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/map/MapPlayerProcessor.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/dungeon/map/MapPlayerProcessor.java @@ -45,11 +45,6 @@ public class MapPlayerProcessor { @Getter private final BiMap mapIconToPlayerMap = HashBiMap.create(); Logger logger = LogManager.getLogger("DG-MapPlayerProcessor"); - /** - * If the player on the map is closer than value this it won't save it - * this should be done with render-distance but whateva - */ - int closenessDistance = 50; private int waitDelay = 0; public MapPlayerProcessor(DungeonContext context) { @@ -67,7 +62,7 @@ public class MapPlayerProcessor { waitDelay++; return; } - ItemStack stack = Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(8); + ItemStack stack = mc.thePlayer.inventory.getStackInSlot(8); if (stack == null || !(stack.getItem() instanceof ItemMap)) { return; @@ -128,7 +123,7 @@ public class MapPlayerProcessor { int y2 = bbb.func_176113_c() / 2 + 64; int dx = x2 - x; int dy = y2 - y; - if (dx * dx + dy * dy < closenessDistance) { + if (dx * dx + dy * dy < mc.gameSettings.renderDistanceChunks * mc.gameSettings.renderDistanceChunks * 256 ) { shouldSave = false; break; } @@ -164,13 +159,13 @@ public class MapPlayerProcessor { } private boolean isPlayerNear(String player, BlockPos mapPos) { - EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(player); + EntityPlayer entityPlayer = mc.theWorld.getPlayerEntityByName(player); if (entityPlayer != null && !entityPlayer.isInvisible()) { BlockPos pos = entityPlayer.getPosition(); int dx = mapPos.getX() - pos.getX(); int dz = mapPos.getZ() - pos.getZ(); - return dx * dx + dz * dz < closenessDistance; + return dx * dx + dz * dz < mc.gameSettings.renderDistanceChunks * mc.gameSettings.renderDistanceChunks * 256; } -- cgit