code cleanup

This commit is contained in:
Oth3r 2024-10-19 17:54:35 -05:00
commit bceb8e573a
3 changed files with 13 additions and 6 deletions

View file

@ -68,6 +68,7 @@ public class Data {
/** /**
* a list of players who just joined, to check if they are mounted to a Sit! entity * 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<ServerPlayerEntity, Integer> checkPlayers = new HashMap<>(); private static final HashMap<ServerPlayerEntity, Integer> checkPlayers = new HashMap<>();
@ -83,6 +84,7 @@ public class Data {
return new HashMap<>(checkPlayers); 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) * a list of players that need a sit entity spawned for them, on the server loop to stop crashing with other mods (ASYNC)
*/ */

View file

@ -57,7 +57,7 @@ public class Events {
client.setScreen(new ConfigScreen(client.currentScreen)); 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; if (player == null) return;
while (toggle_key.wasPressed()) { while (toggle_key.wasPressed()) {

View file

@ -42,7 +42,7 @@ import java.util.List;
public class Utl { 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 * @return true if not obstructed
*/ */
public static boolean isNotObstructed(World world, BlockPos blockPos) { 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) { public static DisplayEntity.TextDisplayEntity create(World world, BlockPos blockPos, double sitHeight) {
DisplayEntity.TextDisplayEntity entity = new DisplayEntity.TextDisplayEntity(EntityType.TEXT_DISPLAY,world); DisplayEntity.TextDisplayEntity entity = new DisplayEntity.TextDisplayEntity(EntityType.TEXT_DISPLAY,world);
// entity flags
entity.setCustomName(Text.of(Data.ENTITY_NAME)); entity.setCustomName(Text.of(Data.ENTITY_NAME));
entity.setCustomNameVisible(false); entity.setCustomNameVisible(false);
entity.setInvulnerable(true); entity.setInvulnerable(true);
entity.setInvisible(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) // get the entities y level
// double oneTwentyTwo = .25; double entityY = blockPos.getY();
// entity.updatePositionAndAngles(entity.getX(),entity.getY()+oneTwentyTwo,entity.getZ(),0,0); 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) // 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 if (entity.getY() == blockPos.getY() + 1) entity.setPitch(90); // below