Prevent spawning multiple sombras and prevent the altar from reactivating after successfully summoning him

This commit is contained in:
Sollace 2023-09-28 21:51:45 +01:00
parent 1654acc2c9
commit 48f9d6242c
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 10 additions and 0 deletions

View file

@ -76,6 +76,7 @@ import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@ -105,6 +106,12 @@ public class SombraEntity extends HostileEntity implements ArenaCombatant, Parti
private float currentSize;
public static void startEncounter(World world, BlockPos pos) {
if (world.getEntitiesByClass(Entity.class, new Box(pos).expand(16), e -> {
return e instanceof SombraEntity || e instanceof StormCloudEntity cloud && cloud.cursed;
}).size() > 0) {
return;
}
StormCloudEntity cloud = UEntities.STORM_CLOUD.create(world);
cloud.setPosition(pos.up(10).toCenterPos());
cloud.setSize(1);

View file

@ -4,6 +4,7 @@ import java.util.*;
import org.jetbrains.annotations.Nullable;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMultimap;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.USounds;
@ -12,6 +13,7 @@ import com.minelittlepony.unicopia.entity.*;
import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
import com.minelittlepony.unicopia.entity.effect.UEffects;
import com.minelittlepony.unicopia.entity.mob.SombraEntity;
import com.minelittlepony.unicopia.entity.mob.SpellbookEntity;
import com.minelittlepony.unicopia.entity.player.*;
import com.minelittlepony.unicopia.particle.FollowingParticleEffect;
import com.minelittlepony.unicopia.particle.ParticleUtils;
@ -201,6 +203,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
stack.decrement(1);
world.createExplosion(null, entity.getX(), entity.getY(), entity.getZ(), 0, ExplosionSourceType.NONE);
world.playSound(null, entity.getBlockPos(), USounds.ENTITY_SOMBRA_LAUGH, SoundCategory.AMBIENT, 10, 1);
world.getEntitiesByClass(SpellbookEntity.class, entity.getBoundingBox().expand(6), Predicates.alwaysTrue()).forEach(Entity::kill);
SombraEntity.startEncounter(world, entity.getBlockPos());
}