Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up a lot of checks & fix some code consistency #1486

Open
wants to merge 20 commits into
base: 2.0
Choose a base branch
from

Conversation

Symmettry
Copy link

fixed code consistency in many files along with unraveling a lot of scopes that make the code hard to read.
I wouldn't be surprised if I made a flaw when inverting some if statements, so please someone check this.

@MachineBreaker MachineBreaker self-requested a review May 26, 2024 09:55
@Symmettry
Copy link
Author

review for latest cleanup please! :)

@ManInMyVan
Copy link
Contributor

I meant newlines at the end of the file

@Symmettry
Copy link
Author

I meant newlines at the end of the file

what? why? there is no need for a new line after the class bracket

@ManInMyVan
Copy link
Contributor

I meant newlines at the end of the file

what? why? there is no need for a new line after the class bracket

"consistency"

@Symmettry
Copy link
Author

I meant newlines at the end of the file

what? why? there is no need for a new line after the class bracket

"consistency"

You seem angry somehow. There is no purpose towards that new line in any case whatsoever. So it doesn't matter.

@Anthony01M
Copy link
Contributor

I meant newlines at the end of the file

either this or remove all of them from a file or just ignore, it doesn't even matter. What's important is "code consistency" not really something else like "add newline at the end of the file" imo

@@ -8,12 +8,12 @@

// This check catches 100% of cheaters.
public class FlightA extends Check implements PacketCheck {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fairly sure this check does nothing, imo it shouldn't stay here and can be considered as "Clean up"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking of removing it but it's a funny check

@Anthony01M
Copy link
Contributor

consider merging ^^ (or not, slowly maybe update what changed/add what is new) there's a few things that can be done through lombok too like (& I think needs to be cleaned up; didn't check much tbh):

@Getter
public abstract class TypedPacketEntity {

    private final EntityType type;
    private final boolean isLivingEntity, isSize, isMinecart, isHorse, isAgeable, isAnimal;

    public TypedPacketEntity(EntityType type) {
        this.type = type;
        this.isLivingEntity = EntityTypes.isTypeInstanceOf(type, EntityTypes.LIVINGENTITY);
        this.isSize = type == EntityTypes.PHANTOM || type == EntityTypes.SLIME || type == EntityTypes.MAGMA_CUBE;
        this.isMinecart = EntityTypes.isTypeInstanceOf(type, EntityTypes.MINECART_ABSTRACT);
        this.isHorse = EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_HORSE);
        this.isAgeable = EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_AGEABLE);
        this.isAnimal = EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_ANIMAL);
    }
}

@Anthony01M
Copy link
Contributor

wouldn't it be better to modify this?

if (EntityTypes.CAMEL.equals(entityType)) {

maybe to something like this (which is better for readability):

if (EntityTypes.isTypeInstanceOf(entityType, EntityTypes.ABSTRACT_HORSE)) {
  packetEntity = new PacketEntityHorse(player, entityType, position.getX(), position.getY(), position.getZ(), xRot);
} else if (EntityTypes.isTypeInstanceOf(entityType, EntityTypes.BOAT)) {
  packetEntity = new PacketEntityTrackXRot(player, entityType, position.getX(), position.getY(), position.getZ(), xRot);
} else {
  switch (entityType) {
    case CAMEL:
      packetEntity = new PacketEntityCamel(player, entityType, position.getX(), position.getY(), position.getZ(), xRot);
      break;
    case SLIME:
    case MAGMA_CUBE:
    case PHANTOM:
      packetEntity = new PacketEntitySizeable(player, entityType, position.getX(), position.getY(), position.getZ());
      break;
    case PIG:
      packetEntity = new PacketEntityRideable(player, entityType, position.getX(), position.getY(), position.getZ());
      break;
    case SHULKER:
      packetEntity = new PacketEntityShulker(player, entityType, position.getX(), position.getY(), position.getZ());
      break;
    case STRIDER:
      packetEntity = new PacketEntityStrider(player, entityType, position.getX(), position.getY(), position.getZ());
      break;
    case CHICKEN:
      packetEntity = new PacketEntityTrackXRot(player, entityType, position.getX(), position.getY(), position.getZ(), xRot);
      break;
    case FISHING_BOBBER:
      packetEntity = new PacketEntityHook(player, entityType, position.getX(), position.getY(), position.getZ(), data);
      break;
    default:
      packetEntity = new PacketEntity(player, entityType, position.getX(), position.getY(), position.getZ());
  }
}

@Symmettry
Copy link
Author

wouldn't it be better to modify this?

if (EntityTypes.CAMEL.equals(entityType)) {

maybe to something like this (which is better for readability):

if (EntityTypes.isTypeInstanceOf(entityType, EntityTypes.ABSTRACT_HORSE)) {
  packetEntity = new PacketEntityHorse(player, entityType, position.getX(), position.getY(), position.getZ(), xRot);
} else if (EntityTypes.isTypeInstanceOf(entityType, EntityTypes.BOAT)) {
  packetEntity = new PacketEntityTrackXRot(player, entityType, position.getX(), position.getY(), position.getZ(), xRot);
} else {
  switch (entityType) {
    case CAMEL:
      packetEntity = new PacketEntityCamel(player, entityType, position.getX(), position.getY(), position.getZ(), xRot);
      break;
    case SLIME:
    case MAGMA_CUBE:
    case PHANTOM:
      packetEntity = new PacketEntitySizeable(player, entityType, position.getX(), position.getY(), position.getZ());
      break;
    case PIG:
      packetEntity = new PacketEntityRideable(player, entityType, position.getX(), position.getY(), position.getZ());
      break;
    case SHULKER:
      packetEntity = new PacketEntityShulker(player, entityType, position.getX(), position.getY(), position.getZ());
      break;
    case STRIDER:
      packetEntity = new PacketEntityStrider(player, entityType, position.getX(), position.getY(), position.getZ());
      break;
    case CHICKEN:
      packetEntity = new PacketEntityTrackXRot(player, entityType, position.getX(), position.getY(), position.getZ(), xRot);
      break;
    case FISHING_BOBBER:
      packetEntity = new PacketEntityHook(player, entityType, position.getX(), position.getY(), position.getZ(), data);
      break;
    default:
      packetEntity = new PacketEntity(player, entityType, position.getX(), position.getY(), position.getZ());
  }
}

Would it? Yes. Are we able to? Nope.
Blame retroopers. EntityTypes is not an enum, but it's a class that has a bunch of values named stuff like CAMEL or SLIME, and stuff that isn't switch'able.

@Symmettry
Copy link
Author

consider merging ^^ (or not, slowly maybe update what changed/add what is new) there's a few things that can be done through lombok too like (& I think needs to be cleaned up; didn't check much tbh):

@Getter
public abstract class TypedPacketEntity {

    private final EntityType type;
    private final boolean isLivingEntity, isSize, isMinecart, isHorse, isAgeable, isAnimal;

    public TypedPacketEntity(EntityType type) {
        this.type = type;
        this.isLivingEntity = EntityTypes.isTypeInstanceOf(type, EntityTypes.LIVINGENTITY);
        this.isSize = type == EntityTypes.PHANTOM || type == EntityTypes.SLIME || type == EntityTypes.MAGMA_CUBE;
        this.isMinecart = EntityTypes.isTypeInstanceOf(type, EntityTypes.MINECART_ABSTRACT);
        this.isHorse = EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_HORSE);
        this.isAgeable = EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_AGEABLE);
        this.isAnimal = EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_ANIMAL);
    }
}

Done

@Symmettry
Copy link
Author

Alternatively I could probably try switching the ID of the entity type but it might have issues with protocol versions.

@SamB440
Copy link
Collaborator

SamB440 commented May 28, 2024

I don't think you rebased properly, PacketEntity seems to be semi-merged with TypedPacketEntity and is also missing trackedServerPosition initializer. isSize can be isSizeable.

Also I'm aware your current code is rebased on when the reach changes were merged, it will be re-merged soon once I re-validate it for older clients and clean it up, so probably best to not rebase until then, sorry for the trouble.

The changes look good though and are my kind of code style, just be careful not to be too abusive of lombok, it usually indicates you need to refactor something if you're hiding a ton of getters

@Symmettry
Copy link
Author

I don't think you rebased properly, PacketEntity seems to be semi-merged with TypedPacketEntity and is also missing trackedServerPosition initializer. isSize can be isSizeable.

Also I'm aware your current code is rebased on when the reach changes were merged, it will be re-merged soon once I re-validate it for older clients and clean it up, so probably best to not rebase until then, sorry for the trouble.

The changes look good though and are my kind of code style, just be careful not to be too abusive of lombok, it usually indicates you need to refactor something if you're hiding a ton of getters

I couldn't find TypedPacketEntity class. I changed a lot of files so it's probably just that the conflicts & how it's not merged with the latest. It says I can't resolve conflicts in web & idk where else to resolve, but if ur gonna handle it then do that (if that's what u said, I couldn't really understand)

@Anthony01M
Copy link
Contributor

would these come in handy somewhere or would you rather not remove the brackets?

paste.ee: https://paste.ee/p/8nEzc

    private static float getWidthMinusBaby(GrimPlayer player, PacketEntity packetEntity) {
        final EntityType type = packetEntity.getType();
        if (EntityTypes.AXOLOTL.equals(type) || EntityTypes.PANDA.equals(type))
            return 1.3f;
        else if (EntityTypes.BAT.equals(type) || EntityTypes.PARROT.equals(type) || EntityTypes.COD.equals(type) || EntityTypes.EVOKER_FANGS.equals(type) || EntityTypes.TROPICAL_FISH.equals(type) || EntityTypes.FROG.equals(type))
            return 0.5f;
        else if (EntityTypes.BEE.equals(type) || EntityTypes.PUFFERFISH.equals(type) || EntityTypes.SALMON.equals(type) || EntityTypes.SNOW_GOLEM.equals(type) || EntityTypes.CAVE_SPIDER.equals(type))
            return 0.7f;
        else if (EntityTypes.WITHER_SKELETON.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 0.7f : 0.72f;
        else if (EntityTypes.WITHER_SKULL.equals(type) || EntityTypes.SHULKER_BULLET.equals(type))
            return 0.3125f;
        else if (EntityTypes.HOGLIN.equals(type) || EntityTypes.ZOGLIN.equals(type))
            return 1.3964844f;
        else if (EntityTypes.SKELETON_HORSE.equals(type) || EntityTypes.ZOMBIE_HORSE.equals(type) || EntityTypes.HORSE.equals(type) ||EntityTypes.DONKEY.equals(type) || EntityTypes.MULE.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 1.3964844f : 1.4f;
        else if (EntityTypes.isTypeInstanceOf(type, EntityTypes.BOAT))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 1.375f : 1.5f;
        else if (EntityTypes.CHICKEN.equals(type) || EntityTypes.ENDERMITE.equals(type) || EntityTypes.SILVERFISH.equals(type) || EntityTypes.VEX.equals(type) || EntityTypes.TADPOLE.equals(type))
            return 0.4f;
        else if (EntityTypes.RABBIT.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 0.4f : 0.6f;
        else if (EntityTypes.STRIDER.equals(type) || EntityTypes.COW.equals(type) || EntityTypes.SHEEP.equals(type) || EntityTypes.MOOSHROOM.equals(type) || EntityTypes.PIG.equals(type) || EntityTypes.LLAMA.equals(type) || EntityTypes.DOLPHIN.equals(type) || EntityTypes.WITHER.equals(type) || EntityTypes.TRADER_LLAMA.equals(type) || EntityTypes.WARDEN.equals(type) || EntityTypes.GOAT.equals(type))
            return 0.9f;
        else if (EntityTypes.PHANTOM.equals(type)) 
            if (packetEntity instanceof PacketEntitySizeable)
                return 0.9f + ((PacketEntitySizeable) packetEntity).size * 0.2f;
            else return 1.5f;
        else if (EntityTypes.ELDER_GUARDIAN.equals(type)) // TODO: 2.35 * guardian?
            return 1.9975f;
        else if (EntityTypes.END_CRYSTAL.equals(type))
            return 2.0f;
        else if (EntityTypes.ENDER_DRAGON.equals(type))
            return 16.0f;
        else if (EntityTypes.FIREBALL.equals(type))
            return 1f;
        else if (EntityTypes.GHAST.equals(type))
            return 4.0f;
        else if (EntityTypes.GIANT.equals(type))
            return 3.6f;
        else if (EntityTypes.GUARDIAN.equals(type))
            return 0.85f;
        else if (EntityTypes.IRON_GOLEM.equals(type))
            return 1.4f;
        else if (EntityTypes.MAGMA_CUBE.equals(type))
            if (packetEntity instanceof PacketEntitySizeable) 
                return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)
                        ? 2.04f * (0.255f * (float) ((PacketEntitySizeable) packetEntity).size)
                        : 0.51000005f * ((PacketEntitySizeable) packetEntity).size;
            else return 0.98f;
        else if (EntityTypes.isTypeInstanceOf(type, EntityTypes.MINECART_ABSTRACT))
            return 0.98f;
        else if (EntityTypes.PLAYER.equals(type))
            return 0.6f;
        else if (EntityTypes.POLAR_BEAR.equals(type))
            return 1.4f;
        else if (EntityTypes.RAVAGER.equals(type))
            return 1.95f;
        else if (EntityTypes.SHULKER.equals(type))
            return 1.0f;
        else if (EntityTypes.SLIME.equals(type))
            if (packetEntity instanceof PacketEntitySizeable) 
                return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)
                        ? 2.04f * (0.255f * (float) ((PacketEntitySizeable) packetEntity).size)
                        : 0.51000005f * ((PacketEntitySizeable) packetEntity).size;
            else return 0.3125f;
        else if (EntityTypes.SMALL_FIREBALL.equals(type))
            return 0.3125f;
        else if (EntityTypes.SPIDER.equals(type))
            return 1.4f;
        else if (EntityTypes.SQUID.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 0.8f : 0.95f;
        else if (EntityTypes.TURTLE.equals(type))
            return 1.2f;
        else if (EntityTypes.ALLAY.equals(type))
            return 0.35f;
        else if (EntityTypes.SNIFFER.equals(type))
            return 1.9f;
        else if (EntityTypes.CAMEL.equals(type))
            return 1.7f;
        else if (EntityTypes.WIND_CHARGE.equals(type))
            return 0.3125F;
        return 0.6f;
    }
    
    public static double getMyRidingOffset(PacketEntity packetEntity) {
        final EntityType type = packetEntity.getType();
        if (EntityTypes.PIGLIN.equals(type) || EntityTypes.ZOMBIFIED_PIGLIN.equals(type) || EntityTypes.ZOMBIE.equals(type))
            return packetEntity.isBaby ? -0.05 : -0.45;
        else if (EntityTypes.SKELETON.equals(type))
            return -0.6;
        else if (EntityTypes.ENDERMITE.equals(type) || EntityTypes.SILVERFISH.equals(type))
            return 0.1;
        else if (EntityTypes.EVOKER.equals(type) || EntityTypes.ILLUSIONER.equals(type) || EntityTypes.PILLAGER.equals(packetEntity.type) || EntityTypes.RAVAGER.equals(packetEntity.type) || EntityTypes.VINDICATOR.equals(packetEntity.type) || EntityTypes.WITCH.equals(packetEntity.type))
            return -0.45;
        else if (EntityTypes.PLAYER.equals(type))
            return -0.35;
        if (EntityTypes.isTypeInstanceOf(type, EntityTypes.ABSTRACT_ANIMAL))
            return 0.14;
        return 0;
    }
    
    public static double getPassengerRidingOffset(GrimPlayer player, PacketEntity packetEntity) {
        if (packetEntity instanceof PacketEntityHorse)
            return (getHeight(player, packetEntity) * 0.75) - 0.25;
        final EntityType type = packetEntity.getType();
        if (EntityTypes.isTypeInstanceOf(type, EntityTypes.MINECART_ABSTRACT))
            return 0;
        else if (EntityTypes.isTypeInstanceOf(type, EntityTypes.BOAT))
            return -0.1;
        else if (EntityTypes.HOGLIN.equals(type) || EntityTypes.ZOGLIN.equals(type))
            return getHeight(player, packetEntity) - (packetEntity.isBaby ? 0.2 : 0.15);
        else if (EntityTypes.LLAMA.equals(type))
            return getHeight(player, packetEntity) * 0.67;
        else if (EntityTypes.PIGLIN.equals(type))
            return getHeight(player, packetEntity) * 0.92;
        else if (EntityTypes.RAVAGER.equals(type))
            return 2.1;
        else if (EntityTypes.SKELETON.equals(type))
            return (getHeight(player, packetEntity) * 0.75) - 0.1875;
        else if (EntityTypes.SPIDER.equals(type))
            return getHeight(player, packetEntity) * 0.5;
        else if (EntityTypes.STRIDER.equals(type))// depends on animation position, good luck getting it exactly, this is the best you can do though
            return getHeight(player, packetEntity) - 0.19;
        return getHeight(player, packetEntity) * 0.75;
    }

    private static float getHeightMinusBaby(GrimPlayer player, PacketEntity packetEntity) {
        final EntityType type = packetEntity.getType();
        if (EntityTypes.AXOLOTL.equals(type) || EntityTypes.BEE.equals(type) || EntityTypes.DOLPHIN.equals(type) || EntityTypes.ALLAY.equals(type)) 
            return 0.6f;
        else if (EntityTypes.EVOKER_FANGS.equals(type) || EntityTypes.VEX.equals(type))
            return 0.8f;
        else if (EntityTypes.SQUID.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 0.8f : 0.95f;
        else if (EntityTypes.PARROT.equals(type) || EntityTypes.BAT.equals(type) || EntityTypes.PIG.equals(type) || EntityTypes.SPIDER.equals(type))
            return 0.9f;
        else if (EntityTypes.WITHER_SKULL.equals(type) || EntityTypes.SHULKER_BULLET.equals(type))
            return 0.3125f;
        else if (EntityTypes.BLAZE.equals(type))
            return 1.8f;
        else if (EntityTypes.isTypeInstanceOf(type, EntityTypes.BOAT)) 
            return 0.5625f;
        // WHY DOES VIAVERSION OFFSET BOATS? THIS MAKES IT HARD TO SUPPORT, EVEN IF WE INTERPOLATE RIGHT.
        // I gave up and just exempted boats from the reach check and gave up with interpolation for collisions
        else if (EntityTypes.CAT.equals(type))
            return 0.7f;
        else if (EntityTypes.CAVE_SPIDER.equals(type))
            return 0.5f;
        else if (EntityTypes.FROG.equals(type))
            return 0.55f;
        else if (EntityTypes.CHICKEN.equals(type))
            return 0.7f;
        else if (EntityTypes.HOGLIN.equals(type) || EntityTypes.ZOGLIN.equals(type))
            return 1.4f;
        else if (EntityTypes.COW.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 1.4f : 1.3f;
        else if (EntityTypes.STRIDER.equals(type))
            return 1.7f;
        else if (EntityTypes.CREEPER.equals(type))
            return 1.7f;
        else if (EntityTypes.DONKEY.equals(type))
            return 1.5f;
        else if (EntityTypes.ELDER_GUARDIAN.equals(type))
            return 1.9975f;
        else if (EntityTypes.ENDERMAN.equals(type) || EntityTypes.WARDEN.equals(type))
            return 2.9f;
        else if (EntityTypes.ENDERMITE.equals(type) || EntityTypes.COD.equals(type))
            return 0.3f;
        else if (EntityTypes.END_CRYSTAL.equals(type))
            return 2.0f;
        else if (EntityTypes.ENDER_DRAGON.equals(type))
            return 8.0f;
        else if (EntityTypes.FIREBALL.equals(type))
            return 1f;
        else if (EntityTypes.FOX.equals(type))
            return 0.7f;
        else if (EntityTypes.GHAST.equals(type))
            return 4.0f;
        else if (EntityTypes.GIANT.equals(type))
            return 12.0f;
        else if (EntityTypes.GUARDIAN.equals(type))
            return 0.85f;
        else if (EntityTypes.HORSE.equals(type))
            return 1.6f;
        else if (EntityTypes.IRON_GOLEM.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 2.7f : 2.9f;
        else if (EntityTypes.LLAMA.equals(type) || EntityTypes.TRADER_LLAMA.equals(type))
            return 1.87f;
        else if (EntityTypes.TROPICAL_FISH.equals(type))
            return 0.4f;
        else if (EntityTypes.MAGMA_CUBE.equals(type))
            if (packetEntity instanceof PacketEntitySizeable)
                return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)
                        ? 2.04f * (0.255f * (float) ((PacketEntitySizeable) packetEntity).size)
                        : 0.51000005f * ((PacketEntitySizeable) packetEntity).size;
            else return 0.7f;
        else if (EntityTypes.isTypeInstanceOf(type, EntityTypes.MINECART_ABSTRACT))
            return 0.7f;
        else if (EntityTypes.MULE.equals(type))
            return 1.6f;
        else if (EntityTypes.MOOSHROOM.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 1.4f : 1.3f;
        else if (EntityTypes.OCELOT.equals(type))
            return 0.7f;
        else if (EntityTypes.PANDA.equals(type))
            return 1.25f;
        else if (EntityTypes.PHANTOM.equals(type))
            if (packetEntity instanceof PacketEntitySizeable)
                return 0.5f + ((PacketEntitySizeable) packetEntity).size * 0.1f;
            else return 1.8f;
        else if (EntityTypes.PLAYER.equals(type))
            return 1.8f;
        else if (EntityTypes.POLAR_BEAR.equals(type))
            return 1.4f;
        else if (EntityTypes.PUFFERFISH.equals(type))
            return 0.7f;
        else if (EntityTypes.RABBIT.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 0.5f : 0.7f;
        else if (EntityTypes.RAVAGER.equals(type))
            return 2.2f;
        else if (EntityTypes.SALMON.equals(type))
            return 0.4f;
        else if (EntityTypes.SHEEP.equals(type) || EntityTypes.GOAT.equals(type))
            return 1.3f;
        else if (EntityTypes.SHULKER.equals(type)) // Could maybe guess peek size, although seems useless
            return 2.0f;
        else if (EntityTypes.SILVERFISH.equals(type))
            return 0.3f;
        else if (EntityTypes.SKELETON.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 1.99f : 1.95f;
        else if (EntityTypes.SKELETON_HORSE.equals(type))
            return 1.6f;
        else if (EntityTypes.SLIME.equals(type))
            if (packetEntity instanceof PacketEntitySizeable)
                return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)
                        ? 2.04f * (0.255f * (float) ((PacketEntitySizeable) packetEntity).size)
                        : 0.51000005f * ((PacketEntitySizeable) packetEntity).size;
            else return 0.3125f;
        else if (EntityTypes.SMALL_FIREBALL.equals(type))
            return 0.3125f;
        else if (EntityTypes.SNOW_GOLEM.equals(type))
            return 1.9f;
        else if (EntityTypes.STRAY.equals(type))
            return 1.99f;
        else if (EntityTypes.TURTLE.equals(type))
            return 0.4f;
        else if (EntityTypes.WITHER.equals(type))
            return 3.5f;
        else if (EntityTypes.WITHER_SKELETON.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 2.4f : 2.535f;
        else if (EntityTypes.WOLF.equals(type))
            return player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) ? 0.85f : 0.8f;
        else if (EntityTypes.ZOMBIE_HORSE.equals(type))
            return 1.6f;
        else if (EntityTypes.TADPOLE.equals(type))
            return 0.3f;
        else if (EntityTypes.SNIFFER.equals(type))
            return 1.75f;
        else if (EntityTypes.CAMEL.equals(type))
            return 2.375f;
        else if (EntityTypes.BREEZE.equals(type))
            return 1.77F;
        else if (EntityTypes.BOGGED.equals(type))
            return 1.99F;
        else if (EntityTypes.WIND_CHARGE.equals(type))
            return 0.3125F;
        return 1.95f;
    }

@Symmettry
Copy link
Author

Symmettry commented May 30, 2024

would these come in handy somewhere or would you rather not remove the brackets?

paste.ee: https://paste.ee/p/8nEzc

I personally find it easier to read with the return on the same line, but if it's too long i'd use brackets still, so in this case I think brackets are best.

Comment on lines +11 to +14
private @NonNull double x, y, z;
private @NonNull float xRot, yRot;
private @NonNull EntityType entityType;
private @NonNull int lastTransactionHung;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

primitives can never be null, why are there @NonNull annotations? (I know you didn't add them but they should be removable)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure, I think it was something with lombok, but I didn't want to risk it.

@Symmettry
Copy link
Author

ok so i just went and resolved all teh conflicts and then apparently none of it saved. thanks github.
i'm too tired, so if someone wants to try resolving this go ahead, because im not doing it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants