| 1 | package net.minecraft.world.level.block.entity.trialspawner;
|
| 2 |
|
| 3 | import com.google.common.annotations.VisibleForTesting;
|
| 4 | import com.mojang.logging.LogUtils;
|
| 5 | import com.mojang.serialization.Codec;
|
| 6 | import com.mojang.serialization.MapCodec;
|
| 7 | import com.mojang.serialization.codecs.RecordCodecBuilder;
|
| 8 | import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
| 9 | import java.util.Optional;
|
| 10 | import java.util.UUID;
|
| 11 | import net.minecraft.core.BlockPos;
|
| 12 | import net.minecraft.core.Direction;
|
| 13 | import net.minecraft.core.Holder;
|
| 14 | import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
| 15 | import net.minecraft.core.particles.ParticleOptions;
|
| 16 | import net.minecraft.core.particles.ParticleTypes;
|
| 17 | import net.minecraft.core.particles.SimpleParticleType;
|
| 18 | import net.minecraft.resources.ResourceKey;
|
| 19 | import net.minecraft.server.level.ServerLevel;
|
| 20 | import net.minecraft.sounds.SoundEvent;
|
| 21 | import net.minecraft.sounds.SoundEvents;
|
| 22 | import net.minecraft.sounds.SoundSource;
|
| 23 | import net.minecraft.util.ExtraCodecs;
|
| 24 | import net.minecraft.util.Mth;
|
| 25 | import net.minecraft.util.ProblemReporter;
|
| 26 | import net.minecraft.util.RandomSource;
|
| 27 | import net.minecraft.world.Difficulty;
|
| 28 | import net.minecraft.world.entity.Entity;
|
| 29 | import net.minecraft.world.entity.EntitySpawnReason;
|
| 30 | import net.minecraft.world.entity.EntityType;
|
| 31 | import net.minecraft.world.entity.Mob;
|
| 32 | import net.minecraft.world.entity.SpawnPlacements;
|
| 33 | import net.minecraft.world.item.ItemStack;
|
| 34 | import net.minecraft.world.item.component.TypedEntityData;
|
| 35 | import net.minecraft.world.level.ClipContext;
|
| 36 | import net.minecraft.world.level.Level;
|
| 37 | import net.minecraft.world.level.SpawnData;
|
| 38 | import net.minecraft.world.level.block.TrialSpawnerBlock;
|
| 39 | import net.minecraft.world.level.gameevent.GameEvent;
|
| 40 | import net.minecraft.world.level.gamerules.GameRules;
|
| 41 | import net.minecraft.world.level.storage.TagValueInput;
|
| 42 | import net.minecraft.world.level.storage.ValueInput;
|
| 43 | import net.minecraft.world.level.storage.ValueOutput;
|
| 44 | import net.minecraft.world.level.storage.loot.LootParams;
|
| 45 | import net.minecraft.world.level.storage.loot.LootTable;
|
| 46 | import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
| 47 | import net.minecraft.world.phys.BlockHitResult;
|
| 48 | import net.minecraft.world.phys.HitResult;
|
| 49 | import net.minecraft.world.phys.Vec3;
|
| 50 | import net.minecraft.world.phys.shapes.CollisionContext;
|
| 51 | import org.slf4j.Logger;
|
| 52 |
|
| 53 | public final class TrialSpawner {
|
| 54 | private static final Logger LOGGER = LogUtils.getLogger();
|
| 55 | public static final int DETECT_PLAYER_SPAWN_BUFFER = 40;
|
| 56 | private static final int DEFAULT_TARGET_COOLDOWN_LENGTH = 36000;
|
| 57 | private static final int DEFAULT_PLAYER_SCAN_RANGE = 14;
|
| 58 | private static final int MAX_MOB_TRACKING_DISTANCE = 47;
|
| 59 | private static final int MAX_MOB_TRACKING_DISTANCE_SQR = Mth.square(47);
|
| 60 | private static final float SPAWNING_AMBIENT_SOUND_CHANCE = 0.02F;
|
| 61 | private final TrialSpawnerStateData data = new TrialSpawnerStateData();
|
| 62 | private TrialSpawner.FullConfig config;
|
| 63 | private final TrialSpawner.StateAccessor stateAccessor;
|
| 64 | private PlayerDetector playerDetector;
|
| 65 | private final PlayerDetector.EntitySelector entitySelector;
|
| 66 | private boolean overridePeacefulAndMobSpawnRule;
|
| 67 | private boolean isOminous;
|
| 68 |
|
| 69 | public TrialSpawner(
|
| 70 | final TrialSpawner.FullConfig config,
|
| 71 | final TrialSpawner.StateAccessor stateAccessor,
|
| 72 | final PlayerDetector playerDetector,
|
| 73 | final PlayerDetector.EntitySelector entitySelector
|
| 74 | ) {
|
| 75 | this.config = config;
|
| 76 | this.stateAccessor = stateAccessor;
|
| 77 | this.playerDetector = playerDetector;
|
| 78 | this.entitySelector = entitySelector;
|
| 79 | }
|
| 80 |
|
| 81 | public TrialSpawnerConfig activeConfig() {
|
| 82 | return this.isOminous ? this.config.ominous().value() : this.config.normal.value();
|
| 83 | }
|
| 84 |
|
| 85 | public TrialSpawnerConfig normalConfig() {
|
| 86 | return this.config.normal.value();
|
| 87 | }
|
| 88 |
|
| 89 | public TrialSpawnerConfig ominousConfig() {
|
| 90 | return this.config.ominous.value();
|
| 91 | }
|
| 92 |
|
| 93 | public void load(final ValueInput input) {
|
| 94 | input.read(TrialSpawnerStateData.Packed.MAP_CODEC).ifPresent(this.data::apply);
|
| 95 | this.config = input.read(TrialSpawner.FullConfig.MAP_CODEC).orElse(TrialSpawner.FullConfig.DEFAULT);
|
| 96 | }
|
| 97 |
|
| 98 | public void store(final ValueOutput output) {
|
| 99 | output.store(TrialSpawnerStateData.Packed.MAP_CODEC, this.data.pack());
|
| 100 | output.store(TrialSpawner.FullConfig.MAP_CODEC, this.config);
|
| 101 | }
|
| 102 |
|
| 103 | public void applyOminous(final ServerLevel level, final BlockPos spawnerPos) {
|
| 104 | level.setBlockAndUpdate(spawnerPos, level.getBlockState(spawnerPos).setValue(TrialSpawnerBlock.OMINOUS, true));
|
| 105 | level.levelEvent(3020, spawnerPos, 1);
|
| 106 | this.isOminous = true;
|
| 107 | this.data.resetAfterBecomingOminous(this, level);
|
| 108 | }
|
| 109 |
|
| 110 | public void removeOminous(final ServerLevel level, final BlockPos spawnerPos) {
|
| 111 | level.setBlockAndUpdate(spawnerPos, level.getBlockState(spawnerPos).setValue(TrialSpawnerBlock.OMINOUS, false));
|
| 112 | this.isOminous = false;
|
| 113 | }
|
| 114 |
|
| 115 | public boolean isOminous() {
|
| 116 | return this.isOminous;
|
| 117 | }
|
| 118 |
|
| 119 | public int getTargetCooldownLength() {
|
| 120 | return this.config.targetCooldownLength;
|
| 121 | }
|
| 122 |
|
| 123 | public int getRequiredPlayerRange() {
|
| 124 | return this.config.requiredPlayerRange;
|
| 125 | }
|
| 126 |
|
| 127 | public TrialSpawnerState getState() {
|
| 128 | return this.stateAccessor.getState();
|
| 129 | }
|
| 130 |
|
| 131 | public TrialSpawnerStateData getStateData() {
|
| 132 | return this.data;
|
| 133 | }
|
| 134 |
|
| 135 | public void setState(final Level level, final TrialSpawnerState state) {
|
| 136 | this.stateAccessor.setState(level, state);
|
| 137 | }
|
| 138 |
|
| 139 | public void markUpdated() {
|
| 140 | this.stateAccessor.markUpdated();
|
| 141 | }
|
| 142 |
|
| 143 | public PlayerDetector getPlayerDetector() {
|
| 144 | return this.playerDetector;
|
| 145 | }
|
| 146 |
|
| 147 | public PlayerDetector.EntitySelector getEntitySelector() {
|
| 148 | return this.entitySelector;
|
| 149 | }
|
| 150 |
|
| 151 | public boolean canSpawnInLevel(final ServerLevel level) {
|
| 152 | if (!level.getGameRules().get(GameRules.SPAWNER_BLOCKS_WORK)) {
|
| 153 | return false;
|
| 154 | } else if (this.overridePeacefulAndMobSpawnRule) {
|
| 155 | return true;
|
| 156 | } else {
|
| 157 | return level.getDifficulty() == Difficulty.PEACEFUL ? false : level.getGameRules().get(GameRules.SPAWN_MOBS);
|
| 158 | }
|
| 159 | }
|
| 160 |
|
| 161 | public Optional<UUID> spawnMob(final ServerLevel level, final BlockPos spawnerPos) {
|
| 162 | RandomSource random = level.getRandom();
|
| 163 | SpawnData nextSpawnData = this.data.getOrCreateNextSpawnData(this, level.getRandom());
|
| 164 |
|
| 165 | try (ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(() -> "spawner@" + spawnerPos, LOGGER)) {
|
| 166 | ValueInput input = TagValueInput.create(reporter, level.registryAccess(), nextSpawnData.entityToSpawn());
|
| 167 | Optional<EntityType<?>> entityType = EntityType.by(input);
|
| 168 | if (entityType.isEmpty()) {
|
| 169 | return Optional.empty();
|
| 170 | }
|
| 171 |
|
| 172 | Vec3 spawnPos = input.read("Pos", Vec3.CODEC)
|
| 173 | .orElseGet(
|
| 174 | () -> {
|
| 175 | TrialSpawnerConfig activeConfig = this.activeConfig();
|
| 176 | return new Vec3(
|
| 177 | spawnerPos.getX() + (random.nextDouble() - random.nextDouble()) * activeConfig.spawnRange() + 0.5,
|
| 178 | spawnerPos.getY() + random.nextInt(3) - 1,
|
| 179 | spawnerPos.getZ() + (random.nextDouble() - random.nextDouble()) * activeConfig.spawnRange() + 0.5
|
| 180 | );
|
| 181 | }
|
| 182 | );
|
| 183 | if (!level.noCollision(entityType.get().getSpawnAABB(spawnPos.x, spawnPos.y, spawnPos.z))) {
|
| 184 | return Optional.empty();
|
| 185 | }
|
| 186 |
|
| 187 | if (!inLineOfSight(level, Vec3.atCenterOf(spawnerPos), spawnPos)) {
|
| 188 | return Optional.empty();
|
| 189 | }
|
| 190 |
|
| 191 | BlockPos spawnBlockPos = BlockPos.containing(spawnPos);
|
| 192 | if (!SpawnPlacements.checkSpawnRules(entityType.get(), level, EntitySpawnReason.TRIAL_SPAWNER, spawnBlockPos, level.getRandom())) {
|
| 193 | return Optional.empty();
|
| 194 | }
|
| 195 |
|
| 196 | if (nextSpawnData.getCustomSpawnRules().isPresent()) {
|
| 197 | SpawnData.CustomSpawnRules customSpawnRules = nextSpawnData.getCustomSpawnRules().get();
|
| 198 | if (!customSpawnRules.isValidPosition(spawnBlockPos, level)) {
|
| 199 | return Optional.empty();
|
| 200 | }
|
| 201 | }
|
| 202 |
|
| 203 | Entity entity = EntityType.loadEntityRecursive(input, level, EntitySpawnReason.TRIAL_SPAWNER, e -> {
|
| 204 | e.snapTo(spawnPos.x, spawnPos.y, spawnPos.z, random.nextFloat() * 360.0F, 0.0F);
|
| 205 | return e;
|
| 206 | });
|
| 207 | if (entity == null) {
|
| 208 | return Optional.empty();
|
| 209 | }
|
| 210 |
|
| 211 | if (entity instanceof Mob mob) {
|
| 212 | if (!mob.checkSpawnObstruction(level)) {
|
| 213 | return Optional.empty();
|
| 214 | }
|
| 215 |
|
| 216 | boolean hasNoConfiguration = nextSpawnData.getEntityToSpawn().size() == 1 && nextSpawnData.getEntityToSpawn().getString("id").isPresent();
|
| 217 | if (hasNoConfiguration) {
|
| 218 | mob.finalizeSpawn(level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.TRIAL_SPAWNER, null);
|
| 219 | }
|
| 220 |
|
| 221 | mob.setPersistenceRequired();
|
| 222 | nextSpawnData.getEquipment().ifPresent(mob::equip);
|
| 223 | }
|
| 224 |
|
| 225 | if (!level.tryAddFreshEntityWithPassengers(entity)) {
|
| 226 | return Optional.empty();
|
| 227 | }
|
| 228 |
|
| 229 | TrialSpawner.FlameParticle flameParticle = this.isOminous ? TrialSpawner.FlameParticle.OMINOUS : TrialSpawner.FlameParticle.NORMAL;
|
| 230 | level.levelEvent(3011, spawnerPos, flameParticle.encode());
|
| 231 | level.levelEvent(3012, spawnBlockPos, flameParticle.encode());
|
| 232 | level.gameEvent(entity, GameEvent.ENTITY_PLACE, spawnBlockPos);
|
| 233 | return Optional.of(entity.getUUID());
|
| 234 | }
|
| 235 | }
|
| 236 |
|
| 237 | public void ejectReward(final ServerLevel level, final BlockPos pos, final ResourceKey<LootTable> ejectingLootTable) {
|
| 238 | LootTable lootTable = level.getServer().reloadableRegistries().getLootTable(ejectingLootTable);
|
| 239 | LootParams params = new LootParams.Builder(level).create(LootContextParamSets.EMPTY);
|
| 240 | ObjectArrayList<ItemStack> lootDrops = lootTable.getRandomItems(params);
|
| 241 | if (!lootDrops.isEmpty()) {
|
| 242 | for (ItemStack item : lootDrops) {
|
| 243 | DefaultDispenseItemBehavior.spawnItem(level, item, 2, Direction.UP, Vec3.atBottomCenterOf(pos).relative(Direction.UP, 1.2));
|
| 244 | }
|
| 245 |
|
| 246 | level.levelEvent(3014, pos, 0);
|
| 247 | }
|
| 248 | }
|
| 249 |
|
| 250 | public void tickClient(final Level level, final BlockPos spawnerPos, final boolean isOminous) {
|
| 251 | TrialSpawnerState currentState = this.getState();
|
| 252 | currentState.emitParticles(level, spawnerPos, isOminous);
|
| 253 | if (currentState.hasSpinningMob()) {
|
| 254 | double spawnDelay = Math.max(0L, this.data.nextMobSpawnsAt - level.getGameTime());
|
| 255 | this.data.oSpin = this.data.spin;
|
| 256 | this.data.spin = (this.data.spin + currentState.spinningMobSpeed() / (spawnDelay + 200.0)) % 360.0;
|
| 257 | }
|
| 258 |
|
| 259 | if (currentState.isCapableOfSpawning()) {
|
| 260 | RandomSource random = level.getRandom();
|
| 261 | if (random.nextFloat() <= 0.02F) {
|
| 262 | SoundEvent ambientSound = isOminous ? SoundEvents.TRIAL_SPAWNER_AMBIENT_OMINOUS : SoundEvents.TRIAL_SPAWNER_AMBIENT;
|
| 263 | level.playLocalSound(spawnerPos, ambientSound, SoundSource.BLOCKS, random.nextFloat() * 0.25F + 0.75F, random.nextFloat() + 0.5F, false);
|
| 264 | }
|
| 265 | }
|
| 266 | }
|
| 267 |
|
| 268 | public void tickServer(final ServerLevel serverLevel, final BlockPos spawnerPos, final boolean isOminous) {
|
| 269 | this.isOminous = isOminous;
|
| 270 | TrialSpawnerState currentState = this.getState();
|
| 271 | if (this.data.currentMobs.removeIf(id -> shouldMobBeUntracked(serverLevel, spawnerPos, id))) {
|
| 272 | this.data.nextMobSpawnsAt = serverLevel.getGameTime() + this.activeConfig().ticksBetweenSpawn();
|
| 273 | }
|
| 274 |
|
| 275 | TrialSpawnerState nextState = currentState.tickAndGetNext(spawnerPos, this, serverLevel);
|
| 276 | if (nextState != currentState) {
|
| 277 | this.setState(serverLevel, nextState);
|
| 278 | }
|
| 279 | }
|
| 280 |
|
| 281 | private static boolean shouldMobBeUntracked(final ServerLevel serverLevel, final BlockPos spawnerPos, final UUID id) {
|
| 282 | Entity entity = serverLevel.getEntity(id);
|
| 283 | return entity == null
|
| 284 | || !entity.isAlive()
|
| 285 | || !entity.level().dimension().equals(serverLevel.dimension())
|
| 286 | || entity.blockPosition().distSqr(spawnerPos) > MAX_MOB_TRACKING_DISTANCE_SQR;
|
| 287 | }
|
| 288 |
|
| 289 | private static boolean inLineOfSight(final Level level, final Vec3 origin, final Vec3 dest) {
|
| 290 | BlockHitResult hitResult = level.clip(new ClipContext(dest, origin, ClipContext.Block.VISUAL, ClipContext.Fluid.NONE, CollisionContext.empty()));
|
| 291 | return hitResult.getBlockPos().equals(BlockPos.containing(origin)) || hitResult.getType() == HitResult.Type.MISS;
|
| 292 | }
|
| 293 |
|
| 294 | public static void addSpawnParticles(final Level level, final BlockPos pos, final RandomSource random, final SimpleParticleType particleType) {
|
| 295 | for (int i = 0; i < 20; i++) {
|
| 296 | double xP = pos.getX() + 0.5 + (random.nextDouble() - 0.5) * 2.0;
|
| 297 | double yP = pos.getY() + 0.5 + (random.nextDouble() - 0.5) * 2.0;
|
| 298 | double zP = pos.getZ() + 0.5 + (random.nextDouble() - 0.5) * 2.0;
|
| 299 | level.addParticle(ParticleTypes.SMOKE, xP, yP, zP, 0.0, 0.0, 0.0);
|
| 300 | level.addParticle(particleType, xP, yP, zP, 0.0, 0.0, 0.0);
|
| 301 | }
|
| 302 | }
|
| 303 |
|
| 304 | public static void addBecomeOminousParticles(final Level level, final BlockPos pos, final RandomSource random) {
|
| 305 | for (int i = 0; i < 20; i++) {
|
| 306 | double xP = pos.getX() + 0.5 + (random.nextDouble() - 0.5) * 2.0;
|
| 307 | double yP = pos.getY() + 0.5 + (random.nextDouble() - 0.5) * 2.0;
|
| 308 | double zP = pos.getZ() + 0.5 + (random.nextDouble() - 0.5) * 2.0;
|
| 309 | double xa = random.nextGaussian() * 0.02;
|
| 310 | double ya = random.nextGaussian() * 0.02;
|
| 311 | double za = random.nextGaussian() * 0.02;
|
| 312 | level.addParticle(ParticleTypes.TRIAL_OMEN, xP, yP, zP, xa, ya, za);
|
| 313 | level.addParticle(ParticleTypes.SOUL_FIRE_FLAME, xP, yP, zP, xa, ya, za);
|
| 314 | }
|
| 315 | }
|
| 316 |
|
| 317 | public static void addDetectPlayerParticles(final Level level, final BlockPos pos, final RandomSource random, final int data, final ParticleOptions type) {
|
| 318 | for (int i = 0; i < 30 + Math.min(data, 10) * 5; i++) {
|
| 319 | double spreadX = (2.0F * random.nextFloat() - 1.0F) * 0.65;
|
| 320 | double spreadZ = (2.0F * random.nextFloat() - 1.0F) * 0.65;
|
| 321 | double xP = pos.getX() + 0.5 + spreadX;
|
| 322 | double yP = pos.getY() + 0.1 + random.nextFloat() * 0.8;
|
| 323 | double zP = pos.getZ() + 0.5 + spreadZ;
|
| 324 | level.addParticle(type, xP, yP, zP, 0.0, 0.0, 0.0);
|
| 325 | }
|
| 326 | }
|
| 327 |
|
| 328 | public static void addEjectItemParticles(final Level level, final BlockPos pos, final RandomSource random) {
|
| 329 | for (int i = 0; i < 20; i++) {
|
| 330 | double xp = pos.getX() + 0.4 + random.nextDouble() * 0.2;
|
| 331 | double yp = pos.getY() + 0.4 + random.nextDouble() * 0.2;
|
| 332 | double zp = pos.getZ() + 0.4 + random.nextDouble() * 0.2;
|
| 333 | double xa = random.nextGaussian() * 0.02;
|
| 334 | double ya = random.nextGaussian() * 0.02;
|
| 335 | double za = random.nextGaussian() * 0.02;
|
| 336 | level.addParticle(ParticleTypes.SMALL_FLAME, xp, yp, zp, xa, ya, za * 0.25);
|
| 337 | level.addParticle(ParticleTypes.SMOKE, xp, yp, zp, xa, ya, za);
|
| 338 | }
|
| 339 | }
|
| 340 |
|
| 341 | public void overrideEntityToSpawn(final EntityType<?> type, final Level level) {
|
| 342 | this.data.reset();
|
| 343 | this.config = this.config.overrideEntity(type);
|
| 344 | this.setState(level, TrialSpawnerState.INACTIVE);
|
| 345 | }
|
| 346 |
|
| 347 | public void overrideEntityToSpawn(final TypedEntityData<EntityType<?>> entityData, final Level level) {
|
| 348 | this.data.reset();
|
| 349 | this.config = this.config.overrideEntityData(entityData);
|
| 350 | this.setState(level, TrialSpawnerState.INACTIVE);
|
| 351 | }
|
| 352 |
|
| 353 | @Deprecated(forRemoval = true)
|
| 354 | @VisibleForTesting
|
| 355 | public void setPlayerDetector(final PlayerDetector playerDetector) {
|
| 356 | this.playerDetector = playerDetector;
|
| 357 | }
|
| 358 |
|
| 359 | @Deprecated(forRemoval = true)
|
| 360 | @VisibleForTesting
|
| 361 | public void overridePeacefulAndMobSpawnRule() {
|
| 362 | this.overridePeacefulAndMobSpawnRule = true;
|
| 363 | }
|
| 364 |
|
| 365 | public enum FlameParticle {
|
| 366 | NORMAL(ParticleTypes.FLAME),
|
| 367 | OMINOUS(ParticleTypes.SOUL_FIRE_FLAME);
|
| 368 |
|
| 369 | public final SimpleParticleType particleType;
|
| 370 |
|
| 371 | FlameParticle(final SimpleParticleType particleType) {
|
| 372 | this.particleType = particleType;
|
| 373 | }
|
| 374 |
|
| 375 | public static TrialSpawner.FlameParticle decode(final int data) {
|
| 376 | TrialSpawner.FlameParticle[] values = values();
|
| 377 | return data <= values.length && data >= 0 ? values[data] : NORMAL;
|
| 378 | }
|
| 379 |
|
| 380 | public int encode() {
|
| 381 | return this.ordinal();
|
| 382 | }
|
| 383 | }
|
| 384 |
|
| 385 | public record FullConfig(Holder<TrialSpawnerConfig> normal, Holder<TrialSpawnerConfig> ominous, int targetCooldownLength, int requiredPlayerRange) {
|
| 386 | public static final MapCodec<TrialSpawner.FullConfig> MAP_CODEC = RecordCodecBuilder.mapCodec(
|
| 387 | i -> i.group(
|
| 388 | TrialSpawnerConfig.CODEC.optionalFieldOf("normal_config", Holder.direct(TrialSpawnerConfig.DEFAULT)).forGetter(TrialSpawner.FullConfig::normal),
|
| 389 | TrialSpawnerConfig.CODEC.optionalFieldOf("ominous_config", Holder.direct(TrialSpawnerConfig.DEFAULT)).forGetter(TrialSpawner.FullConfig::ominous),
|
| 390 | ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("target_cooldown_length", 36000).forGetter(TrialSpawner.FullConfig::targetCooldownLength),
|
| 391 | Codec.intRange(1, 128).optionalFieldOf("required_player_range", 14).forGetter(TrialSpawner.FullConfig::requiredPlayerRange)
|
| 392 | )
|
| 393 | .apply(i, TrialSpawner.FullConfig::new)
|
| 394 | );
|
| 395 | public static final TrialSpawner.FullConfig DEFAULT = new TrialSpawner.FullConfig(
|
| 396 | Holder.direct(TrialSpawnerConfig.DEFAULT), Holder.direct(TrialSpawnerConfig.DEFAULT), 36000, 14
|
| 397 | );
|
| 398 |
|
| 399 | public TrialSpawner.FullConfig overrideEntity(final EntityType<?> type) {
|
| 400 | return new TrialSpawner.FullConfig(
|
| 401 | Holder.direct(this.normal.value().withSpawning(type)),
|
| 402 | Holder.direct(this.ominous.value().withSpawning(type)),
|
| 403 | this.targetCooldownLength,
|
| 404 | this.requiredPlayerRange
|
| 405 | );
|
| 406 | }
|
| 407 |
|
| 408 | public TrialSpawner.FullConfig overrideEntityData(final TypedEntityData<EntityType<?>> entityData) {
|
| 409 | return new TrialSpawner.FullConfig(
|
| 410 | Holder.direct(this.normal.value().withSpawning(entityData)),
|
| 411 | Holder.direct(this.ominous.value().withSpawning(entityData)),
|
| 412 | this.targetCooldownLength,
|
| 413 | this.requiredPlayerRange
|
| 414 | );
|
| 415 | }
|
| 416 | }
|
| 417 |
|
| 418 | public interface StateAccessor {
|
| 419 | void setState(Level level, TrialSpawnerState state);
|
| 420 |
|
| 421 | TrialSpawnerState getState();
|
| 422 |
|
| 423 | void markUpdated();
|
| 424 | }
|
| 425 | }
|
| 426 |
|