-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: ellieisjelly <[email protected]>
- Loading branch information
1 parent
a27efa7
commit 6ca75fc
Showing
3 changed files
with
16 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 7 additions & 11 deletions
18
src/main/java/us/potatoboy/skywars/mixin/ExplosionMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,26 @@ | ||
package us.potatoboy.skywars.mixin; | ||
|
||
import net.minecraft.entity.Entity; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.explosion.Explosion; | ||
import org.spongepowered.asm.mixin.Final; | ||
import net.minecraft.world.explosion.ExplosionBehavior; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
import us.potatoboy.skywars.SkyWars; | ||
import xyz.nucleoid.plasmid.game.manager.GameSpaceManager; | ||
|
||
@Mixin(Explosion.class) | ||
@Mixin(ExplosionBehavior.class) | ||
public abstract class ExplosionMixin { | ||
@Final | ||
@Shadow | ||
private World world; | ||
|
||
@ModifyConstant(method = "collectBlocksAndDamageEntities", constant = @Constant(doubleValue = 7.0)) | ||
private double reduceDamage(double original) { | ||
var gameSpace = GameSpaceManager.get().byWorld(this.world); | ||
|
||
@ModifyConstant(method = "calculateDamage", constant = @Constant(doubleValue = 7.0)) | ||
private double reduceDamage(double original, Explosion explosion, Entity entity) { | ||
var gameSpace = GameSpaceManager.get().byWorld(entity.getWorld()); | ||
|
||
if (gameSpace != null && gameSpace.getBehavior().testRule(SkyWars.REDUCED_EXPLOSION_DAMAGE) == ActionResult.SUCCESS) { | ||
return 4.0D; | ||
} | ||
|
||
return original; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters