-
Notifications
You must be signed in to change notification settings - Fork 326
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
base: 2.0
Are you sure you want to change the base?
Conversation
src/main/java/ac/grim/grimac/checks/impl/prediction/OffsetHandler.java
Outdated
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsQ.java
Outdated
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsU.java
Outdated
Show resolved
Hide resolved
review for latest cleanup please! :) |
src/main/java/ac/grim/grimac/checks/impl/aim/processor/AimProcessor.java
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/utils/data/ReachInterpolationData.java
Outdated
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntity.java
Outdated
Show resolved
Hide resolved
I meant newlines at the end of the file |
src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityShulker.java
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntitySelf.java
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityRideable.java
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityHorse.java
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityHook.java
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityTrackXRot.java
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntityStrider.java
Show resolved
Hide resolved
src/main/java/ac/grim/grimac/utils/data/packetentity/PacketEntitySizeable.java
Show resolved
Hide resolved
what? why? there is no need for a new line after the class bracket |
"consistency" |
src/main/java/ac/grim/grimac/checks/impl/scaffolding/RotationPlace.java
Outdated
Show resolved
Hide resolved
You seem angry somehow. There is no purpose towards that new line in any case whatsoever. So it doesn't matter. |
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 { |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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
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);
}
} |
wouldn't it be better to modify this?
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. |
Done |
Alternatively I could probably try switching the ID of the entity type but it might have issues with protocol versions. |
I don't think you rebased properly, PacketEntity seems to be semi-merged with TypedPacketEntity and is also missing trackedServerPosition initializer. 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) |
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;
} |
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. |
private @NonNull double x, y, z; | ||
private @NonNull float xRot, yRot; | ||
private @NonNull EntityType entityType; | ||
private @NonNull int lastTransactionHung; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
ok so i just went and resolved all teh conflicts and then apparently none of it saved. thanks github. |
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.