-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56e4ec9
commit 1997ad6
Showing
5 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/net/zepalesque/redux/data/gen/ReduxRegistrySets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.zepalesque.redux.data.gen; | ||
|
||
import com.aetherteam.aether.Aether; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.core.RegistryAccess; | ||
import net.minecraft.core.RegistrySetBuilder; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.data.PackOutput; | ||
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider; | ||
import net.zepalesque.redux.Redux; | ||
import net.zepalesque.redux.data.resource.ReduxFeatureConfig; | ||
import net.zepalesque.redux.data.resource.ReduxPlacements; | ||
import net.zepalesque.zenith.Zenith; | ||
import org.apache.commons.compress.utils.Lists; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class ReduxRegistrySets extends DatapackBuiltinEntriesProvider { | ||
public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder() | ||
.add(Registries.CONFIGURED_FEATURE, ReduxFeatureConfig::bootstrap); | ||
|
||
public ReduxRegistrySets(PackOutput output, CompletableFuture<HolderLookup.Provider> registries, String modid, String... otherIds) { | ||
super(output, registries, BUILDER, buildModidList(modid, otherIds)); | ||
} | ||
public static Set<String> buildModidList(String modid, String... otherIds) { | ||
List<String> list = Lists.newArrayList(); | ||
list.add(Aether.MODID); | ||
list.add(modid); | ||
list.addAll(Arrays.stream(otherIds).toList()); | ||
return Set.copyOf(list); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/main/java/net/zepalesque/redux/data/resource/ReduxFeatureConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package net.zepalesque.redux.data.resource; | ||
|
||
import com.aetherteam.aether.block.AetherBlockStateProperties; | ||
import com.aetherteam.aether.data.resources.AetherFeatureStates; | ||
import com.aetherteam.aether.data.resources.registries.AetherConfiguredFeatures; | ||
import com.aetherteam.aether.world.foliageplacer.CrystalFoliagePlacer; | ||
import com.aetherteam.aether.world.trunkplacer.CrystalTreeTrunkPlacer; | ||
import net.minecraft.core.HolderGetter; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.data.worldgen.BootstapContext; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.util.random.SimpleWeightedRandomList; | ||
import net.minecraft.util.valueproviders.ConstantInt; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; | ||
import net.minecraft.world.level.levelgen.feature.Feature; | ||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; | ||
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; | ||
import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize; | ||
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; | ||
import net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider; | ||
import net.neoforged.neoforge.registries.DeferredHolder; | ||
import net.zepalesque.redux.block.state.ReduxStates; | ||
import net.zepalesque.redux.blockset.wood.ReduxWoodSets; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class ReduxFeatureConfig { | ||
|
||
public static final ResourceKey<ConfiguredFeature<?, ?>> CRYSTAL_TREE_OVERRIDE = AetherConfiguredFeatures.CRYSTAL_TREE_CONFIGURATION; | ||
|
||
public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) { | ||
HolderGetter<ConfiguredFeature<?, ?>> configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE); | ||
register(context, CRYSTAL_TREE_OVERRIDE, Feature.TREE, | ||
new TreeConfiguration.TreeConfigurationBuilder( | ||
prov(ReduxWoodSets.CRYSTAL.log()), | ||
new CrystalTreeTrunkPlacer(7, 0, 0), | ||
new WeightedStateProvider(new SimpleWeightedRandomList.Builder<BlockState>().add(AetherFeatureStates.CRYSTAL_LEAVES, 4).add(AetherFeatureStates.CRYSTAL_FRUIT_LEAVES, 1).build()), | ||
new CrystalFoliagePlacer(ConstantInt.of(0), ConstantInt.of(0), ConstantInt.of(6)), | ||
new TwoLayersFeatureSize(1, 0, 1)).ignoreVines().build()); | ||
} | ||
|
||
private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(BootstapContext<ConfiguredFeature<?, ?>> context, ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration) { | ||
context.register(key, new ConfiguredFeature<>(feature, configuration)); | ||
} | ||
|
||
private static String name(DeferredHolder<?, ?> reg) { | ||
return reg.getId().getPath(); | ||
} | ||
|
||
private static BlockStateProvider prov(BlockState state) { | ||
return BlockStateProvider.simple(drops(state)); | ||
} | ||
|
||
private static BlockStateProvider prov(Supplier<? extends Block> block) { | ||
return prov(block.get().defaultBlockState()); | ||
} | ||
|
||
private static BlockState drops(BlockState state) { | ||
return state.hasProperty(AetherBlockStateProperties.DOUBLE_DROPS) ? state.setValue(AetherBlockStateProperties.DOUBLE_DROPS, true) : state; | ||
} | ||
|
||
private static BlockState drops(Supplier<? extends Block> block) { | ||
return drops(block.get().defaultBlockState()); | ||
} | ||
|
||
private static BlockState naturalDrops(Supplier<? extends Block> block) { | ||
BlockState b = block.get().defaultBlockState(); | ||
return b.hasProperty(ReduxStates.NATURAL_GEN) ? drops(b.setValue(ReduxStates.NATURAL_GEN, true)) : drops(b); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/net/zepalesque/redux/data/resource/ReduxPlacements.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.zepalesque.redux.data.resource; | ||
|
||
import com.aetherteam.aether.block.AetherBlockStateProperties; | ||
import com.aetherteam.aether.data.resources.AetherFeatureStates; | ||
import com.aetherteam.aether.data.resources.registries.AetherConfiguredFeatures; | ||
import com.aetherteam.aether.world.foliageplacer.CrystalFoliagePlacer; | ||
import com.aetherteam.aether.world.trunkplacer.CrystalTreeTrunkPlacer; | ||
import net.minecraft.core.HolderGetter; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.data.worldgen.BootstapContext; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.util.random.SimpleWeightedRandomList; | ||
import net.minecraft.util.valueproviders.ConstantInt; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; | ||
import net.minecraft.world.level.levelgen.feature.Feature; | ||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; | ||
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; | ||
import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize; | ||
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider; | ||
import net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider; | ||
import net.neoforged.neoforge.registries.DeferredHolder; | ||
import net.zepalesque.redux.block.state.ReduxStates; | ||
import net.zepalesque.redux.blockset.wood.ReduxWoodSets; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class ReduxPlacements { | ||
|
||
} |