mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Prevent spawning multiple sombras and prevent the altar from reactivating after successfully summoning him
This commit is contained in:
parent
1654acc2c9
commit
48f9d6242c
2 changed files with 10 additions and 0 deletions
|
@ -76,6 +76,7 @@ import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
@ -105,6 +106,12 @@ public class SombraEntity extends HostileEntity implements ArenaCombatant, Parti
|
||||||
private float currentSize;
|
private float currentSize;
|
||||||
|
|
||||||
public static void startEncounter(World world, BlockPos pos) {
|
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);
|
StormCloudEntity cloud = UEntities.STORM_CLOUD.create(world);
|
||||||
cloud.setPosition(pos.up(10).toCenterPos());
|
cloud.setPosition(pos.up(10).toCenterPos());
|
||||||
cloud.setSize(1);
|
cloud.setSize(1);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.*;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
import com.minelittlepony.unicopia.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.USounds;
|
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.damage.UDamageTypes;
|
||||||
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
||||||
import com.minelittlepony.unicopia.entity.mob.SombraEntity;
|
import com.minelittlepony.unicopia.entity.mob.SombraEntity;
|
||||||
|
import com.minelittlepony.unicopia.entity.mob.SpellbookEntity;
|
||||||
import com.minelittlepony.unicopia.entity.player.*;
|
import com.minelittlepony.unicopia.entity.player.*;
|
||||||
import com.minelittlepony.unicopia.particle.FollowingParticleEffect;
|
import com.minelittlepony.unicopia.particle.FollowingParticleEffect;
|
||||||
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||||
|
@ -201,6 +203,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
|
||||||
stack.decrement(1);
|
stack.decrement(1);
|
||||||
world.createExplosion(null, entity.getX(), entity.getY(), entity.getZ(), 0, ExplosionSourceType.NONE);
|
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.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());
|
SombraEntity.startEncounter(world, entity.getBlockPos());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue