Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MoriyaShiine committed Oct 18, 2024
1 parent 1141bc8 commit 2f312ff
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void explode() {
ticksUntilRemoval = 1;
CustomExplosion explosion = getExplosion();
explosion.collectBlocksAndDamageEntities();
explosion.affectWorld(true);
explosion.affectWorld(getWorld().isClient);
if (getWorld() instanceof ServerWorld serverWorld) {
for (ServerPlayerEntity player : PlayerLookup.world(serverWorld)) {
if (player.squaredDistanceTo(getX(), getY(), getZ()) < 4096) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public BonesburrierEntity(EntityType<? extends BombEntity> entityType, World wor
public void explode() {
CustomExplosion explosion = new BonesburrierExplosion(getWorld(), this, getX(), getBodyY(0.0625), getZ(), getExplosionRadius(), Explosion.DestructionType.DESTROY);
explosion.collectBlocksAndDamageEntities();
explosion.affectWorld(true);
explosion.affectWorld(getWorld().isClient);
getWorld().playSound(null, getX(), getBodyY(0.0625), getZ(), SoundEvents.ENTITY_WITHER_BREAK_BLOCK, SoundCategory.BLOCKS, 5, 1);
remove(RemovalReason.DISCARDED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void explode() {
if (getWorld().getBlockState(mutable).getBlock().getBlastResistance() < 1200) {
CustomExplosion explosion = new CustomExplosion(getWorld(), this, mutable.getX() + 0.5, mutable.getY() + 0.5, mutable.getZ() + 0.5, getExplosionRadius(), CustomExplosion.BlockBreakEffect.FROSTY, Explosion.DestructionType.DESTROY);
explosion.collectBlocksAndDamageEntities();
explosion.affectWorld(true);
explosion.affectWorld(getWorld().isClient);
} else {
break;
}
Expand All @@ -38,7 +38,7 @@ public void explode() {
if (getWorld().getBlockState(mutable).getBlock().getBlastResistance() < 1200) {
CustomExplosion explosion = new CustomExplosion(getWorld(), this, mutable.getX() + 0.5, mutable.getY() + 0.5, mutable.getZ() + 0.5, 1f, null, Explosion.DestructionType.DESTROY);
explosion.collectBlocksAndDamageEntities();
explosion.affectWorld(true);
explosion.affectWorld(getWorld().isClient);
} else {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void explode() {
}
CustomExplosion explosion = getExplosion();
explosion.collectBlocksAndDamageEntities();
explosion.affectWorld(true);
explosion.affectWorld(getWorld().isClient);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void explode() {
}
CustomExplosion explosion = getExplosion();
explosion.collectBlocksAndDamageEntities();
explosion.affectWorld(true);
explosion.affectWorld(getWorld().isClient);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void explode() {
if (getWorld().getBlockState(mutable).getBlock().getBlastResistance() < 1200) {
CustomExplosion explosion = new CustomExplosion(getWorld(), this, mutable.getX() + 0.5, mutable.getY() + 0.5, mutable.getZ() + 0.5, getExplosionRadius(), null, Explosion.DestructionType.DESTROY);
explosion.collectBlocksAndDamageEntities();
explosion.affectWorld(true);
explosion.affectWorld(getWorld().isClient);
} else {
break;
}
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/ladysnake/blast/common/world/EnderExplosion.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public void affectWorld(boolean particles) {
if (canExplode(pos)) {
BlockState state = world.getBlockState(pos);
if (!state.isAir()) {
if (particles) {
for (int x = 0; x <= 1; x += PARTICLE_DISTANCE) {
for (int y = 0; y <= 1; y += PARTICLE_DISTANCE) {
for (int z = 0; z <= 1; z += PARTICLE_DISTANCE) {
world.addParticle(ParticleTypes.REVERSE_PORTAL, pos.getX() + x, pos.getY() + y, pos.getZ() + z, 0, 0, 0);
}
}
}
}
world.getProfiler().push("explosion_blocks");
if (world instanceof ServerWorld serverWorld) {
if (state.getBlock().shouldDropItemsOnExplosion(this)) {
Expand All @@ -48,14 +57,6 @@ public void affectWorld(boolean particles) {
state.getDroppedStacks(getBuilder(serverWorld, pos, stack, world.getBlockEntity(pos) != null ? world.getBlockEntity(pos) : null)).forEach(droppedStack -> tryMergeStack(destroyedBlocks, droppedStack, source));
}
world.setBlockState(pos, Blocks.AIR.getDefaultState());
} else {
for (int x = 0; x <= 1; x += PARTICLE_DISTANCE) {
for (int y = 0; y <= 1; y += PARTICLE_DISTANCE) {
for (int z = 0; z <= 1; z += PARTICLE_DISTANCE) {
world.addParticle(ParticleTypes.REVERSE_PORTAL, pos.getX() + x, pos.getY() + y, pos.getZ() + z, 0, 0, 0);
}
}
}
}
state.getBlock().onDestroyedByExplosion(world, pos, this);
world.getProfiler().pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public KnockbackExplosion(World world, Entity entity, double x, double y, double

@Override
public void affectWorld(boolean particles) {
Vec3d source = new Vec3d(x, y, z);
collectEntities();
if (world.isClient) {
if (particles) {
for (int i = 0; i < 500; i++) {
world.addParticle(ParticleTypes.SNEEZE, this.x, this.y, this.z, this.random.nextGaussian() / 5, this.random.nextGaussian() / 5, this.random.nextGaussian() / 5);
}
}
Vec3d source = new Vec3d(x, y, z);
for (Entity entity : affectedEntities) {
if (ProtectionsProvider.canDamageEntity(entity, damageSource)) {
double distance = Math.sqrt(entity.squaredDistanceTo(source)) / (getPower() * 2);
Expand Down

0 comments on commit 2f312ff

Please sign in to comment.