2023-10-30 18:18:52 +01:00
|
|
|
package net.anvilcraft.anvillib.worldgen;
|
|
|
|
|
|
|
|
import com.mojang.serialization.Codec;
|
|
|
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
|
|
|
|
|
|
import net.minecraft.structure.pool.StructurePool;
|
|
|
|
import net.minecraft.util.registry.RegistryEntry;
|
|
|
|
import net.minecraft.world.gen.feature.StructurePoolFeatureConfig;
|
|
|
|
|
|
|
|
public class AdvancedStructurePoolFeatureConfig extends StructurePoolFeatureConfig {
|
2023-11-24 18:52:05 +01:00
|
|
|
public static final Codec<StructurePoolFeatureConfig> CODEC
|
|
|
|
= RecordCodecBuilder.create((instance) -> {
|
|
|
|
return instance
|
|
|
|
.group(
|
|
|
|
StructurePool.REGISTRY_CODEC.fieldOf("start_pool")
|
|
|
|
.forGetter(
|
|
|
|
(self)
|
|
|
|
-> ((AdvancedStructurePoolFeatureConfig) self)
|
|
|
|
.getStartPool()
|
|
|
|
),
|
|
|
|
Codec.intRange(0, 7).fieldOf("size").forGetter(
|
|
|
|
(self) -> ((AdvancedStructurePoolFeatureConfig) self).getSize()
|
|
|
|
),
|
|
|
|
Codec.INT.fieldOf("max_distance_from_center")
|
|
|
|
.forGetter(
|
|
|
|
(self)
|
|
|
|
-> ((AdvancedStructurePoolFeatureConfig) self)
|
|
|
|
.maxDistanceFromCenter
|
2023-11-26 12:27:45 +01:00
|
|
|
),
|
|
|
|
Codec.BOOL.fieldOf("use_box_beardifier").forGetter(
|
|
|
|
(self) -> ((AdvancedStructurePoolFeatureConfig) self).useBoxBeardifier
|
|
|
|
)
|
2023-11-24 18:52:05 +01:00
|
|
|
)
|
|
|
|
.apply(instance, AdvancedStructurePoolFeatureConfig::new);
|
|
|
|
});
|
2023-10-30 18:18:52 +01:00
|
|
|
|
|
|
|
public final int maxDistanceFromCenter;
|
2023-11-26 12:27:45 +01:00
|
|
|
public final boolean useBoxBeardifier;
|
2023-10-30 18:18:52 +01:00
|
|
|
|
|
|
|
public AdvancedStructurePoolFeatureConfig(
|
2023-11-26 12:27:45 +01:00
|
|
|
RegistryEntry<StructurePool> startPool, int size, int maxDistanceFromCenter, boolean useBoxBeardifier
|
2023-10-30 18:18:52 +01:00
|
|
|
) {
|
|
|
|
super(startPool, size);
|
|
|
|
this.maxDistanceFromCenter = maxDistanceFromCenter;
|
2023-11-26 12:27:45 +01:00
|
|
|
this.useBoxBeardifier = useBoxBeardifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
public AdvancedStructurePoolFeatureConfig(
|
|
|
|
RegistryEntry<StructurePool> startPool, int size, int maxDistanceFromCenter
|
|
|
|
) {
|
|
|
|
this(startPool, size, maxDistanceFromCenter, false);
|
2023-10-30 18:18:52 +01:00
|
|
|
}
|
|
|
|
}
|