From bceb8e573a47e97268f16a853e804bc8697c4a78 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Sat, 19 Oct 2024 17:54:35 -0500 Subject: [PATCH] code cleanup --- src/main/java/one/oth3r/sit/utl/Data.java | 2 ++ src/main/java/one/oth3r/sit/utl/Events.java | 2 +- src/main/java/one/oth3r/sit/utl/Utl.java | 15 ++++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/one/oth3r/sit/utl/Data.java b/src/main/java/one/oth3r/sit/utl/Data.java index f62b7c8..0486cf3 100644 --- a/src/main/java/one/oth3r/sit/utl/Data.java +++ b/src/main/java/one/oth3r/sit/utl/Data.java @@ -68,6 +68,7 @@ public class Data { /** * a list of players who just joined, to check if they are mounted to a Sit! entity + * (they don't load in on the player join event for some reason) */ private static final HashMap checkPlayers = new HashMap<>(); @@ -83,6 +84,7 @@ public class Data { return new HashMap<>(checkPlayers); } + /** * a list of players that need a sit entity spawned for them, on the server loop to stop crashing with other mods (ASYNC) */ diff --git a/src/main/java/one/oth3r/sit/utl/Events.java b/src/main/java/one/oth3r/sit/utl/Events.java index 40d5222..f06a485 100644 --- a/src/main/java/one/oth3r/sit/utl/Events.java +++ b/src/main/java/one/oth3r/sit/utl/Events.java @@ -57,7 +57,7 @@ public class Events { client.setScreen(new ConfigScreen(client.currentScreen)); } - // anything below uses the player object, make sure it's not null + /// anything below uses the player object, make sure it's not null if (player == null) return; while (toggle_key.wasPressed()) { diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 28616ef..af028ff 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -42,7 +42,7 @@ import java.util.List; public class Utl { /** - * check if a block is obstructed (no collision / custom list) + * check if a block is obstructed (no collision) * @return true if not obstructed */ public static boolean isNotObstructed(World world, BlockPos blockPos) { @@ -274,16 +274,21 @@ public class Utl { public static DisplayEntity.TextDisplayEntity create(World world, BlockPos blockPos, double sitHeight) { DisplayEntity.TextDisplayEntity entity = new DisplayEntity.TextDisplayEntity(EntityType.TEXT_DISPLAY,world); + // entity flags entity.setCustomName(Text.of(Data.ENTITY_NAME)); entity.setCustomNameVisible(false); entity.setInvulnerable(true); entity.setInvisible(true); - entity.updatePositionAndAngles(blockPos.getX()+.5, blockPos.getY()+sitHeight, blockPos.getZ()+.5, 0, 0); + /// make a double for adjusting the entity height if some versions change the player sit height on entities again + double adjustmentY = 0; - // // 1.20.2 mounting pos change (shifts everything down by .25) - // double oneTwentyTwo = .25; - // entity.updatePositionAndAngles(entity.getX(),entity.getY()+oneTwentyTwo,entity.getZ(),0,0); + // get the entities y level + double entityY = blockPos.getY(); + entityY += sitHeight + adjustmentY; + + // set the entities position + entity.updatePositionAndAngles(blockPos.getX()+.5, entityY, blockPos.getZ()+.5, 0, 0); // change pitch based on if player is sitting below block height or not (full block height only) if (entity.getY() == blockPos.getY() + 1) entity.setPitch(90); // below