Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Fix SyncExplosionPacket desync.
Browse files Browse the repository at this point in the history
  • Loading branch information
MerchantPug committed May 18, 2024
1 parent e80321c commit deb16cb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ protected void summonExplosion(SerializableData.Instance data, Entity entity, fl
true,
data.get(blockConditionFieldKey),
indestructible,
createFire,
power,
data.get("destruction_type")
power
), entity);
} else {
Explosion explosion = new Explosion(entity.level(), entity,
Expand All @@ -154,9 +152,7 @@ protected void summonExplosion(SerializableData.Instance data, Entity entity, fl
false,
null,
false,
createFire,
power,
data.get("destruction_type")
power
), entity);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ protected void summonExplosion(SerializableData.Instance data, Entity entity, Hi
true,
data.get(blockConditionFieldKey),
indestructible,
createFire,
power,
data.get("destruction_type")), entity);
power), entity);
} else {
Explosion explosion = new Explosion(entity.level(), damageSelf ? null : entity,
null, null,
Expand All @@ -194,9 +192,7 @@ protected void summonExplosion(SerializableData.Instance data, Entity entity, Hi
false,
null,
false,
createFire,
power,
data.get("destruction_type")), entity);
power), entity);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public record SyncExplosionPacket<BI, B>(int userId,
boolean hasCalculator,
@Nullable B blockConditions,
boolean indestructible,
boolean causesFire,
float power,
Explosion.BlockInteraction interaction) implements ApugliPacketS2C {
float power) implements ApugliPacketS2C {
public static final ResourceLocation ID = Apugli.asResource("sync_explosion");

@Override
Expand All @@ -62,9 +60,7 @@ public void encode(FriendlyByteBuf buf) {
}

buf.writeBoolean(indestructible());
buf.writeBoolean(causesFire());
buf.writeFloat(power());
SerializableDataTypes.DESTRUCTION_TYPE.send(buf, interaction());
}

public static <BI, B> SyncExplosionPacket<BI, B> decode(FriendlyByteBuf buf) {
Expand All @@ -89,12 +85,9 @@ public static <BI, B> SyncExplosionPacket<BI, B> decode(FriendlyByteBuf buf) {
blockDataCondition = (B) Services.CONDITION.blockDataType().receive(buf);
}
boolean indestructible = buf.readBoolean();
boolean causesFire = buf.readBoolean();
float radius = buf.readFloat();

Explosion.BlockInteraction interaction = SerializableDataTypes.DESTRUCTION_TYPE.receive(buf);

return new SyncExplosionPacket<>(userId, x, y, z, damageModifiers, knockbackModifiers, volumeModifiers, pitchModifiers, biEntityCondition, hasCalculator, blockDataCondition, indestructible, causesFire, radius, interaction);
return new SyncExplosionPacket<>(userId, x, y, z, damageModifiers, knockbackModifiers, volumeModifiers, pitchModifiers, biEntityCondition, hasCalculator, blockDataCondition, indestructible, radius);
}

@Override
Expand All @@ -110,13 +103,12 @@ public void run() {
Level level = Minecraft.getInstance().level;
Entity entity = level.getEntity(userId);
Explosion explosion = new Explosion(level, entity,
null, createBlockConditionedExplosionDamageCalculator(blockConditions(), level, indestructible), x, y, z, power, causesFire, interaction);
null, createBlockConditionedExplosionDamageCalculator(blockConditions(), level, indestructible), x, y, z, power, false, Explosion.BlockInteraction.KEEP);
((ExplosionAccess) explosion).apugli$setExplosionDamageModifiers(damageModifiers());
((ExplosionAccess) explosion).apugli$setExplosionKnockbackModifiers(knockbackModifiers());
((ExplosionAccess) explosion).apugli$setExplosionVolumeModifiers(volumeModifiers());
((ExplosionAccess) explosion).apugli$setExplosionPitchModifiers(pitchModifiers());
((ExplosionAccess) explosion).apugli$setBiEntityPredicate(biEntityConditions());
explosion.explode();
explosion.finalizeExplosion(true);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ default void sendExplosionToClient(P power, SerializableData.Instance data, Livi
false,
null,
false,
false,
radius,
Explosion.BlockInteraction.KEEP);
radius);
if (entity instanceof ServerPlayer serverPlayer)
Services.PLATFORM.sendS2CTrackingAndSelf(packet, serverPlayer);
}
Expand Down

0 comments on commit deb16cb

Please sign in to comment.