diff --git a/src/main/java/ladysnake/blast/common/world/BlockFillingExplosion.java b/src/main/java/ladysnake/blast/common/world/BlockFillingExplosion.java index d24419c..4196bc8 100644 --- a/src/main/java/ladysnake/blast/common/world/BlockFillingExplosion.java +++ b/src/main/java/ladysnake/blast/common/world/BlockFillingExplosion.java @@ -1,8 +1,6 @@ package ladysnake.blast.common.world; import net.minecraft.block.BlockState; -import net.minecraft.block.FluidBlock; -import net.minecraft.block.FluidFillable; import net.minecraft.entity.Entity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -21,7 +19,7 @@ public void affectWorld(boolean particles) { for (BlockPos pos : affectedBlocks) { if (canPlace(pos)) { BlockState state = world.getBlockState(pos); - if (state.isAir() || state.getBlock() instanceof FluidBlock || state.getBlock() instanceof FluidFillable) { + if (state.isReplaceable()) { if (!world.isClient) { world.setBlockState(pos, blockStateToPlace); } diff --git a/src/main/java/ladysnake/blast/common/world/BonesburrierExplosion.java b/src/main/java/ladysnake/blast/common/world/BonesburrierExplosion.java index b1dd02f..7b3e93c 100644 --- a/src/main/java/ladysnake/blast/common/world/BonesburrierExplosion.java +++ b/src/main/java/ladysnake/blast/common/world/BonesburrierExplosion.java @@ -83,8 +83,8 @@ public void collectBlocksAndDamageEntities() { int minZ = MathHelper.floor(z - power - 1); int maxZ = MathHelper.floor(z + power + 1); Vec3d source = new Vec3d(x, y, z); - for (Entity entity : world.getOtherEntities(entity, new Box(minX, minY, minZ, maxX, maxY, maxZ))) { - if (!entity.isImmuneToExplosion(this)) { + for (Entity entity : world.getOtherEntities(null, new Box(minX, minY, minZ, maxX, maxY, maxZ))) { + if (!entity.isImmuneToExplosion(this) && ProtectionsProvider.canDamageEntity(entity, damageSource)) { double distance = Math.sqrt(entity.squaredDistanceTo(source)) / power; if (distance <= 1) { double dX = entity.getX() - x; diff --git a/src/main/java/ladysnake/blast/common/world/KnockbackExplosion.java b/src/main/java/ladysnake/blast/common/world/KnockbackExplosion.java index b04340e..191cbeb 100644 --- a/src/main/java/ladysnake/blast/common/world/KnockbackExplosion.java +++ b/src/main/java/ladysnake/blast/common/world/KnockbackExplosion.java @@ -4,6 +4,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.EntityAttributes; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleTypes; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -22,7 +23,7 @@ public void affectWorld(boolean particles) { } } for (Entity entity : affectedEntities) { - if (ProtectionsProvider.canDamageEntity(entity, damageSource)) { + if (ProtectionsProvider.canInteractEntity(entity, damageSource)) { double distance = Math.sqrt(entity.squaredDistanceTo(source)) / (getPower() * 2); if (distance <= 1.0D) { double dX = entity.getX() - this.x; @@ -33,7 +34,10 @@ public void affectWorld(boolean particles) { dX /= product; dY /= product; dZ /= product; - double strength = (1 - distance) * getExposure(source, entity) * 3; + double strength = (1 - distance) * getExposure(source, entity); + if (entity instanceof PlayerEntity player) { + getAffectedPlayers().put(player, new Vec3d(dX * strength, dY * strength, dZ * strength)); + } if (entity instanceof LivingEntity living) { strength *= 1 - living.getAttributeValue(EntityAttributes.GENERIC_EXPLOSION_KNOCKBACK_RESISTANCE); } diff --git a/src/main/java/ladysnake/blast/mixin/ExplosionMixin.java b/src/main/java/ladysnake/blast/mixin/ExplosionMixin.java index 73e36b4..4d457f5 100644 --- a/src/main/java/ladysnake/blast/mixin/ExplosionMixin.java +++ b/src/main/java/ladysnake/blast/mixin/ExplosionMixin.java @@ -5,26 +5,35 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; +import ladysnake.blast.common.util.ProtectionsProvider; import ladysnake.blast.common.world.CustomExplosion; import ladysnake.blast.common.world.EnderExplosion; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.ExperienceOrbEntity; import net.minecraft.entity.ItemEntity; +import net.minecraft.entity.damage.DamageSource; import net.minecraft.fluid.FluidState; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.BlockView; import net.minecraft.world.explosion.Explosion; import net.minecraft.world.explosion.ExplosionBehavior; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +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.ModifyArg; import java.util.Optional; @Mixin(Explosion.class) public class ExplosionMixin { + @Shadow + @Final + public DamageSource damageSource; + @WrapOperation(method = "collectBlocksAndDamageEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/explosion/ExplosionBehavior;getBlastResistance(Lnet/minecraft/world/explosion/Explosion;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/fluid/FluidState;)Ljava/util/Optional;")) private Optional blast$overrideBlastResistance(ExplosionBehavior instance, Explosion explosion, BlockView world, BlockPos pos, BlockState blockState, FluidState fluidState, Operation> original) { if (isEffect(explosion, CustomExplosion.BlockBreakEffect.AQUATIC) || isEffect(explosion, CustomExplosion.BlockBreakEffect.FROSTY)) { @@ -37,6 +46,23 @@ public class ExplosionMixin { return original.call(instance, explosion, world, pos, blockState, fluidState); } + @ModifyArg(method = "collectBlocksAndDamageEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getOtherEntities(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Box;)Ljava/util/List;")) + private Entity blast$removeOwner(Entity value) { + if ((Object) this instanceof CustomExplosion) { + return null; + } + return value; + } + + @SuppressWarnings("ConstantValue") + @ModifyExpressionValue(method = "collectBlocksAndDamageEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isImmuneToExplosion(Lnet/minecraft/world/explosion/Explosion;)Z")) + private boolean blast$protections(boolean original, @Local Entity entity) { + if ((Object) this instanceof CustomExplosion && !ProtectionsProvider.canDamageEntity(entity, damageSource)) { + return false; + } + return original; + } + @ModifyExpressionValue(method = "collectBlocksAndDamageEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/explosion/ExplosionBehavior;shouldDamage(Lnet/minecraft/world/explosion/Explosion;Lnet/minecraft/entity/Entity;)Z")) private boolean blast$customDamage(boolean original, @Local Entity entity) { if ((Object) this instanceof CustomExplosion customExplosion) {