mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 23:27:59 +01:00
Fixed black hole behaviour
This commit is contained in:
parent
17c175c8ce
commit
8ff6514306
3 changed files with 51 additions and 22 deletions
|
@ -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);
|
||||||
|
|
|
@ -23,15 +23,26 @@ 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) {
|
||||||
|
if (!source.isClient()) {
|
||||||
Vec3d pos = source.getOriginVector();
|
Vec3d pos = source.getOriginVector();
|
||||||
source.getWorld().createExplosion(
|
source.getWorld().createExplosion(
|
||||||
source.getMaster(),
|
source.getMaster(),
|
||||||
|
@ -39,6 +50,7 @@ public class DarkVortexSpell extends AttractiveSpell {
|
||||||
null,
|
null,
|
||||||
pos.getX(), pos.getY(), pos.getZ(), 17, true, Explosion.DestructionType.DESTROY
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,19 +127,22 @@ 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
|
&& !(ownerIsValid && (Pony.equal(entity, owner) || owner.isConnectedThroughVehicle(entity)));
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isValidTarget(Entity entity) {
|
||||||
|
return (entity instanceof LivingEntity
|
||||||
|| entity instanceof TntEntity
|
|| entity instanceof TntEntity
|
||||||
|| entity instanceof FallingBlockEntity
|
|| entity instanceof FallingBlockEntity
|
||||||
|| entity instanceof EyeOfEnderEntity
|
|| entity instanceof EyeOfEnderEntity
|
||||||
|| entity instanceof BoatEntity
|
|| entity instanceof BoatEntity
|
||||||
|| ProjectileUtil.isFlyingProjectile(entity)
|
|| ProjectileUtil.isFlyingProjectile(entity)
|
||||||
|| entity instanceof AbstractMinecartEntity)
|
|| entity instanceof AbstractMinecartEntity)
|
||||||
&& !(entity instanceof ArmorStandEntity)
|
&& !(entity instanceof ArmorStandEntity);
|
||||||
&& !(ownerIsValid && (Pony.equal(entity, owner) || owner.isConnectedThroughVehicle(entity)));
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long applyEntities(Caster<?> source) {
|
protected long applyEntities(Caster<?> source) {
|
||||||
|
|
Loading…
Reference in a new issue