37 lines
1.4 KiB
Java
37 lines
1.4 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.datafixers.kinds.App
|
|
* com.mojang.datafixers.kinds.Applicative
|
|
* com.mojang.serialization.MapCodec
|
|
* com.mojang.serialization.codecs.RecordCodecBuilder
|
|
*/
|
|
package net.minecraft.world.entity.variant;
|
|
|
|
import com.mojang.datafixers.kinds.App;
|
|
import com.mojang.datafixers.kinds.Applicative;
|
|
import com.mojang.serialization.MapCodec;
|
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
import net.minecraft.core.HolderSet;
|
|
import net.minecraft.core.RegistryCodecs;
|
|
import net.minecraft.core.registries.Registries;
|
|
import net.minecraft.world.entity.variant.SpawnCondition;
|
|
import net.minecraft.world.entity.variant.SpawnContext;
|
|
import net.minecraft.world.level.levelgen.structure.Structure;
|
|
|
|
public record StructureCheck(HolderSet<Structure> requiredStructures) implements SpawnCondition
|
|
{
|
|
public static final MapCodec<StructureCheck> MAP_CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)RegistryCodecs.homogeneousList(Registries.STRUCTURE).fieldOf("structures").forGetter(StructureCheck::requiredStructures)).apply((Applicative)i, StructureCheck::new));
|
|
|
|
@Override
|
|
public boolean test(SpawnContext context) {
|
|
return context.level().getLevel().structureManager().getStructureWithPieceAt(context.pos(), this.requiredStructures).isValid();
|
|
}
|
|
|
|
public MapCodec<StructureCheck> codec() {
|
|
return MAP_CODEC;
|
|
}
|
|
}
|
|
|