Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/zeta120' into zeta120
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Dec 5, 2023
2 parents 0f145d1 + 2d99547 commit 93b75b1
Show file tree
Hide file tree
Showing 15 changed files with 305 additions and 126 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/violetmoon/quark/base/Quark.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.violetmoon.quark.base;

import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod;
Expand Down Expand Up @@ -35,4 +37,8 @@ public Quark() {
public static ResourceLocation asResource(String name) {
return new ResourceLocation(MOD_ID, name);
}

public static <T> ResourceKey<T> asResourceKey(ResourceKey<? extends Registry<T>> base, String name) {
return ResourceKey.create(base, asResource(name));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.violetmoon.quark.content.building.block;

import org.jetbrains.annotations.NotNull;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.zeta.block.ZetaBlock;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.registry.RenderLayerRegistry;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand All @@ -11,6 +15,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.CeilingHangingSignBlock;
import net.minecraft.world.level.block.ChainBlock;
import net.minecraft.world.level.block.LanternBlock;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
Expand All @@ -24,10 +29,6 @@
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.zeta.block.ZetaBlock;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.registry.RenderLayerRegistry;

public class WoodPostBlock extends ZetaBlock implements SimpleWaterloggedBlock {

Expand Down Expand Up @@ -115,7 +116,8 @@ private BlockState getState(Level world, BlockPos pos, Axis axis) {

BlockState sideState = world.getBlockState(pos.relative(d));
if((sideState.getBlock() instanceof ChainBlock && sideState.getValue(BlockStateProperties.AXIS) == d.getAxis())
|| (d == Direction.DOWN && sideState.getBlock() instanceof LanternBlock && sideState.getValue(LanternBlock.HANGING))) {
|| (d == Direction.DOWN && sideState.getBlock() instanceof LanternBlock && sideState.getValue(LanternBlock.HANGING))
|| (d == Direction.DOWN && sideState.getBlock() instanceof CeilingHangingSignBlock)) {
BooleanProperty prop = CHAINED[d.ordinal()];
state = state.setValue(prop, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public final void setup(ZCommonSetup event) {
postsTag = ItemTags.create(new ResourceLocation(Quark.MOD_ID, "posts"));
}

public static boolean canLanternConnect(BlockState state, LevelReader worldIn, BlockPos pos, boolean prev) {
public static boolean canHangingBlockConnect(BlockState state, LevelReader worldIn, BlockPos pos, boolean prev) {
return prev ||
(Quark.ZETA.modules.isEnabled(WoodenPostsModule.class)
&& state.getValue(LanternBlock.HANGING)
&& (!state.hasProperty(LanternBlock.HANGING) || state.getValue(LanternBlock.HANGING))
&& worldIn.getBlockState(pos.above()).getBlock() instanceof WoodPostBlock);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,8 @@

public class AncientSaplingBlock extends ZetaSaplingBlock {

public AncientSaplingBlock(ZetaModule module) {
super("ancient", module, new AncientTree());
}

public static class AncientTree extends AbstractTreeGrower {

public final TreeConfiguration config;

public AncientTree() {
config = (new TreeConfiguration.TreeConfigurationBuilder(
BlockStateProvider.simple(AncientWoodModule.woodSet.log),
new MultiFoliageStraightTrunkPlacer(17, 4, 6, 5, 3),
BlockStateProvider.simple(AncientWoodModule.ancient_leaves),
new FancyFoliagePlacer(UniformInt.of(2, 4), ConstantInt.of(-3) , 2),
new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4))))
.decorators(Lists.newArrayList(new AncientTreeTopperDecorator()))
.ignoreVines()
.build();
}

ResourceKey<ConfiguredFeature<?, ?>> ANCIENT_TREE = ResourceKey.create(Registries.CONFIGURED_FEATURE, Quark.asResource("ancient_tree"));

@Override
protected ResourceKey<ConfiguredFeature<?, ?>> getConfiguredFeature(@NotNull RandomSource rand, boolean hasFlowers) {
return ANCIENT_TREE;
}

//fixme find how to call this
public void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
context.register(ANCIENT_TREE, new ConfiguredFeature<>(Feature.TREE, config));
}
public AncientSaplingBlock(ZetaModule module, AbstractTreeGrower grower) {
super("ancient", module, grower);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType;
import org.violetmoon.quark.content.world.module.AncientWoodModule;

//for Ancient Trees, TODO register me
public class AncientTreeTopperDecorator extends TreeDecorator {

public static final Codec<AncientTreeTopperDecorator> CODEC = Codec.unit(AncientTreeTopperDecorator::new);

//Registered in AncientWoodModule
public static final TreeDecoratorType<AncientTreeTopperDecorator> TYPE = new TreeDecoratorType<>(CODEC);

//TODO register me
@Override
protected TreeDecoratorType<?> type() {
//return TYPE;
return null;
return TYPE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ public MultiFoliageStraightTrunkPlacer(int baseHeight, int heightRandA, int heig
)
).apply(overengineered, MultiFoliageStraightTrunkPlacer::new));

//TODO: register me
//Registered in AncientWoodModule
public static final TrunkPlacerType<MultiFoliageStraightTrunkPlacer> TYPE = new TrunkPlacerType<>(CODEC);

@Override
protected TrunkPlacerType<?> type() {
//return TYPE;
return null;
return TYPE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
package org.violetmoon.quark.content.world.module;

import java.util.List;
import java.util.OptionalInt;

import com.google.common.base.Functions;
import com.google.common.collect.ImmutableSet;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.valueproviders.ConstantInt;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.ComposterBlock;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.TreeFeature;
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.foliageplacers.FancyFoliagePlacer;
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
import net.minecraft.world.level.storage.loot.entries.LootItem;
Expand All @@ -16,11 +29,13 @@
import org.violetmoon.quark.base.handler.GeneralConfig;
import org.violetmoon.quark.base.handler.WoodSetHandler;
import org.violetmoon.quark.base.handler.WoodSetHandler.WoodSet;
import org.violetmoon.quark.content.world.block.AncientSaplingBlock;
import org.violetmoon.quark.content.world.feature.AncientTreeTopperDecorator;
import org.violetmoon.quark.content.world.feature.MultiFoliageStraightTrunkPlacer;
import org.violetmoon.quark.content.world.item.AncientFruitItem;
import org.violetmoon.zeta.advancement.ManualTrigger;
import org.violetmoon.zeta.advancement.modifier.BalancedDietModifier;
import org.violetmoon.zeta.block.ZetaLeavesBlock;
import org.violetmoon.zeta.block.ZetaSaplingBlock;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.bus.PlayEvent;
import org.violetmoon.zeta.event.load.ZCommonSetup;
Expand All @@ -29,6 +44,7 @@
import org.violetmoon.zeta.module.ZetaLoadModule;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.util.Hint;
import org.violetmoon.zeta.world.PassthruTreeGrower;

@ZetaLoadModule(category = "world")
public class AncientWoodModule extends ZetaModule {
Expand Down Expand Up @@ -61,6 +77,7 @@ public class AncientWoodModule extends ZetaModule {
public static Block ancient_leaves;
@Hint public static Block ancient_sapling;
@Hint public static Item ancient_fruit;
public static final ResourceKey<ConfiguredFeature<?, ?>> configuredFeatureKey = Quark.asResourceKey(Registries.CONFIGURED_FEATURE, "ancient_tree");

public static ManualTrigger ancientFruitTrigger;

Expand All @@ -75,17 +92,35 @@ public void setup(ZCommonSetup e) {

@LoadEvent
public void register(ZRegister event) {
// wood //

woodSet = WoodSetHandler.addWoodSet(event, this, "ancient", MapColor.TERRACOTTA_WHITE, MapColor.TERRACOTTA_WHITE, true);
ancient_leaves = new ZetaLeavesBlock(woodSet.name, this, MapColor.PLANT);
ancient_sapling = new AncientSaplingBlock(this);
ancient_fruit = new AncientFruitItem(this);
ancient_sapling = new ZetaSaplingBlock("ancient", this, new PassthruTreeGrower(configuredFeatureKey)); //actually called "ancient_sapling"

event.getVariantRegistry().addFlowerPot(ancient_sapling, Quark.ZETA.registry.getRegistryName(ancient_sapling, BuiltInRegistries.BLOCK).getPath(), Functions.identity());
event.getVariantRegistry().addFlowerPot(ancient_sapling, "ancient_sapling", Functions.identity()); //actually "potted_ancient_sapling"

// fruit //

ancient_fruit = new AncientFruitItem(this);
event.getAdvancementModifierRegistry().addModifier(new BalancedDietModifier(this, ImmutableSet.of(ancient_fruit))
.setCondition(() -> GeneralConfig.enableAdvancementModification));

ancientFruitTrigger = event.getAdvancementModifierRegistry().registerManualTrigger("ancient_fruit_overlevel");

// tree //

//i don't think these custom tree placer bits *strictly* need to be registered in json, but it doesn't hurt
event.getRegistry().registerDynamic(MultiFoliageStraightTrunkPlacer.TYPE, "multi_foliage_straight_trunk_placer", Registries.TRUNK_PLACER_TYPE);
event.getRegistry().registerDynamic(AncientTreeTopperDecorator.TYPE, "ancient_tree_topper_decorator", Registries.TREE_DECORATOR_TYPE);

TreeConfiguration treeCfg = new TreeConfiguration.TreeConfigurationBuilder(
BlockStateProvider.simple(woodSet.log),
new MultiFoliageStraightTrunkPlacer(17, 4, 6, 5, 3),
BlockStateProvider.simple(ancient_leaves),
new FancyFoliagePlacer(UniformInt.of(2, 4), ConstantInt.of(-3), 2),
new TwoLayersFeatureSize(0, 0, 0, OptionalInt.of(4))
).decorators(List.of(new AncientTreeTopperDecorator())).ignoreVines().build();
event.getRegistry().registerDynamic(new ConfiguredFeature<>((TreeFeature) Feature.TREE, treeCfg), configuredFeatureKey, Registries.CONFIGURED_FEATURE);
}

@PlayEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import com.google.common.collect.ImmutableSet;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistrySetBuilder;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BiomeDefaultFeatures;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.data.worldgen.biome.OverworldBiomes;
import net.minecraft.data.worldgen.features.OreFeatures;
import net.minecraft.data.worldgen.placement.OrePlacements;
import net.minecraft.resources.RegistryOps;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.Music;
Expand All @@ -31,6 +34,7 @@
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
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.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
Expand Down Expand Up @@ -66,15 +70,7 @@ public class GlimmeringWealdModule extends ZetaModule {
public static final ResourceLocation BIOME_NAME = new ResourceLocation(Quark.MOD_ID, "glimmering_weald");
public static final ResourceKey<Biome> BIOME_KEY = ResourceKey.create(Registries.BIOME, BIOME_NAME);

public static final BootstapContext<PlacedFeature> bootstapContext = new RegistrySetBuilder().createState(RegistryAccessUtil.getRegistryAccess()).bootstapContext();
public static final BootstapContext<ConfiguredFeature<?,?>> bootstapContextConfig = new RegistrySetBuilder().createState(RegistryAccessUtil.getRegistryAccess()).bootstapContext();
public static final BootstapContext<ConfiguredWorldCarver<?>> bootstapContextWorld = new RegistrySetBuilder().createState(RegistryAccessUtil.getRegistryAccess()).bootstapContext();


static {
}

public static final Holder<PlacedFeature> ORE_LAPIS_EXTRA = bootstapContext.register(ResourceKey.create(Registries.PLACED_FEATURE, new ResourceLocation("quark", "ore_lapis_glimmering_weald")), new PlacedFeature(bootstapContext.lookup(Registries.CONFIGURED_FEATURE).getOrThrow(OreFeatures.ORE_LAPIS), OrePlacements.commonOrePlacement(12, HeightRangePlacement.uniform(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(0)))));
public static Holder<PlacedFeature> ore_lapis_extra;
public static Holder<PlacedFeature> placed_glow_shrooms;
public static Holder<PlacedFeature> placed_glow_extras;

Expand Down Expand Up @@ -110,14 +106,50 @@ public final void register(ZRegister event) {
event.getVariantRegistry().addFlowerPot(glow_lichen_growth, "glow_lichen_growth", prop -> prop.lightLevel((state) -> 8));
event.getVariantRegistry().addFlowerPot(glow_shroom, "glow_shroom", prop -> prop.lightLevel((state) -> 10));

//fixme
makeFeatures();
// Features, Configured Features, Placed Features //

placed_glow_shrooms = place(event, "glow_shrooms", new GlowShroomsFeature(), GlowShroomsFeature.placed());
placed_glow_extras = place(event, "glow_extras", new GlowExtrasFeature(), GlowExtrasFeature.placed());
ore_lapis_extra = event.getRegistry().registerDynamicF(lookup -> {
Holder<ConfiguredFeature<?, ?>> lapisConfigured = lookup.lookup(Registries.CONFIGURED_FEATURE)
.orElseThrow() //it better exist
.getter()
.getOrThrow(OreFeatures.ORE_LAPIS); //it better exist
return new PlacedFeature(lapisConfigured, OrePlacements.commonOrePlacement(12, HeightRangePlacement.uniform(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(0))));
}, Quark.asResourceKey(Registries.PLACED_FEATURE, "ore_lapis_glimmering_weald"), Registries.PLACED_FEATURE);

// Biomes //

event.getRegistry().registerDynamicF(lookup -> {
HolderGetter<PlacedFeature> placedFeatures = lookup.lookup(Registries.PLACED_FEATURE).orElseThrow().getter();
HolderGetter<ConfiguredWorldCarver<?>> configuredCarvers = lookup.lookup(Registries.CONFIGURED_CARVER).orElseThrow().getter();

MobSpawnSettings.Builder mobs = new MobSpawnSettings.Builder();
BiomeDefaultFeatures.commonSpawns(mobs);
if(Quark.ZETA.modules.isEnabled(StonelingsModule.class))
mobs.addSpawn(MobCategory.CREATURE, new MobSpawnSettings.SpawnerData(StonelingsModule.stonelingType, 200, 1, 4));
mobs.addSpawn(MobCategory.UNDERGROUND_WATER_CREATURE, new MobSpawnSettings.SpawnerData(EntityType.GLOW_SQUID, 20, 4, 6));

BiomeGenerationSettings.Builder settings = new BiomeGenerationSettings.Builder(placedFeatures, configuredCarvers);
OverworldBiomes.globalOverworldGeneration(settings);
BiomeDefaultFeatures.addPlainGrass(settings);
BiomeDefaultFeatures.addDefaultOres(settings, true);
BiomeDefaultFeatures.addDefaultSoftDisks(settings);
BiomeDefaultFeatures.addPlainVegetation(settings);
BiomeDefaultFeatures.addDefaultMushrooms(settings);
BiomeDefaultFeatures.addDefaultExtraVegetation(settings);

settings.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, placed_glow_shrooms);
settings.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, placed_glow_extras);
settings.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, ore_lapis_extra);

Music music = Musics.createGameMusic(Holder.direct(QuarkSounds.MUSIC_GLIMMERING_WEALD));
return OverworldBiomes.biome(true, 0.8F, 0.4F, mobs, settings, music);
}, BIOME_KEY, Registries.BIOME);
}

@LoadEvent
public void postRegister(ZRegister.Post e) {
//fixme
Quark.ZETA.registry.register(makeBiome(), BIOME_NAME, Registries.BIOME);
float wmin = (float) minDepthRange;
float wmax = (float) maxDepthRange;
if(wmin >= wmax){
Expand Down Expand Up @@ -146,48 +178,14 @@ public void setup(ZCommonSetup e) {
});
}

//fixme
private static void makeFeatures() {
placed_glow_shrooms = place("glow_shrooms", new GlowShroomsFeature(), GlowShroomsFeature.placed());
placed_glow_extras = place("glow_extras", new GlowExtrasFeature(), GlowExtrasFeature.placed());
}


private static Holder<PlacedFeature> place(String featureName, Feature<NoneFeatureConfiguration> feature, List<PlacementModifier> placer) {
String name = Quark.MOD_ID + ":" + featureName;

Quark.ZETA.registry.register(feature, name, Registries.FEATURE);
Holder<ConfiguredFeature<?, ?>> configured = bootstapContextConfig.register(ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(name)), new ConfiguredFeature<>(feature, NoneFeatureConfiguration.NONE));
return bootstapContext.register(ResourceKey.create(Registries.PLACED_FEATURE, new ResourceLocation(name)), new PlacedFeature(configured, placer));
}


private static Biome makeBiome() {
MobSpawnSettings.Builder mobs = new MobSpawnSettings.Builder();
BiomeDefaultFeatures.commonSpawns(mobs);

if(Quark.ZETA.modules.isEnabled(StonelingsModule.class))
mobs.addSpawn(MobCategory.CREATURE, new MobSpawnSettings.SpawnerData(StonelingsModule.stonelingType, 200, 1, 4));
mobs.addSpawn(MobCategory.UNDERGROUND_WATER_CREATURE, new MobSpawnSettings.SpawnerData(EntityType.GLOW_SQUID, 20, 4, 6));

BiomeGenerationSettings.Builder settings = new BiomeGenerationSettings.Builder(bootstapContext.lookup(Registries.PLACED_FEATURE), bootstapContextWorld.lookup(Registries.CONFIGURED_CARVER));
OverworldBiomes.globalOverworldGeneration(settings);
BiomeDefaultFeatures.addPlainGrass(settings);
BiomeDefaultFeatures.addDefaultOres(settings, true);
BiomeDefaultFeatures.addDefaultSoftDisks(settings);
BiomeDefaultFeatures.addPlainVegetation(settings);
BiomeDefaultFeatures.addDefaultMushrooms(settings);
BiomeDefaultFeatures.addDefaultExtraVegetation(settings);

settings.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, placed_glow_shrooms);
settings.addFeature(GenerationStep.Decoration.UNDERGROUND_DECORATION, placed_glow_extras);

settings.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, ORE_LAPIS_EXTRA);
@SuppressWarnings("unchecked")
private static Holder<PlacedFeature> place(ZRegister event, String featureName, Feature<NoneFeatureConfiguration> feature, List<PlacementModifier> placer) {
Holder<Feature<?>> featureHolder = event.getRegistry().registerDynamic(feature, featureName, Registries.FEATURE);

Music music = Musics.createGameMusic(Holder.direct(QuarkSounds.MUSIC_GLIMMERING_WEALD));
Biome biome = OverworldBiomes.biome(true, 0.8F, 0.4F, mobs, settings, music);
ConfiguredFeature<?, ?> cfg = new ConfiguredFeature<>((Feature<NoneFeatureConfiguration>) featureHolder.get(), NoneFeatureConfiguration.NONE);
Holder<ConfiguredFeature<?, ?>> configuredFeatureHolder = event.getRegistry().registerDynamic(cfg, featureName, Registries.CONFIGURED_FEATURE);

return biome;
return event.getRegistry().registerDynamic(new PlacedFeature(configuredFeatureHolder, placer), featureName, Registries.PLACED_FEATURE);
}

}
Loading

0 comments on commit 93b75b1

Please sign in to comment.