fix: on forge

also tons of changes i cannot sensibly categorize anymore
This commit is contained in:
LordMZTE 2023-10-05 17:44:40 +02:00
parent 9523c14468
commit 87e0233696
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
26 changed files with 815 additions and 395 deletions

View file

@ -20,9 +20,11 @@ import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules;
import com.cursedcauldron.wildbackport.common.registry.entity.WBSensorTypes;
import com.cursedcauldron.wildbackport.common.registry.worldgen.RootPlacerType;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBFeatures;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBStructureFeatures;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBStructures;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBTreeDecorators;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBTrunkPlacers;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBWorldGeneration;
import com.cursedcauldron.wildbackport.common.tag.InstrumentTags;
import com.cursedcauldron.wildbackport.common.tag.WBBiomeTags;
import com.cursedcauldron.wildbackport.common.tag.WBBlockTags;
@ -58,6 +60,12 @@ public class WildBackport {
WBSoundEvents.SOUNDS.register();
WBTreeDecorators.DECORATORS.register();
WBTrunkPlacers.PLACERS.register();
WBWorldGeneration.CONFIGURED_FEATURES.register();
WBWorldGeneration.PLACED_FEATURES.register();
WBStructureFeatures.STRUCTURE_FEATURES.register();
WBStructures.CONFIGURED_STRUCTURE_FEATURES.register();
WBStructures.STRUCTURE_SETS.register();
WBStructures.STRUCTURE_PROCESSORS.register();
WBGameRules.setup();

View file

@ -4,17 +4,11 @@ import com.cursedcauldron.wildbackport.common.entities.Allay;
import com.cursedcauldron.wildbackport.common.entities.Frog;
import com.cursedcauldron.wildbackport.common.entities.Tadpole;
import com.cursedcauldron.wildbackport.common.entities.Warden;
import com.cursedcauldron.wildbackport.common.entities.access.Recovery;
import com.cursedcauldron.wildbackport.common.items.CompassItemPropertyFunction;
import com.cursedcauldron.wildbackport.common.registry.WBItems;
import com.cursedcauldron.wildbackport.common.registry.entity.WBEntityTypes;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBWorldGeneration;
import com.cursedcauldron.wildbackport.common.worldgen.structure.StructureGeneration;
import com.cursedcauldron.wildbackport.core.api.MobRegistry;
import com.cursedcauldron.wildbackport.core.api.worldgen.BiomeModifier;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
public class CommonSetup {
/**
@ -37,4 +31,4 @@ public class CommonSetup {
VanillaIntegration.setup();
StructureGeneration.registerAllayCages();
}
}
}

View file

@ -2,11 +2,13 @@ package com.cursedcauldron.wildbackport.common.blocks;
import java.util.Random;
import org.jetbrains.annotations.Nullable;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBWorldGeneration;
import net.minecraft.core.Holder;
import net.minecraft.world.level.block.grower.AbstractTreeGrower;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import org.jetbrains.annotations.Nullable;
public class MangroveTreeGrower extends AbstractTreeGrower {
private final float tallChance;
@ -22,4 +24,4 @@ public class MangroveTreeGrower extends AbstractTreeGrower {
return random.nextFloat() < this.tallChance ? WBWorldGeneration.TALL_MANGROVE
: WBWorldGeneration.MANGROVE;
}
}
}

View file

@ -2,9 +2,9 @@ package com.cursedcauldron.wildbackport.common.registry;
import java.util.function.Supplier;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.core.api.CoreRegistry;
import com.cursedcauldron.wildbackport.core.mixin.access.OverworldBiomesAccessor;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.data.worldgen.BiomeDefaultFeatures;
@ -126,4 +126,4 @@ public class WBBiomes {
modifier = Mth.clamp(modifier, -1.0F, 1.0F);
return Mth.hsvToRgb(0.62222224F - modifier * 0.05F, 0.5F + modifier * 0.1F, 1.0F);
}
}
}

View file

@ -2,8 +2,6 @@ package com.cursedcauldron.wildbackport.common.registry.worldgen;
import java.util.function.Supplier;
import com.cursedcauldron.wildbackport.common.worldgen.AdvancedJigsawConfiguration;
import com.cursedcauldron.wildbackport.common.worldgen.features.AncientCityFeature;
import com.cursedcauldron.wildbackport.common.worldgen.features.GrassDiskConfiguration;
import com.cursedcauldron.wildbackport.common.worldgen.features.GrassDiskFeature;
import com.cursedcauldron.wildbackport.common.worldgen.features.RootedTreeConfig;
@ -12,10 +10,8 @@ import com.cursedcauldron.wildbackport.common.worldgen.features.SculkGrowthFeatu
import com.cursedcauldron.wildbackport.common.worldgen.features.SculkPatchConfiguration;
import com.cursedcauldron.wildbackport.common.worldgen.features.SculkPatchFeature;
import com.cursedcauldron.wildbackport.core.api.CoreRegistry;
import com.cursedcauldron.wildbackport.core.mixin.access.StructureFeatureAccessor;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.GlowLichenConfiguration;
@ -40,11 +36,4 @@ public class WBFeatures {
= FEATURES.register(
"sculk_growth", () -> new SculkGrowthFeature(GlowLichenConfiguration.CODEC)
);
public static final AncientCityFeature ANCIENT_CITY
= StructureFeatureAccessor.callRegister(
"ancient_city",
new AncientCityFeature(AdvancedJigsawConfiguration.CODEC),
Decoration.UNDERGROUND_STRUCTURES
);
}

View file

@ -0,0 +1,26 @@
package com.cursedcauldron.wildbackport.common.registry.worldgen;
import com.cursedcauldron.wildbackport.common.utils.SupplierHolder;
import com.cursedcauldron.wildbackport.common.worldgen.AdvancedJigsawConfiguration;
import com.cursedcauldron.wildbackport.common.worldgen.features.AncientCityFeature;
import com.cursedcauldron.wildbackport.core.api.CoreRegistry;
import com.cursedcauldron.wildbackport.core.mixin.access.StructureFeatureAccessor;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
public class WBStructureFeatures {
public static final CoreRegistry<StructureFeature<?>> STRUCTURE_FEATURES
= CoreRegistry.create(Registry.STRUCTURE_FEATURE, "minecraft");
public static final Holder<StructureFeature<?>> ANCIENT_CITY
= SupplierHolder.createAndRegister(STRUCTURE_FEATURES, "ancient_city", () -> {
var acf = new AncientCityFeature(AdvancedJigsawConfiguration.CODEC);
StructureFeatureAccessor.getStep().put(
acf, Decoration.UNDERGROUND_STRUCTURES
);
return acf;
});
}

View file

@ -5,72 +5,85 @@ import java.util.Optional;
import java.util.stream.Collectors;
import com.cursedcauldron.wildbackport.common.tag.WBBiomeTags;
import com.cursedcauldron.wildbackport.common.utils.SupplierHolder;
import com.cursedcauldron.wildbackport.common.worldgen.AdvancedJigsawConfiguration;
import com.cursedcauldron.wildbackport.common.worldgen.features.AncientCityFeature;
import com.cursedcauldron.wildbackport.common.worldgen.structure.AncientCityStructurePieces;
import com.cursedcauldron.wildbackport.common.worldgen.structure.processors.BlockTagRotProcessor;
import com.cursedcauldron.wildbackport.core.api.CoreRegistry;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.random.WeightedRandomList;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.structure.StructureSet;
import net.minecraft.world.level.levelgen.structure.StructureSpawnOverride;
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement;
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
public class WBStructures {
public static final Holder<ConfiguredStructureFeature<?, ?>> ANCIENT_CITY = create(
"ancient_city",
WBFeatures.ANCIENT_CITY.configured(
new AdvancedJigsawConfiguration(
AncientCityStructurePieces.START,
7,
116,
Optional.of(new ResourceLocation("city_anchor"))
),
WBBiomeTags.HAS_ANCIENT_CITY,
true,
Arrays.stream(MobCategory.values())
.collect(Collectors.toMap(
mobCategory
-> mobCategory,
mobCategory
-> new StructureSpawnOverride(
StructureSpawnOverride.BoundingBoxType.STRUCTURE,
WeightedRandomList.create()
)
))
)
);
public static final CoreRegistry<ConfiguredStructureFeature<?, ?>>
CONFIGURED_STRUCTURE_FEATURES = CoreRegistry.create(
BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE, "minecraft"
);
public static final Holder<StructureSet> ANCIENT_CITIES = BuiltinRegistries.register(
BuiltinRegistries.STRUCTURE_SETS,
ResourceKey.create(
Registry.STRUCTURE_SET_REGISTRY, new ResourceLocation("ancient_cities")
),
new StructureSet(
ANCIENT_CITY,
new RandomSpreadStructurePlacement(24, 8, RandomSpreadType.LINEAR, 20083232)
)
);
public static final CoreRegistry<StructureSet> STRUCTURE_SETS
= CoreRegistry.create(BuiltinRegistries.STRUCTURE_SETS, "minecraft");
public static final CoreRegistry<StructureProcessorType<?>> STRUCTURE_PROCESSORS
= CoreRegistry.create(Registry.STRUCTURE_PROCESSOR, "minecraft");
public static final Holder<StructureProcessorType<BlockTagRotProcessor>> BLOCK_TAG_ROT
= SupplierHolder.createAndRegister(
STRUCTURE_PROCESSORS, "block_rot_alec", () -> () -> BlockTagRotProcessor.CODEC
);
public static final Holder<ConfiguredStructureFeature<?, ?>> ANCIENT_CITY
= SupplierHolder.createAndRegister(
CONFIGURED_STRUCTURE_FEATURES,
"ancient_city",
()
-> ((AncientCityFeature) WBStructureFeatures.ANCIENT_CITY.value())
.configured(
new AdvancedJigsawConfiguration(
AncientCityStructurePieces.START,
7,
116,
Optional.of(new ResourceLocation("city_anchor"))
),
WBBiomeTags.HAS_ANCIENT_CITY,
true,
Arrays.stream(MobCategory.values())
.collect(Collectors.toMap(
mobCategory
-> mobCategory,
mobCategory
-> new StructureSpawnOverride(
StructureSpawnOverride.BoundingBoxType.STRUCTURE,
WeightedRandomList.create()
)
))
)
);
public static final Holder<StructureSet> ANCIENT_CITIES
= SupplierHolder.createAndRegister(
STRUCTURE_SETS,
"ancient_cities",
()
-> new StructureSet(
ANCIENT_CITY,
new RandomSpreadStructurePlacement(
24, 8, RandomSpreadType.LINEAR, 20083232
)
)
);
public static void setup() {
AncientCityStructurePieces.bootstrap();
}
private static <FC extends FeatureConfiguration, F extends StructureFeature<FC>>
Holder<ConfiguredStructureFeature<?, ?>>
create(String key, ConfiguredStructureFeature<FC, F> feature) {
return BuiltinRegistries.register(
BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE,
ResourceKey.create(
Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY, new ResourceLocation(key)
),
feature
);
}
}

View file

@ -2,16 +2,13 @@ package com.cursedcauldron.wildbackport.common.registry.worldgen;
import java.util.function.Supplier;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.common.worldgen.decorator.AttachedToLeavesDecorator;
import com.cursedcauldron.wildbackport.common.worldgen.decorator.WeightedLeaveVineDecorator;
import com.cursedcauldron.wildbackport.common.worldgen.placers.UpwardBranchingTrunk;
import com.cursedcauldron.wildbackport.core.api.CoreRegistry;
import com.cursedcauldron.wildbackport.core.mixin.access.TreeDecoratorTypeAccessor;
import com.cursedcauldron.wildbackport.core.mixin.access.TrunkPlacerTypeAccessor;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType;
import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType;
//<>
@ -35,4 +32,4 @@ public class WBTreeDecorators {
AttachedToLeavesDecorator.CODEC
)
);
}
}

View file

@ -2,10 +2,10 @@ package com.cursedcauldron.wildbackport.common.registry.worldgen;
import java.util.function.Supplier;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.common.worldgen.placers.UpwardBranchingTrunk;
import com.cursedcauldron.wildbackport.core.api.CoreRegistry;
import com.cursedcauldron.wildbackport.core.mixin.access.TrunkPlacerTypeAccessor;
import net.minecraft.core.Registry;
import net.minecraft.world.level.levelgen.feature.trunkplacers.TrunkPlacerType;
@ -21,4 +21,4 @@ public class WBTrunkPlacers {
(
) -> TrunkPlacerTypeAccessor.createTrunkPlacerType(UpwardBranchingTrunk.CODEC)
);
}
}

View file

@ -2,11 +2,13 @@ package com.cursedcauldron.wildbackport.common.registry.worldgen;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import com.cursedcauldron.wildbackport.WildBackport;
import com.cursedcauldron.wildbackport.common.blocks.MangrovePropaguleBlock;
import com.cursedcauldron.wildbackport.common.registry.WBBlocks;
import com.cursedcauldron.wildbackport.common.tag.WBBlockTags;
import com.cursedcauldron.wildbackport.common.utils.ModUtils;
import com.cursedcauldron.wildbackport.common.utils.SupplierHolder;
import com.cursedcauldron.wildbackport.common.worldgen.PredicatedStateProvider;
import com.cursedcauldron.wildbackport.common.worldgen.WorldGenerator;
import com.cursedcauldron.wildbackport.common.worldgen.decorator.AboveRootPlacement;
@ -18,6 +20,8 @@ import com.cursedcauldron.wildbackport.common.worldgen.features.RootedTreeConfig
import com.cursedcauldron.wildbackport.common.worldgen.features.SculkPatchConfiguration;
import com.cursedcauldron.wildbackport.common.worldgen.placers.MangroveRootPlacer;
import com.cursedcauldron.wildbackport.common.worldgen.placers.UpwardBranchingTrunk;
import com.cursedcauldron.wildbackport.core.api.CoreRegistry;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
@ -34,7 +38,6 @@ import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.WeightedPlacedFeature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.GlowLichenConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.RandomFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize;
@ -55,287 +58,379 @@ import net.minecraft.world.level.material.Fluids;
//<>
public class WBWorldGeneration {
public static final CoreRegistry<ConfiguredFeature<?, ?>> CONFIGURED_FEATURES
= CoreRegistry.create(BuiltinRegistries.CONFIGURED_FEATURE, "minecraft");
public static final CoreRegistry<PlacedFeature> PLACED_FEATURES
= CoreRegistry.create(BuiltinRegistries.PLACED_FEATURE, "minecraft");
public static void bootstrap() {
WorldGenerator.setup();
}
// Mangrove Swamp
public static final Holder<ConfiguredFeature<RootedTreeConfig, ?>> MANGROVE = create(
"mangrove",
WBFeatures.TREE.get(),
new RootedTreeConfig
.Builder(
BlockStateProvider.simple(WBBlocks.MANGROVE_LOG.get()),
new UpwardBranchingTrunk(
2,
1,
4,
UniformInt.of(1, 4),
0.5F,
UniformInt.of(0, 1),
Registry.BLOCK.getOrCreateTag(
WBBlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH
)
),
BlockStateProvider.simple(WBBlocks.MANGROVE_LEAVES.get()),
new RandomSpreadFoliagePlacer(
ConstantInt.of(3), ConstantInt.of(0), ConstantInt.of(2), 70
),
Optional.of(new MangroveRootPlacer(
UniformInt.of(1, 3),
BlockStateProvider.simple(WBBlocks.MANGROVE_ROOTS.get()),
Optional.of(new AboveRootPlacement(
BlockStateProvider.simple(Blocks.MOSS_CARPET), 0.5F
)),
new MangroveRootPlacement(
Registry.BLOCK
.getOrCreateTag(WBBlockTags.MANGROVE_ROOTS_CAN_GROW_THROUGH),
HolderSet.direct(
Block::builtInRegistryHolder,
WBBlocks.MUD.get(),
WBBlocks.MUDDY_MANGROVE_ROOTS.get()
),
BlockStateProvider.simple(WBBlocks.MUDDY_MANGROVE_ROOTS.get()),
8,
15,
0.2F
)
)),
new TwoLayersFeatureSize(2, 0, 2)
)
.decorators(List.of(
new WeightedLeaveVineDecorator(0.125F),
new AttachedToLeavesDecorator(
0.14F,
1,
0,
new RandomizedIntStateProvider(
BlockStateProvider
.simple(WBBlocks.MANGROVE_PROPAGULE.get()
.defaultBlockState()
.setValue(MangrovePropaguleBlock.HANGING, true)),
MangrovePropaguleBlock.AGE,
UniformInt.of(0, 4)
),
2,
List.of(Direction.DOWN)
),
new BeehiveDecorator(0.01F)
))
.ignoreVines()
.build()
);
public static final Holder<ConfiguredFeature<RootedTreeConfig, ?>> TALL_MANGROVE
= create(
"tall_mangrove",
WBFeatures.TREE.get(),
new RootedTreeConfig
.Builder(
BlockStateProvider.simple(WBBlocks.MANGROVE_LOG.get()),
new UpwardBranchingTrunk(
4,
1,
9,
UniformInt.of(1, 6),
0.5F,
UniformInt.of(0, 1),
Registry.BLOCK.getOrCreateTag(
WBBlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH
public static final Holder<ConfiguredFeature<RootedTreeConfig, ?>> MANGROVE
= SupplierHolder.createAndRegister(
CONFIGURED_FEATURES,
"mangrove",
()
-> new ConfiguredFeature<>(
WBFeatures.TREE.get(),
new RootedTreeConfig
.Builder(
BlockStateProvider.simple(WBBlocks.MANGROVE_LOG.get()),
new UpwardBranchingTrunk(
2,
1,
4,
UniformInt.of(1, 4),
0.5F,
UniformInt.of(0, 1),
Registry.BLOCK.getOrCreateTag(
WBBlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH
)
),
BlockStateProvider.simple(WBBlocks.MANGROVE_LEAVES.get()),
new RandomSpreadFoliagePlacer(
ConstantInt.of(3),
ConstantInt.of(0),
ConstantInt.of(2),
70
),
Optional.of(new MangroveRootPlacer(
UniformInt.of(1, 3),
BlockStateProvider.simple(WBBlocks.MANGROVE_ROOTS.get()),
Optional.of(new AboveRootPlacement(
BlockStateProvider.simple(Blocks.MOSS_CARPET), 0.5F
)),
new MangroveRootPlacement(
Registry.BLOCK.getOrCreateTag(
WBBlockTags.MANGROVE_ROOTS_CAN_GROW_THROUGH
),
HolderSet.direct(
Block::builtInRegistryHolder,
WBBlocks.MUD.get(),
WBBlocks.MUDDY_MANGROVE_ROOTS.get()
),
BlockStateProvider
.simple(WBBlocks.MUDDY_MANGROVE_ROOTS.get()),
8,
15,
0.2F
)
)),
new TwoLayersFeatureSize(2, 0, 2)
)
),
BlockStateProvider.simple(WBBlocks.MANGROVE_LEAVES.get()),
new RandomSpreadFoliagePlacer(
ConstantInt.of(3), ConstantInt.of(0), ConstantInt.of(2), 70
),
Optional.of(new MangroveRootPlacer(
UniformInt.of(3, 7),
BlockStateProvider.simple(WBBlocks.MANGROVE_ROOTS.get()),
Optional.of(new AboveRootPlacement(
BlockStateProvider.simple(Blocks.MOSS_CARPET), 0.5F
)),
new MangroveRootPlacement(
Registry.BLOCK.getOrCreateTag(
WBBlockTags.MANGROVE_ROOTS_CAN_GROW_THROUGH
.decorators(List.of(
new WeightedLeaveVineDecorator(0.125F),
new AttachedToLeavesDecorator(
0.14F,
1,
0,
new RandomizedIntStateProvider(
BlockStateProvider.simple(
WBBlocks.MANGROVE_PROPAGULE.get()
.defaultBlockState()
.setValue(
MangrovePropaguleBlock.HANGING, true
)
),
MangrovePropaguleBlock.AGE,
UniformInt.of(0, 4)
),
2,
List.of(Direction.DOWN)
),
HolderSet.direct(
Block::builtInRegistryHolder,
WBBlocks.MUD.get(),
WBBlocks.MUDDY_MANGROVE_ROOTS.get()
),
BlockStateProvider.simple(WBBlocks.MUDDY_MANGROVE_ROOTS.get()
),
8,
15,
0.2F
)
)),
new TwoLayersFeatureSize(3, 0, 2)
new BeehiveDecorator(0.01F)
))
.ignoreVines()
.build()
)
.decorators(List.of(
new WeightedLeaveVineDecorator(0.125F),
new AttachedToLeavesDecorator(
0.14F,
1,
0,
new RandomizedIntStateProvider(
BlockStateProvider.simple(
WBBlocks.MANGROVE_PROPAGULE.get()
.defaultBlockState()
.setValue(MangrovePropaguleBlock.HANGING, true)
);
public static final Holder<ConfiguredFeature<RootedTreeConfig, ?>> TALL_MANGROVE
= SupplierHolder.createAndRegister(
CONFIGURED_FEATURES,
"tall_mangrove",
()
-> new ConfiguredFeature<>(
WBFeatures.TREE.get(),
new RootedTreeConfig
.Builder(
BlockStateProvider.simple(WBBlocks.MANGROVE_LOG.get()),
new UpwardBranchingTrunk(
4,
1,
9,
UniformInt.of(1, 6),
0.5F,
UniformInt.of(0, 1),
Registry.BLOCK.getOrCreateTag(
WBBlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH
)
),
MangrovePropaguleBlock.AGE,
UniformInt.of(0, 4)
),
2,
List.of(Direction.DOWN)
),
new BeehiveDecorator(0.01F)
))
.ignoreVines()
.build()
BlockStateProvider.simple(WBBlocks.MANGROVE_LEAVES.get()),
new RandomSpreadFoliagePlacer(
ConstantInt.of(3),
ConstantInt.of(0),
ConstantInt.of(2),
70
),
Optional.of(new MangroveRootPlacer(
UniformInt.of(3, 7),
BlockStateProvider.simple(WBBlocks.MANGROVE_ROOTS.get()),
Optional.of(new AboveRootPlacement(
BlockStateProvider.simple(Blocks.MOSS_CARPET), 0.5F
)),
new MangroveRootPlacement(
Registry.BLOCK.getOrCreateTag(
WBBlockTags.MANGROVE_ROOTS_CAN_GROW_THROUGH
),
HolderSet.direct(
Block::builtInRegistryHolder,
WBBlocks.MUD.get(),
WBBlocks.MUDDY_MANGROVE_ROOTS.get()
),
BlockStateProvider
.simple(WBBlocks.MUDDY_MANGROVE_ROOTS.get()),
8,
15,
0.2F
)
)),
new TwoLayersFeatureSize(3, 0, 2)
)
.decorators(List.of(
new WeightedLeaveVineDecorator(0.125F),
new AttachedToLeavesDecorator(
0.14F,
1,
0,
new RandomizedIntStateProvider(
BlockStateProvider.simple(
WBBlocks.MANGROVE_PROPAGULE.get()
.defaultBlockState()
.setValue(
MangrovePropaguleBlock.HANGING, true
)
),
MangrovePropaguleBlock.AGE,
UniformInt.of(0, 4)
),
2,
List.of(Direction.DOWN)
),
new BeehiveDecorator(0.01F)
))
.ignoreVines()
.build()
)
);
public static final Holder<PlacedFeature> MANGROVE_CHECKED = create(
"mangrove_checked",
MANGROVE,
PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get())
);
public static final Holder<PlacedFeature> TALL_MANGROVE_CHECKED = create(
"tall_mangrove_checked",
TALL_MANGROVE,
PlacementUtils.filteredByBlockSurvival(WBBlocks.MANGROVE_PROPAGULE.get())
);
public static final Holder<ConfiguredFeature<RandomFeatureConfiguration, ?>>
MANGROVE_VEGETATION = create(
"mangrove_vegetation",
Feature.RANDOM_SELECTOR,
new RandomFeatureConfiguration(
List.of(new WeightedPlacedFeature(TALL_MANGROVE_CHECKED, 0.85F)),
MANGROVE_CHECKED
)
);
public static final Holder<PlacedFeature> TREES_MANGROVE_PLACED = create(
"trees_mangrove",
MANGROVE_VEGETATION,
CountPlacement.of(25),
InSquarePlacement.spread(),
SurfaceWaterDepthFilter.forMaxDepth(5),
PlacementUtils.HEIGHTMAP_OCEAN_FLOOR,
BiomeFilter.biome(),
BlockPredicateFilter.forPredicate(BlockPredicate.wouldSurvive(
WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState(), BlockPos.ZERO
))
);
public static final Holder<ConfiguredFeature<GrassDiskConfiguration, ?>> DISK_GRASS
= create(
"disk_grass",
WBFeatures.DISK.get(),
new GrassDiskConfiguration(
new PredicatedStateProvider(
BlockStateProvider.simple(Blocks.DIRT),
List.of(new PredicatedStateProvider.Rule(
BlockPredicate.not(BlockPredicate.allOf(
BlockPredicate.solid(Direction.UP.getNormal()),
BlockPredicate
.matchesFluid(Fluids.WATER, Direction.UP.getNormal())
)),
BlockStateProvider.simple(Blocks.GRASS_BLOCK)
public static final Holder<PlacedFeature> MANGROVE_CHECKED
= SupplierHolder.createAndRegister(
PLACED_FEATURES,
"mangrove_checked",
()
-> new PlacedFeature(
(Holder) MANGROVE,
List.of(PlacementUtils.filteredByBlockSurvival(
WBBlocks.MANGROVE_PROPAGULE.get()
))
),
BlockPredicate.matchesBlocks(List.of(Blocks.DIRT, WBBlocks.MUD.get())),
UniformInt.of(2, 6),
2
)
)
);
public static final Holder<PlacedFeature> TALL_MANGROVE_CHECKED
= SupplierHolder.createAndRegister(
PLACED_FEATURES,
"tall_mangrove_checked",
()
-> new PlacedFeature(
(Holder) TALL_MANGROVE,
List.of(PlacementUtils.filteredByBlockSurvival(
WBBlocks.MANGROVE_PROPAGULE.get()
))
)
);
public static final Holder<ConfiguredFeature<RandomFeatureConfiguration, ?>>
MANGROVE_VEGETATION = SupplierHolder.createAndRegister(
CONFIGURED_FEATURES,
"mangrove_vegetation",
()
-> new ConfiguredFeature<>(
Feature.RANDOM_SELECTOR,
new RandomFeatureConfiguration(
List.of(new WeightedPlacedFeature(TALL_MANGROVE_CHECKED, 0.85F)),
MANGROVE_CHECKED
)
)
);
public static final Holder<PlacedFeature> TREES_MANGROVE_PLACED
= SupplierHolder.createAndRegister(
PLACED_FEATURES,
"trees_mangrove",
()
-> new PlacedFeature(
(Holder) MANGROVE_VEGETATION,
List.of(
CountPlacement.of(25),
InSquarePlacement.spread(),
SurfaceWaterDepthFilter.forMaxDepth(5),
PlacementUtils.HEIGHTMAP_OCEAN_FLOOR,
BiomeFilter.biome(),
BlockPredicateFilter.forPredicate(BlockPredicate.wouldSurvive(
WBBlocks.MANGROVE_PROPAGULE.get().defaultBlockState(),
BlockPos.ZERO
))
)
)
);
public static final Holder<ConfiguredFeature<GrassDiskConfiguration, ?>> DISK_GRASS
= SupplierHolder.createAndRegister(
CONFIGURED_FEATURES,
"disk_grass",
()
-> new ConfiguredFeature<>(
WBFeatures.DISK.get(),
new GrassDiskConfiguration(
new PredicatedStateProvider(
BlockStateProvider.simple(Blocks.DIRT),
List.of(new PredicatedStateProvider.Rule(
BlockPredicate.not(BlockPredicate.allOf(
BlockPredicate.solid(Direction.UP.getNormal()),
BlockPredicate.matchesFluid(
Fluids.WATER, Direction.UP.getNormal()
)
)),
BlockStateProvider.simple(Blocks.GRASS_BLOCK)
))
),
BlockPredicate.matchesBlocks(
List.of(Blocks.DIRT, WBBlocks.MUD.get())
),
UniformInt.of(2, 6),
2
)
)
);
public static final Holder<PlacedFeature> DISK_GRASS_PLACED
= SupplierHolder.createAndRegister(
PLACED_FEATURES,
"disk_grass",
()
-> new PlacedFeature(
(Holder) DISK_GRASS,
List.of(
CountPlacement.of(1),
InSquarePlacement.spread(),
PlacementUtils.HEIGHTMAP_TOP_SOLID,
RandomOffsetPlacement.vertical(ConstantInt.of(-1)),
BlockPredicateFilter.forPredicate(
BlockPredicate.matchesBlock(WBBlocks.MUD.get(), Vec3i.ZERO)
),
BiomeFilter.biome()
)
)
);
public static final Holder<PlacedFeature> DISK_GRASS_PLACED = create(
"disk_grass",
DISK_GRASS,
CountPlacement.of(1),
InSquarePlacement.spread(),
PlacementUtils.HEIGHTMAP_TOP_SOLID,
RandomOffsetPlacement.vertical(ConstantInt.of(-1)),
BlockPredicateFilter.forPredicate(
BlockPredicate.matchesBlock(WBBlocks.MUD.get(), Vec3i.ZERO)
),
BiomeFilter.biome()
);
// Deep Dark
public static final Holder<ConfiguredFeature<SculkPatchConfiguration, ?>>
SCULK_PATCH_DEEP_DARK = create(
SCULK_PATCH_DEEP_DARK = SupplierHolder.createAndRegister(
CONFIGURED_FEATURES,
"sculk_patch_deep_dark",
WBFeatures.SCULK_PATCH.get(),
new SculkPatchConfiguration(10, 32, 64, 0, 1, ConstantInt.of(0), 0.5F)
);
public static final Holder<PlacedFeature> SCULK_PATCH_DEEP_DARK_PLACED = create(
"sculk_patch_deep_dark",
SCULK_PATCH_DEEP_DARK,
CountPlacement.of(ConstantInt.of(256)),
InSquarePlacement.spread(),
PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
BiomeFilter.biome()
);
public static final Holder<ConfiguredFeature<SculkPatchConfiguration, ?>>
SCULK_PATCH_ANCIENT_CITY = create(
"sculk_patch_ancient_city",
WBFeatures.SCULK_PATCH.get(),
new SculkPatchConfiguration(10, 32, 64, 0, 1, UniformInt.of(1, 3), 0.5F)
);
public static final Holder<PlacedFeature> SCULK_PATCH_ANCIENT_CITY_PLACED
= create("sculk_patch_ancient_city", SCULK_PATCH_ANCIENT_CITY);
public static final Holder<ConfiguredFeature<GlowLichenConfiguration, ?>> SCULK_VEIN
= create(
"sculk_vein",
WBFeatures.SCULK_GROWTH.get(),
new GlowLichenConfiguration(
20,
true,
true,
true,
1.0F,
HolderSet.direct(
Block::builtInRegistryHolder,
Blocks.STONE,
Blocks.ANDESITE,
Blocks.DIORITE,
Blocks.GRANITE,
Blocks.DRIPSTONE_BLOCK,
Blocks.CALCITE,
Blocks.TUFF,
Blocks.DEEPSLATE
()
-> new ConfiguredFeature<>(
WBFeatures.SCULK_PATCH.get(),
new SculkPatchConfiguration(10, 32, 64, 0, 1, ConstantInt.of(0), 0.5F)
)
)
);
public static final Holder<PlacedFeature> SCULK_VEIN_PLACED = create(
"sculk_vein",
SCULK_VEIN,
CountPlacement.of(UniformInt.of(204, 250)),
InSquarePlacement.spread(),
PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
BiomeFilter.biome()
);
// Registry
public static final Holder<PlacedFeature> SCULK_PATCH_DEEP_DARK_PLACED
= SupplierHolder.createAndRegister(
PLACED_FEATURES,
"sculk_patch_deep_dark",
()
-> new PlacedFeature(
(Holder) SCULK_PATCH_DEEP_DARK,
List.of(
CountPlacement.of(ConstantInt.of(256)),
InSquarePlacement.spread(),
PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
BiomeFilter.biome()
)
)
public static <FC extends FeatureConfiguration, F extends Feature<FC>>
Holder<ConfiguredFeature<FC, ?>> create(String key, F feature, FC configuration) {
return BuiltinRegistries.registerExact(
BuiltinRegistries.CONFIGURED_FEATURE,
"minecraft"
+ ":" + key,
new ConfiguredFeature<>(feature, configuration)
);
}
public static Holder<PlacedFeature> create(
String key,
Holder<? extends ConfiguredFeature<?, ?>> feature,
PlacementModifier... modifiers
) {
return BuiltinRegistries.registerExact(
BuiltinRegistries.PLACED_FEATURE,
"minecraft"
+ ":" + key,
new PlacedFeature(Holder.hackyErase(feature), List.copyOf(List.of(modifiers)))
public static final Holder<ConfiguredFeature<SculkPatchConfiguration, ?>>
SCULK_PATCH_ANCIENT_CITY = SupplierHolder.createAndRegister(
CONFIGURED_FEATURES,
"sculk_patch_ancient_city",
()
-> new ConfiguredFeature<>(
WBFeatures.SCULK_PATCH.get(),
new SculkPatchConfiguration(
10, 32, 64, 0, 1, UniformInt.of(1, 3), 0.5F
)
)
);
}
}
public static final Holder<PlacedFeature> SCULK_PATCH_ANCIENT_CITY_PLACED
= SupplierHolder.createAndRegister(
PLACED_FEATURES,
"sculk_patch_ancient_city",
() -> new PlacedFeature((Holder) SCULK_PATCH_ANCIENT_CITY, List.of())
);
public static final Holder<ConfiguredFeature<GlowLichenConfiguration, ?>> SCULK_VEIN
= SupplierHolder.createAndRegister(
CONFIGURED_FEATURES,
"sculk_vein",
()
-> new ConfiguredFeature<>(
WBFeatures.SCULK_GROWTH.get(),
new GlowLichenConfiguration(
20,
true,
true,
true,
1.0F,
HolderSet.direct(
Block::builtInRegistryHolder,
Blocks.STONE,
Blocks.ANDESITE,
Blocks.DIORITE,
Blocks.GRANITE,
Blocks.DRIPSTONE_BLOCK,
Blocks.CALCITE,
Blocks.TUFF,
Blocks.DEEPSLATE
)
)
)
);
public static final Holder<PlacedFeature> SCULK_VEIN_PLACED
= SupplierHolder.createAndRegister(
PLACED_FEATURES,
"sculk_vein",
()
-> new PlacedFeature(
(Holder) SCULK_VEIN,
List.of(
CountPlacement.of(UniformInt.of(204, 250)),
InSquarePlacement.spread(),
PlacementUtils.RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT,
BiomeFilter.biome()
)
)
);
}

View file

@ -24,4 +24,4 @@ public class ModUtils {
shuffle(objects, random);
return objects;
}
}
}

View file

@ -0,0 +1,104 @@
package com.cursedcauldron.wildbackport.common.utils;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
import com.cursedcauldron.wildbackport.core.api.CoreRegistry;
import com.mojang.datafixers.util.Either;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
public class SupplierHolder<E, T extends E> implements Holder<T> {
public ResourceKey<T> key;
public Supplier<T> supplier;
public SupplierHolder(
ResourceKey<? extends Registry<E>> regKey, String loc, Supplier<T> supplier
) {
this(regKey, new ResourceLocation(loc), supplier);
}
@SuppressWarnings("unchecked")
public SupplierHolder(
ResourceKey<? extends Registry<E>> regKey,
ResourceLocation loc,
Supplier<T> supplier
) {
this((ResourceKey<T>) ResourceKey.create(regKey, loc), supplier);
}
public SupplierHolder(ResourceKey<T> key, Supplier<T> supplier) {
this.key = key;
this.supplier = supplier;
}
public static <E, T extends E> SupplierHolder<E, T>
createAndRegister(CoreRegistry<E> reg, String loc, Supplier<T> supplier) {
return new SupplierHolder<E, T>(
reg.registry.key(), loc, reg.register(loc, supplier)
);
}
@Override
public boolean is(ResourceLocation resourceLocation) {
return this.key.location().equals(resourceLocation);
}
@Override
public boolean is(ResourceKey<T> resourceKey) {
return this.key.equals(resourceKey);
}
@Override
public boolean is(Predicate<ResourceKey<T>> predicate) {
return predicate.test(this.key);
}
@Override
public boolean is(TagKey<T> tagKey) {
return false;
}
@Override
public boolean isBound() {
return true;
}
@Override
public boolean isValidInRegistry(Registry<T> registry) {
return registry.key().location().equals(this.key.registry());
}
@Override
public Kind kind() {
return Holder.Kind.REFERENCE;
}
@Override
public Stream<TagKey<T>> tags() {
return Stream.empty();
}
@Override
public Either<ResourceKey<T>, T> unwrap() {
// This NEEDS to always return a key and not a value. Otherwise, Mojank's shitty chunk
// serialization breaks.
return Either.left(this.key);
}
@Override
public Optional<ResourceKey<T>> unwrapKey() {
return Optional.of(this.key);
}
@Override
public T value() {
return this.supplier.get();
}
}

View file

@ -5,6 +5,7 @@ import com.cursedcauldron.wildbackport.common.registry.entity.WBEntityTypes;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBWorldGeneration;
import com.cursedcauldron.wildbackport.core.api.worldgen.BiomeModifier;
import com.cursedcauldron.wildbackport.core.api.worldgen.BiomeWriter;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.Biome;
@ -48,4 +49,4 @@ public class WorldGenerator {
public static void addFrogs(BiomeWriter writer) {
writer.addSpawn(MobCategory.CREATURE, WBEntityTypes.FROG.get(), 10, 2, 5);
}
}
}

View file

@ -2,13 +2,16 @@ package com.cursedcauldron.wildbackport.common.worldgen.structure.processors;
import java.util.Optional;
import org.jetbrains.annotations.Nullable;
import com.cursedcauldron.wildbackport.common.registry.worldgen.WBStructures;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryCodecs;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
@ -16,7 +19,6 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlac
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import org.jetbrains.annotations.Nullable;
public class BlockTagRotProcessor extends StructureProcessor {
public static final Codec<BlockTagRotProcessor> CODEC
@ -32,10 +34,7 @@ public class BlockTagRotProcessor extends StructureProcessor {
)
.apply(instance, BlockTagRotProcessor::new);
});
private static final StructureProcessorType<BlockTagRotProcessor> BLOCK_TAG_ROT
= Registry.register(
Registry.STRUCTURE_PROCESSOR, new ResourceLocation("block_rot_alec"), () -> CODEC
);
private final Optional<HolderSet<Block>> rottableBlocks;
private final float integrity;
@ -68,6 +67,6 @@ public class BlockTagRotProcessor extends StructureProcessor {
@Override
protected StructureProcessorType<?> getType() {
return BLOCK_TAG_ROT;
return WBStructures.BLOCK_TAG_ROT.value();
}
}

View file

@ -7,12 +7,12 @@ import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
/**
* @author Trikzon & Andante
* @author LordMZTE & tilera
*/
public abstract class CoreRegistry<T> {
protected final Registry<T> registry;
protected final String modId;
protected boolean isPresent;
public final Registry<T> registry;
public final String modId;
public boolean isPresent;
protected CoreRegistry(Registry<T> registry, String modId) {
this.registry = registry;
@ -54,4 +54,4 @@ public abstract class CoreRegistry<T> {
@Override
public void bootstrap() {}
}
}
}

View file

@ -1,9 +1,13 @@
package com.cursedcauldron.wildbackport.core.mixin.access;
import java.util.Map;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(StructureFeature.class)
public interface StructureFeatureAccessor {
@ -12,4 +16,9 @@ public interface StructureFeatureAccessor {
F callRegister(String string, F arg, Decoration arg2) {
throw new AssertionError();
}
@Accessor("STEP")
public static Map<StructureFeature<?>, Decoration> getStep() {
throw new AssertionError();
}
}

View file

@ -2,15 +2,14 @@ package com.cursedcauldron.wildbackport.core.mixin.common;
import java.util.Optional;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
@Mixin(Items.class)
public class ItemsMixin {
@Overwrite

View file

@ -33,9 +33,7 @@
"access.WalkNodeEvaluatorAccessor",
"access.WoodButtonBlockAccessor",
"access.WoodTypeAccessor",
"common.BeardifierMixin",
"common.ItemsMixin",
"common.JigsawPlacementMixin",
"common.BlockEntityTypeMixin",
"common.FlyNodeEvaluatorMixin",
"common.LivingEntityMixin",

View file

@ -1,4 +1,5 @@
accessWidener v2 named
# vim: ft=conf
transitive-accessible class net/minecraft/world/level/block/entity/BlockEntityType$BlockEntitySupplier
transitive-accessible class net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement$Placer
@ -24,4 +25,5 @@ transitive-accessible method net/minecraft/client/particle/HugeExplosionParticle
transitive-accessible method net/minecraft/world/level/block/MultifaceBlock hasFace (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/Direction;)Z
transitive-accessible method net/minecraft/core/Registry registerSimple (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/core/Registry$RegistryBootstrap;)Lnet/minecraft/core/Registry;
transitive-accessible method net/minecraft/client/renderer/item/ItemProperties register (Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/item/ClampedItemPropertyFunction;)V
# Doesn't work and not needed?
#transitive-accessible method net/minecraft/client/renderer/item/ItemProperties register (Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/item/ClampedItemPropertyFunction;)V

View file

@ -1,4 +1,4 @@
package com.cursedcauldron.wildbackport.core.mixin.common;
package com.cursedcauldron.wildbackport.core.mixin.fabric.common;
import java.util.HashMap;
import java.util.Map;
@ -41,7 +41,8 @@ public class BeardifierMixin {
at = @At(
value = "INVOKE",
target = "Lit/unimi/dsi/fastutil/objects/ObjectList;add(Ljava/lang/Object;)Z"
)
),
remap = false
)
private void
addStructurePieceToMap(

View file

@ -1,4 +1,4 @@
package com.cursedcauldron.wildbackport.core.mixin.common;
package com.cursedcauldron.wildbackport.core.mixin.fabric.common;
import com.cursedcauldron.wildbackport.common.worldgen.AdvancedJigsawConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.JigsawConfiguration;
@ -12,8 +12,11 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(JigsawPlacement.class)
public class JigsawPlacementMixin {
// this is a lambda
@ModifyVariable(method = "method_39824", at = @At(value = "STORE", ordinal = 0))
private static AABB adjustAncientCityBoundingBox(
@ModifyVariable(
method = "method_39824", at = @At(value = "STORE", ordinal = 0), remap = false
)
private static AABB
adjustAncientCityBoundingBox(
AABB aabb, PoolElementStructurePiece alec, JigsawConfiguration conf
) {
if (conf instanceof AdvancedJigsawConfiguration aconf) {

View file

@ -1,16 +1,18 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.cursedcauldron.wildbackport.core.mixin.fabric",
"compatibilityLevel": "JAVA_17",
"mixins": [
"access.BiomeAccessor"
],
"client": [
"client.FogRendererMixin",
"client.SheetsMixin"
],
"injectors": {
"defaultRequire": 1
}
"required": true,
"minVersion": "0.8",
"package": "com.cursedcauldron.wildbackport.core.mixin.fabric",
"compatibilityLevel": "JAVA_17",
"mixins": [
"access.BiomeAccessor"
],
"client": [
"client.FogRendererMixin",
"client.SheetsMixin",
"common.BeardifierMixin",
"common.JigsawPlacementMixin"
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -91,4 +91,4 @@ publishing {
repositories {
// Add repositories to publish to here.
}
}
}

View file

@ -0,0 +1,139 @@
package com.cursedcauldron.wildbackport.core.mixin.forge.common;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import com.cursedcauldron.wildbackport.common.worldgen.features.AncientCityFeature;
import com.cursedcauldron.wildbackport.core.mixinhelper.BeardifierLocals;
import net.minecraft.util.Mth;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.levelgen.Beardifier;
import net.minecraft.world.level.levelgen.DensityFunction;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.StructurePiece;
import net.minecraft.world.level.levelgen.structure.StructureStart;
/**
* This mixin is responsible for reimplementing 1.19's BEARD_BOX which causes terrain
* to be removed around ancient city structures.
*/
@Mixin(Beardifier.class)
public class BeardifierMixin {
private static ThreadLocal<BeardifierLocals> currentLocals = new ThreadLocal<>();
@Unique
private Map<Object, StructureFeature<?>> featureMap = new HashMap<>();
// This is different than the fabric implementation where this is @ModifyArgs, but
// that's borked on Forge (as per usual).
@Inject(
// for this nonsense to work in the devenv, replace this with method_38319
// for prod, use m_208194_
// very elegant!
method = "m_208194_",
at = @At(
value = "INVOKE",
target = "Lit/unimi/dsi/fastutil/objects/ObjectList;add(Ljava/lang/Object;)Z"
),
remap = false,
locals = LocalCapture.CAPTURE_FAILHARD
)
private void
addStructurePieceToMap(
ChunkPos alec1,
int alec2,
int alec3,
StructureStart ss,
CallbackInfo ci,
Iterator<?> alec4,
StructurePiece sp
) {
featureMap.put(sp, ss.getFeature().feature);
}
@Inject(
method = "compute",
at = @At(
value = "INVOKE",
target
= "Lnet/minecraft/world/level/levelgen/structure/StructurePiece;getNoiseEffect()Lnet/minecraft/world/level/levelgen/feature/NoiseEffect;"
),
locals = LocalCapture.CAPTURE_FAILHARD
)
private void
collectVariables(
DensityFunction.FunctionContext alec1,
CallbackInfoReturnable<Double> ci,
int i,
int j,
int k,
double alec2,
StructurePiece structurePiece,
BoundingBox boundingBox,
int l,
int m
) {
currentLocals.set(new BeardifierLocals(i, j, k, structurePiece, boundingBox, l, m)
);
}
@Shadow
protected static double getBeardContribution(int l, int m, int n) {
throw new AssertionError();
}
@Redirect(
method = "compute",
at = @At(
value = "INVOKE",
target
= "Lnet/minecraft/world/level/levelgen/Beardifier;getBeardContribution(III)D"
)
)
private double
beardContribution(int l, int m, int n) {
BeardifierLocals locals = currentLocals.get();
if (locals == null)
return getBeardContribution(l, m, n);
currentLocals.remove();
StructureFeature<?> sf = this.featureMap.get(locals.structurePiece());
if (sf == null /* WTF */ || !(sf instanceof AncientCityFeature))
return getBeardContribution(l, m, n);
int q = Math.max(0, Math.max(-m, locals.y() - locals.boundingBox().maxY()));
return getAncientCityBeardContribution(l, q, n, m);
}
private static double getAncientCityBeardContribution(int i, int j, int k, int l) {
int m = i + 12;
int n = j + 12;
int o = k + 12;
if (!(m >= 0 && m < 24 && n >= 0 && n < 24 && o >= 0 && o < 24)) {
return 0.0;
}
double d = (double) l + 0.5;
double e = Mth.lengthSquared(i, d, k);
double f = -d * Mth.fastInvSqrt(e / 2.0) / 2.0;
return f * (double) computeBeardContribution(o - 12, m - 12, n - 12);
}
private static double computeBeardContribution(int i, double d, int j) {
double e = Mth.lengthSquared(i, d, j);
double f = Math.pow(Math.E, -e / 16.0);
return f;
}
}

View file

@ -0,0 +1,38 @@
package com.cursedcauldron.wildbackport.core.mixin.forge.common;
import com.cursedcauldron.wildbackport.common.worldgen.AdvancedJigsawConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.JigsawConfiguration;
import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece;
import net.minecraft.world.level.levelgen.structure.pools.JigsawPlacement;
import net.minecraft.world.phys.AABB;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
// this is an exact duplicate of this mixin for fabric, but with the target changed to
// SRG mappings. you have failed me, refmap.
@Mixin(JigsawPlacement.class)
public class JigsawPlacementMixin {
// for this nonsense to work in the devenv, replace this with method_39824
// for prod, use m_210268_
// very elegant!
@ModifyVariable(
method = "m_210268_", at = @At(value = "STORE", ordinal = 0), remap = false
)
private static AABB
adjustAncientCityBoundingBox(
AABB aabb, PoolElementStructurePiece alec, JigsawConfiguration conf
) {
if (conf instanceof AdvancedJigsawConfiguration aconf) {
return new AABB(
aabb.minX + 80 - aconf.maxDistanceFromCenter,
aabb.minY + 80 - aconf.maxDistanceFromCenter,
aabb.minZ + 80 - aconf.maxDistanceFromCenter,
aabb.maxX - 80 + aconf.maxDistanceFromCenter,
aabb.maxY - 80 + aconf.maxDistanceFromCenter,
aabb.maxZ - 80 + aconf.maxDistanceFromCenter
);
}
return aabb;
}
}

View file

@ -1,13 +1,14 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.cursedcauldron.wildbackport.core.mixin.forge",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
"required": true,
"minVersion": "0.8",
"package": "com.cursedcauldron.wildbackport.core.mixin.forge",
"compatibilityLevel": "JAVA_17",
"mixins": [
"common.BeardifierMixin",
"common.JigsawPlacementMixin"
],
"client": [],
"injectors": {
"defaultRequire": 1
}
}