mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-20 00:13:21 +02:00
code cleanup
This commit is contained in:
parent
81f8cf6244
commit
bceb8e573a
3 changed files with 13 additions and 6 deletions
|
@ -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<ServerPlayerEntity, Integer> 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)
|
||||
*/
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue