Skip to content

Commit

Permalink
fix 1133
Browse files Browse the repository at this point in the history
  • Loading branch information
MWHunter committed Sep 5, 2023
1 parent 4dcdc78 commit 6ca7863
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,15 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) {
}


public VelocityData getPossibleExplosions(int lastTransaction) {
public VelocityData getPossibleExplosions(int lastTransaction, boolean isJustTesting) {
handleTransactionPacket(lastTransaction);
if (lastExplosionsKnownTaken == null)
return null;

VelocityData returnLastExplosion = lastExplosionsKnownTaken;
lastExplosionsKnownTaken = null;
if (!isJustTesting) {
lastExplosionsKnownTaken = null;
}
return returnLastExplosion;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void addPlayerKnockback(int entityID, int breadOne, Vector knockback) {
firstBreadMap.add(new VelocityData(entityID, breadOne, player.getSetbackTeleportUtil().isSendingSetback, knockback));
}

public VelocityData calculateRequiredKB(int entityID, int transaction) {
public VelocityData calculateRequiredKB(int entityID, int transaction, boolean isJustTesting) {
tickKnockback(transaction);

VelocityData returnLastKB = null;
Expand All @@ -101,7 +101,9 @@ public VelocityData calculateRequiredKB(int entityID, int transaction) {
returnLastKB = data;
}

lastKnockbackKnownTaken.clear();
if (!isJustTesting) {
lastKnockbackKnownTaken.clear();
}
return returnLastKB;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,12 @@ public void onPacketReceive(PacketReceiveEvent event) {
int kbEntityId = player.compensatedEntities.getSelf().inVehicle() ? player.getRidingVehicleId() : player.entityID;

VelocityData calculatedFirstBreadKb = player.checkManager.getKnockbackHandler().calculateFirstBreadKnockback(kbEntityId, player.lastTransactionReceived.get());
VelocityData calculatedRequireKb = player.checkManager.getKnockbackHandler().calculateRequiredKB(kbEntityId, player.lastTransactionReceived.get());
VelocityData calculatedRequireKb = player.checkManager.getKnockbackHandler().calculateRequiredKB(kbEntityId, player.lastTransactionReceived.get(), false);
player.firstBreadKB = calculatedFirstBreadKb == null ? player.firstBreadKB : calculatedFirstBreadKb;
player.likelyKB = calculatedRequireKb == null ? player.likelyKB : calculatedRequireKb;

VelocityData calculateFirstBreadExplosion = player.checkManager.getExplosionHandler().getFirstBreadAddedExplosion(player.lastTransactionReceived.get());
VelocityData calculateRequiredExplosion = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get());
VelocityData calculateRequiredExplosion = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get(), false);
player.firstBreadExplosion = calculateFirstBreadExplosion == null ? player.firstBreadExplosion : calculateFirstBreadExplosion;
player.likelyExplosions = calculateRequiredExplosion == null ? player.likelyExplosions : calculateRequiredExplosion;
}
Expand Down Expand Up @@ -492,7 +492,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
if ((placedWith.getType().getPlacedType() != null || placedWith.getType() == ItemTypes.FIRE_CHARGE) && !player.compensatedEntities.getSelf().inVehicle())
player.checkManager.onBlockPlace(blockPlace);

if (blockPlace.isCancelled() || player.getSetbackTeleportUtil().shouldBlockMovement()) { // The player tried placing blocks in air/water
if (true || blockPlace.isCancelled() || player.getSetbackTeleportUtil().shouldBlockMovement()) { // The player tried placing blocks in air/water
event.setCancelled(true);
player.onPacketCancel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
// Update knockback and explosions after getting the vehicle
int controllingEntityId = player.compensatedEntities.getSelf().inVehicle() ? player.getRidingVehicleId() : player.entityID;
player.firstBreadKB = player.checkManager.getKnockbackHandler().calculateFirstBreadKnockback(controllingEntityId, player.lastTransactionReceived.get());
player.likelyKB = player.checkManager.getKnockbackHandler().calculateRequiredKB(controllingEntityId, player.lastTransactionReceived.get());
player.likelyKB = player.checkManager.getKnockbackHandler().calculateRequiredKB(controllingEntityId, player.lastTransactionReceived.get(), false);

// The player still applies kb even if they aren't in control of the vehicle, for some reason
if (player.firstBreadKB != null) {
Expand All @@ -73,7 +73,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
}

player.firstBreadExplosion = player.checkManager.getExplosionHandler().getFirstBreadAddedExplosion(player.lastTransactionReceived.get());
player.likelyExplosions = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get());
player.likelyExplosions = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get(), false);

// Not responsible for applying knockback/explosions
player.checkManager.getExplosionHandler().forceExempt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ public void handleChangeBlock(int x, int y, int z, WrappedBlockState state) {
// https://github.com/MWHunter/Grim/issues/613
int controllingEntityId = player.compensatedEntities.getSelf().inVehicle() ? player.getRidingVehicleId() : player.entityID;
player.firstBreadKB = player.checkManager.getKnockbackHandler().calculateFirstBreadKnockback(controllingEntityId, player.lastTransactionReceived.get());
player.likelyKB = player.checkManager.getKnockbackHandler().calculateRequiredKB(controllingEntityId, player.lastTransactionReceived.get());
player.likelyKB = player.checkManager.getKnockbackHandler().calculateRequiredKB(controllingEntityId, player.lastTransactionReceived.get(), true);

player.firstBreadExplosion = player.checkManager.getExplosionHandler().getFirstBreadAddedExplosion(player.lastTransactionReceived.get());
player.likelyExplosions = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get());
player.likelyExplosions = player.checkManager.getExplosionHandler().getPossibleExplosions(player.lastTransactionReceived.get(), true);

player.updateVelocityMovementSkipping();

Expand Down

0 comments on commit 6ca7863

Please sign in to comment.