Skip to content

Commit

Permalink
revert renaming compensatedWorld and compensatedEntities
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan committed Jan 25, 2025
1 parent 3a40ba8 commit 22074dc
Show file tree
Hide file tree
Showing 71 changed files with 351 additions and 351 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public AimDuplicateLook(GrimPlayer playerData) {

@Override
public void process(final RotationUpdate rotationUpdate) {
if (player.packetStateData.lastPacketWasTeleport || player.packetStateData.lastPacketWasOnePointSeventeenDuplicate || player.entities.self.getRiding() != null) {
if (player.packetStateData.lastPacketWasTeleport || player.packetStateData.lastPacketWasOnePointSeventeenDuplicate || player.compensatedEntities.self.getRiding() != null) {
exempt = true;
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void onPacketReceive(PacketReceiveEvent event) {

final WrapperPlayClientInteractEntity wrapper = new WrapperPlayClientInteractEntity(event);

final PacketEntity entity = player.entities.entityMap.get(wrapper.getEntityId());
final PacketEntity entity = player.compensatedEntities.entityMap.get(wrapper.getEntityId());

// For armor stands, vanilla clients send:
// - when renaming the armor stand or in spectator mode: INTERACT_AT + INTERACT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public void onPacketReceive(final PacketReceiveEvent event) {
long ms = (player.getPlayerClockAtLeast() - clock) / 1000000L;
long diff = (System.currentTimeMillis() - lastTransTime);
if (diff > 2000 && ms > 2000) {
if (positions == 0 && clock != 0 && player.gamemode != GameMode.SPECTATOR && !player.entities.self.isDead) {
if (positions == 0 && clock != 0 && player.gamemode != GameMode.SPECTATOR && !player.compensatedEntities.self.isDead) {
flag("time=" + ms + "ms, " + "lst=" + diff + "ms, positions=" + positions);
} else {
reward();
}
player.world.removeInvalidPistonLikeStuff(oldTransId);
player.compensatedWorld.removeInvalidPistonLikeStuff(oldTransId);
positions = 0;
clock = player.getPlayerClockAtLeast();
lastTransTime = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void onPacketReceive(final PacketReceiveEvent event) {
final WrapperPlayClientInteractEntity wrapper = new WrapperPlayClientInteractEntity(event);
// Only INTERACT_AT actually has an interaction vector
wrapper.getTarget().ifPresent(targetVector -> {
final PacketEntity packetEntity = player.entities.getEntity(wrapper.getEntityId());
final PacketEntity packetEntity = player.compensatedEntities.getEntity(wrapper.getEntityId());
// Don't continue if the compensated entity hasn't been resolved
if (packetEntity == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void onBlockBreak(BlockBreak blockBreak) {

// getPickRange() determines this?
// With 1.20.5+ the new attribute determines creative mode reach using a modifier
double maxReach = player.entities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE);
double maxReach = player.compensatedEntities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE);
if (player.packetStateData.didLastMovementIncludePosition || player.canSkipTicks()) {
double threshold = player.getMovementThreshold();
maxReach += Math.hypot(threshold, threshold);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public void onPacketReceive(final PacketReceiveEvent event) {
return;
}

PacketEntity entity = player.entities.entityMap.get(action.getEntityId());
PacketEntity entity = player.compensatedEntities.entityMap.get(action.getEntityId());
// Stop people from freezing transactions before an entity spawns to bypass reach
// TODO: implement dragon parts?
if (entity == null || entity instanceof PacketEntityEnderDragonPart) {
// Only cancel if and only if we are tracking this entity
// This is because we don't track paintings.
if (shouldModifyPackets() && player.entities.serverPositionsMap.containsKey(action.getEntityId())) {
if (shouldModifyPackets() && player.compensatedEntities.serverPositionsMap.containsKey(action.getEntityId())) {
event.setCancelled(true);
player.onPacketCancel();
}
Expand Down Expand Up @@ -139,13 +139,13 @@ private boolean isKnownInvalid(PacketEntity reachEntity) {
if (reachEntity.getType() == EntityTypes.END_CRYSTAL) {
targetBox = new SimpleCollisionBox(reachEntity.trackedServerPosition.getPos().subtract(1, 0, 1), reachEntity.trackedServerPosition.getPos().add(1, 2, 1));
}
return ReachUtils.getMinReachToBox(player, targetBox) > player.entities.self.getAttributeValue(Attributes.ENTITY_INTERACTION_RANGE);
return ReachUtils.getMinReachToBox(player, targetBox) > player.compensatedEntities.self.getAttributeValue(Attributes.ENTITY_INTERACTION_RANGE);
}
}

private void tickBetterReachCheckWithAngle() {
for (Int2ObjectMap.Entry<Vector3d> attack : playerAttackQueue.int2ObjectEntrySet()) {
PacketEntity reachEntity = player.entities.entityMap.get(attack.getIntKey());
PacketEntity reachEntity = player.compensatedEntities.entityMap.get(attack.getIntKey());
if (reachEntity == null) continue;

CheckResult result = checkReach(reachEntity, attack.getValue(), false);
Expand Down Expand Up @@ -208,7 +208,7 @@ private CheckResult checkReach(PacketEntity reachEntity, Vector3d from, boolean
}
}

final double maxReach = player.entities.self.getAttributeValue(Attributes.ENTITY_INTERACTION_RANGE);
final double maxReach = player.compensatedEntities.self.getAttributeValue(Attributes.ENTITY_INTERACTION_RANGE);
// +3 would be 3 + 3 = 6, which is the pre-1.20.5 behaviour, preventing "Missed Hitbox"
final double distance = maxReach + 3;
final double[] possibleEyeHeights = player.getPossibleEyeHeights();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION
&& new WrapperPlayClientEntityAction(event).getAction() == WrapperPlayClientEntityAction.Action.START_FLYING_WITH_ELYTRA
&& player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_16)
&& player.entities.self.hasPotionEffect(PotionTypes.LEVITATION)
&& player.compensatedEntities.self.hasPotionEffect(PotionTypes.LEVITATION)
&& flagAndAlert()
) {
setback = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ private boolean checkForBoxes(SimpleCollisionBox playerBB) {
}
}

return player.world.isNearHardEntity(playerBB.copy().expand(4));
return player.compensatedWorld.isNearHardEntity(playerBB.copy().expand(4));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void onPacketReceive(final PacketReceiveEvent event) {
}

// Player is dead
if (player.entities.self.isDead) {
if (player.compensatedEntities.self.isDead) {
event.setCancelled(true);
}
}
Expand All @@ -63,7 +63,7 @@ public void onPacketReceive(final PacketReceiveEvent event) {
}

// Player is dead
if (player.entities.self.isDead) {
if (player.compensatedEntities.self.isDead) {
event.setCancelled(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) {
if (newBB.isIntersected(box) && !oldBB.isIntersected(box)) {
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
// A bit of a hacky way to get the block state, but this is much faster to use the tuinity method for grabbing collision boxes
WrappedBlockState state = player.world.getBlock((box.minX + box.maxX) / 2, (box.minY + box.maxY) / 2, (box.minZ + box.maxZ) / 2);
WrappedBlockState state = player.compensatedWorld.getBlock((box.minX + box.maxX) / 2, (box.minY + box.maxY) / 2, (box.minZ + box.maxZ) / 2);
if (BlockTags.ANVIL.contains(state.getType()) || state.getType() == StateTypes.CHEST || state.getType() == StateTypes.TRAPPED_CHEST) {
continue; // 1.8 glitchy block, ignore
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void onBlockPlace(final BlockPlace place) {
if (player.gamemode == GameMode.CREATIVE) return;

Vector3i blockPos = place.getPlacedAgainstBlockLocation();
StateType placeAgainst = player.world.getBlockType(blockPos.getX(), blockPos.getY(), blockPos.getZ());
StateType placeAgainst = player.compensatedWorld.getBlockType(blockPos.getX(), blockPos.getY(), blockPos.getZ());

int currentTick = GrimAPI.INSTANCE.getTickManager().currentTick;
// this is actual more lenient then we need to be, We can check up to 1 ticks for all changes at location sand up to 0 ticks for first change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void onBlockPlace(final BlockPlace place) {

// getPickRange() determines this?
// With 1.20.5+ the new attribute determines creative mode reach using a modifier
double maxReach = player.entities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE);
double maxReach = player.compensatedEntities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE);
double threshold = player.getMovementThreshold();
maxReach += Math.hypot(threshold, threshold);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private boolean didRayTraceHit(BlockPlace place) {
possibleLookDirs = Collections.singletonList(new Vector3f(player.xRot, player.yRot, 0));
}

final double distance = player.entities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE);
final double distance = player.compensatedEntities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE);
for (double d : possibleEyeHeights) {
for (Vector3f lookDir : possibleLookDirs) {
// x, y, z are correct for the block placement even after post tick because of code elsewhere
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
public void onPredictionComplete(final PredictionComplete predictionComplete) {
if (!predictionComplete.isChecked()) return;

if (player.entities.self.hasPotionEffect(BLINDNESS)) {
if (player.compensatedEntities.self.hasPotionEffect(BLINDNESS)) {
if (player.isSprinting && !startedSprintingBeforeBlind) {
flagAndAlertWithSetback();
} else reward();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public VehicleD(GrimPlayer player) {
@Override
public void onPacketReceive(final PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION && new WrapperPlayClientEntityAction(event).getAction() == WrapperPlayClientEntityAction.Action.START_JUMPING_WITH_HORSE) {
final EntityType vehicle = player.inVehicle() ? player.entities.self.getRiding().getType() : null;
final EntityType vehicle = player.inVehicle() ? player.compensatedEntities.self.getRiding().getType() : null;

if (!EntityTypes.isTypeInstanceOf(vehicle, EntityTypes.ABSTRACT_HORSE)) {
flagAndAlert("vehicle=" + (vehicle == null ? "null" : vehicle.getName().getKey().toLowerCase()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ private void handleBlockExplosions(WrapperPlayServerExplosion explosion) {
for (Vector3i record : explosion.getRecords()) {
// Null OR not flip redstone blocks, then set to air
if (blockInteraction != WrapperPlayServerExplosion.BlockInteraction.TRIGGER_BLOCKS) {
player.world.updateBlock(record.x, record.y, record.z, 0);
player.compensatedWorld.updateBlock(record.x, record.y, record.z, 0);
} else {
// We need to flip redstone blocks, or do special things with other blocks
final WrappedBlockState state = player.world.getBlock(record);
final WrappedBlockState state = player.compensatedWorld.getBlock(record);
final StateType type = state.getType();
if (BlockTags.CANDLES.contains(type) || BlockTags.CANDLE_CAKES.contains(type)) {
state.setLit(false);
Expand All @@ -95,7 +95,7 @@ private void handleBlockExplosions(WrapperPlayServerExplosion explosion) {
final Object poweredValue = state.getInternalData().get(StateValue.POWERED);
final boolean canFlip = (poweredValue != null && !(Boolean) poweredValue) || type == StateTypes.LEVER;
if (canFlip) {
player.world.tickOpenable(record.x, record.y, record.z);
player.compensatedWorld.tickOpenable(record.x, record.y, record.z);
}
}
}
Expand Down Expand Up @@ -204,7 +204,7 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) {
}

// 100% known kb was taken
if (player.likelyExplosions != null && !player.entities.self.isDead) {
if (player.likelyExplosions != null && !player.compensatedEntities.self.isDead) {
if (player.likelyExplosions.offset > offsetToFlag) {
flagAndAlertWithSetback(player.likelyExplosions.offset == Integer.MAX_VALUE ? "ignored explosion" : "o: " + formatOffset(offset));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public void onPacketSend(final PacketSendEvent event) {

// Detect whether this knockback packet affects the player or if it is useless
// Mojang sends extra useless knockback packets for no apparent reason
if (player.entities.serverPlayerVehicle != null && entityId != player.entities.serverPlayerVehicle) {
if (player.compensatedEntities.serverPlayerVehicle != null && entityId != player.compensatedEntities.serverPlayerVehicle) {
return;
}
if (player.entities.serverPlayerVehicle == null && entityId != player.entityID) {
if (player.compensatedEntities.serverPlayerVehicle == null && entityId != player.entityID) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected boolean shouldCancel() {
protected SimpleCollisionBox getCombinedBox(final BlockPlace place) {
// Alright, instead of skidding AACAdditionsPro, let's just use bounding boxes
Vector3i clicked = place.getPlacedAgainstBlockLocation();
CollisionBox placedOn = HitboxData.getBlockHitbox(player, place.getMaterial(), player.getClientVersion(), player.world.getBlock(clicked), true, clicked.getX(), clicked.getY(), clicked.getZ());
CollisionBox placedOn = HitboxData.getBlockHitbox(player, place.getMaterial(), player.getClientVersion(), player.compensatedWorld.getBlock(clicked), true, clicked.getX(), clicked.getY(), clicked.getZ());

int size = placedOn.downCast(boxes);

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/ac/grim/grimac/events/bukkit/PistonEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public void onPistonPushEvent(BlockPistonExtendEvent event) {
piston.getZ() + event.getDirection().getModZ()));

for (GrimPlayer player : GrimAPI.INSTANCE.getPlayerDataManager().getEntries()) {
if (player.world.isChunkLoaded(event.getBlock().getX() >> 4, event.getBlock().getZ() >> 4)) {
if (player.compensatedWorld.isChunkLoaded(event.getBlock().getX() >> 4, event.getBlock().getZ() >> 4)) {
PistonData data = new PistonData(BlockFaceHelper.fromBukkitFace(event.getDirection()), boxes, player.lastTransactionSent.get(), true, hasSlimeBlock, hasHoneyBlock);
player.latencyUtils.addRealTimeTaskAsync(player.lastTransactionSent.get(), () -> player.world.activePistons.add(data));
player.latencyUtils.addRealTimeTaskAsync(player.lastTransactionSent.get(), () -> player.compensatedWorld.activePistons.add(data));
}
}
}
Expand Down Expand Up @@ -109,9 +109,9 @@ public void onPistonRetractEvent(BlockPistonRetractEvent event) {
}

for (GrimPlayer player : GrimAPI.INSTANCE.getPlayerDataManager().getEntries()) {
if (player.world.isChunkLoaded(event.getBlock().getX() >> 4, event.getBlock().getZ() >> 4)) {
if (player.compensatedWorld.isChunkLoaded(event.getBlock().getX() >> 4, event.getBlock().getZ() >> 4)) {
PistonData data = new PistonData(BlockFaceHelper.fromBukkitFace(event.getDirection()), boxes, player.lastTransactionSent.get(), false, hasSlimeBlock, hasHoneyBlock);
player.latencyUtils.addRealTimeTaskAsync(player.lastTransactionSent.get(), () -> player.world.activePistons.add(data));
player.latencyUtils.addRealTimeTaskAsync(player.lastTransactionSent.get(), () -> player.compensatedWorld.activePistons.add(data));
}
}
}
Expand Down
Loading

0 comments on commit 22074dc

Please sign in to comment.