Compare commits

..

No commits in common. "1.21" and "1.21-0.8.4-claim-fix" have entirely different histories.

2 changed files with 9 additions and 21 deletions

View file

@ -425,7 +425,7 @@ public class C4Entity extends Entity implements GeoEntity, OwnableEntity {
CustomExplosion explosion = new CustomExplosion(level(), this, CustomExplosion explosion = new CustomExplosion(level(), this,
ModDamageTypes.causeProjectileBoomDamage(level().registryAccess(), this, this.getOwner()), ExplosionConfig.C4_EXPLOSION_DAMAGE.get(), ModDamageTypes.causeProjectileBoomDamage(level().registryAccess(), this, this.getOwner()), ExplosionConfig.C4_EXPLOSION_DAMAGE.get(),
pos.x, pos.y, pos.z, ExplosionConfig.C4_EXPLOSION_RADIUS.get(), ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true, true).setDamageMultiplier(1); pos.x, pos.y, pos.z, ExplosionConfig.C4_EXPLOSION_RADIUS.get(), ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true).setDamageMultiplier(1);
explosion.explode(); explosion.explode();
EventHooks.onExplosionStart(level(), explosion); EventHooks.onExplosionStart(level(), explosion);
ParticleTool.spawnHugeExplosionParticles(level(), position()); ParticleTool.spawnHugeExplosionParticles(level(), position());

View file

@ -21,7 +21,6 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.event.EventHooks; import net.neoforged.neoforge.event.EventHooks;
@ -45,12 +44,11 @@ public class CustomExplosion extends Explosion {
private final float damage; private final float damage;
private int fireTime; private int fireTime;
private float damageMultiplier; private float damageMultiplier;
private boolean ignoreFluids;
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source,
@Nullable ExplosionDamageCalculator pDamageCalculator, @Nullable ExplosionDamageCalculator pDamageCalculator,
float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius,
BlockInteraction pBlockInteraction, ParticleOptions smallParticle, ParticleOptions bigParticle, Holder<SoundEvent> sound, boolean ignoreFluids) { BlockInteraction pBlockInteraction, ParticleOptions smallParticle, ParticleOptions bigParticle, Holder<SoundEvent> sound) {
super(pLevel, pSource, source, null, pToBlowX, pToBlowY, pToBlowZ, pRadius, false, pBlockInteraction, smallParticle, bigParticle, sound); super(pLevel, pSource, source, null, pToBlowX, pToBlowY, pToBlowZ, pRadius, false, pBlockInteraction, smallParticle, bigParticle, sound);
this.level = pLevel; this.level = pLevel;
@ -62,26 +60,21 @@ public class CustomExplosion extends Explosion {
this.y = pToBlowY; this.y = pToBlowY;
this.z = pToBlowZ; this.z = pToBlowZ;
this.damage = damage; this.damage = damage;
this.ignoreFluids = ignoreFluids;
} }
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source,
@Nullable ExplosionDamageCalculator pDamageCalculator, @Nullable ExplosionDamageCalculator pDamageCalculator,
float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius,
BlockInteraction pBlockInteraction, boolean ignoreFluids) { BlockInteraction pBlockInteraction) {
this(pLevel, pSource, source, pDamageCalculator, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE, ignoreFluids); this(pLevel, pSource, source, pDamageCalculator, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE);
} }
public CustomExplosion(Level pLevel, @Nullable Entity pSource, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, BlockInteraction pBlockInteraction) { public CustomExplosion(Level pLevel, @Nullable Entity pSource, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, BlockInteraction pBlockInteraction) {
this(pLevel, pSource, null, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction, false); this(pLevel, pSource, null, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction);
} }
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, Explosion.BlockInteraction pBlockInteraction, boolean vanillaExplode) { public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, Explosion.BlockInteraction pBlockInteraction, boolean vanillaExplode) {
this(pLevel, pSource, source, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction, false, false); this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction);
}
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, Explosion.BlockInteraction pBlockInteraction, boolean vanillaExplode, boolean ignoreFluids) {
this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction, ignoreFluids);
if (pLevel instanceof ServerLevel && vanillaExplode) { if (pLevel instanceof ServerLevel && vanillaExplode) {
pLevel.explode(source == null ? null : source.getEntity(), pToBlowX, pToBlowY, pToBlowZ, 0.4f * pRadius, ExplosionConfig.EXPLOSION_DESTROY.get() ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE); pLevel.explode(source == null ? null : source.getEntity(), pToBlowX, pToBlowY, pToBlowZ, 0.4f * pRadius, ExplosionConfig.EXPLOSION_DESTROY.get() ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE);
@ -91,13 +84,13 @@ public class CustomExplosion extends Explosion {
} }
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, Explosion.BlockInteraction pBlockInteraction) { public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, Explosion.BlockInteraction pBlockInteraction) {
this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction, false); this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction);
ShakeClientMessage.sendToNearbyPlayers(level, pToBlowX, pToBlowY, pToBlowZ, 4 * radius, 5 + 0.02 * damage, 0.75 * pRadius, 4 + 0.02 * damage); ShakeClientMessage.sendToNearbyPlayers(level, pToBlowX, pToBlowY, pToBlowZ, 4 * radius, 5 + 0.02 * damage, 0.75 * pRadius, 4 + 0.02 * damage);
} }
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius) { public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius) {
this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, BlockInteraction.KEEP, false); this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, BlockInteraction.KEEP);
ShakeClientMessage.sendToNearbyPlayers(level, pToBlowX, pToBlowY, pToBlowZ, radius, 20 + 0.02 * damage, pRadius, 10 + 0.03 * damage); ShakeClientMessage.sendToNearbyPlayers(level, pToBlowX, pToBlowY, pToBlowZ, radius, 20 + 0.02 * damage, pRadius, 10 + 0.03 * damage);
} }
@ -145,12 +138,7 @@ public class CustomExplosion extends Explosion {
break; break;
} }
Optional<Float> optional; Optional<Float> optional = this.damageCalculator.getBlockExplosionResistance(this, this.level, blockpos, blockstate, fluidstate);
if (this.ignoreFluids) {
optional = this.damageCalculator.getBlockExplosionResistance(this, this.level, blockpos, blockstate, Fluids.EMPTY.defaultFluidState());
} else {
optional = this.damageCalculator.getBlockExplosionResistance(this, this.level, blockpos, blockstate, fluidstate);
}
if (optional.isPresent()) { if (optional.isPresent()) {
f -= (optional.get() + 1F) * 0.3F; f -= (optional.get() + 1F) * 0.3F;
} }