Skip to content

Commit

Permalink
Merge pull request #16 from StellarWitch7/main
Browse files Browse the repository at this point in the history
Stop server-side logic from running on the client in ExplosionMixin.java
  • Loading branch information
ArkoSammy12 authored Aug 11, 2024
2 parents 11403d5 + 7fac992 commit f5eca77
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public abstract class ExplosionMixin implements ExplosionAccessor {
// Save the affected block states and block entities before the explosion takes effect
@Inject(method = "collectBlocksAndDamageEntities", at = @At("RETURN"))
private void collectAffectedStatesAndBlockEntities(CallbackInfo ci){
if (world.isClient())
return;

this.checkForIndirectlyAffectedPositions();
this.getAffectedBlocks().forEach(pos -> this.affectedStatesAndBlockEntities.put(pos, new Pair<>(this.world.getBlockState(pos), this.world.getBlockEntity(pos))));
this.indirectlyAffectedPositions.forEach(pos -> this.affectedStatesAndBlockEntities.put(pos, new Pair<>(this.world.getBlockState(pos), this.world.getBlockEntity(pos))));
Expand All @@ -67,6 +70,9 @@ private void collectAffectedStatesAndBlockEntities(CallbackInfo ci){
// Make sure the thread local is reset when entering and exiting Explosion#affectWorld
@Inject(method = "affectWorld", at = @At(value = "HEAD"))
private void setThreadLocals(boolean particles, CallbackInfo ci){
if (world.isClient())
return;

ExplosionUtils.DROP_BLOCK_ITEMS.set(true);
ExplosionUtils.DROP_CONTAINER_INVENTORY_ITEMS.set(true);
}
Expand All @@ -76,6 +82,9 @@ private void setThreadLocals(boolean particles, CallbackInfo ci){
// Emit an ExplosionContext object for ExplosionManagers to receive.
@Inject(method = "affectWorld", at = @At(value = "RETURN"))
private void onExplosion(boolean particles, CallbackInfo ci){
if (world.isClient())
return;

ExplosionUtils.DROP_BLOCK_ITEMS.set(true);
ExplosionUtils.DROP_CONTAINER_INVENTORY_ITEMS.set(true);
this.indirectlyAffectedPositions.removeIf(pos -> {
Expand Down

0 comments on commit f5eca77

Please sign in to comment.