feat: implement AdvancedStructurePoolFeatureConfig
This commit is contained in:
parent
13fc26a964
commit
64a9efbd5b
|
@ -16,7 +16,7 @@ loom.platform=forge
|
|||
yarn_mappings=1.18.2+build.4
|
||||
|
||||
# Mod Properties
|
||||
mod_version=0.1.0
|
||||
mod_version=0.1.1
|
||||
maven_group=net.anvilcraft
|
||||
archives_base_name=anvillib-18
|
||||
mod_id=anvillib
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package net.anvilcraft.anvillib.mixin.common;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
||||
import net.anvilcraft.anvillib.worldgen.AdvancedStructurePoolFeatureConfig;
|
||||
import net.minecraft.structure.PoolStructurePiece;
|
||||
import net.minecraft.structure.pool.StructurePoolBasedGenerator;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.world.gen.feature.StructurePoolFeatureConfig;
|
||||
|
||||
@Mixin(StructurePoolBasedGenerator.class)
|
||||
public class StructurePoolBasedGeneratorMixin {
|
||||
// this is a lambda
|
||||
@ModifyVariable(method = "method_39824", at = @At(value = "STORE", ordinal = 0))
|
||||
private static Box adjustAdvBoundingBox(
|
||||
Box box, PoolStructurePiece alec, StructurePoolFeatureConfig conf
|
||||
) {
|
||||
if (conf instanceof AdvancedStructurePoolFeatureConfig aconf) {
|
||||
return new Box(
|
||||
box.minX + 80 - aconf.maxDistanceFromCenter,
|
||||
box.minY + 80 - aconf.maxDistanceFromCenter,
|
||||
box.minZ + 80 - aconf.maxDistanceFromCenter,
|
||||
box.maxX - 80 + aconf.maxDistanceFromCenter,
|
||||
box.maxY - 80 + aconf.maxDistanceFromCenter,
|
||||
box.maxZ - 80 + aconf.maxDistanceFromCenter
|
||||
);
|
||||
}
|
||||
return box;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
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 {
|
||||
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
|
||||
)
|
||||
)
|
||||
.apply(instance, AdvancedStructurePoolFeatureConfig::new);
|
||||
}
|
||||
);
|
||||
|
||||
public final int maxDistanceFromCenter;
|
||||
|
||||
public AdvancedStructurePoolFeatureConfig(
|
||||
RegistryEntry<StructurePool> startPool, int size, int maxDistanceFromCenter
|
||||
) {
|
||||
super(startPool, size);
|
||||
this.maxDistanceFromCenter = maxDistanceFromCenter;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,8 @@
|
|||
"compatibilityLevel": "JAVA_17",
|
||||
"minVersion": "0.8",
|
||||
"mixins": [
|
||||
"common.RecipeManagerMixin"
|
||||
"common.RecipeManagerMixin",
|
||||
"common.StructurePoolBasedGeneratorMixin"
|
||||
],
|
||||
"client": [],
|
||||
"injectors": {
|
||||
|
|
Loading…
Reference in a new issue