Skip to content

Commit

Permalink
Disable Lithium's explosion mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
ArkoSammy12 committed Dec 9, 2024
1 parent 8618a9a commit 251bda2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package xd.arkosammy.creeperhealing.mixin;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
Expand All @@ -18,8 +20,6 @@
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xd.arkosammy.creeperhealing.ExplosionManagerRegistrar;
import xd.arkosammy.creeperhealing.config.ConfigSettings;
import xd.arkosammy.creeperhealing.config.ConfigUtils;
Expand Down Expand Up @@ -113,19 +113,18 @@ private List<BlockPos> collectAffectedBlocks(List<BlockPos> original) {
return original;
}

// Make sure the thread local is reset when entering and exiting Explosion#affectWorld
@Inject(method = "destroyBlocks", at = @At(value = "HEAD"))
private void setThreadLocals(List<BlockPos> positions, CallbackInfo ci) {
@WrapMethod(method = "destroyBlocks")
private void onDestroyBlocks(List<BlockPos> positions, Operation<Void> original) {
// Make sure the thread local is reset when entering and exiting ExplosionImpl#destroyBlocks
// If adding more logic here, remember to check logical server side with World#isClient
ExplosionUtils.DROP_BLOCK_ITEMS.set(true);
ExplosionUtils.DROP_CONTAINER_INVENTORY_ITEMS.set(true);
}

// Filter out indirectly affected positions whose corresponding state did not change before and after the explosion.
// Filter out entries in the affected states and block entities map with block position keys not in the affected positions.
// Emit an ExplosionContext object for ExplosionManagers to receive.
@Inject(method = "destroyBlocks", at = @At(value = "RETURN"))
private void emitExplosionContext(List<BlockPos> positions, CallbackInfo ci) {
original.call(positions);

// Filter out indirectly affected positions whose corresponding state did not change before and after the explosion.
// Filter out entries in the affected states and block entities map with block position keys not in the affected positions.
// Emit an ExplosionContext object for ExplosionManagers to receive.
ExplosionUtils.DROP_BLOCK_ITEMS.set(true);
ExplosionUtils.DROP_CONTAINER_INVENTORY_ITEMS.set(true);
if ((this.getWorld().isClient() || !(this.getWorld() instanceof ServerWorld serverWorld)) || !this.creeperhealing$shouldHeal()) {
Expand Down Expand Up @@ -181,6 +180,7 @@ private void emitExplosionContext(List<BlockPos> positions, CallbackInfo ci) {
this.vanillaAffectedPositions.clear();
this.affectedStatesAndBlockEntities.clear();
this.indirectlyAffectedPositions.clear();

}

// Recursively find indirectly affected positions connected to the main affected positions.
Expand Down Expand Up @@ -240,5 +240,4 @@ private void checkNeighbors(int maxCheckDepth, BlockPos currentPosition, Set<Blo
}
}


}
7 changes: 6 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "creeperhealing",
"version": "${version}",
"name": "Creeper Healing",
"description": "A server and client side, customizable Fabric mod to automatically and naturally heal Creeper explosions (and other types of explosions!).",
"description": "A server side, customizable Fabric mod to automatically and naturally heal Creeper explosions (and other types of explosions!).",
"authors": [
"ArkoSammy12"
],
Expand All @@ -28,5 +28,10 @@
"java": ">=21",
"fabric-api": "*",
"monkeyconfig" : "*"
},
"custom": {
"lithium:options": {
"mixin.world.explosions": false
}
}
}

0 comments on commit 251bda2

Please sign in to comment.