diff --git a/src/main/java/ac/grim/grimac/checks/impl/aim/AimDuplicateLook.java b/src/main/java/ac/grim/grimac/checks/impl/aim/AimDuplicateLook.java index 59559cc9d2..8eef6cf4c2 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/aim/AimDuplicateLook.java +++ b/src/main/java/ac/grim/grimac/checks/impl/aim/AimDuplicateLook.java @@ -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; } diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsM.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsM.java index d48d1f3e9d..55ad3e3040 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsM.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsM.java @@ -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 diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java index 2723516ab8..b9a07929e9 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsR.java @@ -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(); diff --git a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java index 37aaceda30..872682f2e2 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java +++ b/src/main/java/ac/grim/grimac/checks/impl/badpackets/BadPacketsT.java @@ -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; diff --git a/src/main/java/ac/grim/grimac/checks/impl/breaking/FarBreak.java b/src/main/java/ac/grim/grimac/checks/impl/breaking/FarBreak.java index bcfdc85f2f..cc7571813a 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/breaking/FarBreak.java +++ b/src/main/java/ac/grim/grimac/checks/impl/breaking/FarBreak.java @@ -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); diff --git a/src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java b/src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java index 80742ad5e4..6228b55ebc 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java +++ b/src/main/java/ac/grim/grimac/checks/impl/combat/Reach.java @@ -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(); } @@ -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 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); @@ -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(); diff --git a/src/main/java/ac/grim/grimac/checks/impl/elytra/ElytraG.java b/src/main/java/ac/grim/grimac/checks/impl/elytra/ElytraG.java index d729b15eb9..d45e996ee0 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/elytra/ElytraG.java +++ b/src/main/java/ac/grim/grimac/checks/impl/elytra/ElytraG.java @@ -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; diff --git a/src/main/java/ac/grim/grimac/checks/impl/groundspoof/NoFall.java b/src/main/java/ac/grim/grimac/checks/impl/groundspoof/NoFall.java index eb34d63609..5ea7460c28 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/groundspoof/NoFall.java +++ b/src/main/java/ac/grim/grimac/checks/impl/groundspoof/NoFall.java @@ -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)); } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/movement/SetbackBlocker.java b/src/main/java/ac/grim/grimac/checks/impl/movement/SetbackBlocker.java index 84e3178082..7ad1f81fe4 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/movement/SetbackBlocker.java +++ b/src/main/java/ac/grim/grimac/checks/impl/movement/SetbackBlocker.java @@ -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); } } @@ -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); } } diff --git a/src/main/java/ac/grim/grimac/checks/impl/prediction/Phase.java b/src/main/java/ac/grim/grimac/checks/impl/prediction/Phase.java index 6e91c4132d..e56bfe0a76 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/prediction/Phase.java +++ b/src/main/java/ac/grim/grimac/checks/impl/prediction/Phase.java @@ -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 } diff --git a/src/main/java/ac/grim/grimac/checks/impl/scaffolding/AirLiquidPlace.java b/src/main/java/ac/grim/grimac/checks/impl/scaffolding/AirLiquidPlace.java index dddbe6765a..f24f82f4e1 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/scaffolding/AirLiquidPlace.java +++ b/src/main/java/ac/grim/grimac/checks/impl/scaffolding/AirLiquidPlace.java @@ -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 diff --git a/src/main/java/ac/grim/grimac/checks/impl/scaffolding/FarPlace.java b/src/main/java/ac/grim/grimac/checks/impl/scaffolding/FarPlace.java index d1d7cf46c6..bcc971815e 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/scaffolding/FarPlace.java +++ b/src/main/java/ac/grim/grimac/checks/impl/scaffolding/FarPlace.java @@ -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); diff --git a/src/main/java/ac/grim/grimac/checks/impl/scaffolding/RotationPlace.java b/src/main/java/ac/grim/grimac/checks/impl/scaffolding/RotationPlace.java index 74c91c4f1a..08741e09c1 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/scaffolding/RotationPlace.java +++ b/src/main/java/ac/grim/grimac/checks/impl/scaffolding/RotationPlace.java @@ -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 diff --git a/src/main/java/ac/grim/grimac/checks/impl/sprint/SprintD.java b/src/main/java/ac/grim/grimac/checks/impl/sprint/SprintD.java index a9792b2970..370151d208 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/sprint/SprintD.java +++ b/src/main/java/ac/grim/grimac/checks/impl/sprint/SprintD.java @@ -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(); diff --git a/src/main/java/ac/grim/grimac/checks/impl/vehicle/VehicleD.java b/src/main/java/ac/grim/grimac/checks/impl/vehicle/VehicleD.java index 5f020d6b77..ef129a3b00 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/vehicle/VehicleD.java +++ b/src/main/java/ac/grim/grimac/checks/impl/vehicle/VehicleD.java @@ -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())); diff --git a/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java b/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java index d4304f0088..dad835ece1 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java +++ b/src/main/java/ac/grim/grimac/checks/impl/velocity/ExplosionHandler.java @@ -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); @@ -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); } } } @@ -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 { diff --git a/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java b/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java index 58eb904aad..fb5dd326e4 100644 --- a/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java +++ b/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java @@ -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; } diff --git a/src/main/java/ac/grim/grimac/checks/type/BlockPlaceCheck.java b/src/main/java/ac/grim/grimac/checks/type/BlockPlaceCheck.java index 123ad0aab3..cc9507eb75 100644 --- a/src/main/java/ac/grim/grimac/checks/type/BlockPlaceCheck.java +++ b/src/main/java/ac/grim/grimac/checks/type/BlockPlaceCheck.java @@ -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); diff --git a/src/main/java/ac/grim/grimac/events/bukkit/PistonEvent.java b/src/main/java/ac/grim/grimac/events/bukkit/PistonEvent.java index d663e6cec4..19f04e1e84 100644 --- a/src/main/java/ac/grim/grimac/events/bukkit/PistonEvent.java +++ b/src/main/java/ac/grim/grimac/events/bukkit/PistonEvent.java @@ -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)); } } } @@ -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)); } } } diff --git a/src/main/java/ac/grim/grimac/events/packets/CheckManagerListener.java b/src/main/java/ac/grim/grimac/events/packets/CheckManagerListener.java index c7a2cb6730..b18a5b0823 100644 --- a/src/main/java/ac/grim/grimac/events/packets/CheckManagerListener.java +++ b/src/main/java/ac/grim/grimac/events/packets/CheckManagerListener.java @@ -81,7 +81,7 @@ public static HitData traverseBlocks(GrimPlayer player, Vector3d start, Vector3d if (start.equals(end)) return null; - WrappedBlockState state = player.world.getBlock(floorStartX, floorStartY, floorStartZ); + WrappedBlockState state = player.compensatedWorld.getBlock(floorStartX, floorStartY, floorStartZ); HitData apply = predicate.apply(state, new Vector3i(floorStartX, floorStartY, floorStartZ)); if (apply != null) { @@ -121,7 +121,7 @@ public static HitData traverseBlocks(GrimPlayer player, Vector3d start, Vector3d d14 += posZInverse; } - state = player.world.getBlock(floorStartX, floorStartY, floorStartZ); + state = player.compensatedWorld.getBlock(floorStartX, floorStartY, floorStartZ); apply = predicate.apply(state, new Vector3i(floorStartX, floorStartY, floorStartZ)); if (apply != null) { @@ -184,7 +184,7 @@ public static void handleQueuedPlaces(GrimPlayer player, boolean hasLook, float player.isSneaking = snapshot.isSneaking(); if (player.inVehicle()) { - Vector3d posFromVehicle = BoundingBoxSize.getRidingOffsetFromVehicle(player.entities.self.getRiding(), player); + Vector3d posFromVehicle = BoundingBoxSize.getRidingOffsetFromVehicle(player.compensatedEntities.self.getRiding(), player); player.x = posFromVehicle.getX(); player.y = posFromVehicle.getY(); player.z = posFromVehicle.getZ(); @@ -198,9 +198,9 @@ public static void handleQueuedPlaces(GrimPlayer player, boolean hasLook, float player.yRot = pitch; } - player.world.startPredicting(); + player.compensatedWorld.startPredicting(); handleBlockPlaceOrUseItem(snapshot.getWrapper(), player); - player.world.stopPredicting(snapshot.getWrapper()); + player.compensatedWorld.stopPredicting(snapshot.getWrapper()); player.x = lastX; player.y = lastY; @@ -277,14 +277,14 @@ private static void handleBlockPlaceOrUseItem(PacketWrapper packet, GrimPlaye player.checkManager.onPostFlyingBlockPlace(blockPlace); } Vector3i location = blockPlace.getPlacedAgainstBlockLocation(); - player.world.tickOpenable(location.getX(), location.getY(), location.getZ()); + player.compensatedWorld.tickOpenable(location.getX(), location.getY(), location.getZ()); return; } // This also has side effects // This method is for when the block doesn't always consume the click // This causes a ton of desync's but mojang doesn't seem to care... - if (ConsumesBlockPlace.consumesPlace(player, player.world.getBlock(blockPlace.getPlacedAgainstBlockLocation()), blockPlace)) { + if (ConsumesBlockPlace.consumesPlace(player, player.compensatedWorld.getBlock(blockPlace.getPlacedAgainstBlockLocation()), blockPlace)) { if (!player.inVehicle()) { player.checkManager.onPostFlyingBlockPlace(blockPlace); } @@ -462,7 +462,7 @@ public void onPacketReceive(PacketReceiveEvent event) { final DiggingAction action = packet.getAction(); if (action == DiggingAction.START_DIGGING || action == DiggingAction.FINISHED_DIGGING || action == DiggingAction.CANCELLED_DIGGING) { - final BlockBreak blockBreak = new BlockBreak(player, packet.getBlockPosition(), packet.getBlockFace(), packet.getBlockFaceId(), action, player.world.getBlock(packet.getBlockPosition())); + final BlockBreak blockBreak = new BlockBreak(player, packet.getBlockPosition(), packet.getBlockFace(), packet.getBlockFaceId(), action, player.compensatedWorld.getBlock(packet.getBlockPosition())); player.checkManager.onBlockBreak(blockBreak); @@ -472,9 +472,9 @@ public void onPacketReceive(PacketReceiveEvent event) { ResyncWorldUtil.resyncPosition(player, blockBreak.position, packet.getSequence()); } else { if (action == DiggingAction.FINISHED_DIGGING && BREAKABLE.apply(blockBreak.block.getType())) { - player.world.startPredicting(); - player.world.updateBlock(blockBreak.position.x, blockBreak.position.y, blockBreak.position.z, 0); - player.world.stopPredicting(packet); + player.compensatedWorld.startPredicting(); + player.compensatedWorld.updateBlock(blockBreak.position.x, blockBreak.position.y, blockBreak.position.z, 0); + player.compensatedWorld.stopPredicting(packet); } if (action == DiggingAction.START_DIGGING) { @@ -482,10 +482,10 @@ public void onPacketReceive(PacketReceiveEvent event) { // Instant breaking, no damage means it is unbreakable by creative players (with swords) if (damage >= 1) { - player.world.startPredicting(); + player.compensatedWorld.startPredicting(); player.blockHistory.add( new BlockModification( - player.world.getBlock(blockBreak.position), + player.compensatedWorld.getBlock(blockBreak.position), WrappedBlockState.getByGlobalId(0), blockBreak.position, GrimAPI.INSTANCE.getTickManager().currentTick, @@ -495,15 +495,15 @@ public void onPacketReceive(PacketReceiveEvent event) { if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13) && Materials.isWaterSource(player.getClientVersion(), blockBreak.block)) { // Vanilla uses a method to grab water flowing, but as you can't break flowing water // We can simply treat all waterlogged blocks or source blocks as source blocks - player.world.updateBlock(blockBreak.position, StateTypes.WATER.createBlockState(CompensatedWorld.blockVersion)); + player.compensatedWorld.updateBlock(blockBreak.position, StateTypes.WATER.createBlockState(CompensatedWorld.blockVersion)); } else { - player.world.updateBlock(blockBreak.position.x, blockBreak.position.y, blockBreak.position.z, 0); + player.compensatedWorld.updateBlock(blockBreak.position.x, blockBreak.position.y, blockBreak.position.z, 0); } - player.world.stopPredicting(packet); + player.compensatedWorld.stopPredicting(packet); } } - player.world.handleBlockBreakPrediction(packet); + player.compensatedWorld.handleBlockBreakPrediction(packet); } } } @@ -627,7 +627,7 @@ private static void placeBucket(GrimPlayer player, InteractionHand hand) { } // We didn't hit fluid source - if (!placed && !player.world.isWaterSourceBlock(data.getPosition().getX(), data.getPosition().getY(), data.getPosition().getZ())) + if (!placed && !player.compensatedWorld.isWaterSourceBlock(data.getPosition().getX(), data.getPosition().getY(), data.getPosition().getZ())) return; // We can't replace plants with a water bucket @@ -721,7 +721,7 @@ private void handleFlying(GrimPlayer player, double x, double y, double z, float // // This may need to be secured better, but limiting the new setback positions seems good enough for now... boolean canFeasiblyPointThree = Collisions.slowCouldPointThreeHitGround(player, player.x, player.y, player.z); - if ((!canFeasiblyPointThree && !player.world.isNearHardEntity(player.boundingBox.copy().expand(4))) || player.clientVelocity.getY() > 0.06) { + if ((!canFeasiblyPointThree && !player.compensatedWorld.isNearHardEntity(player.boundingBox.copy().expand(4))) || player.clientVelocity.getY() > 0.06) { player.getSetbackTeleportUtil().executeForceResync(); } } @@ -779,14 +779,14 @@ private static void placeLilypad(GrimPlayer player, InteractionHand hand) { if (data != null) { // A lilypad cannot replace a fluid - if (player.world.getFluidLevelAt(data.getPosition().getX(), data.getPosition().getY() + 1, data.getPosition().getZ()) > 0) + if (player.compensatedWorld.getFluidLevelAt(data.getPosition().getX(), data.getPosition().getY() + 1, data.getPosition().getZ()) > 0) return; BlockPlace blockPlace = new BlockPlace(player, hand, data.getPosition(), data.getClosestDirection().getFaceValue(), data.getClosestDirection(), ItemStack.EMPTY, data); blockPlace.setReplaceClicked(false); // Not possible with use item // We checked for a full fluid block below here. - if (player.world.getWaterFluidLevelAt(data.getPosition().getX(), data.getPosition().getY(), data.getPosition().getZ()) > 0 + if (player.compensatedWorld.getWaterFluidLevelAt(data.getPosition().getX(), data.getPosition().getY(), data.getPosition().getZ()) > 0 || data.getState().getType() == StateTypes.ICE || data.getState().getType() == StateTypes.FROSTED_ICE) { Vector3i pos = data.getPosition(); pos = pos.add(0, 1, 0); @@ -809,7 +809,7 @@ private static HitData getNearestHitResult(GrimPlayer player, StateType heldItem Vector3d startingPos = new Vector3d(player.x, player.y + player.getEyeHeight(), player.z); Vector startingVec = new Vector(startingPos.getX(), startingPos.getY(), startingPos.getZ()); Ray trace = new Ray(player, startingPos.getX(), startingPos.getY(), startingPos.getZ(), player.xRot, player.yRot); - final double distance = itemUsePlacement && player.getClientVersion().isOlderThan(ClientVersion.V_1_20_5) ? 5 : player.entities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE); + final double distance = itemUsePlacement && player.getClientVersion().isOlderThan(ClientVersion.V_1_20_5) ? 5 : player.compensatedEntities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE); Vector endVec = trace.getPointAtDistance(distance); Vector3d endPos = new Vector3d(endVec.getX(), endVec.getY(), endVec.getZ()); @@ -844,10 +844,10 @@ private static HitData getNearestHitResult(GrimPlayer player, StateType heldItem } if (sourcesHaveHitbox && - (player.world.isWaterSourceBlock(vector3i.getX(), vector3i.getY(), vector3i.getZ()) - || player.world.getLavaFluidLevelAt(vector3i.getX(), vector3i.getY(), vector3i.getZ()) == (8 / 9f))) { + (player.compensatedWorld.isWaterSourceBlock(vector3i.getX(), vector3i.getY(), vector3i.getZ()) + || player.compensatedWorld.getLavaFluidLevelAt(vector3i.getX(), vector3i.getY(), vector3i.getZ()) == (8 / 9f))) { double waterHeight = player.getClientVersion().isOlderThan(ClientVersion.V_1_13) ? 1 - : player.world.getFluidLevelAt(vector3i.getX(), vector3i.getY(), vector3i.getZ()); + : player.compensatedWorld.getFluidLevelAt(vector3i.getX(), vector3i.getY(), vector3i.getZ()); SimpleCollisionBox box = new SimpleCollisionBox(vector3i.getX(), vector3i.getY(), vector3i.getZ(), vector3i.getX() + 1, vector3i.getY() + waterHeight, vector3i.getZ() + 1); Pair intercept = ReachUtils.calculateIntercept(box, trace.getOrigin(), trace.getPointAtDistance(distance)); diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketBlockAction.java b/src/main/java/ac/grim/grimac/events/packets/PacketBlockAction.java index 1cfec25899..df8c25100c 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketBlockAction.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketBlockAction.java @@ -34,19 +34,19 @@ public void onPacketSend(PacketSendEvent event) { player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> { // The client ignores the state sent to the client. - WrappedBlockState existing = player.world.getBlock(blockPos); + WrappedBlockState existing = player.compensatedWorld.getBlock(blockPos); if (Materials.isShulker(existing.getType())) { // Param is the number of viewers of the shulker box. // Hashset with .equals() set to be position if (blockAction.getActionData() >= 1) { ShulkerData data = new ShulkerData(blockPos, player.lastTransactionSent.get(), false); - player.world.openShulkerBoxes.remove(data); - player.world.openShulkerBoxes.add(data); + player.compensatedWorld.openShulkerBoxes.remove(data); + player.compensatedWorld.openShulkerBoxes.add(data); } else { // The shulker box is closing ShulkerData data = new ShulkerData(blockPos, player.lastTransactionSent.get(), true); - player.world.openShulkerBoxes.remove(data); - player.world.openShulkerBoxes.add(data); + player.compensatedWorld.openShulkerBoxes.remove(data); + player.compensatedWorld.openShulkerBoxes.add(data); } } }); diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java b/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java index 45a00d03d7..19661a5e13 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketEntityReplication.java @@ -66,8 +66,8 @@ public void onPacketReceive(PacketReceiveEvent event) { boolean isTickingReliably = player.isTickingReliablyFor(3); - PacketEntity playerVehicle = player.entities.self.getRiding(); - for (PacketEntity entity : player.entities.entityMap.values()) { + PacketEntity playerVehicle = player.compensatedEntities.self.getRiding(); + for (PacketEntity entity : player.compensatedEntities.entityMap.values()) { if (entity == playerVehicle && !player.vehicleData.lastDummy) { // The player has this as their vehicle, so they aren't interpolating it. // And it isn't a dummy position @@ -128,7 +128,7 @@ else if (event.getPacketType() == PacketType.Play.Server.ENTITY_ROTATION) { // A } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_METADATA) { WrapperPlayServerEntityMetadata entityMetadata = new WrapperPlayServerEntityMetadata(event); - player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.entities.updateEntityMetadata(entityMetadata.getEntityId(), entityMetadata.getEntityMetadata())); + player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.compensatedEntities.updateEntityMetadata(entityMetadata.getEntityId(), entityMetadata.getEntityMetadata())); } // 1.19.3+ @@ -138,12 +138,12 @@ else if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO_UPDATE) { for (WrapperPlayServerPlayerInfoUpdate.PlayerInfo entry : info.getEntries()) { final UserProfile gameProfile = entry.getGameProfile(); final UUID uuid = gameProfile.getUUID(); - player.entities.profiles.put(uuid, gameProfile); + player.compensatedEntities.profiles.put(uuid, gameProfile); } }); } else if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO_REMOVE) { WrapperPlayServerPlayerInfoRemove remove = new WrapperPlayServerPlayerInfoRemove(event); - player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> remove.getProfileIds().forEach(player.entities.profiles::remove)); + player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> remove.getProfileIds().forEach(player.compensatedEntities.profiles::remove)); } else if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO) { WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo(event); player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> { @@ -151,10 +151,10 @@ else if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO_UPDATE) { for (WrapperPlayServerPlayerInfo.PlayerData entry : info.getPlayerDataList()) { final UserProfile gameProfile = entry.getUserProfile(); final UUID uuid = gameProfile.getUUID(); - player.entities.profiles.put(uuid, gameProfile); + player.compensatedEntities.profiles.put(uuid, gameProfile); } } else if (info.getAction() == WrapperPlayServerPlayerInfo.Action.REMOVE_PLAYER) { - info.getPlayerDataList().forEach(profile -> player.entities.profiles.remove(profile.getUserProfile().getUUID())); + info.getPlayerDataList().forEach(profile -> player.compensatedEntities.profiles.remove(profile.getUserProfile().getUUID())); } }); } @@ -184,7 +184,7 @@ else if (event.getPacketType() == PacketType.Play.Server.ENTITY_EFFECT) { if (isDirectlyAffectingPlayer(player, effect.getEntityId())) player.sendTransaction(); player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> { - PacketEntity entity = player.entities.getEntity(effect.getEntityId()); + PacketEntity entity = player.compensatedEntities.getEntity(effect.getEntityId()); if (entity == null) return; entity.addPotionEffect(type, effect.getEffectAmplifier()); @@ -197,7 +197,7 @@ else if (event.getPacketType() == PacketType.Play.Server.REMOVE_ENTITY_EFFECT) { if (isDirectlyAffectingPlayer(player, effect.getEntityId())) player.sendTransaction(); player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> { - PacketEntity entity = player.entities.getEntity(effect.getEntityId()); + PacketEntity entity = player.compensatedEntities.getEntity(effect.getEntityId()); if (entity == null) return; entity.removePotionEffect(effect.getPotionType()); @@ -213,7 +213,7 @@ else if (event.getPacketType() == PacketType.Play.Server.UPDATE_ATTRIBUTES) { if (isDirectlyAffectingPlayer(player, entityID)) player.sendTransaction(); player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), - () -> player.entities.updateAttributes(entityID, attributes.getProperties())); + () -> player.compensatedEntities.updateAttributes(entityID, attributes.getProperties())); } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) { @@ -221,7 +221,7 @@ else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) { // This hasn't changed from 1.7.2 to 1.17 // Needed to exempt players on dead vehicles, as dead entities have strange physics. if (status.getStatus() == 3) { - PacketEntity entity = player.entities.getEntity(status.getEntityId()); + PacketEntity entity = player.compensatedEntities.getEntity(status.getEntityId()); if (entity == null) return; entity.isDead = true; @@ -235,7 +235,7 @@ else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) { } if (status.getStatus() == 31) { - PacketEntity hook = player.entities.getEntity(status.getEntityId()); + PacketEntity hook = player.compensatedEntities.getEntity(status.getEntityId()); if (!(hook instanceof PacketEntityHook hookEntity)) return; if (hookEntity.attached == player.entityID) { @@ -246,7 +246,7 @@ else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) { } if (status.getStatus() >= 24 && status.getStatus() <= 28 && status.getEntityId() == player.entityID) { - player.entities.self.setOpLevel(status.getStatus() - 24); + player.compensatedEntities.self.setOpLevel(status.getStatus() - 24); } } @@ -313,7 +313,7 @@ else if (event.getPacketType() == PacketType.Play.Server.ATTACH_ENTITY) { // Alright, let's convert this to the 1.9+ format to make it easier for grim int vehicleID = attach.getHoldingId(); int attachID = attach.getAttachedId(); - TrackerData trackerData = player.entities.getTrackedEntity(attachID); + TrackerData trackerData = player.compensatedEntities.getTrackedEntity(attachID); if (trackerData != null) { // 1.8 sends a vehicle ID of -1 to dismount the entity from its vehicle @@ -339,17 +339,17 @@ else if (event.getPacketType() == PacketType.Play.Server.DESTROY_ENTITIES) { for (int entityID : destroyEntityIds) { despawnedEntitiesThisTransaction.add(entityID); - player.entities.serverPositionsMap.remove(entityID); + player.compensatedEntities.serverPositionsMap.remove(entityID); // Remove the tracked vehicle (handling tracking knockback) if despawned - if (player.entities.serverPlayerVehicle != null && player.entities.serverPlayerVehicle == entityID) { - player.entities.serverPlayerVehicle = null; + if (player.compensatedEntities.serverPlayerVehicle != null && player.compensatedEntities.serverPlayerVehicle == entityID) { + player.compensatedEntities.serverPlayerVehicle = null; } } final int destroyTransaction = player.lastTransactionSent.get() + 1; player.latencyUtils.addRealTimeTask(destroyTransaction, () -> { for (int integer : destroyEntityIds) { - player.entities.removeEntity(integer); + player.compensatedEntities.removeEntity(integer); player.fireworks.removeFirework(integer); } }); @@ -392,7 +392,7 @@ private void handleMountVehicle(PacketSendEvent event, int vehicleID, int[] pass player.sendTransaction(); } player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> { - PacketEntity vehicle = player.entities.getEntity(vehicleID); + PacketEntity vehicle = player.compensatedEntities.getEntity(vehicleID); // Vanilla likes sending null vehicles, so we must ignore those like the client ignores them if (vehicle == null) return; @@ -404,7 +404,7 @@ private void handleMountVehicle(PacketSendEvent event, int vehicleID, int[] pass // Add the entities as vehicles for (int entityID : passengers) { - PacketEntity passenger = player.entities.getEntity(entityID); + PacketEntity passenger = player.compensatedEntities.getEntity(entityID); if (passenger == null) continue; passenger.mount(vehicle); } @@ -412,7 +412,7 @@ private void handleMountVehicle(PacketSendEvent event, int vehicleID, int[] pass } private void handleMoveEntity(PacketSendEvent event, int entityId, double deltaX, double deltaY, double deltaZ, Float yaw, Float pitch, boolean isRelative, boolean hasPos) { - TrackerData data = player.entities.getTrackedEntity(entityId); + TrackerData data = player.compensatedEntities.getTrackedEntity(entityId); final boolean didNotSendPreWave = hasSentPreWavePacket.compareAndSet(false, true); if (didNotSendPreWave) player.sendTransaction(); @@ -425,8 +425,8 @@ private void handleMoveEntity(PacketSendEvent event, int entityId, double deltaX // As we don't want vehicles to fly, we need to replace it with a teleport if it is player vehicle // // Don't bother with client controlled vehicles though - boolean vanillaVehicleFlight = player.entities.serverPlayerVehicle != null - && player.entities.serverPlayerVehicle == entityId + boolean vanillaVehicleFlight = player.compensatedEntities.serverPlayerVehicle != null + && player.compensatedEntities.serverPlayerVehicle == entityId && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) // TODO: https://discord.com/channels/721686193061888071/721686193515003966/1310659538831020123 // Why does the server now send an entity rel move packet matching the player's vehicle movement every time? @@ -467,7 +467,7 @@ private void handleMoveEntity(PacketSendEvent event, int entityId, double deltaX int lastTrans = player.lastTransactionSent.get(); player.latencyUtils.addRealTimeTask(lastTrans, () -> { - PacketEntity entity = player.entities.getEntity(entityId); + PacketEntity entity = player.compensatedEntities.getEntity(entityId); if (entity == null) return; if (entity instanceof PacketEntityTrackXRot xRotEntity && yaw != null) { xRotEntity.packetYaw = yaw; @@ -478,7 +478,7 @@ private void handleMoveEntity(PacketSendEvent event, int entityId, double deltaX }); player.latencyUtils.addRealTimeTask(lastTrans + 1, () -> { - PacketEntity entity = player.entities.getEntity(entityId); + PacketEntity entity = player.compensatedEntities.getEntity(entityId); if (entity == null) return; entity.onSecondTransaction(); }); @@ -489,20 +489,20 @@ public void addEntity(int entityID, UUID uuid, EntityType type, Vector3d positio player.sendTransaction(); } - player.entities.serverPositionsMap.put(entityID, new TrackerData(position.getX(), position.getY(), position.getZ(), xRot, yRot, type, player.lastTransactionSent.get())); + player.compensatedEntities.serverPositionsMap.put(entityID, new TrackerData(position.getX(), position.getY(), position.getZ(), xRot, yRot, type, player.lastTransactionSent.get())); player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> { - player.entities.addEntity(entityID, uuid, type, position, xRot, extraData); + player.compensatedEntities.addEntity(entityID, uuid, type, position, xRot, extraData); if (entityMetadata != null) { - player.entities.updateEntityMetadata(entityID, entityMetadata); + player.compensatedEntities.updateEntityMetadata(entityID, entityMetadata); } }); } private boolean isDirectlyAffectingPlayer(GrimPlayer player, int entityID) { // The attributes for this entity is active, currently - return (player.entities.serverPlayerVehicle == null && entityID == player.entityID) || - (player.entities.serverPlayerVehicle != null && entityID == player.entities.serverPlayerVehicle); + return (player.compensatedEntities.serverPlayerVehicle == null && entityID == player.entityID) || + (player.compensatedEntities.serverPlayerVehicle != null && entityID == player.compensatedEntities.serverPlayerVehicle); } public void onEndOfTickEvent() { diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java index 52d56c860f..19d13b5ceb 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerAttack.java @@ -32,7 +32,7 @@ public void onPacketReceive(PacketReceiveEvent event) { if (player == null) return; // The entity does not exist - if (!player.entities.entityMap.containsKey(interact.getEntityId()) && !player.entities.serverPositionsMap.containsKey(interact.getEntityId())) { + if (!player.compensatedEntities.entityMap.containsKey(interact.getEntityId()) && !player.compensatedEntities.serverPositionsMap.containsKey(interact.getEntityId())) { final BadPacketsW badPacketsW = player.checkManager.getPacketCheck(BadPacketsW.class); if (badPacketsW.flagAndAlert("entityId=" + interact.getEntityId()) && badPacketsW.shouldModifyPackets()) { event.setCancelled(true); @@ -47,7 +47,7 @@ public void onPacketReceive(PacketReceiveEvent event) { } ItemStack heldItem = player.getInventory().getHeldItem(); - PacketEntity entity = player.entities.getEntity(interact.getEntityId()); + PacketEntity entity = player.compensatedEntities.getEntity(interact.getEntityId()); if (entity != null && (!entity.isLivingEntity() || entity.getType() == EntityTypes.PLAYER)) { int knockbackLevel = player.getClientVersion().isOlderThan(ClientVersion.V_1_21) && heldItem != null @@ -75,7 +75,7 @@ public void onPacketReceive(PacketReceiveEvent event) { // 1.9+ players who have attack speed cannot slow themselves twice in one tick because their attack cooldown gets reset on swing. if (player.maxAttackSlow > 0 && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9) - && player.entities.self.getAttributeValue(Attributes.ATTACK_SPEED) < 16) { // 16 is a reasonable limit + && player.compensatedEntities.self.getAttributeValue(Attributes.ATTACK_SPEED) < 16) { // 16 is a reasonable limit return; } diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerRespawn.java b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerRespawn.java index 1530eed10a..eea63aaf0b 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerRespawn.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerRespawn.java @@ -90,9 +90,9 @@ public void onPacketSend(PacketSendEvent event) { } if (health.getHealth() <= 0) { - player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.entities.self.isDead = true); + player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.compensatedEntities.self.isDead = true); } else { - player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, () -> player.entities.self.isDead = false); + player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, () -> player.compensatedEntities.self.isDead = false); } event.getTasksAfterSend().add(player::sendTransaction); @@ -108,7 +108,7 @@ public void onPacketSend(PacketSendEvent event) { player.dimensionType = joinGame.getDimensionType(); if (PacketEvents.getAPI().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_17)) return; - player.world.setDimension(joinGame.getDimensionType(), event.getUser()); + player.compensatedWorld.setDimension(joinGame.getDimensionType(), event.getUser()); } if (event.getPacketType() == PacketType.Play.Server.RESPAWN) { @@ -128,7 +128,7 @@ public void onPacketSend(PacketSendEvent event) { // clear server entity positions when the world changes if (isWorldChange(player, respawn)) { - player.entities.serverPositionsMap.clear(); + player.compensatedEntities.serverPositionsMap.clear(); } player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, () -> { @@ -149,7 +149,7 @@ public void onPacketSend(PacketSendEvent event) { if (!keepTrackedData) { player.powderSnowFrozenTicks = 0; - player.entities.self.hasGravity = true; + player.compensatedEntities.self.hasGravity = true; player.playerEntityHasGravity = true; } @@ -171,36 +171,36 @@ public void onPacketSend(PacketSendEvent event) { // EVERYTHING gets reset on a cross dimensional teleport, clear chunks and entities! if (isWorldChange(player, respawn)) { - player.entities.entityMap.clear(); - player.world.activePistons.clear(); - player.world.openShulkerBoxes.clear(); - player.world.chunks.clear(); - player.world.isRaining = false; + player.compensatedEntities.entityMap.clear(); + player.compensatedWorld.activePistons.clear(); + player.compensatedWorld.openShulkerBoxes.clear(); + player.compensatedWorld.chunks.clear(); + player.compensatedWorld.isRaining = false; } player.dimensionType = respawn.getDimensionType(); - player.entities.serverPlayerVehicle = null; // All entities get removed on respawn - player.entities.self = new PacketEntitySelf(player, player.entities.self); - player.entities.selfTrackedEntity = new TrackerData(0, 0, 0, 0, 0, EntityTypes.PLAYER, player.lastTransactionSent.get()); + player.compensatedEntities.serverPlayerVehicle = null; // All entities get removed on respawn + player.compensatedEntities.self = new PacketEntitySelf(player, player.compensatedEntities.self); + player.compensatedEntities.selfTrackedEntity = new TrackerData(0, 0, 0, 0, 0, EntityTypes.PLAYER, player.lastTransactionSent.get()); if (player.getClientVersion().isOlderThan(ClientVersion.V_1_14)) { // 1.14+ players send a packet for this, listen for it instead player.isSprinting = false; player.checkManager.getPacketCheck(BadPacketsF.class).lastSprinting = false; // Pre 1.14 clients set this to false when creating new entity // TODO: What the fuck viaversion, why do you throw out keep all metadata? // The server doesn't even use it... what do we do? - player.entities.hasSprintingAttributeEnabled = false; + player.compensatedEntities.hasSprintingAttributeEnabled = false; } player.pose = Pose.STANDING; player.clientVelocity = new Vector(); player.gamemode = respawn.getGameMode(); if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_17)) { - player.world.setDimension(respawn.getDimensionType(), event.getUser()); + player.compensatedWorld.setDimension(respawn.getDimensionType(), event.getUser()); } if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_16) && !this.hasFlag(respawn, KEEP_ATTRIBUTES)) { // Reset attributes if not kept - player.entities.self.resetAttributes(); - player.entities.hasSprintingAttributeEnabled = false; + player.compensatedEntities.self.resetAttributes(); + player.compensatedEntities.hasSprintingAttributeEnabled = false; } }); } diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerSteer.java b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerSteer.java index 27159fe95f..5a9561b400 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketPlayerSteer.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketPlayerSteer.java @@ -36,7 +36,7 @@ public void onPacketReceive(PacketReceiveEvent event) { player.vehicleData.nextVehicleForward = forwards; player.vehicleData.nextVehicleHorizontal = sideways; - PacketEntity riding = player.entities.self.getRiding(); + PacketEntity riding = player.compensatedEntities.self.getRiding(); // Multiple steer vehicles in a row, the player is not in control of their vehicle // We must do this SYNC! to netty, as to get the packet location of the vehicle @@ -44,7 +44,7 @@ public void onPacketReceive(PacketReceiveEvent event) { if (player.packetStateData.receivedSteerVehicle && riding != null) { // Horse and boat have first passenger in control // If the player is the first passenger, disregard this attempt to have the server control the entity - if ((riding.isBoat() || riding instanceof PacketEntityHorse) && riding.passengers.get(0) == player.entities.self && + if ((riding.isBoat() || riding instanceof PacketEntityHorse) && riding.passengers.get(0) == player.compensatedEntities.self && // Although if the player has server controlled entities player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) && // or the server controls the entities, then this is vanilla logic so allow it @@ -53,8 +53,8 @@ public void onPacketReceive(PacketReceiveEvent event) { } // Tick update - player.world.tickPlayerInPistonPushingArea(); - player.entities.tick(); + player.compensatedWorld.tickPlayerInPistonPushingArea(); + player.compensatedEntities.tick(); // Note for the movement check player.vehicleData.lastDummy = true; @@ -87,14 +87,14 @@ public void onPacketReceive(PacketReceiveEvent event) { player.lastY = player.y; player.lastZ = player.z; - SimpleCollisionBox vehiclePos = player.entities.self.getRiding().getPossibleCollisionBoxes(); + SimpleCollisionBox vehiclePos = player.compensatedEntities.self.getRiding().getPossibleCollisionBoxes(); player.x = (vehiclePos.minX + vehiclePos.maxX) / 2; player.y = (vehiclePos.minY + vehiclePos.maxY) / 2; player.z = (vehiclePos.minZ + vehiclePos.maxZ) / 2; if (player.isSprinting != player.lastSprinting) { - player.entities.hasSprintingAttributeEnabled = player.isSprinting; + player.compensatedEntities.hasSprintingAttributeEnabled = player.isSprinting; } player.lastSprinting = player.isSprinting; } diff --git a/src/main/java/ac/grim/grimac/events/packets/PacketServerTeleport.java b/src/main/java/ac/grim/grimac/events/packets/PacketServerTeleport.java index 7683de6b4b..902ee0fc34 100644 --- a/src/main/java/ac/grim/grimac/events/packets/PacketServerTeleport.java +++ b/src/main/java/ac/grim/grimac/events/packets/PacketServerTeleport.java @@ -84,7 +84,7 @@ public void onPacketSend(PacketSendEvent event) { if (teleport.isDismountVehicle()) { // Remove player from vehicle - event.getTasksAfterSend().add(() -> player.entities.self.eject()); + event.getTasksAfterSend().add(() -> player.compensatedEntities.self.eject()); } // For some reason teleports on 1.7 servers are offset by 1.62? diff --git a/src/main/java/ac/grim/grimac/events/packets/patch/ResyncWorldUtil.java b/src/main/java/ac/grim/grimac/events/packets/patch/ResyncWorldUtil.java index d400b565a3..5e9f69d9e9 100644 --- a/src/main/java/ac/grim/grimac/events/packets/patch/ResyncWorldUtil.java +++ b/src/main/java/ac/grim/grimac/events/packets/patch/ResyncWorldUtil.java @@ -35,8 +35,8 @@ public static void resyncPositions(GrimPlayer player, SimpleCollisionBox box) { public static void resyncPositions(GrimPlayer player, int minBlockX, int mY, int minBlockZ, int maxBlockX, int mxY, int maxBlockZ) { // Check the 4 corners of the player world for loaded chunks before calling event - if (!player.world.isChunkLoaded(minBlockX >> 4, minBlockZ >> 4) || !player.world.isChunkLoaded(minBlockX >> 4, maxBlockZ >> 4) - || !player.world.isChunkLoaded(maxBlockX >> 4, minBlockZ >> 4) || !player.world.isChunkLoaded(maxBlockX >> 4, maxBlockZ >> 4)) + if (!player.compensatedWorld.isChunkLoaded(minBlockX >> 4, minBlockZ >> 4) || !player.compensatedWorld.isChunkLoaded(minBlockX >> 4, maxBlockZ >> 4) + || !player.compensatedWorld.isChunkLoaded(maxBlockX >> 4, minBlockZ >> 4) || !player.compensatedWorld.isChunkLoaded(maxBlockX >> 4, maxBlockZ >> 4)) return; if (player.bukkitPlayer == null) return; @@ -57,9 +57,9 @@ public static void resyncPositions(GrimPlayer player, int minBlockX, int mY, int // This is based on Tuinity's code, thanks leaf. Now merged into paper. // I have no idea how I could possibly get this more efficient... - final int minSection = player.world.getMinHeight() >> 4; + final int minSection = player.compensatedWorld.getMinHeight() >> 4; final int minBlock = minSection << 4; - final int maxBlock = player.world.getMaxHeight() - 1; + final int maxBlock = player.compensatedWorld.getMaxHeight() - 1; int minBlockY = Math.max(minBlock, mY); int maxBlockY = Math.min(maxBlock, mxY); @@ -130,7 +130,7 @@ public static void resyncPosition(GrimPlayer player, Vector3i pos, int sequence) FoliaScheduler.getRegionScheduler().execute(GrimAPI.INSTANCE.getPlugin(), world, chunkX, chunkZ, () -> { if (!player.bukkitPlayer.isOnline() || !player.getSetbackTeleportUtil().hasAcceptedSpawnTeleport) return; - if (!player.world.isChunkLoaded(chunkX, chunkZ)) return; + if (!player.compensatedWorld.isChunkLoaded(chunkX, chunkZ)) return; if (player.bukkitPlayer.getLocation().distance(new Location(world, pos.x, pos.y, pos.z)) >= 64) return; if (!world.isChunkLoaded(chunkX, chunkZ)) return; // Don't load chunks sync diff --git a/src/main/java/ac/grim/grimac/events/packets/worldreader/BasePacketWorldReader.java b/src/main/java/ac/grim/grimac/events/packets/worldreader/BasePacketWorldReader.java index ec86dd9e52..1729fbf4d4 100644 --- a/src/main/java/ac/grim/grimac/events/packets/worldreader/BasePacketWorldReader.java +++ b/src/main/java/ac/grim/grimac/events/packets/worldreader/BasePacketWorldReader.java @@ -62,7 +62,7 @@ public void onPacketSend(PacketSendEvent event) { if (player == null) return; WrapperPlayServerAcknowledgeBlockChanges changes = new WrapperPlayServerAcknowledgeBlockChanges(event); - player.world.handlePredictionConfirmation(changes.getSequence()); + player.compensatedWorld.handlePredictionConfirmation(changes.getSequence()); } if (event.getPacketType() == PacketType.Play.Server.ACKNOWLEDGE_PLAYER_DIGGING) { @@ -70,7 +70,7 @@ public void onPacketSend(PacketSendEvent event) { if (player == null) return; WrapperPlayServerAcknowledgePlayerDigging ack = new WrapperPlayServerAcknowledgePlayerDigging(event); - player.world.handleBlockBreakAck(ack.getBlockPosition(), ack.getBlockId(), ack.getAction(), ack.isSuccessful()); + player.compensatedWorld.handleBlockBreakAck(ack.getBlockPosition(), ack.getBlockId(), ack.getAction(), ack.isSuccessful()); } if (event.getPacketType() == PacketType.Play.Server.CHANGE_GAME_STATE) { @@ -81,11 +81,11 @@ public void onPacketSend(PacketSendEvent event) { player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> { if (newState.getReason() == WrapperPlayServerChangeGameState.Reason.BEGIN_RAINING) { - player.world.isRaining = true; + player.compensatedWorld.isRaining = true; } else if (newState.getReason() == WrapperPlayServerChangeGameState.Reason.END_RAINING) { - player.world.isRaining = false; + player.compensatedWorld.isRaining = false; } else if (newState.getReason() == WrapperPlayServerChangeGameState.Reason.RAIN_LEVEL_CHANGE) { - player.world.isRaining = newState.getValue() > 0.2f; + player.compensatedWorld.isRaining = newState.getValue() > 0.2f; } }); } @@ -122,10 +122,10 @@ public void addChunkToCache(PacketSendEvent event, GrimPlayer player, BaseChunk[ } if (isGroundUp) { Column column = new Column(chunkX, chunkZ, chunks, player.lastTransactionSent.get()); - player.world.addToCache(column, chunkX, chunkZ); + player.compensatedWorld.addToCache(column, chunkX, chunkZ); } else { player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> { - Column existingColumn = player.world.getChunk(chunkX, chunkZ); + Column existingColumn = player.compensatedWorld.getChunk(chunkX, chunkZ); if (existingColumn == null) { // Corrupting the player's empty chunk is actually quite meaningless // You are able to set blocks inside it, and they do apply, it just always returns air despite what its data says @@ -141,7 +141,7 @@ public void addChunkToCache(PacketSendEvent event, GrimPlayer player, BaseChunk[ public void unloadChunk(GrimPlayer player, int x, int z) { if (player == null) return; - player.world.removeChunkLater(x, z); + player.compensatedWorld.removeChunkLater(x, z); } public void handleBlockChange(GrimPlayer player, PacketSendEvent event) { @@ -154,7 +154,7 @@ public void handleBlockChange(GrimPlayer player, PacketSendEvent event) { player.lastTransSent + 2 < System.currentTimeMillis()) player.sendTransaction(); - player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.world.updateBlock(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(), blockChange.getBlockId())); + player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.compensatedWorld.updateBlock(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(), blockChange.getBlockId())); } public void handleMultiBlockChange(GrimPlayer player, PacketSendEvent event) { @@ -171,7 +171,7 @@ public void handleMultiBlockChange(GrimPlayer player, PacketSendEvent event) { player.sendTransaction(); } - player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.world.updateBlock(blockChange.getX(), blockChange.getY(), blockChange.getZ(), blockChange.getBlockId())); + player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.compensatedWorld.updateBlock(blockChange.getX(), blockChange.getY(), blockChange.getZ(), blockChange.getBlockId())); } } } diff --git a/src/main/java/ac/grim/grimac/manager/SetbackTeleportUtil.java b/src/main/java/ac/grim/grimac/manager/SetbackTeleportUtil.java index b0e38e2484..312703876a 100644 --- a/src/main/java/ac/grim/grimac/manager/SetbackTeleportUtil.java +++ b/src/main/java/ac/grim/grimac/manager/SetbackTeleportUtil.java @@ -208,7 +208,7 @@ private void sendSetback(SetBackData data) { // Player is in a vehicle if (player.inVehicle()) { int vehicleId = player.getRidingVehicleId(); - if (player.entities.serverPlayerVehicle != null) { + if (player.compensatedEntities.serverPlayerVehicle != null) { // Dismount player from vehicle if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9)) { player.user.sendPacket(new WrapperPlayServerSetPassengers(vehicleId, new int[2])); @@ -376,7 +376,7 @@ private boolean isPendingSetback() { * @return Whether the player has loaded the chunk and accepted a teleport to correct movement or not */ public boolean insideUnloadedChunk() { - Column column = player.world.getChunk(GrimMath.floor(player.x) >> 4, GrimMath.floor(player.z) >> 4); + Column column = player.compensatedWorld.getChunk(GrimMath.floor(player.x) >> 4, GrimMath.floor(player.z) >> 4); // If true, the player is in an unloaded chunk return !player.disableGrim && (column == null || column.transaction() >= player.lastTransactionReceived.get() || diff --git a/src/main/java/ac/grim/grimac/manager/init/start/SuperDebug.java b/src/main/java/ac/grim/grimac/manager/init/start/SuperDebug.java index 3621d2e544..1614181f5a 100644 --- a/src/main/java/ac/grim/grimac/manager/init/start/SuperDebug.java +++ b/src/main/java/ac/grim/grimac/manager/init/start/SuperDebug.java @@ -153,7 +153,7 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) { maxPosLength = (int) Math.max(maxPosLength, Math.ceil(Math.log10(Math.abs(z)))); for (int x = GrimMath.floor(player.boundingBox.minX) - 2; x <= GrimMath.ceil(player.boundingBox.maxX) + 2; x++) { maxPosLength = (int) Math.max(maxPosLength, Math.ceil(Math.log10(Math.abs(x)))); - WrappedBlockState block = player.world.getBlock(x, y, z); + WrappedBlockState block = player.compensatedWorld.getBlock(x, y, z); maxLength = Math.max(block.toString().replace("minecraft:", "").length(), maxLength); } } @@ -176,7 +176,7 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) { for (int z = GrimMath.floor(player.boundingBox.minZ) - 2; z <= GrimMath.ceil(player.boundingBox.maxZ) + 2; z++) { sb.append(String.format("%-" + maxPosLength + "s", "z: " + z + " ")); for (int x = GrimMath.floor(player.boundingBox.minX) - 2; x <= GrimMath.ceil(player.boundingBox.maxX) + 2; x++) { - WrappedBlockState block = player.world.getBlock(x, y, z); + WrappedBlockState block = player.compensatedWorld.getBlock(x, y, z); sb.append(String.format("%-" + maxLength + "s", block.toString().replace("minecraft:", ""))); } sb.append("\n"); diff --git a/src/main/java/ac/grim/grimac/player/GrimPlayer.java b/src/main/java/ac/grim/grimac/player/GrimPlayer.java index 4d393970b1..668ba15a2d 100644 --- a/src/main/java/ac/grim/grimac/player/GrimPlayer.java +++ b/src/main/java/ac/grim/grimac/player/GrimPlayer.java @@ -200,8 +200,8 @@ public class GrimPlayer implements GrimUser { // You cannot initialize everything here for some reason public LastInstanceManager lastInstanceManager; public final CompensatedFireworks fireworks; - public final CompensatedWorld world; - public final CompensatedEntities entities; + public final CompensatedWorld compensatedWorld; + public final CompensatedEntities compensatedEntities; public LatencyUtils latencyUtils; public PointThreeEstimator pointThreeEstimator; public TrigHandler trigHandler; @@ -257,8 +257,8 @@ public GrimPlayer(User user) { tagManager = new SyncedTags(this); movementCheckRunner = new MovementCheckRunner(this); - world = new CompensatedWorld(this); - entities = new CompensatedEntities(this); + compensatedWorld = new CompensatedWorld(this); + compensatedEntities = new CompensatedEntities(this); latencyUtils = new LatencyUtils(this); trigHandler = new TrigHandler(this); uncertaintyHandler = new UncertaintyHandler(this); // must be after checkmanager @@ -270,7 +270,7 @@ public GrimPlayer(User user) { uncertaintyHandler.collidingEntities.add(0); if (getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_14)) { - final float scale = (float) entities.self.getAttributeValue(Attributes.SCALE); + final float scale = (float) compensatedEntities.self.getAttributeValue(Attributes.SCALE); possibleEyeHeights[2] = new double[]{0.4 * scale, 1.62 * scale, 1.27 * scale}; // Elytra, standing, sneaking (1.14) possibleEyeHeights[1] = new double[]{1.27 * scale, 1.62 * scale, 0.4 * scale}; // sneaking (1.14), standing, Elytra possibleEyeHeights[0] = new double[]{1.62 * scale, 1.27 * scale, 0.4 * scale}; // standing, sneaking (1.14), Elytra @@ -398,7 +398,7 @@ public void trackBaseTickAddition(Vector vector) { } public float getMaxUpStep() { - final PacketEntitySelf self = entities.self; + final PacketEntitySelf self = compensatedEntities.self; final PacketEntity riding = self.getRiding(); if (riding == null) return (float) self.getAttributeValue(Attributes.STEP_HEIGHT); @@ -595,7 +595,7 @@ public boolean isTickingReliablyFor(int ticks) { } public boolean inVehicle() { - return entities.self.inVehicle(); + return compensatedEntities.self.inVehicle(); } public CompensatedInventory getInventory() { @@ -652,13 +652,13 @@ public boolean exemptOnGround() { return inVehicle() || Collections.max(uncertaintyHandler.pistonX) != 0 || Collections.max(uncertaintyHandler.pistonY) != 0 || Collections.max(uncertaintyHandler.pistonZ) != 0 || uncertaintyHandler.isStepMovement - || isFlying || entities.self.isDead || isInBed || lastInBed || uncertaintyHandler.lastFlyingStatusChange.hasOccurredSince(30) + || isFlying || compensatedEntities.self.isDead || isInBed || lastInBed || uncertaintyHandler.lastFlyingStatusChange.hasOccurredSince(30) || uncertaintyHandler.lastHardCollidingLerpingEntity.hasOccurredSince(3) || uncertaintyHandler.isOrWasNearGlitchyBlock; } public void handleMountVehicle(int vehicleID) { - entities.serverPlayerVehicle = vehicleID; - TrackerData data = entities.getTrackedEntity(vehicleID); + compensatedEntities.serverPlayerVehicle = vehicleID; + TrackerData data = compensatedEntities.getTrackedEntity(vehicleID); if (data != null) { // If we actually need to check vehicle movement @@ -679,18 +679,18 @@ public void handleMountVehicle(int vehicleID) { } public int getRidingVehicleId() { - return entities.getPacketEntityID(entities.self.getRiding()); + return compensatedEntities.getPacketEntityID(compensatedEntities.self.getRiding()); } public void handleDismountVehicle(PacketSendEvent event) { // Help prevent transaction split sendTransaction(); - entities.serverPlayerVehicle = null; + compensatedEntities.serverPlayerVehicle = null; event.getTasksAfterSend().add(() -> { if (inVehicle()) { int ridingId = getRidingVehicleId(); - TrackerData data = entities.serverPositionsMap.get(ridingId); + TrackerData data = compensatedEntities.serverPositionsMap.get(ridingId); if (data != null) { user.writePacket(new WrapperPlayServerEntityTeleport(ridingId, new Vector3d(data.getX(), data.getY(), data.getZ()), data.getXRot(), data.getYRot(), false)); } @@ -701,7 +701,7 @@ public void handleDismountVehicle(PacketSendEvent event) { this.vehicleData.wasVehicleSwitch = true; // Pre-1.14 players desync sprinting attribute when in vehicle to be false, sprinting itself doesn't change if (getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_14)) { - entities.hasSprintingAttributeEnabled = false; + compensatedEntities.hasSprintingAttributeEnabled = false; } }); } @@ -738,7 +738,7 @@ public void resyncPose() { public boolean canUseGameMasterBlocks() { // This check was added in 1.11 // 1.11+ players must be in creative and have a permission level at or above 2 - return getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_10) || (gamemode == GameMode.CREATIVE && entities.self.getOpLevel() >= 2); + return getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_10) || (gamemode == GameMode.CREATIVE && compensatedEntities.self.getOpLevel() >= 2); } @Contract(pure = true) diff --git a/src/main/java/ac/grim/grimac/predictionengine/GhostBlockDetector.java b/src/main/java/ac/grim/grimac/predictionengine/GhostBlockDetector.java index 421056a843..38a32217fc 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/GhostBlockDetector.java +++ b/src/main/java/ac/grim/grimac/predictionengine/GhostBlockDetector.java @@ -51,7 +51,7 @@ public static boolean isGhostBlock(GrimPlayer player) { if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9)) { SimpleCollisionBox largeExpandedBB = player.boundingBox.copy().expand(12, 0.5, 12); - for (PacketEntity entity : player.entities.entityMap.values()) { + for (PacketEntity entity : player.compensatedEntities.entityMap.values()) { if (entity.isBoat()) { if (entity.getPossibleCollisionBoxes().isIntersected(largeExpandedBB)) { return true; diff --git a/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java b/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java index b094611917..711925418c 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java +++ b/src/main/java/ac/grim/grimac/predictionengine/MovementCheckRunner.java @@ -160,8 +160,8 @@ private void check(PositionUpdate update) { } } - player.world.tickPlayerInPistonPushingArea(); - player.entities.tick(); + player.compensatedWorld.tickPlayerInPistonPushingArea(); + player.compensatedEntities.tick(); // The game's movement is glitchy when switching between vehicles // This is due to mojang not telling us where the new vehicle's location is @@ -178,7 +178,7 @@ private void check(PositionUpdate update) { player.clientVelocity.multiply(0.98); // This is vanilla, do not touch } - final PacketEntity riding = player.entities.self.getRiding(); + final PacketEntity riding = player.compensatedEntities.self.getRiding(); if (player.vehicleData.wasVehicleSwitch || player.vehicleData.lastDummy) { update.setTeleport(true); @@ -238,7 +238,7 @@ private void check(PositionUpdate update) { if (player.isInBed) return; if (!player.inVehicle()) { - player.speed = player.entities.self.getAttributeValue(Attributes.MOVEMENT_SPEED); + player.speed = player.compensatedEntities.self.getAttributeValue(Attributes.MOVEMENT_SPEED); if (player.hasGravity != player.playerEntityHasGravity) { player.pointThreeEstimator.updatePlayerGravity(); } @@ -304,7 +304,7 @@ private void check(PositionUpdate update) { player.actualMovement = new Vector(player.x - player.lastX, player.y - player.lastY, player.z - player.lastZ); if (player.isSprinting != player.lastSprinting) { - player.entities.hasSprintingAttributeEnabled = player.isSprinting; + player.compensatedEntities.hasSprintingAttributeEnabled = player.isSprinting; } boolean oldFlying = player.isFlying; @@ -334,13 +334,13 @@ private void check(PositionUpdate update) { // Sprinting status itself does not desync, only the attribute as mojang forgot that the server // can change the attribute if (!player.inVehicle()) { - player.speed += player.entities.hasSprintingAttributeEnabled ? player.speed * 0.3f : 0; + player.speed += player.compensatedEntities.hasSprintingAttributeEnabled ? player.speed * 0.3f : 0; } boolean clientClaimsRiptide = player.packetStateData.tryingToRiptide; if (player.packetStateData.tryingToRiptide) { long currentTime = System.currentTimeMillis(); - boolean isInWater = player.world.isRaining || Collisions.hasMaterial(player, player.boundingBox.copy().expand(0.1f), (block) -> Materials.isWater(CompensatedWorld.blockVersion, block.first())); + boolean isInWater = player.compensatedWorld.isRaining || Collisions.hasMaterial(player, player.boundingBox.copy().expand(0.1f), (block) -> Materials.isWater(CompensatedWorld.blockVersion, block.first())); if (currentTime - player.packetStateData.lastRiptide < 450 || !isInWater) { player.packetStateData.tryingToRiptide = false; @@ -409,7 +409,7 @@ private void check(PositionUpdate update) { player.uncertaintyHandler.lastThirtyMillionHardBorder.reset(); } - if (player.isFlying && player.getClientVersion().isOlderThan(ClientVersion.V_1_13) && player.world.containsLiquid(player.boundingBox)) { + if (player.isFlying && player.getClientVersion().isOlderThan(ClientVersion.V_1_13) && player.compensatedWorld.containsLiquid(player.boundingBox)) { player.uncertaintyHandler.lastUnderwaterFlyingHack.reset(); } @@ -426,7 +426,7 @@ private void check(PositionUpdate update) { boolean wasChecked = false; // Exempt if the player is dead or is riding a dead entity - if (player.entities.self.isDead || (riding != null && riding.isDead)) { + if (player.compensatedEntities.self.isDead || (riding != null && riding.isDead)) { // Dead players can't cheat, if you find a way how they could, open an issue player.predictedVelocity = new VectorData(new Vector(), VectorData.VectorType.Dead); player.clientVelocity = new Vector(); @@ -443,8 +443,8 @@ private void check(PositionUpdate update) { } else if (riding == null) { wasChecked = true; - player.depthStriderLevel = (float) player.entities.self.getAttributeValue(Attributes.WATER_MOVEMENT_EFFICIENCY); - player.sneakingSpeedMultiplier = (float) player.entities.self.getAttributeValue(Attributes.SNEAKING_SPEED); + player.depthStriderLevel = (float) player.compensatedEntities.self.getAttributeValue(Attributes.WATER_MOVEMENT_EFFICIENCY); + player.sneakingSpeedMultiplier = (float) player.compensatedEntities.self.getAttributeValue(Attributes.SNEAKING_SPEED); // This is wrong and the engine was not designed around stuff like this player.verticalCollision = false; diff --git a/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java b/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java index b47f533af9..c825249566 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java +++ b/src/main/java/ac/grim/grimac/predictionengine/PlayerBaseTick.java @@ -26,7 +26,7 @@ public static boolean canEnterPose(GrimPlayer player, Pose pose, double x, doubl } private static SimpleCollisionBox getBoundingBoxForPose(GrimPlayer player, Pose pose, double x, double y, double z) { - final float scale = (float) player.entities.self.getAttributeValue(Attributes.SCALE); + final float scale = (float) player.compensatedEntities.self.getAttributeValue(Attributes.SCALE); final float width = pose.width * scale; final float height = pose.height * scale; float radius = width / 2.0F; @@ -103,12 +103,12 @@ private static void updateFluidOnEyes(GrimPlayer player) { double d0 = player.lastY + player.getEyeHeight() - 0.1111111119389534D; - final PacketEntity riding = player.entities.self.getRiding(); + final PacketEntity riding = player.compensatedEntities.self.getRiding(); if (riding != null && riding.isBoat() && !player.vehicleData.boatUnderwater && player.boundingBox.maxY >= d0 && player.boundingBox.minY <= d0) { return; } - double d1 = (float) Math.floor(d0) + player.world.getWaterFluidLevelAt(player.lastX, d0, player.lastZ); + double d1 = (float) Math.floor(d0) + player.compensatedWorld.getWaterFluidLevelAt(player.lastX, d0, player.lastZ); if (d1 > d0) { player.fluidOnEyes = FluidTag.WATER; if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_15_2)) @@ -119,7 +119,7 @@ private static void updateFluidOnEyes(GrimPlayer player) { if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_15_2)) player.wasEyeInWater = false; - d1 = (float) Math.floor(d0) + player.world.getWaterFluidLevelAt(player.lastX, d0, player.lastZ); + d1 = (float) Math.floor(d0) + player.compensatedWorld.getWaterFluidLevelAt(player.lastX, d0, player.lastZ); if (d1 > d0) { player.fluidOnEyes = FluidTag.LAVA; } @@ -134,7 +134,7 @@ private static void updateInWaterStateAndDoFluidPushing(GrimPlayer player) { // 1.13 and below clients use this stupid method to check if in lava else if (player.getClientVersion().isOlderThan(ClientVersion.V_1_14)) { SimpleCollisionBox playerBox = player.boundingBox.copy().expand(-0.1F, -0.4F, -0.1F); - player.wasTouchingLava = player.world.containsLava(playerBox); + player.wasTouchingLava = player.compensatedWorld.containsLava(playerBox); } } @@ -142,7 +142,7 @@ public static void updatePowderSnow(GrimPlayer player) { // Pre-1.17 clients don't have powder snow and therefore don't desync if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_16_4)) return; - final ValuedAttribute playerSpeed = player.entities.self.getAttribute(Attributes.MOVEMENT_SPEED).orElseThrow(); + final ValuedAttribute playerSpeed = player.compensatedEntities.self.getAttribute(Attributes.MOVEMENT_SPEED).orElseThrow(); // Might be null after respawn? final Optional property = playerSpeed.property(); @@ -255,7 +255,7 @@ private static void updateSwimming(GrimPlayer player) { // Requirement added in 1.17 to fix player glitching between two swimming states // while swimming with feet in air and eyes in water boolean feetInWater = player.getClientVersion().isOlderThan(ClientVersion.V_1_17) - || player.world.getWaterFluidLevelAt(player.lastX, player.lastY, player.lastZ) > 0; + || player.compensatedWorld.getWaterFluidLevelAt(player.lastX, player.lastY, player.lastZ) > 0; player.isSwimming = player.lastSprinting && player.wasEyeInWater && player.wasTouchingWater && feetInWater; } } @@ -381,7 +381,7 @@ private static void moveTowardsClosestSpaceModern(GrimPlayer player, double xPos } public static void updateInWaterStateAndDoWaterCurrentPushing(GrimPlayer player) { - final PacketEntity riding = player.entities.self.getRiding(); + final PacketEntity riding = player.compensatedEntities.self.getRiding(); player.wasTouchingWater = updateFluidHeightAndDoFluidPushing(player, FluidTag.WATER, 0.014) && !(riding != null && riding.isBoat()); if (player.wasTouchingWater) player.fallDistance = 0; @@ -416,9 +416,9 @@ private static boolean updateFluidHeightAndDoFluidPushingLegacy(GrimPlayer playe for (int z = floorZ; z < ceilZ; ++z) { double fluidHeight; if (tag == FluidTag.WATER) { - fluidHeight = player.world.getWaterFluidLevelAt(x, y, z); + fluidHeight = player.compensatedWorld.getWaterFluidLevelAt(x, y, z); } else { - fluidHeight = player.world.getLavaFluidLevelAt(x, y, z); + fluidHeight = player.compensatedWorld.getLavaFluidLevelAt(x, y, z); } if (fluidHeight == 0) @@ -469,9 +469,9 @@ private static boolean updateFluidHeightAndDoFluidPushingModern(GrimPlayer playe double fluidHeight; if (tag == FluidTag.WATER) { - fluidHeight = player.world.getWaterFluidLevelAt(x, y, z); + fluidHeight = player.compensatedWorld.getWaterFluidLevelAt(x, y, z); } else { - fluidHeight = player.world.getLavaFluidLevelAt(x, y, z); + fluidHeight = player.compensatedWorld.getLavaFluidLevelAt(x, y, z); } if (player.getClientVersion().isOlderThan(ClientVersion.V_1_14)) diff --git a/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java b/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java index 30e15027da..1fb0420c3d 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java +++ b/src/main/java/ac/grim/grimac/predictionengine/PointThreeEstimator.java @@ -443,7 +443,7 @@ public double getAdditionalVerticalUncertainty(VectorData vector) { } private double iterateGravity(GrimPlayer player, double y) { - final OptionalInt levitation = player.entities.getPotionLevelForPlayer(PotionTypes.LEVITATION); + final OptionalInt levitation = player.compensatedEntities.getPotionLevelForPlayer(PotionTypes.LEVITATION); if (levitation.isPresent()) { // This supports both positive and negative levitation y += (0.05 * (levitation.getAsInt() + 1) - y * 0.2); diff --git a/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java b/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java index d96075808e..7a1ca6c9a2 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java +++ b/src/main/java/ac/grim/grimac/predictionengine/UncertaintyHandler.java @@ -137,7 +137,7 @@ public void tickFireworksBox() { fireworksBox = null; for (int owner : fishingRodPulls) { - PacketEntity entity = player.entities.getEntity(owner); + PacketEntity entity = player.compensatedEntities.getEntity(owner); if (entity == null) continue; SimpleCollisionBox entityBox = entity.getPossibleCollisionBoxes(); @@ -305,7 +305,7 @@ public double reduceOffset(double offset) { // This is the end of that section. // I can't figure out how the client exactly tracks boost time - if (player.entities.self.getRiding() instanceof PacketEntityRideable vehicle) { + if (player.compensatedEntities.self.getRiding() instanceof PacketEntityRideable vehicle) { if (vehicle.currentBoostTime < vehicle.boostTimeMax + 20) offset -= 0.01; } @@ -326,8 +326,8 @@ private boolean hasHardCollision() { } private boolean regularHardCollision(SimpleCollisionBox expandedBB) { - final PacketEntity riding = player.entities.self.getRiding(); - for (PacketEntity entity : player.entities.entityMap.values()) { + final PacketEntity riding = player.compensatedEntities.self.getRiding(); + for (PacketEntity entity : player.compensatedEntities.entityMap.values()) { if ((entity.isBoat() || entity.getType() == EntityTypes.SHULKER) && entity != riding && entity.getPossibleCollisionBoxes().isIntersected(expandedBB)) { return true; @@ -339,9 +339,9 @@ private boolean regularHardCollision(SimpleCollisionBox expandedBB) { private boolean striderCollision(SimpleCollisionBox expandedBB) { // Stiders can walk on top of other striders - if (player.entities.self.getRiding() instanceof PacketEntityStrider) { - for (PacketEntity entity : player.entities.entityMap.values()) { - if (entity.getType() == EntityTypes.STRIDER && entity != player.entities.self.getRiding() + if (player.compensatedEntities.self.getRiding() instanceof PacketEntityStrider) { + for (PacketEntity entity : player.compensatedEntities.entityMap.values()) { + if (entity.getType() == EntityTypes.STRIDER && entity != player.compensatedEntities.self.getRiding() && !entity.hasPassenger(entity) && entity.getPossibleCollisionBoxes().isIntersected(expandedBB)) { return true; } @@ -353,10 +353,10 @@ private boolean striderCollision(SimpleCollisionBox expandedBB) { private boolean boatCollision(SimpleCollisionBox expandedBB) { // Boats can collide with quite literally anything - final PacketEntity riding = player.entities.self.getRiding(); + final PacketEntity riding = player.compensatedEntities.self.getRiding(); if (riding == null || !riding.isBoat()) return false; - for (PacketEntity entity : player.entities.entityMap.values()) { + for (PacketEntity entity : player.compensatedEntities.entityMap.values()) { if (entity != riding && entity.isPushable() && !riding.hasPassenger(entity) && entity.getPossibleCollisionBoxes().isIntersected(expandedBB)) { return true; diff --git a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTicker.java b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTicker.java index f763d15aab..60556ab11a 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTicker.java +++ b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTicker.java @@ -52,7 +52,7 @@ public static void handleEntityCollisions(GrimPlayer player) { final TeamHandler teamHandler = player.checkManager.getPacketCheck(TeamHandler.class); - for (PacketEntity entity : player.entities.entityMap.values()) { + for (PacketEntity entity : player.compensatedEntities.entityMap.values()) { // TODO actually handle entity collisions instead of this awfulness SimpleCollisionBox entityBox = entity.getPossibleCollisionBoxes(); @@ -133,7 +133,7 @@ public void move(Vector inputVel, Vector collide) { player.boundingBox = GetBoundingBox.getCollisionBoxForPlayer(player, player.x, player.y, player.z); // This is how the player checks for fall damage // By running fluid pushing for the player - final PacketEntity riding = player.entities.self.getRiding(); + final PacketEntity riding = player.compensatedEntities.self.getRiding(); if (!player.wasTouchingWater && (riding == null || !riding.isBoat())) { PlayerBaseTick.updateInWaterStateAndDoWaterCurrentPushing(player); } @@ -338,11 +338,11 @@ public void doNormalMove(float blockFriction) { public void livingEntityTravel() { double playerGravity = !player.inVehicle() - ? player.entities.self.getAttributeValue(Attributes.GRAVITY) - : player.entities.self.getRiding().getAttributeValue(Attributes.GRAVITY); + ? player.compensatedEntities.self.getAttributeValue(Attributes.GRAVITY) + : player.compensatedEntities.self.getRiding().getAttributeValue(Attributes.GRAVITY); boolean isFalling = player.actualMovement.getY() <= 0.0; - if (isFalling && player.entities.getSlowFallingAmplifier().isPresent()) { + if (isFalling && player.compensatedEntities.getSlowFallingAmplifier().isPresent()) { playerGravity = player.getClientVersion().isOlderThan(ClientVersion.V_1_20_5) ? 0.01 : Math.min(playerGravity, 0.01); // Set fall distance to 0 if the player has slow falling player.fallDistance = 0; @@ -354,12 +354,12 @@ public void livingEntityTravel() { double lavaLevel = 0; if (canStandOnLava()) - lavaLevel = player.world.getLavaFluidLevelAt(GrimMath.floor(player.lastX), GrimMath.floor(player.lastY), GrimMath.floor(player.lastZ)); + lavaLevel = player.compensatedWorld.getLavaFluidLevelAt(GrimMath.floor(player.lastX), GrimMath.floor(player.lastY), GrimMath.floor(player.lastZ)); if (player.wasTouchingWater && !player.isFlying) { // 0.8F seems hardcoded in // 1.13+ players on skeleton horses swim faster! Cool feature. - boolean isSkeletonHorse = player.inVehicle() && player.entities.self.getRiding().getType() == EntityTypes.SKELETON_HORSE && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13); + boolean isSkeletonHorse = player.inVehicle() && player.compensatedEntities.self.getRiding().getType() == EntityTypes.SKELETON_HORSE && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13); swimFriction = player.isSprinting && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13) ? 0.9F : (isSkeletonHorse ? 0.96F : 0.8F); float swimSpeed = 0.02F; @@ -377,7 +377,7 @@ public void livingEntityTravel() { swimSpeed += (player.speed - swimSpeed) * player.depthStriderLevel / divisor; } - if (player.entities.getPotionLevelForPlayer(PotionTypes.DOLPHINS_GRACE).isPresent()) { + if (player.compensatedEntities.getPotionLevelForPlayer(PotionTypes.DOLPHINS_GRACE).isPresent()) { swimFriction = 0.96F; } diff --git a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerCamel.java b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerCamel.java index ee1788649e..c870a3a75c 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerCamel.java +++ b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerCamel.java @@ -11,7 +11,7 @@ public MovementTickerCamel(GrimPlayer player) { @Override public float getExtraSpeed() { - PacketEntityCamel camel = (PacketEntityCamel) player.entities.self.getRiding(); + PacketEntityCamel camel = (PacketEntityCamel) player.compensatedEntities.self.getRiding(); // If jumping... speed wouldn't apply after this // This engine was not designed for this edge case diff --git a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerHorse.java b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerHorse.java index 2e1ebec407..7f1b13c826 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerHorse.java +++ b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerHorse.java @@ -12,7 +12,7 @@ public class MovementTickerHorse extends MovementTickerLivingVehicle { public MovementTickerHorse(GrimPlayer player) { super(player); - PacketEntityHorse horsePacket = (PacketEntityHorse) player.entities.self.getRiding(); + PacketEntityHorse horsePacket = (PacketEntityHorse) player.compensatedEntities.self.getRiding(); if (!horsePacket.hasSaddle) return; diff --git a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerPig.java b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerPig.java index 7f75f73e9e..34ac288dd3 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerPig.java +++ b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerPig.java @@ -13,7 +13,7 @@ public MovementTickerPig(GrimPlayer player) { @Override public float getSteeringSpeed() { // Vanilla multiples by 0.225f - PacketEntityRideable pig = (PacketEntityRideable) player.entities.self.getRiding(); + PacketEntityRideable pig = (PacketEntityRideable) player.compensatedEntities.self.getRiding(); return (float) pig.getAttributeValue(Attributes.MOVEMENT_SPEED) * 0.225f; } } diff --git a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerRideable.java b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerRideable.java index f4ec38642e..af308febf3 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerRideable.java +++ b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerRideable.java @@ -13,7 +13,7 @@ public MovementTickerRideable(GrimPlayer player) { // If the player has carrot/fungus on a stick, otherwise the player has no control float f = getSteeringSpeed(); - PacketEntityRideable boost = ((PacketEntityRideable) player.entities.self.getRiding()); + PacketEntityRideable boost = ((PacketEntityRideable) player.compensatedEntities.self.getRiding()); // Do stuff for boosting on a pig/strider if (boost.currentBoostTime++ < boost.boostTimeMax) { diff --git a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerStrider.java b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerStrider.java index e22ebb4ce4..ba1f993192 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerStrider.java +++ b/src/main/java/ac/grim/grimac/predictionengine/movementtick/MovementTickerStrider.java @@ -24,7 +24,7 @@ public MovementTickerStrider(GrimPlayer player) { public static void floatStrider(GrimPlayer player) { if (player.wasTouchingLava) { - if (isAbove(player) && player.world.getLavaFluidLevelAt((int) Math.floor(player.x), (int) Math.floor(player.y + 1), (int) Math.floor(player.z)) == 0) { + if (isAbove(player) && player.compensatedWorld.getLavaFluidLevelAt((int) Math.floor(player.x), (int) Math.floor(player.y + 1), (int) Math.floor(player.z)) == 0) { player.onGround = true; } else { player.clientVelocity.multiply(0.5).add(new Vector(0, 0.05, 0)); @@ -40,10 +40,10 @@ public static boolean isAbove(GrimPlayer player) { public void livingEntityAIStep() { super.livingEntityAIStep(); - StateType posMaterial = player.world.getBlockType(player.x, player.y, player.z); + StateType posMaterial = player.compensatedWorld.getBlockType(player.x, player.y, player.z); StateType belowMaterial = BlockProperties.getOnPos(player, player.mainSupportingBlockData, new Vector3d(player.x, player.y, player.z)); - final PacketEntityStrider strider = (PacketEntityStrider) player.entities.self.getRiding(); + final PacketEntityStrider strider = (PacketEntityStrider) player.compensatedEntities.self.getRiding(); strider.isShaking = !BlockTags.STRIDER_WARM_BLOCKS.contains(posMaterial) && !BlockTags.STRIDER_WARM_BLOCKS.contains(belowMaterial) && !player.wasTouchingLava; @@ -54,7 +54,7 @@ public void livingEntityAIStep() { @Override public float getSteeringSpeed() { - PacketEntityStrider strider = (PacketEntityStrider) player.entities.self.getRiding(); + PacketEntityStrider strider = (PacketEntityStrider) player.compensatedEntities.self.getRiding(); // Unsure which version the speed changed in final boolean newSpeed = player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_20); final float coldSpeed = newSpeed ? 0.35F : 0.23F; diff --git a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java index 045d1c84ca..a21121c61e 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java +++ b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngine.java @@ -561,7 +561,7 @@ public Vector handleStartingVelocityUncertainty(GrimPlayer player, VectorData ve // We can't simulate the player's Y velocity, unknown number of ticks with a gravity change // Feel free to simulate all 104857600000000000000000000 possibilities! if (!player.pointThreeEstimator.canPredictNextVerticalMovement()) { - minVector.setY(minVector.getY() - player.entities.self.getAttributeValue(Attributes.GRAVITY)); + minVector.setY(minVector.getY() - player.compensatedEntities.self.getAttributeValue(Attributes.GRAVITY)); } // Hidden slime block bounces by missing idle tick and 0.03 @@ -780,7 +780,7 @@ private void loopVectors(GrimPlayer player, Set possibleVectors, flo public boolean canSwimHop(GrimPlayer player) { // Boats cannot swim hop, all other living entities should be able to. - if (player.inVehicle() && player.entities.self.getRiding().isBoat()) + if (player.inVehicle() && player.compensatedEntities.self.getRiding().isBoat()) return false; // Vanilla system -> @@ -808,7 +808,7 @@ public boolean canSwimHop(GrimPlayer player) { SimpleCollisionBox oldBox = player.inVehicle() ? GetBoundingBox.getCollisionBoxForPlayer(player, player.lastX, player.lastY, player.lastZ) : GetBoundingBox.getBoundingBoxFromPosAndSize(player, player.lastX, player.lastY, player.lastZ, 0.6f, 1.8f); - if (!player.world.containsLiquid(oldBox.expand(0.1, 0.1, 0.1))) return false; + if (!player.compensatedWorld.containsLiquid(oldBox.expand(0.1, 0.1, 0.1))) return false; SimpleCollisionBox oldBB = player.boundingBox; player.boundingBox = player.boundingBox.copy().expand(-0.03, 0, -0.03); diff --git a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineElytra.java b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineElytra.java index 0450b53093..ebd89f614a 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineElytra.java +++ b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineElytra.java @@ -45,8 +45,8 @@ public static Vector getElytraMovement(GrimPlayer player, Vector vector, Vector // So we actually use the player's actual movement to get the gravity/slow falling status // However, this is wrong with elytra movement because players can control vertical movement after gravity is calculated // Yeah, slow falling needs a refactor in grim. - double recalculatedGravity = player.entities.self.getAttributeValue(Attributes.GRAVITY); - if (player.clientVelocity.getY() <= 0 && player.entities.getSlowFallingAmplifier().isPresent()) { + double recalculatedGravity = player.compensatedEntities.self.getAttributeValue(Attributes.GRAVITY); + if (player.clientVelocity.getY() <= 0 && player.compensatedEntities.getSlowFallingAmplifier().isPresent()) { recalculatedGravity = player.getClientVersion().isOlderThan(ClientVersion.V_1_20_5) ? 0.01 : Math.min(recalculatedGravity, 0.01); } diff --git a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineNormal.java b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineNormal.java index ae1a0931bc..fbecfc5413 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineNormal.java +++ b/src/main/java/ac/grim/grimac/predictionengine/predictions/PredictionEngineNormal.java @@ -21,7 +21,7 @@ public class PredictionEngineNormal extends PredictionEngine { public static void staticVectorEndOfTick(GrimPlayer player, Vector vector) { double adjustedY = vector.getY(); - final OptionalInt levitation = player.entities.getPotionLevelForPlayer(PotionTypes.LEVITATION); + final OptionalInt levitation = player.compensatedEntities.getPotionLevelForPlayer(PotionTypes.LEVITATION); if (levitation.isPresent()) { adjustedY += (0.05 * (levitation.getAsInt() + 1) - vector.getY()) * 0.2; // Reset fall distance with levitation @@ -50,7 +50,7 @@ public void addJumpsToPossibilities(GrimPlayer player, Set existingV // If the player didn't try to jump // And 0.03 didn't affect onGround status // The player cannot jump - final OptionalInt jumpBoost = player.entities.getPotionLevelForPlayer(PotionTypes.JUMP_BOOST); + final OptionalInt jumpBoost = player.compensatedEntities.getPotionLevelForPlayer(PotionTypes.JUMP_BOOST); if (((jumpBoost.isEmpty() || jumpBoost.getAsInt() >= 0) && player.onGround) || !player.lastOnGround) return; @@ -75,7 +75,7 @@ public void endOfTick(GrimPlayer player, double delta) { boolean walkingOnPowderSnow = false; if (!player.inVehicle() && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_17) && - player.world.getBlockType(player.x, player.y, player.z) == StateTypes.POWDER_SNOW) { + player.compensatedWorld.getBlockType(player.x, player.y, player.z) == StateTypes.POWDER_SNOW) { ItemStack boots = player.getInventory().getBoots(); walkingOnPowderSnow = boots != null && boots.getType() == ItemTypes.LEATHER_BOOTS; } @@ -107,7 +107,7 @@ public Vector handleOnClimbable(Vector vector, GrimPlayer player) { vector.setY(Math.max(vector.getY(), -0.15F)); // Yes, this uses shifting not crouching - if (vector.getY() < 0.0 && !(player.world.getBlockType(player.lastX, player.lastY, player.lastZ) == StateTypes.SCAFFOLDING) && player.isSneaking && !player.isFlying) { + if (vector.getY() < 0.0 && !(player.compensatedWorld.getBlockType(player.lastX, player.lastY, player.lastZ) == StateTypes.SCAFFOLDING) && player.isSneaking && !player.isFlying) { vector.setY(0.0); } } diff --git a/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/BoatPredictionEngine.java b/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/BoatPredictionEngine.java index 5cd14c4884..a297c4c1d3 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/BoatPredictionEngine.java +++ b/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/BoatPredictionEngine.java @@ -61,9 +61,9 @@ private static BoatEntityStatus isUnderwater(GrimPlayer player) { for (int k1 = i; k1 < j; ++k1) { for (int l1 = k; l1 < l; ++l1) { for (int i2 = i1; i2 < j1; ++i2) { - double level = player.world.getWaterFluidLevelAt(k1, l1, i2); + double level = player.compensatedWorld.getWaterFluidLevelAt(k1, l1, i2); if (d0 < l1 + level) { - if (!player.world.isWaterSourceBlock(k1, l1, i2)) { + if (!player.compensatedWorld.isWaterSourceBlock(k1, l1, i2)) { return BoatEntityStatus.UNDER_FLOWING_WATER; } @@ -90,7 +90,7 @@ private static boolean checkInWater(GrimPlayer grimPlayer) { for (int k1 = i; k1 < j; ++k1) { for (int l1 = k; l1 < l; ++l1) { for (int i2 = i1; i2 < j1; ++i2) { - double level = grimPlayer.world.getWaterFluidLevelAt(k1, l1, i2); + double level = grimPlayer.compensatedWorld.getWaterFluidLevelAt(k1, l1, i2); if (level > 0) { float f = (float) ((float) l1 + level); grimPlayer.vehicleData.waterLevel = Math.max(f, grimPlayer.vehicleData.waterLevel); @@ -122,7 +122,7 @@ public static float getGroundFriction(GrimPlayer player) { if (j2 != 2) { for (int k2 = k; k2 < l; ++k2) { if (j2 <= 0 || k2 != k && k2 != l - 1) { - WrappedBlockState blockData = player.world.getBlock(l1, k2, i2); + WrappedBlockState blockData = player.compensatedWorld.getBlock(l1, k2, i2); StateType blockMaterial = blockData.getType(); if (blockMaterial != StateTypes.LILY_PAD && CollisionData.getData(blockMaterial).getMovementCollisionBox(player, player.getClientVersion(), blockData, l1, k2, i2).isIntersected(axisalignedbb1)) { @@ -242,7 +242,7 @@ public float getWaterLevelAbove(GrimPlayer player) { for (int l1 = i; l1 < j; ++l1) { for (int i2 = i1; i2 < j1; ++i2) { - double level = player.world.getWaterFluidLevelAt(l1, k1, i2); + double level = player.compensatedWorld.getWaterFluidLevelAt(l1, k1, i2); f = (float) Math.max(f, level); diff --git a/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/PredictionEngineRideableUtils.java b/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/PredictionEngineRideableUtils.java index 69cdd8a254..3f795b2eb6 100644 --- a/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/PredictionEngineRideableUtils.java +++ b/src/main/java/ac/grim/grimac/predictionengine/predictions/rideable/PredictionEngineRideableUtils.java @@ -22,7 +22,7 @@ public final class PredictionEngineRideableUtils { public static Set handleJumps(GrimPlayer player, Set possibleVectors) { - if (!(player.entities.self.getRiding() instanceof PacketEntityHorse horse)) return possibleVectors; + if (!(player.compensatedEntities.self.getRiding() instanceof PacketEntityHorse horse)) return possibleVectors; if (horse instanceof PacketEntityCamel camel) { handleCamelDash(player, possibleVectors, camel); @@ -47,7 +47,7 @@ private static void handleCamelDash(GrimPlayer player, Set possibleV double jumpYVelocity; - final OptionalInt jumpBoost = player.entities.getPotionLevelForPlayer(PotionTypes.JUMP_BOOST); + final OptionalInt jumpBoost = player.compensatedEntities.getPotionLevelForPlayer(PotionTypes.JUMP_BOOST); if (jumpBoost.isPresent()) { jumpYVelocity = jumpFactor + ((jumpBoost.getAsInt() + 1) * 0.1F); } else { @@ -86,7 +86,7 @@ private static void handleHorseJumping(GrimPlayer player, Set possib // broken ever since vehicle control became client sided // // But plugins can still send this, so support it anyways - final OptionalInt jumpBoost = player.entities.getPotionLevelForPlayer(PotionTypes.JUMP_BOOST); + final OptionalInt jumpBoost = player.compensatedEntities.getPotionLevelForPlayer(PotionTypes.JUMP_BOOST); if (jumpBoost.isPresent()) { jumpVelocity = jumpFactor + ((jumpBoost.getAsInt() + 1) * 0.1F); } else { diff --git a/src/main/java/ac/grim/grimac/utils/anticheat/update/BlockPlace.java b/src/main/java/ac/grim/grimac/utils/anticheat/update/BlockPlace.java index f474656960..121b04e4ec 100644 --- a/src/main/java/ac/grim/grimac/utils/anticheat/update/BlockPlace.java +++ b/src/main/java/ac/grim/grimac/utils/anticheat/update/BlockPlace.java @@ -92,7 +92,7 @@ public BlockPlace(GrimPlayer player, InteractionHand hand, Vector3i blockPositio } this.hitData = hitData; - WrappedBlockState state = player.world.getBlock(getPlacedAgainstBlockLocation()); + WrappedBlockState state = player.compensatedWorld.getBlock(getPlacedAgainstBlockLocation()); this.replaceClicked = canBeReplaced(this.material, state, face); } @@ -101,29 +101,29 @@ public Vector3i getPlacedAgainstBlockLocation() { } public WrappedBlockState getExistingBlockData() { - return player.world.getBlock(getPlacedBlockPos()); + return player.compensatedWorld.getBlock(getPlacedBlockPos()); } public StateType getPlacedAgainstMaterial() { - return player.world.getBlock(getPlacedAgainstBlockLocation()).getType(); + return player.compensatedWorld.getBlock(getPlacedAgainstBlockLocation()).getType(); } public WrappedBlockState getBelowState() { Vector3i pos = getPlacedBlockPos(); pos = pos.withY(pos.getY() - 1); - return player.world.getBlock(pos); + return player.compensatedWorld.getBlock(pos); } public WrappedBlockState getAboveState() { Vector3i pos = getPlacedBlockPos(); pos = pos.withY(pos.getY() + 1); - return player.world.getBlock(pos); + return player.compensatedWorld.getBlock(pos); } public WrappedBlockState getDirectionalState(BlockFace facing) { Vector3i pos = getPlacedBlockPos(); pos = pos.add(facing.getModX(), facing.getModY(), facing.getModZ()); - return player.world.getBlock(pos); + return player.compensatedWorld.getBlock(pos); } public boolean isSolidBlocking(BlockFace relative) { @@ -311,9 +311,9 @@ public boolean isBlockFaceOpen(BlockFace facing) { Vector3i pos = getPlacedBlockPos(); pos = pos.add(facing.getModX(), facing.getModY(), facing.getModZ()); // You can't build above height limit. - if (pos.getY() >= player.world.getMaxHeight()) return false; + if (pos.getY() >= player.compensatedWorld.getMaxHeight()) return false; - return player.world.getBlock(pos).getType().isReplaceable(); + return player.compensatedWorld.getBlock(pos).getType().isReplaceable(); } @@ -361,7 +361,7 @@ public boolean isFaceEmpty(BlockFace facing) { public boolean isLava(BlockFace facing) { Vector3i pos = getPlacedBlockPos(); pos = pos.add(facing.getModX(), facing.getModY(), facing.getModZ()); - return player.world.getBlock(pos).getType() == StateTypes.LAVA; + return player.compensatedWorld.getBlock(pos).getType() == StateTypes.LAVA; } // I believe this is correct, although I'm using a method here just in case it's a tick off... I don't trust Mojang @@ -371,12 +371,12 @@ public boolean isSecondaryUse() { public boolean isInWater() { Vector3i pos = getPlacedBlockPos(); - return player.world.isWaterSourceBlock(pos.getX(), pos.getY(), pos.getZ()); + return player.compensatedWorld.isWaterSourceBlock(pos.getX(), pos.getY(), pos.getZ()); } public boolean isInLiquid() { Vector3i pos = getPlacedBlockPos(); - WrappedBlockState data = player.world.getBlock(pos); + WrappedBlockState data = player.compensatedWorld.getBlock(pos); return Materials.isWater(player.getClientVersion(), data) || data.getType() == StateTypes.LAVA; } @@ -403,12 +403,12 @@ public boolean isBlockPlacedPowered() { Vector3i modified = placed.add(face.getModX(), face.getModY(), face.getModZ()); // A block next to the player is providing power. Therefore the block is powered - if (player.world.getRawPowerAtState(face, modified.getX(), modified.getY(), modified.getZ()) > 0) { + if (player.compensatedWorld.getRawPowerAtState(face, modified.getX(), modified.getY(), modified.getZ()) > 0) { return true; } // Check if a block can even provide power... bukkit doesn't have a method for this? - WrappedBlockState state = player.world.getBlock(modified); + WrappedBlockState state = player.compensatedWorld.getBlock(modified); boolean isByDefaultConductive = !Materials.isSolidBlockingBlacklist(state.getType(), player.getClientVersion()) && CollisionData.getData(state.getType()).getMovementCollisionBox(player, player.getClientVersion(), state).isFullBlock(); @@ -429,7 +429,7 @@ public boolean isBlockPlacedPowered() { Vector3i poweredRecursive = placed.add(recursive.getModX(), recursive.getModY(), recursive.getModZ()); // A block next to the player is directly powered. Therefore, the block is powered - if (player.world.getDirectSignalAtState(recursive, poweredRecursive.getX(), poweredRecursive.getY(), poweredRecursive.getZ()) > 0) { + if (player.compensatedWorld.getDirectSignalAtState(recursive, poweredRecursive.getX(), poweredRecursive.getY(), poweredRecursive.getZ()) > 0) { return true; } } @@ -580,7 +580,7 @@ public void set(Vector3i position, WrappedBlockState state) { // 1.9+ introduced the mechanic where both the client and server must agree upon a block place // 1.8 clients will simply not send the place when it fails, thanks mojang. if (player.getClientVersion().isNewerThan(ClientVersion.V_1_8)) { - for (PacketEntity entity : player.entities.entityMap.values()) { + for (PacketEntity entity : player.compensatedEntities.entityMap.values()) { SimpleCollisionBox interpBox = entity.getPossibleCollisionBoxes(); final double scale = entity.getAttributeValue(Attributes.SCALE); @@ -605,13 +605,13 @@ public void set(Vector3i position, WrappedBlockState state) { } // If a block already exists here, then we can't override it. - WrappedBlockState existingState = player.world.getBlock(position); + WrappedBlockState existingState = player.compensatedWorld.getBlock(position); if (!replaceClicked && !canBeReplaced(material, existingState, face)) { return; } // Check for min and max bounds of world - if (player.world.getMaxHeight() <= position.getY() || position.getY() < player.world.getMinHeight()) { + if (player.compensatedWorld.getMaxHeight() <= position.getY() || position.getY() < player.compensatedWorld.getMinHeight()) { return; } @@ -623,7 +623,7 @@ public void set(Vector3i position, WrappedBlockState state) { } player.getInventory().onBlockPlace(this); - player.world.updateBlock(position.getX(), position.getY(), position.getZ(), state.getGlobalId()); + player.compensatedWorld.updateBlock(position.getX(), position.getY(), position.getZ(), state.getGlobalId()); } public boolean isZAxis() { @@ -665,7 +665,7 @@ public Vector getClickedLocation() { SimpleCollisionBox box = new SimpleCollisionBox(getPlacedAgainstBlockLocation()); Vector look = ReachUtils.getLook(player, player.xRot, player.yRot); - final double distance = player.entities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE) + 3; + final double distance = player.compensatedEntities.self.getAttributeValue(Attributes.BLOCK_INTERACTION_RANGE) + 3; Vector eyePos = new Vector(player.x, player.y + player.getEyeHeight(), player.z); Vector endReachPos = eyePos.clone().add(new Vector(look.getX() * distance, look.getY() * distance, look.getZ() * distance)); Vector intercept = ReachUtils.calculateIntercept(box, eyePos, endReachPos).first(); diff --git a/src/main/java/ac/grim/grimac/utils/blockplace/BlockPlaceResult.java b/src/main/java/ac/grim/grimac/utils/blockplace/BlockPlaceResult.java index 38bb4aa094..14c0ffe9e1 100644 --- a/src/main/java/ac/grim/grimac/utils/blockplace/BlockPlaceResult.java +++ b/src/main/java/ac/grim/grimac/utils/blockplace/BlockPlaceResult.java @@ -114,7 +114,7 @@ public enum BlockPlaceResult { LADDER((player, place) -> { // No placing a ladder against another ladder if (!place.isReplaceClicked()) { - WrappedBlockState existing = player.world.getBlock(place.getPlacedAgainstBlockLocation()); + WrappedBlockState existing = player.compensatedWorld.getBlock(place.getPlacedAgainstBlockLocation()); if (existing.getType() == StateTypes.LADDER && existing.getFacing() == place.getDirection()) { return; } @@ -150,7 +150,7 @@ public enum BlockPlaceResult { BAMBOO((player, place) -> { Vector3i clicked = place.getPlacedAgainstBlockLocation(); - if (player.world.getFluidLevelAt(clicked.getX(), clicked.getY(), clicked.getZ()) > 0) return; + if (player.compensatedWorld.getFluidLevelAt(clicked.getX(), clicked.getY(), clicked.getZ()) > 0) return; WrappedBlockState below = place.getBelowState(); if (BlockTags.BAMBOO_PLANTABLE_ON.contains(below.getType())) { @@ -413,7 +413,7 @@ public enum BlockPlaceResult { toSearchPos = toSearchPos.withX(toSearchPos.getX() + direction.getModX()); toSearchPos = toSearchPos.withZ(toSearchPos.getZ() + direction.getModZ()); - WrappedBlockState directional = player.world.getBlock(toSearchPos); + WrappedBlockState directional = player.compensatedWorld.getBlock(toSearchPos); if (Materials.isWater(player.getClientVersion(), directional) || directional.getType() == StateTypes.FROSTED_ICE) { place.set(); return; @@ -473,7 +473,7 @@ public enum BlockPlaceResult { Vector3i placedPos = place.getPlacedBlockPos(); placedPos = placedPos.add(direction.getModX(), -1, direction.getModZ()); - WrappedBlockState blockstate2 = player.world.getBlock(placedPos); + WrappedBlockState blockstate2 = player.compensatedWorld.getBlock(placedPos); if (blockstate2.getType() == StateTypes.CHORUS_PLANT || blockstate2.getType() == StateTypes.END_STONE) { place.set(); } @@ -905,7 +905,7 @@ public enum BlockPlaceResult { CollisionBox ccwBox = CollisionData.getData(ccwState.getType()).getMovementCollisionBox(player, player.getClientVersion(), ccwState); Vector aboveCCWPos = place.getClickedLocation().add(new Vector(ccw.getModX(), ccw.getModY(), ccw.getModZ())).add(new Vector(0, 1, 0)); - WrappedBlockState aboveCCWState = player.world.getBlock(aboveCCWPos); + WrappedBlockState aboveCCWState = player.compensatedWorld.getBlock(aboveCCWPos); CollisionBox aboveCCWBox = CollisionData.getData(aboveCCWState.getType()).getMovementCollisionBox(player, player.getClientVersion(), aboveCCWState); BlockFace cw = BlockFaceHelper.getPEClockWise(playerFacing); @@ -913,7 +913,7 @@ public enum BlockPlaceResult { CollisionBox cwBox = CollisionData.getData(cwState.getType()).getMovementCollisionBox(player, player.getClientVersion(), cwState); Vector aboveCWPos = place.getClickedLocation().add(new Vector(cw.getModX(), cw.getModY(), cw.getModZ())).add(new Vector(0, 1, 0)); - WrappedBlockState aboveCWState = player.world.getBlock(aboveCWPos); + WrappedBlockState aboveCWState = player.compensatedWorld.getBlock(aboveCWPos); CollisionBox aboveCWBox = CollisionData.getData(aboveCWState.getType()).getMovementCollisionBox(player, player.getClientVersion(), aboveCWState); int i = (ccwBox.isFullBlock() ? -1 : 0) + (aboveCCWBox.isFullBlock() ? -1 : 0) + (cwBox.isFullBlock() ? 1 : 0) + (aboveCWBox.isFullBlock() ? 1 : 0); @@ -988,8 +988,8 @@ public enum BlockPlaceResult { int i = 0; Vector3i starting = new Vector3i(place.getPlacedAgainstBlockLocation().getX() + direction.getModX(), place.getPlacedAgainstBlockLocation().getY() + direction.getModY(), place.getPlacedAgainstBlockLocation().getZ() + direction.getModZ()); while (i < 7) { - if (player.world.getBlock(starting).getType() != StateTypes.SCAFFOLDING) { - if (player.world.getBlock(starting).getType().isReplaceable()) { + if (player.compensatedWorld.getBlock(starting).getType() != StateTypes.SCAFFOLDING) { + if (player.compensatedWorld.getBlock(starting).getType().isReplaceable()) { place.setBlockPosition(starting); place.setReplaceClicked(true); break; // We found it! diff --git a/src/main/java/ac/grim/grimac/utils/blockplace/ConsumesBlockPlace.java b/src/main/java/ac/grim/grimac/utils/blockplace/ConsumesBlockPlace.java index d58e2e3a28..ed4e96b4db 100644 --- a/src/main/java/ac/grim/grimac/utils/blockplace/ConsumesBlockPlace.java +++ b/src/main/java/ac/grim/grimac/utils/blockplace/ConsumesBlockPlace.java @@ -24,21 +24,21 @@ public static boolean consumesPlace(GrimPlayer player, WrappedBlockState state, if (BlockTags.CANDLE_CAKES.contains(state.getType())) { WrappedBlockState cake = StateTypes.CAKE.createBlockState(CompensatedWorld.blockVersion); cake.setBites(1); - player.world.updateBlock(place.getPlacedAgainstBlockLocation(), cake); + player.compensatedWorld.updateBlock(place.getPlacedAgainstBlockLocation(), cake); return true; } if (state.getType() == StateTypes.CAKE) { if (state.getBites() == 0 && BlockTags.CANDLES.contains(place.getMaterial())) { - player.world.updateBlock(place.getPlacedAgainstBlockLocation(), StateTypes.CANDLE_CAKE.createBlockState(CompensatedWorld.blockVersion)); + player.compensatedWorld.updateBlock(place.getPlacedAgainstBlockLocation(), StateTypes.CANDLE_CAKE.createBlockState(CompensatedWorld.blockVersion)); return true; } if (player.gamemode == GameMode.CREATIVE || (player.food < 20)) { if (state.getBites() != 6) { state.setBites(state.getBites() + 1); - player.world.updateBlock(place.getPlacedAgainstBlockLocation(), state); + player.compensatedWorld.updateBlock(place.getPlacedAgainstBlockLocation(), state); } else { - player.world.updateBlock(place.getPlacedAgainstBlockLocation(), StateTypes.AIR.createBlockState(CompensatedWorld.blockVersion)); + player.compensatedWorld.updateBlock(place.getPlacedAgainstBlockLocation(), StateTypes.AIR.createBlockState(CompensatedWorld.blockVersion)); } return true; } @@ -48,7 +48,7 @@ public static boolean consumesPlace(GrimPlayer player, WrappedBlockState state, if (state.getType() == StateTypes.CAVE_VINES || state.getType() == StateTypes.CAVE_VINES_PLANT) { if (state.isBerries()) { state.setBerries(false); - player.world.updateBlock(place.getPlacedAgainstBlockLocation(), state); + player.compensatedWorld.updateBlock(place.getPlacedAgainstBlockLocation(), state); return true; } return false; @@ -58,7 +58,7 @@ public static boolean consumesPlace(GrimPlayer player, WrappedBlockState state, return false; } else if (state.getAge() > 1) { state.setAge(1); - player.world.updateBlock(place.getPlacedAgainstBlockLocation(), state); + player.compensatedWorld.updateBlock(place.getPlacedAgainstBlockLocation(), state); return true; } else { return false; @@ -66,7 +66,7 @@ public static boolean consumesPlace(GrimPlayer player, WrappedBlockState state, } if (state.getType() == StateTypes.TNT) { if (place.getItemStack().getType() == ItemTypes.FIRE_CHARGE || place.getItemStack().getType() == ItemTypes.FLINT_AND_STEEL) { - player.world.updateBlock(place.getPlacedAgainstBlockLocation(), StateTypes.AIR.createBlockState(CompensatedWorld.blockVersion)); + player.compensatedWorld.updateBlock(place.getPlacedAgainstBlockLocation(), StateTypes.AIR.createBlockState(CompensatedWorld.blockVersion)); return true; } } diff --git a/src/main/java/ac/grim/grimac/utils/collisions/CollisionData.java b/src/main/java/ac/grim/grimac/utils/collisions/CollisionData.java index fa7cb949dd..319d110719 100644 --- a/src/main/java/ac/grim/grimac/utils/collisions/CollisionData.java +++ b/src/main/java/ac/grim/grimac/utils/collisions/CollisionData.java @@ -62,7 +62,7 @@ public enum CollisionData { }, StateTypes.VINE, StateTypes.FIRE), LAVA((player, version, block, x, y, z) -> { - if (MovementTickerStrider.isAbove(player) && player.entities.self.getRiding() instanceof PacketEntityStrider) { + if (MovementTickerStrider.isAbove(player) && player.compensatedEntities.self.getRiding() instanceof PacketEntityStrider) { if (block.getLevel() == 0) { return new HexCollisionBox(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D); } @@ -633,7 +633,7 @@ public enum CollisionData { LILYPAD((player, version, data, x, y, z) -> { // Boats break lilypads client sided on 1.12- clients. - if (player.inVehicle() && player.entities.self.getRiding().isBoat() && version.isOlderThanOrEquals(ClientVersion.V_1_12_2)) + if (player.inVehicle() && player.compensatedEntities.self.getRiding().isBoat() && version.isOlderThanOrEquals(ClientVersion.V_1_12_2)) return NoCollisionBox.INSTANCE; if (version.isOlderThan(ClientVersion.V_1_9)) diff --git a/src/main/java/ac/grim/grimac/utils/collisions/HitboxData.java b/src/main/java/ac/grim/grimac/utils/collisions/HitboxData.java index 579b3199c8..aaeece9914 100644 --- a/src/main/java/ac/grim/grimac/utils/collisions/HitboxData.java +++ b/src/main/java/ac/grim/grimac/utils/collisions/HitboxData.java @@ -60,12 +60,12 @@ public enum HitboxData { boolean isInWall; boolean isXAxis = data.getFacing() == BlockFace.WEST || data.getFacing() == BlockFace.EAST; if (isXAxis) { - boolean zPosWall = Materials.isWall(player.world.getBlockType(x, y, z + 1)); - boolean zNegWall = Materials.isWall(player.world.getBlockType(x, y, z - 1)); + boolean zPosWall = Materials.isWall(player.compensatedWorld.getBlockType(x, y, z + 1)); + boolean zNegWall = Materials.isWall(player.compensatedWorld.getBlockType(x, y, z - 1)); isInWall = zPosWall || zNegWall; } else { - boolean xPosWall = Materials.isWall(player.world.getBlockType(x + 1, y, z)); - boolean xNegWall = Materials.isWall(player.world.getBlockType(x - 1, y, z)); + boolean xPosWall = Materials.isWall(player.compensatedWorld.getBlockType(x + 1, y, z)); + boolean xNegWall = Materials.isWall(player.compensatedWorld.getBlockType(x - 1, y, z)); isInWall = xPosWall || xNegWall; } diff --git a/src/main/java/ac/grim/grimac/utils/collisions/blocks/DoorHandler.java b/src/main/java/ac/grim/grimac/utils/collisions/blocks/DoorHandler.java index c0179f01f9..185c416b3c 100644 --- a/src/main/java/ac/grim/grimac/utils/collisions/blocks/DoorHandler.java +++ b/src/main/java/ac/grim/grimac/utils/collisions/blocks/DoorHandler.java @@ -44,7 +44,7 @@ public BlockFace fetchDirection(GrimPlayer player, ClientVersion version, Wrappe if (PacketEvents.getAPI().getServerManager().getVersion().isOlderThanOrEquals(ServerVersion.V_1_12_2) || version.isOlderThanOrEquals(ClientVersion.V_1_12_2)) { if (door.getHalf() == Half.LOWER) { - WrappedBlockState above = player.world.getBlock(x, y + 1, z); + WrappedBlockState above = player.compensatedWorld.getBlock(x, y + 1, z); facingDirection = door.getFacing(); isClosed = !door.isOpen(); @@ -58,7 +58,7 @@ public BlockFace fetchDirection(GrimPlayer player, ClientVersion version, Wrappe isRightHinge = false; } } else { - WrappedBlockState below = player.world.getBlock(x, y - 1, z); + WrappedBlockState below = player.compensatedWorld.getBlock(x, y - 1, z); if (below.getType() == door.getType() && below.getHalf() == Half.LOWER) { isClosed = !below.isOpen(); diff --git a/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicChest.java b/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicChest.java index 64318ee01c..14c213bfa5 100644 --- a/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicChest.java +++ b/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicChest.java @@ -40,23 +40,23 @@ public CollisionBox fetch(GrimPlayer player, ClientVersion version, WrappedBlock // 1.12 clients on 1.12 servers // 1.13 clients on 1.12 servers if (chest.getFacing() == BlockFace.EAST || chest.getFacing() == BlockFace.WEST) { - WrappedBlockState westState = player.world.getBlock(x - 1, y, z); + WrappedBlockState westState = player.compensatedWorld.getBlock(x - 1, y, z); if (westState.getType() == chest.getType()) { return new HexCollisionBox(0.0D, 0.0D, 1.0D, 15.0D, 14.0D, 15.0D); // Connected to the west face } - WrappedBlockState eastState = player.world.getBlock(x + 1, y, z); + WrappedBlockState eastState = player.compensatedWorld.getBlock(x + 1, y, z); if (eastState.getType() == chest.getType()) { return new HexCollisionBox(1.0D, 0.0D, 1.0D, 16.0D, 14.0D, 15.0D); // Connected to the east face } } else { - WrappedBlockState northState = player.world.getBlock(x, y, z - 1); + WrappedBlockState northState = player.compensatedWorld.getBlock(x, y, z - 1); if (northState.getType() == chest.getType()) { return new HexCollisionBox(1.0D, 0.0D, 0.0D, 15.0D, 14.0D, 15.0D); // Connected to the north face } - WrappedBlockState southState = player.world.getBlock(x, y, z + 1); + WrappedBlockState southState = player.compensatedWorld.getBlock(x, y, z + 1); if (southState.getType() == chest.getType()) { return new HexCollisionBox(1.0D, 0.0D, 1.0D, 15.0D, 14.0D, 16.0D); // Connected to the south face } diff --git a/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicChorusPlant.java b/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicChorusPlant.java index 9481492dc0..bb585653a6 100644 --- a/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicChorusPlant.java +++ b/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicChorusPlant.java @@ -106,12 +106,12 @@ public Set getLegacyStates(GrimPlayer player, ClientVersion version, // 1.13 clients on 1.12 servers don't see chorus flowers attached to chorus because of a ViaVersion bug StateType versionFlower = version.isOlderThanOrEquals(ClientVersion.V_1_12_2) ? StateTypes.CHORUS_FLOWER : null; - StateType downBlock = player.world.getBlockType(x, y - 1, z); - StateType upBlock = player.world.getBlockType(x, y + 1, z); - StateType northBlock = player.world.getBlockType(x, y, z - 1); - StateType eastBlock = player.world.getBlockType(x + 1, y, z); - StateType southBlock = player.world.getBlockType(x, y, z + 1); - StateType westBlock = player.world.getBlockType(x - 1, y, z); + StateType downBlock = player.compensatedWorld.getBlockType(x, y - 1, z); + StateType upBlock = player.compensatedWorld.getBlockType(x, y + 1, z); + StateType northBlock = player.compensatedWorld.getBlockType(x, y, z - 1); + StateType eastBlock = player.compensatedWorld.getBlockType(x + 1, y, z); + StateType southBlock = player.compensatedWorld.getBlockType(x, y, z + 1); + StateType westBlock = player.compensatedWorld.getBlockType(x - 1, y, z); if (downBlock == StateTypes.CHORUS_PLANT || downBlock == versionFlower || downBlock == StateTypes.END_STONE) { faces.add(BlockFace.DOWN); diff --git a/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicStair.java b/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicStair.java index ac1aa3ad36..a447e67c5c 100644 --- a/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicStair.java +++ b/src/main/java/ac/grim/grimac/utils/collisions/blocks/DynamicStair.java @@ -31,7 +31,7 @@ public class DynamicStair implements CollisionFactory { public static EnumShape getStairsShape(GrimPlayer player, WrappedBlockState originalStairs, int x, int y, int z) { BlockFace facing = originalStairs.getFacing(); - WrappedBlockState offsetOne = player.world.getBlock(x + facing.getModX(), y + facing.getModY(), z + facing.getModZ()); + WrappedBlockState offsetOne = player.compensatedWorld.getBlock(x + facing.getModX(), y + facing.getModY(), z + facing.getModZ()); if (Materials.isStairs(offsetOne.getType()) && originalStairs.getHalf() == offsetOne.getHalf()) { BlockFace enumfacing1 = offsetOne.getFacing(); @@ -45,7 +45,7 @@ public static EnumShape getStairsShape(GrimPlayer player, WrappedBlockState orig } } - WrappedBlockState offsetTwo = player.world.getBlock(x + facing.getOppositeFace().getModX(), y + facing.getOppositeFace().getModY(), z + facing.getOppositeFace().getModZ()); + WrappedBlockState offsetTwo = player.compensatedWorld.getBlock(x + facing.getOppositeFace().getModX(), y + facing.getOppositeFace().getModY(), z + facing.getOppositeFace().getModZ()); if (Materials.isStairs(offsetTwo.getType()) && originalStairs.getHalf() == offsetTwo.getHalf()) { BlockFace enumfacing2 = offsetTwo.getFacing(); @@ -63,7 +63,7 @@ public static EnumShape getStairsShape(GrimPlayer player, WrappedBlockState orig } private static boolean canTakeShape(GrimPlayer player, WrappedBlockState stairOne, int x, int y, int z) { - WrappedBlockState otherStair = player.world.getBlock(x, y, z); + WrappedBlockState otherStair = player.compensatedWorld.getBlock(x, y, z); return !(BlockTags.STAIRS.contains(otherStair.getType())) || (stairOne.getFacing() != otherStair.getFacing() || stairOne.getHalf() != otherStair.getHalf()); diff --git a/src/main/java/ac/grim/grimac/utils/collisions/blocks/connecting/DynamicCollisionWall.java b/src/main/java/ac/grim/grimac/utils/collisions/blocks/connecting/DynamicCollisionWall.java index c3d359872d..2123f56822 100644 --- a/src/main/java/ac/grim/grimac/utils/collisions/blocks/connecting/DynamicCollisionWall.java +++ b/src/main/java/ac/grim/grimac/utils/collisions/blocks/connecting/DynamicCollisionWall.java @@ -149,13 +149,13 @@ public CollisionBox fetch(GrimPlayer player, ClientVersion version, WrappedBlock boolean up = connectsTo(player, version, x, y, z, BlockFace.UP); if (!up) { - WrappedBlockState currBlock = player.world.getBlock(x, y, z); + WrappedBlockState currBlock = player.compensatedWorld.getBlock(x, y, z); StateType currType = currBlock.getType(); - boolean selfNorth = currType == player.world.getBlock(x, y, z + 1).getType(); - boolean selfSouth = currType == player.world.getBlock(x, y, z - 1).getType(); - boolean selfWest = currType == player.world.getBlock(x - 1, y, z).getType(); - boolean selfEast = currType == player.world.getBlock(x + 1, y, z).getType(); + boolean selfNorth = currType == player.compensatedWorld.getBlock(x, y, z + 1).getType(); + boolean selfSouth = currType == player.compensatedWorld.getBlock(x, y, z - 1).getType(); + boolean selfWest = currType == player.compensatedWorld.getBlock(x - 1, y, z).getType(); + boolean selfEast = currType == player.compensatedWorld.getBlock(x + 1, y, z).getType(); up = (!selfNorth || !selfSouth || selfWest || selfEast) && (!selfWest || !selfEast || selfNorth || selfSouth); diff --git a/src/main/java/ac/grim/grimac/utils/collisions/blocks/connecting/DynamicConnecting.java b/src/main/java/ac/grim/grimac/utils/collisions/blocks/connecting/DynamicConnecting.java index 1a6c0e1ee7..b70468af6f 100644 --- a/src/main/java/ac/grim/grimac/utils/collisions/blocks/connecting/DynamicConnecting.java +++ b/src/main/java/ac/grim/grimac/utils/collisions/blocks/connecting/DynamicConnecting.java @@ -51,8 +51,8 @@ public static CollisionBox[] makeShapes(float p_196408_1_, float p_196408_2_, fl } public boolean connectsTo(GrimPlayer player, ClientVersion v, int currX, int currY, int currZ, BlockFace direction) { - WrappedBlockState targetBlock = player.world.getBlock(currX + direction.getModX(), currY + direction.getModY(), currZ + direction.getModZ()); - WrappedBlockState currBlock = player.world.getBlock(currX, currY, currZ); + WrappedBlockState targetBlock = player.compensatedWorld.getBlock(currX + direction.getModX(), currY + direction.getModY(), currZ + direction.getModZ()); + WrappedBlockState currBlock = player.compensatedWorld.getBlock(currX, currY, currZ); StateType target = targetBlock.getType(); StateType fence = currBlock.getType(); diff --git a/src/main/java/ac/grim/grimac/utils/data/packetentity/dragon/PacketEntityEnderDragon.java b/src/main/java/ac/grim/grimac/utils/data/packetentity/dragon/PacketEntityEnderDragon.java index 159422ded9..81d10eee2a 100644 --- a/src/main/java/ac/grim/grimac/utils/data/packetentity/dragon/PacketEntityEnderDragon.java +++ b/src/main/java/ac/grim/grimac/utils/data/packetentity/dragon/PacketEntityEnderDragon.java @@ -15,7 +15,7 @@ public final class PacketEntityEnderDragon extends PacketEntity { public PacketEntityEnderDragon(GrimPlayer player, UUID uuid, int entityID, double x, double y, double z) { super(player, uuid, EntityTypes.ENDER_DRAGON, x, y, z); - final Int2ObjectOpenHashMap entityMap = player.entities.entityMap; + final Int2ObjectOpenHashMap entityMap = player.compensatedEntities.entityMap; parts.add(new PacketEntityEnderDragonPart(player, DragonPart.HEAD, x, y, z, 1.0F, 1.0F)); parts.add(new PacketEntityEnderDragonPart(player, DragonPart.NECK, x, y, z, 3.0F, 3.0F)); parts.add(new PacketEntityEnderDragonPart(player, DragonPart.BODY, x, y, z, 5.0F, 3.0F)); diff --git a/src/main/java/ac/grim/grimac/utils/latency/CompensatedEntities.java b/src/main/java/ac/grim/grimac/utils/latency/CompensatedEntities.java index c453be1948..7b2bbe641e 100644 --- a/src/main/java/ac/grim/grimac/utils/latency/CompensatedEntities.java +++ b/src/main/java/ac/grim/grimac/utils/latency/CompensatedEntities.java @@ -123,7 +123,7 @@ public void updateAttributes(int entityID, List watchableObjects) { - PacketEntity entity = player.entities.getEntity(entityID); + PacketEntity entity = player.compensatedEntities.getEntity(entityID); if (entity == null) return; if (entity.isAgeable()) { @@ -290,12 +290,12 @@ public void updateEntityMetadata(int entityID, List watchableObjects if (height != null) { if ((byte) height.getValue() == 0) { ShulkerData data = new ShulkerData(shulker, player.lastTransactionSent.get(), true); - player.world.openShulkerBoxes.remove(data); - player.world.openShulkerBoxes.add(data); + player.compensatedWorld.openShulkerBoxes.remove(data); + player.compensatedWorld.openShulkerBoxes.add(data); } else { ShulkerData data = new ShulkerData(shulker, player.lastTransactionSent.get(), false); - player.world.openShulkerBoxes.remove(data); - player.world.openShulkerBoxes.add(data); + player.compensatedWorld.openShulkerBoxes.remove(data); + player.compensatedWorld.openShulkerBoxes.add(data); } } } diff --git a/src/main/java/ac/grim/grimac/utils/latency/CompensatedWorld.java b/src/main/java/ac/grim/grimac/utils/latency/CompensatedWorld.java index 9fdde6dccf..707d3c1845 100644 --- a/src/main/java/ac/grim/grimac/utils/latency/CompensatedWorld.java +++ b/src/main/java/ac/grim/grimac/utils/latency/CompensatedWorld.java @@ -214,8 +214,8 @@ public static long chunkPositionToLong(int x, int z) { } public boolean isNearHardEntity(SimpleCollisionBox playerBox) { - for (PacketEntity entity : player.entities.entityMap.values()) { - if ((entity.isBoat() || entity.getType() == EntityTypes.SHULKER) && player.entities.self.getRiding() != entity) { + for (PacketEntity entity : player.compensatedEntities.entityMap.values()) { + if ((entity.isBoat() || entity.getType() == EntityTypes.SHULKER) && player.compensatedEntities.self.getRiding() != entity) { SimpleCollisionBox box = entity.getPossibleCollisionBoxes(); if (box.isIntersected(playerBox)) { return true; @@ -428,7 +428,7 @@ public void removeInvalidPistonLikeStuff(int transactionId) { if (box.blockPos != null) { // Block is no longer valid return !Materials.isShulker(getBlock(box.blockPos).getType()); } else { // Entity is no longer valid - return !player.entities.entityMap.containsValue(box.entity); + return !player.compensatedEntities.entityMap.containsValue(box.entity); } }); } diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/BlockBreakSpeed.java b/src/main/java/ac/grim/grimac/utils/nmsutil/BlockBreakSpeed.java index 55679df9d5..3a7837e646 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/BlockBreakSpeed.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/BlockBreakSpeed.java @@ -26,7 +26,7 @@ public static double getBlockDamage(GrimPlayer player, Vector3i position) { // Starts with itemstack get destroy speed ItemStack tool = player.getInventory().getHeldItem(); - WrappedBlockState block = player.world.getBlock(position); + WrappedBlockState block = player.compensatedWorld.getBlock(position); float blockHardness = block.getType().getHardness(); // 1.15.2 and below need this hack @@ -119,7 +119,7 @@ public static double getBlockDamage(GrimPlayer player, Vector3i position) { if (speedMultiplier > 1.0f) { if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_21) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_21)) { - speedMultiplier += (float) player.entities.self.getAttributeValue(Attributes.MINING_EFFICIENCY); + speedMultiplier += (float) player.compensatedEntities.self.getAttributeValue(Attributes.MINING_EFFICIENCY); } else { int digSpeed = tool.getEnchantmentLevel(EnchantmentTypes.BLOCK_EFFICIENCY, PacketEvents.getAPI().getServerManager().getVersion().toClientVersion()); if (digSpeed > 0) { @@ -128,15 +128,15 @@ public static double getBlockDamage(GrimPlayer player, Vector3i position) { } } - OptionalInt digSpeed = player.entities.getPotionLevelForPlayer(PotionTypes.HASTE); - OptionalInt conduit = player.entities.getPotionLevelForPlayer(PotionTypes.CONDUIT_POWER); + OptionalInt digSpeed = player.compensatedEntities.getPotionLevelForPlayer(PotionTypes.HASTE); + OptionalInt conduit = player.compensatedEntities.getPotionLevelForPlayer(PotionTypes.CONDUIT_POWER); if (digSpeed.isPresent() || conduit.isPresent()) { int hasteLevel = Math.max(digSpeed.isEmpty() ? 0 : digSpeed.getAsInt(), conduit.isEmpty() ? 0 : conduit.getAsInt()); speedMultiplier *= (float) (1 + (0.2 * (hasteLevel + 1))); } - OptionalInt miningFatigue = player.entities.getPotionLevelForPlayer(PotionTypes.MINING_FATIGUE); + OptionalInt miningFatigue = player.compensatedEntities.getPotionLevelForPlayer(PotionTypes.MINING_FATIGUE); if (miningFatigue.isPresent()) { switch (miningFatigue.getAsInt()) { @@ -154,11 +154,11 @@ public static double getBlockDamage(GrimPlayer player, Vector3i position) { } } - speedMultiplier *= (float) player.entities.self.getAttributeValue(Attributes.BLOCK_BREAK_SPEED); + speedMultiplier *= (float) player.compensatedEntities.self.getAttributeValue(Attributes.BLOCK_BREAK_SPEED); if (player.fluidOnEyes == FluidTag.WATER) { if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_21) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_21)) { - speedMultiplier *= (float) player.entities.self.getAttributeValue(Attributes.SUBMERGED_MINING_SPEED); + speedMultiplier *= (float) player.compensatedEntities.self.getAttributeValue(Attributes.SUBMERGED_MINING_SPEED); } else { if (EnchantmentHelper.getMaximumEnchantLevel(player.getInventory(), EnchantmentTypes.AQUA_AFFINITY, PacketEvents.getAPI().getServerManager().getVersion().toClientVersion()) == 0) { speedMultiplier /= 5; diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/BlockProperties.java b/src/main/java/ac/grim/grimac/utils/nmsutil/BlockProperties.java index d010c41c7c..66256197e3 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/BlockProperties.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/BlockProperties.java @@ -25,11 +25,11 @@ public static float getFrictionInfluencedSpeed(float f, GrimPlayer player) { // The game uses values known as flyingSpeed for some vehicles in the air if (player.inVehicle()) { - if (player.entities.self.getRiding().getType() == EntityTypes.PIG || player.entities.self.getRiding() instanceof PacketEntityHorse) { + if (player.compensatedEntities.self.getRiding().getType() == EntityTypes.PIG || player.compensatedEntities.self.getRiding() instanceof PacketEntityHorse) { return (float) (player.speed * 0.1f); } - if (player.entities.self.getRiding() instanceof PacketEntityStrider strider) { + if (player.compensatedEntities.self.getRiding() instanceof PacketEntityStrider strider) { // Unsure which version the speed changed in if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_20)) { return (float) player.speed * 0.1f; @@ -65,7 +65,7 @@ public static StateType getOnPos(GrimPlayer player, MainSupportingBlockData main } Vector3i pos = getOnPos(player, playerPos, mainSupportingBlockData, 0.2F); - return player.world.getBlockType(pos.x, pos.y, pos.z); + return player.compensatedWorld.getBlockType(pos.x, pos.y, pos.z); } public static float getFriction(GrimPlayer player, MainSupportingBlockData mainSupportingBlockData, Vector3d playerPos) { @@ -75,7 +75,7 @@ public static float getFriction(GrimPlayer player, MainSupportingBlockData mainS if (player.getClientVersion().isOlderThan(ClientVersion.V_1_15)) searchBelowAmount = 1; - StateType type = player.world.getBlockType(playerPos.getX(), playerPos.getY() - searchBelowAmount, playerPos.getZ()); + StateType type = player.compensatedWorld.getBlockType(playerPos.getX(), playerPos.getY() - searchBelowAmount, playerPos.getZ()); return getMaterialFriction(player, type); } @@ -92,7 +92,7 @@ public static float getBlockSpeedFactor(GrimPlayer player, MainSupportingBlockDa return getBlockSpeedFactorLegacy(player, playerPos); } - WrappedBlockState inBlock = player.world.getBlock(playerPos.getX(), playerPos.getY(), playerPos.getZ()); + WrappedBlockState inBlock = player.compensatedWorld.getBlock(playerPos.getX(), playerPos.getY(), playerPos.getZ()); float inBlockSpeedFactor = getBlockSpeedFactor(player, inBlock.getType()); if (inBlockSpeedFactor != 1.0f || inBlock.getType() == StateTypes.WATER || inBlock.getType() == StateTypes.BUBBLE_COLUMN) { return getModernVelocityMultiplier(player, inBlockSpeedFactor); @@ -105,7 +105,7 @@ public static float getBlockSpeedFactor(GrimPlayer player, MainSupportingBlockDa public static boolean onHoneyBlock(GrimPlayer player, MainSupportingBlockData mainSupportingBlockData, Vector3d playerPos) { if (player.getClientVersion().isOlderThan(ClientVersion.V_1_15)) return false; - StateType inBlock = player.world.getBlockType(playerPos.getX(), playerPos.getY(), playerPos.getZ()); + StateType inBlock = player.compensatedWorld.getBlockType(playerPos.getX(), playerPos.getY(), playerPos.getZ()); return inBlock == StateTypes.HONEY_BLOCK || getOnPos(player, mainSupportingBlockData, playerPos) == StateTypes.HONEY_BLOCK; } @@ -118,13 +118,13 @@ public static boolean onHoneyBlock(GrimPlayer player, MainSupportingBlockData ma */ private static StateType getBlockPosBelowThatAffectsMyMovement(GrimPlayer player, MainSupportingBlockData mainSupportingBlockData, Vector3d playerPos) { Vector3i pos = getOnPos(player, playerPos, mainSupportingBlockData, 0.500001F); - return player.world.getBlockType(pos.x, pos.y, pos.z); + return player.compensatedWorld.getBlockType(pos.x, pos.y, pos.z); } private static Vector3i getOnPos(GrimPlayer player, Vector3d playerPos, MainSupportingBlockData mainSupportingBlockData, float searchBelowPlayer) { Vector3i mainBlockPos = mainSupportingBlockData.getBlockPos(); if (mainBlockPos != null) { - StateType blockstate = player.world.getBlockType(mainBlockPos.x, mainBlockPos.y, mainBlockPos.z); + StateType blockstate = player.compensatedWorld.getBlockType(mainBlockPos.x, mainBlockPos.y, mainBlockPos.z); // I genuinely don't understand this code, or why fences are special boolean shouldReturn = (!((double)searchBelowPlayer <= 0.5D) || !BlockTags.FENCES.contains(blockstate)) && @@ -157,10 +157,10 @@ public static float getMaterialFriction(GrimPlayer player, StateType material) { } private static StateType getOnBlock(GrimPlayer player, double x, double y, double z) { - StateType block1 = player.world.getBlockType(GrimMath.floor(x), GrimMath.floor(y - 0.2F), GrimMath.floor(z)); + StateType block1 = player.compensatedWorld.getBlockType(GrimMath.floor(x), GrimMath.floor(y - 0.2F), GrimMath.floor(z)); if (block1.isAir()) { - StateType block2 = player.world.getBlockType(GrimMath.floor(x), GrimMath.floor(y - 1.2F), GrimMath.floor(z)); + StateType block2 = player.compensatedWorld.getBlockType(GrimMath.floor(x), GrimMath.floor(y - 1.2F), GrimMath.floor(z)); if (Materials.isFence(block2) || Materials.isWall(block2) || Materials.isGate(block2)) { return block2; @@ -171,7 +171,7 @@ private static StateType getOnBlock(GrimPlayer player, double x, double y, doubl } private static float getBlockSpeedFactorLegacy(GrimPlayer player, Vector3d pos) { - StateType block = player.world.getBlockType(pos.getX(), pos.getY(), pos.getZ()); + StateType block = player.compensatedWorld.getBlockType(pos.getX(), pos.getY(), pos.getZ()); // This is the 1.16.0 and 1.16.1 method for detecting if the player is on soul speed if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_16) && player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_16_1)) { @@ -183,7 +183,7 @@ private static float getBlockSpeedFactorLegacy(GrimPlayer player, Vector3d pos) float speed = getBlockSpeedFactor(player, block); if (speed != 1.0f || block == StateTypes.SOUL_SAND || block == StateTypes.WATER || block == StateTypes.BUBBLE_COLUMN) return speed; - StateType block2 = player.world.getBlockType(pos.getX(), pos.getY() - 0.5000001, pos.getZ()); + StateType block2 = player.compensatedWorld.getBlockType(pos.getX(), pos.getY() - 0.5000001, pos.getZ()); return getBlockSpeedFactor(player, block2); } @@ -204,6 +204,6 @@ private static float getBlockSpeedFactor(GrimPlayer player, StateType type) { private static float getModernVelocityMultiplier(GrimPlayer player, float blockSpeedFactor) { if (player.getClientVersion().isOlderThan(ClientVersion.V_1_21)) return blockSpeedFactor; - return (float) GrimMath.lerp((float) player.entities.self.getAttributeValue(Attributes.MOVEMENT_EFFICIENCY), blockSpeedFactor, 1.0F); + return (float) GrimMath.lerp((float) player.compensatedEntities.self.getAttributeValue(Attributes.MOVEMENT_EFFICIENCY), blockSpeedFactor, 1.0F); } } diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/BoundingBoxSize.java b/src/main/java/ac/grim/grimac/utils/nmsutil/BoundingBoxSize.java index 3034dd789e..fb6178f23c 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/BoundingBoxSize.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/BoundingBoxSize.java @@ -141,7 +141,7 @@ public static Vector3d getRidingOffsetFromVehicle(PacketEntity entity, GrimPlaye float f1 = (float) (getPassengerRidingOffset(player, entity) - 0.35f); // hardcoded player offset if (!entity.passengers.isEmpty()) { - int i = entity.passengers.indexOf(player.entities.self); + int i = entity.passengers.indexOf(player.compensatedEntities.self); if (i == 0) { f = 0.2f; diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/CheckIfChunksLoaded.java b/src/main/java/ac/grim/grimac/utils/nmsutil/CheckIfChunksLoaded.java index 21e42c37ab..05b5d3839d 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/CheckIfChunksLoaded.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/CheckIfChunksLoaded.java @@ -4,7 +4,7 @@ public class CheckIfChunksLoaded { public static boolean isChunksUnloadedAt(GrimPlayer player, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { - if (maxY < player.world.getMinHeight() || minY >= player.world.getMaxHeight()) { + if (maxY < player.compensatedWorld.getMinHeight() || minY >= player.compensatedWorld.getMaxHeight()) { return true; } @@ -15,7 +15,7 @@ public static boolean isChunksUnloadedAt(GrimPlayer player, int minX, int minY, for (int i = minX; i <= maxX; ++i) { for (int j = minZ; j <= maxZ; ++j) { - if (player.world.getChunk(i, j) == null) { + if (player.compensatedWorld.getChunk(i, j) == null) { return true; } } diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/Collisions.java b/src/main/java/ac/grim/grimac/utils/nmsutil/Collisions.java index 8ea47758a3..7060a4e352 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/Collisions.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/Collisions.java @@ -267,9 +267,9 @@ public static boolean getCollisionBoxes(GrimPlayer player, SimpleCollisionBox wa int minBlockZ = (int) Math.floor(expandedBB.minZ - COLLISION_EPSILON) - 1; int maxBlockZ = (int) Math.floor(expandedBB.maxZ + COLLISION_EPSILON) + 1; - final int minSection = player.world.getMinHeight() >> 4; + final int minSection = player.compensatedWorld.getMinHeight() >> 4; final int minBlock = minSection << 4; - final int maxBlock = player.world.getMaxHeight() - 1; + final int maxBlock = player.compensatedWorld.getMaxHeight() - 1; int minChunkX = minBlockX >> 4; int maxChunkX = maxBlockX >> 4; @@ -291,7 +291,7 @@ public static boolean getCollisionBoxes(GrimPlayer player, SimpleCollisionBox wa int chunkXGlobalPos = currChunkX << 4; int chunkZGlobalPos = currChunkZ << 4; - Column chunk = player.world.getChunk(currChunkX, currChunkZ); + Column chunk = player.compensatedWorld.getChunk(currChunkX, currChunkZ); if (chunk == null) continue; BaseChunk[] sections = chunk.chunks(); @@ -454,11 +454,11 @@ public static void handleInsideBlocks(GrimPlayer player) { for (int blockX = blockPos.getBlockX(); blockX <= blockPos2.getBlockX(); ++blockX) { for (int blockY = blockPos.getBlockY(); blockY <= blockPos2.getBlockY(); ++blockY) { for (int blockZ = blockPos.getBlockZ(); blockZ <= blockPos2.getBlockZ(); ++blockZ) { - WrappedBlockState block = player.world.getBlock(blockX, blockY, blockZ); + WrappedBlockState block = player.compensatedWorld.getBlock(blockX, blockY, blockZ); StateType blockType = block.getType(); if (blockType == StateTypes.COBWEB) { - if (player.entities.hasPotionEffect(PotionTypes.WEAVING)) { + if (player.compensatedEntities.hasPotionEffect(PotionTypes.WEAVING)) { player.stuckSpeedMultiplier = new Vector(0.5, 0.25, 0.5); } else { player.stuckSpeedMultiplier = new Vector(0.25, 0.05000000074505806, 0.25); @@ -485,9 +485,9 @@ public static void handleInsideBlocks(GrimPlayer player) { } if (blockType == StateTypes.BUBBLE_COLUMN && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_13)) { - WrappedBlockState blockAbove = player.world.getBlock(blockX, blockY + 1, blockZ); + WrappedBlockState blockAbove = player.compensatedWorld.getBlock(blockX, blockY + 1, blockZ); - if (player.inVehicle() && player.entities.self.getRiding().isBoat()) { + if (player.inVehicle() && player.compensatedEntities.self.getRiding().isBoat()) { if (!blockAbove.getType().isAir()) { if (block.isDrag()) { player.clientVelocity.setY(Math.max(-0.3D, player.clientVelocity.getY() - 0.03D)); @@ -570,7 +570,7 @@ public static boolean checkStuckSpeed(GrimPlayer player, double expand) { for (int i = blockPos.getBlockX(); i <= blockPos2.getBlockX(); ++i) { for (int j = blockPos.getBlockY(); j <= blockPos2.getBlockY(); ++j) { for (int k = blockPos.getBlockZ(); k <= blockPos2.getBlockZ(); ++k) { - WrappedBlockState block = player.world.getBlock(i, j, k); + WrappedBlockState block = player.compensatedWorld.getBlock(i, j, k); StateType blockType = block.getType(); if (blockType == StateTypes.COBWEB) { @@ -600,7 +600,7 @@ public static boolean suffocatesAt(GrimPlayer player, SimpleCollisionBox playerB // Mojang re-added soul sand pushing by checking if the player is actually in the block // (This is why from 1.14-1.15 soul sand didn't push) if (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_16)) { - WrappedBlockState data = player.world.getBlock(x, y, z); + WrappedBlockState data = player.compensatedWorld.getBlock(x, y, z); CollisionBox box = CollisionData.getData(data.getType()).getMovementCollisionBox(player, player.getClientVersion(), data, x, y, z); if (!box.isIntersected(playerBB)) continue; @@ -616,7 +616,7 @@ public static boolean suffocatesAt(GrimPlayer player, SimpleCollisionBox playerB } public static boolean doesBlockSuffocate(GrimPlayer player, int x, int y, int z) { - WrappedBlockState data = player.world.getBlock(x, y, z); + WrappedBlockState data = player.compensatedWorld.getBlock(x, y, z); StateType mat = data.getType(); // Optimization - all blocks that can suffocate must have a hitbox @@ -662,9 +662,9 @@ public static boolean hasMaterial(GrimPlayer player, SimpleCollisionBox checkBox int minBlockZ = (int) Math.floor(checkBox.minZ); int maxBlockZ = (int) Math.floor(checkBox.maxZ); - final int minSection = player.world.getMinHeight() >> 4; + final int minSection = player.compensatedWorld.getMinHeight() >> 4; final int minBlock = minSection << 4; - final int maxBlock = player.world.getMaxHeight() - 1; + final int maxBlock = player.compensatedWorld.getMaxHeight() - 1; int minChunkX = minBlockX >> 4; int maxChunkX = maxBlockX >> 4; @@ -686,7 +686,7 @@ public static boolean hasMaterial(GrimPlayer player, SimpleCollisionBox checkBox int chunkXGlobalPos = currChunkX << 4; int chunkZGlobalPos = currChunkZ << 4; - Column chunk = player.world.getChunk(currChunkX, currChunkZ); + Column chunk = player.compensatedWorld.getChunk(currChunkX, currChunkZ); if (chunk == null) continue; BaseChunk[] sections = chunk.chunks(); @@ -726,9 +726,9 @@ public static void forEachCollisionBox(GrimPlayer player, SimpleCollisionBox che int minBlockZ = (int) Math.floor(checkBox.minZ - COLLISION_EPSILON) - 1; int maxBlockZ = (int) Math.floor(checkBox.maxZ + COLLISION_EPSILON) + 1; - final int minSection = player.world.getMinHeight() >> 4; + final int minSection = player.compensatedWorld.getMinHeight() >> 4; final int minBlock = minSection << 4; - final int maxBlock = player.world.getMaxHeight() - 1; + final int maxBlock = player.compensatedWorld.getMaxHeight() - 1; int minChunkX = minBlockX >> 4; int maxChunkX = maxBlockX >> 4; @@ -750,7 +750,7 @@ public static void forEachCollisionBox(GrimPlayer player, SimpleCollisionBox che int chunkXGlobalPos = currChunkX << 4; int chunkZGlobalPos = currChunkZ << 4; - Column chunk = player.world.getChunk(currChunkX, currChunkZ); + Column chunk = player.compensatedWorld.getChunk(currChunkX, currChunkZ); if (chunk == null) continue; BaseChunk[] sections = chunk.chunks(); @@ -797,7 +797,7 @@ public static void forEachCollisionBox(GrimPlayer player, SimpleCollisionBox che } public static boolean onClimbable(GrimPlayer player, double x, double y, double z) { - WrappedBlockState blockState = player.world.getBlock(x, y, z); + WrappedBlockState blockState = player.compensatedWorld.getBlock(x, y, z); StateType blockMaterial = blockState.getType(); // ViaVersion replacement block -> glow berry vines (cave vines) -> fern @@ -823,7 +823,7 @@ public static boolean trapdoorUsableAsLadder(GrimPlayer player, double x, double if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) return false; if (blockData.isOpen()) { - WrappedBlockState blockBelow = player.world.getBlock(x, y - 1, z); + WrappedBlockState blockBelow = player.compensatedWorld.getBlock(x, y - 1, z); if (blockBelow.getType() == StateTypes.LADDER) { return blockData.getFacing() == blockBelow.getFacing(); diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/Dripstone.java b/src/main/java/ac/grim/grimac/utils/nmsutil/Dripstone.java index b6dc95fa30..1e14064b93 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/Dripstone.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/Dripstone.java @@ -11,7 +11,7 @@ public static WrappedBlockState update(GrimPlayer player, WrappedBlockState toPl VerticalDirection primaryDirection = toPlace.getVerticalDirection(); VerticalDirection opposite = toPlace.getVerticalDirection() == VerticalDirection.UP ? VerticalDirection.DOWN : VerticalDirection.UP; - WrappedBlockState typePlacingOn = player.world.getBlock(x, y + (primaryDirection == VerticalDirection.UP ? 1 : -1), z); + WrappedBlockState typePlacingOn = player.compensatedWorld.getBlock(x, y + (primaryDirection == VerticalDirection.UP ? 1 : -1), z); if (isPointedDripstoneWithDirection(typePlacingOn, opposite)) { // Use tip if the player is sneaking, or if it already is merged (somehow) @@ -27,7 +27,7 @@ public static WrappedBlockState update(GrimPlayer player, WrappedBlockState toPl Thickness dripThick = typePlacingOn.getThickness(); if (dripThick != Thickness.TIP && dripThick != Thickness.TIP_MERGE) { // Look downwards - WrappedBlockState oppositeData = player.world.getBlock(x, y + (opposite == VerticalDirection.UP ? 1 : -1), z); + WrappedBlockState oppositeData = player.compensatedWorld.getBlock(x, y + (opposite == VerticalDirection.UP ? 1 : -1), z); Thickness toSetThick = !isPointedDripstoneWithDirection(oppositeData, primaryDirection) ? Thickness.BASE : Thickness.MIDDLE; toPlace.setThickness(toSetThick); diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/FluidTypeFlowing.java b/src/main/java/ac/grim/grimac/utils/nmsutil/FluidTypeFlowing.java index abfbf31858..ff66a2f4d9 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/FluidTypeFlowing.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/FluidTypeFlowing.java @@ -13,7 +13,7 @@ public class FluidTypeFlowing { public static Vector getFlow(GrimPlayer player, int originalX, int originalY, int originalZ) { - float fluidLevel = (float) Math.min(player.world.getFluidLevelAt(originalX, originalY, originalZ), 8 / 9D); + float fluidLevel = (float) Math.min(player.compensatedWorld.getFluidLevelAt(originalX, originalY, originalZ), 8 / 9D); ClientVersion version = player.getClientVersion(); if (fluidLevel == 0) return new Vector(); @@ -25,17 +25,17 @@ public static Vector getFlow(GrimPlayer player, int originalX, int originalY, in int modifiedZ = originalZ + enumdirection.getModZ(); if (affectsFlow(player, originalX, originalY, originalZ, modifiedX, originalY, modifiedZ)) { - float f = (float) Math.min(player.world.getFluidLevelAt(modifiedX, originalY, modifiedZ), 8 / 9D); + float f = (float) Math.min(player.compensatedWorld.getFluidLevelAt(modifiedX, originalY, modifiedZ), 8 / 9D); float f1 = 0.0F; if (f == 0.0F) { - StateType mat = player.world.getBlockType(modifiedX, originalY, modifiedZ); + StateType mat = player.compensatedWorld.getBlockType(modifiedX, originalY, modifiedZ); // Grim's definition of solid is whether the block has a hitbox // Minecraft is... it's whatever Mojang was feeling like, but it's very consistent // Use method call to support 1.13-1.15 clients and banner oddity if (Materials.isSolidBlockingBlacklist(mat, version)) { if (affectsFlow(player, originalX, originalY, originalZ, modifiedX, originalY - 1, modifiedZ)) { - f = (float) Math.min(player.world.getFluidLevelAt(modifiedX, originalY - 1, modifiedZ), 8 / 9D); + f = (float) Math.min(player.compensatedWorld.getFluidLevelAt(modifiedX, originalY - 1, modifiedZ), 8 / 9D); if (f > 0.0F) { f1 = fluidLevel - (f - 0.8888889F); } @@ -57,7 +57,7 @@ public static Vector getFlow(GrimPlayer player, int originalX, int originalY, in // Fluid level 1-7 is for regular fluid heights // Fluid level 8-15 is for falling fluids - WrappedBlockState state = player.world.getBlock(originalX, originalY, originalZ); + WrappedBlockState state = player.compensatedWorld.getBlock(originalX, originalY, originalZ); if ((state.getType() == StateTypes.WATER || state.getType() == StateTypes.LAVA) && state.getLevel() >= 8) { for (BlockFace enumdirection : new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}) { if (isSolidFace(player, originalX, originalY, originalZ, enumdirection) || isSolidFace(player, originalX, originalY + 1, originalZ, enumdirection)) { @@ -77,7 +77,7 @@ protected static boolean isSolidFace(GrimPlayer player, int originalX, int y, in int x = originalX + direction.getModX(); int z = originalZ + direction.getModZ(); - WrappedBlockState data = player.world.getBlock(x, y, z); + WrappedBlockState data = player.compensatedWorld.getBlock(x, y, z); StateType type = data.getType(); if (isSame(player, x, y, z, originalX, y, originalZ)) return false; @@ -156,15 +156,15 @@ private static Vector normalizeVectorWithoutNaN(Vector vector) { } public static boolean isEmpty(GrimPlayer player, int x, int y, int z) { - return player.world.getFluidLevelAt(x, y, z) == 0; + return player.compensatedWorld.getFluidLevelAt(x, y, z) == 0; } // Check if both are a type of water or both are a type of lava // This is a bit slow... but I don't see a better way to do it with the bukkit api and no nms public static boolean isSame(GrimPlayer player, int x1, int y1, int z1, int x2, int y2, int z2) { - return player.world.getWaterFluidLevelAt(x1, y1, z1) > 0 && - player.world.getWaterFluidLevelAt(x2, y2, z2) > 0 || - player.world.getLavaFluidLevelAt(x1, y1, z1) > 0 && - player.world.getLavaFluidLevelAt(x2, y2, z2) > 0; + return player.compensatedWorld.getWaterFluidLevelAt(x1, y1, z1) > 0 && + player.compensatedWorld.getWaterFluidLevelAt(x2, y2, z2) > 0 || + player.compensatedWorld.getLavaFluidLevelAt(x1, y1, z1) > 0 && + player.compensatedWorld.getLavaFluidLevelAt(x2, y2, z2) > 0; } } diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/GetBoundingBox.java b/src/main/java/ac/grim/grimac/utils/nmsutil/GetBoundingBox.java index 35265af600..cfe9430047 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/GetBoundingBox.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/GetBoundingBox.java @@ -8,7 +8,7 @@ public class GetBoundingBox { public static SimpleCollisionBox getCollisionBoxForPlayer(GrimPlayer player, double centerX, double centerY, double centerZ) { if (player.inVehicle()) { - return getPacketEntityBoundingBox(player, centerX, centerY, centerZ, player.entities.self.getRiding()); + return getPacketEntityBoundingBox(player, centerX, centerY, centerZ, player.compensatedEntities.self.getRiding()); } return getPlayerBoundingBox(player, centerX, centerY, centerZ); @@ -31,7 +31,7 @@ public static SimpleCollisionBox getPlayerBoundingBox(GrimPlayer player, double } public static SimpleCollisionBox getBoundingBoxFromPosAndSize(GrimPlayer player, double centerX, double minY, double centerZ, float width, float height) { - return getBoundingBoxFromPosAndSize(player.entities.self, centerX, minY, centerZ, width, height); + return getBoundingBoxFromPosAndSize(player.compensatedEntities.self, centerX, minY, centerZ, width, height); } public static SimpleCollisionBox getBoundingBoxFromPosAndSize(PacketEntity entity, double centerX, double minY, double centerZ, float width, float height) { diff --git a/src/main/java/ac/grim/grimac/utils/nmsutil/JumpPower.java b/src/main/java/ac/grim/grimac/utils/nmsutil/JumpPower.java index b14c0b0c74..7711e7c9fc 100644 --- a/src/main/java/ac/grim/grimac/utils/nmsutil/JumpPower.java +++ b/src/main/java/ac/grim/grimac/utils/nmsutil/JumpPower.java @@ -13,7 +13,7 @@ public class JumpPower { public static void jumpFromGround(GrimPlayer player, Vector vector) { float jumpPower = getJumpPower(player); - final OptionalInt jumpBoost = player.entities.getPotionLevelForPlayer(PotionTypes.JUMP_BOOST); + final OptionalInt jumpBoost = player.compensatedEntities.getPotionLevelForPlayer(PotionTypes.JUMP_BOOST); if (jumpBoost.isPresent()) { jumpPower += 0.1f * (jumpBoost.getAsInt() + 1); } @@ -29,7 +29,7 @@ public static void jumpFromGround(GrimPlayer player, Vector vector) { } public static float getJumpPower(GrimPlayer player) { - return (float) player.entities.self.getAttributeValue(Attributes.JUMP_STRENGTH) * getPlayerJumpFactor(player); + return (float) player.compensatedEntities.self.getAttributeValue(Attributes.JUMP_STRENGTH) * getPlayerJumpFactor(player); } public static float getPlayerJumpFactor(GrimPlayer player) { diff --git a/src/main/java/ac/grim/grimac/utils/team/EntityTeam.java b/src/main/java/ac/grim/grimac/utils/team/EntityTeam.java index 27069270c0..b99223d471 100644 --- a/src/main/java/ac/grim/grimac/utils/team/EntityTeam.java +++ b/src/main/java/ac/grim/grimac/utils/team/EntityTeam.java @@ -34,7 +34,7 @@ public void update(WrapperPlayServerTeams teams) { } boolean flag = false; - for (UserProfile profile : player.entities.profiles.values()) { + for (UserProfile profile : player.compensatedEntities.profiles.values()) { if (profile.getName() != null && profile.getName().equals(teamsPlayer)) { teamHandler.addEntityToTeam(profile.getUUID().toString(), this); flag = true;