Fixed black hole behaviour

This commit is contained in:
Sollace 2021-12-24 18:37:23 +02:00
parent 17c175c8ce
commit 8ff6514306
3 changed files with 51 additions and 22 deletions

View file

@ -97,6 +97,11 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
} }
static void createBlockEntity(World world, BlockPos bpos, @Nullable Consumer<Entity> apply) { static void createBlockEntity(World world, BlockPos bpos, @Nullable Consumer<Entity> apply) {
if (world.isAir(bpos)) {
return;
}
Vec3d pos = Vec3d.ofBottomCenter(bpos); Vec3d pos = Vec3d.ofBottomCenter(bpos);
FallingBlockEntity e = new FallingBlockEntity(world, pos.x, pos.y, pos.z, world.getBlockState(bpos)); FallingBlockEntity e = new FallingBlockEntity(world, pos.x, pos.y, pos.z, world.getBlockState(bpos));
world.removeBlock(bpos, true); world.removeBlock(bpos, true);

View file

@ -23,22 +23,34 @@ public class DarkVortexSpell extends AttractiveSpell {
.with(Trait.DARKNESS, 100) .with(Trait.DARKNESS, 100)
.build(); .build();
private int accumulatedMass = 10; private int accumulatedMass = 0;
protected DarkVortexSpell(SpellType<?> type, SpellTraits traits) { protected DarkVortexSpell(SpellType<?> type, SpellTraits traits) {
super(type, traits); super(type, traits);
} }
@Override
public boolean apply(Caster<?> source) {
return toPlaceable().apply(source);
}
@Override @Override
public boolean tick(Caster<?> source, Situation situation) { public boolean tick(Caster<?> source, Situation situation) {
if (situation == Situation.BODY) {
return true;
}
if (accumulatedMass > 20) { if (accumulatedMass > 20) {
Vec3d pos = source.getOriginVector(); if (!source.isClient()) {
source.getWorld().createExplosion( Vec3d pos = source.getOriginVector();
source.getMaster(), source.getWorld().createExplosion(
MagicalDamageSource.create("super_nova"), source.getMaster(),
null, MagicalDamageSource.create("super_nova"),
pos.getX(), pos.getY(), pos.getZ(), 17, true, Explosion.DestructionType.DESTROY null,
); pos.getX(), pos.getY(), pos.getZ(), 17, true, Explosion.DestructionType.DESTROY
);
}
return false; return false;
} }
return super.tick(source, situation); return super.tick(source, situation);
@ -53,7 +65,7 @@ public class DarkVortexSpell extends AttractiveSpell {
source.addParticle(new MagicParticleEffect(getType().getColor()), p, p.subtract(pos)); source.addParticle(new MagicParticleEffect(getType().getColor()), p, p.subtract(pos));
}); });
float radius = (float)getDrawDropOffRange(source) / 2; float radius = 1 + (float)getDrawDropOffRange(source) / 2;
particlEffect.ifAbsent(getUuid(), source, spawner -> { particlEffect.ifAbsent(getUuid(), source, spawner -> {
spawner.addParticle(new SphereParticleEffect(getType().getColor(), 0.99F, radius), source.getOriginVector(), Vec3d.ZERO); spawner.addParticle(new SphereParticleEffect(getType().getColor(), 0.99F, radius), source.getOriginVector(), Vec3d.ZERO);
@ -69,9 +81,18 @@ public class DarkVortexSpell extends AttractiveSpell {
@Override @Override
protected long applyEntities(Caster<?> source) { protected long applyEntities(Caster<?> source) {
PosHelper.getAllInRegionMutable(source.getOrigin(), new Sphere(false, ((int)getDrawDropOffRange(source) / 2F))).forEach(i -> { if (!source.isClient()) {
CatapultSpell.createBlockEntity(source.getWorld(), i, null); PosHelper.getAllInRegionMutable(source.getOrigin(), new Sphere(false, 1 + ((int)getDrawDropOffRange(source) / 2F))).forEach(i -> {
}); if (!source.getWorld().isAir(i)) {
source.getWorld().breakBlock(i, false);
if (source.getWorld().random.nextInt(accumulatedMass + 1) == 0) {
accumulatedMass++;
setDirty();
}
}
});
}
return super.applyEntities(source); return super.applyEntities(source);
} }

View file

@ -127,21 +127,24 @@ public class ShieldSpell extends AbstractSpell {
return source.findAllEntitiesInRange(radius) return source.findAllEntitiesInRange(radius)
.filter(entity -> { .filter(entity -> {
return return !FriendshipBraceletItem.isComrade(source, entity)
!FriendshipBraceletItem.isComrade(source, entity) && isValidTarget(entity)
&& (entity instanceof LivingEntity
|| entity instanceof TntEntity
|| entity instanceof FallingBlockEntity
|| entity instanceof EyeOfEnderEntity
|| entity instanceof BoatEntity
|| ProjectileUtil.isFlyingProjectile(entity)
|| entity instanceof AbstractMinecartEntity)
&& !(entity instanceof ArmorStandEntity)
&& !(ownerIsValid && (Pony.equal(entity, owner) || owner.isConnectedThroughVehicle(entity))); && !(ownerIsValid && (Pony.equal(entity, owner) || owner.isConnectedThroughVehicle(entity)));
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
protected boolean isValidTarget(Entity entity) {
return (entity instanceof LivingEntity
|| entity instanceof TntEntity
|| entity instanceof FallingBlockEntity
|| entity instanceof EyeOfEnderEntity
|| entity instanceof BoatEntity
|| ProjectileUtil.isFlyingProjectile(entity)
|| entity instanceof AbstractMinecartEntity)
&& !(entity instanceof ArmorStandEntity);
}
protected long applyEntities(Caster<?> source) { protected long applyEntities(Caster<?> source) {
double radius = getDrawDropOffRange(source); double radius = getDrawDropOffRange(source);