Skip to content

Commit

Permalink
Started implementing worldgen features again
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed May 7, 2023
1 parent 3f1baff commit ff310d0
Show file tree
Hide file tree
Showing 34 changed files with 658 additions and 616 deletions.
9 changes: 4 additions & 5 deletions src/main/java/com/teammetallurgy/atum/Atum.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.teammetallurgy.atum.misc.AtumConfig;
import com.teammetallurgy.atum.network.NetworkHandler;
import com.teammetallurgy.atum.world.SandstormHandler;
import com.teammetallurgy.atum.world.gen.feature.tree.TreePlacerTypes;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
Expand All @@ -19,9 +20,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.dimension.LevelStem;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CreativeModeTabEvent;
import net.minecraftforge.event.RegisterCommandsEvent;
Expand Down Expand Up @@ -85,8 +83,7 @@ private void setupCommon(FMLCommonSetupEvent event) {
if (AtumConfig.SANDSTORM.sandstormEnabled.get()) {
MinecraftForge.EVENT_BUS.register(SandstormHandler.INSTANCE);
}
// MinecraftForge.EVENT_BUS.register(AtumStructures.PYRAMID_STRUCTURE); //TODO
// Require structures functioning
// MinecraftForge.EVENT_BUS.register(AtumStructures.PYRAMID_STRUCTURE); //TODO Require structures functioning
KhnumiteFaceBlock.addDispenserSupport();
NetworkHandler.initialize();
IntegrationHandler.INSTANCE.setup();
Expand Down Expand Up @@ -118,6 +115,8 @@ public void registerDeferredRegistries(IEventBus modBus) {
AtumItems.ITEM_DEFERRED.register(modBus);
AtumEntities.ENTITY_DEFERRED.register(modBus);
AtumTileEntities.BLOCK_ENTITY_DEFERRED.register(modBus);
AtumFeatures.FEATURES_DEFERRED.register(modBus);
TreePlacerTypes.FOLIAGE_PLACER_DEFERRED.register(modBus);
AtumMenuType.MENU_TYPE_DEFERRED.register(modBus);
AtumPoiTypes.POI_DEFERRED.register(modBus);
AtumSounds.SOUND_DEFERRED.register(modBus);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.teammetallurgy.atum.blocks.wood;

import com.teammetallurgy.atum.init.AtumBlocks;
import com.teammetallurgy.atum.world.gen.feature.tree.PalmTree;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.grower.AcaciaTreeGrower;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
Expand All @@ -19,7 +19,7 @@ public class PalmSaplingBlock extends SaplingBlock implements BonemealableBlock
private static final VoxelShape PALM_SAPLING_AABB = Block.box(0.0D, 0.0D, 0.0D, 6.0D, 7.0D, 6.0D);

public PalmSaplingBlock() {
super(new AcaciaTreeGrower() /*new PalmTree() //TODO Uncomment when worldgen stuff is re-added*/, Block.Properties.of(Material.PLANT).noCollission().randomTicks().strength(0.0F).sound(SoundType.GRASS));
super(new PalmTree(), Block.Properties.of(Material.PLANT).noCollission().randomTicks().strength(0.0F).sound(SoundType.GRASS));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ protected void onHitEntity(@Nonnull EntityHitResult rayTraceResult) {

if (livingBase.getEffect(MobEffects.POISON) != null) { //Extra damage, if target is already poisoned
this.setBaseDamage(this.getBaseDamage() * 1.5D);
System.out.println("Extra Damage for posioned: " + this.getBaseDamage());
}

livingBase.addEffect(poison);
Expand Down
200 changes: 77 additions & 123 deletions src/main/java/com/teammetallurgy/atum/init/AtumFeatures.java

Large diffs are not rendered by default.

11 changes: 2 additions & 9 deletions src/main/java/com/teammetallurgy/atum/misc/AtumConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,11 @@ public static class Sandstorm {
}
}

public static class WorldGen {
public static class WorldGen { //TODO
public static final String WORLDGEN = "world gen";
public static final String OREGEN = "ore gen";
public final ForgeConfigSpec.DoubleValue mineshaftProbability;
public final ForgeConfigSpec.IntValue ruinsAmount;
public final ForgeConfigSpec.IntValue shrubFrequency;
public final ForgeConfigSpec.IntValue fossilsChance;
public final ForgeConfigSpec.IntValue dungeonChance;
public final ForgeConfigSpec.BooleanValue sandLayerEdge;

WorldGen(ForgeConfigSpec.Builder builder) {
Expand All @@ -109,19 +106,15 @@ public static class WorldGen {
this.ruinsAmount = builder.comment("Specify the amount of ruin variants structures/ruins. Allows for additional ruin structures with a resourcepack")
.translation("atum.config.ruins_amount")
.defineInRange("Ruins Amount", 17, 1, 999);
this.shrubFrequency = builder.defineInRange("Shrub frequency, set to 0 to disable", 1, 0, 64);
this.fossilsChance = builder.defineInRange("Fossils chance, set to 0 to disable", 64, 0, 255);
this.dungeonChance = builder.defineInRange("Dungeon chance, set to 0 to disable", 8, 0, 255);
this.sandLayerEdge = builder.comment("Should Sand Layers generate along all edges?")
.translation("atum.config.sand_layer_enabled")
.define("Enable Sand Layer along edges", true);
builder.pop();
builder.push(OREGEN).comment("All vanilla based ores, uses the vanilla values by default.");
builder.pop();
}
}

public static class Biome {
public static class Biome { //TODO
public static final String BIOME = "biome";
public ForgeConfigSpec.IntValue subBiomeChance;
public ForgeConfigSpec.IntValue oasisChance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ public static void addDefaultSpawns(String biomeName) {
}

public static void addCamelSpawning(String biomeName) {
//addSpawn(biomeName, AtumEntities.CAMEL.get(), 6, 2, 6, MobCategory.CREATURE); //TODO
//addSpawn(biomeName, AtumEntities.CAMEL.get(), 6, 2, 6, MobCategory.CREATURE);
}

public static void addDesertWolfSpawning(String biomeName) {
//addSpawn(biomeName, AtumEntities.DESERT_WOLF.get(), 6, 2, 4, MobCategory.CREATURE); //TODO
//addSpawn(biomeName, AtumEntities.DESERT_WOLF.get(), 6, 2, 4, MobCategory.CREATURE);
}

public static class Builder extends Biome.BiomeBuilder {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,49 @@
/*
package com.teammetallurgy.atum.world.gen.feature;

import com.mojang.serialization.Codec;
import com.teammetallurgy.atum.init.AtumBlocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.RandomPatchFeature;
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;

import javax.annotation.Nonnull;
import java.util.Random;

public class AnputsFingersFeature extends RandomPatchFeature { //TODO
public class AnputsFingersFeature extends Feature<NoneFeatureConfiguration> {

public AnputsFingersFeature(Codec<RandomPatchConfiguration> config) {
public AnputsFingersFeature(Codec<NoneFeatureConfiguration> config) {
super(config);
}

@Override
public boolean place(@Nonnull WorldGenLevel seedReader, @Nonnull ChunkGenerator generator, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull RandomPatchConfiguration config) {
BlockState state = config.stateProvider.getState(rand, pos);
BlockPos placePos = seedReader.getHeightmapPos(Heightmap.Types.WORLD_SURFACE_WG, pos);
public boolean place(@Nonnull FeaturePlaceContext<NoneFeatureConfiguration> placeContext) {
WorldGenLevel genLevel = placeContext.level();
BlockPos pos = placeContext.origin();
RandomSource random = placeContext.random();

BlockState state = AtumBlocks.ANPUTS_FINGERS.get().defaultBlockState();
BlockPos placePos = genLevel.getHeightmapPos(Heightmap.Types.WORLD_SURFACE_WG, pos);

boolean isNextToDeadwood = false;
for (Direction direction : Direction.Plane.HORIZONTAL) {
if (seedReader.getBlockState(placePos.relative(direction)).getBlock() == AtumBlocks.DEADWOOD_LOG) {
if (genLevel.getBlockState(placePos.relative(direction)).getBlock() == AtumBlocks.DEADWOOD_LOG.get()) {
isNextToDeadwood = true;
}
}

if (isNextToDeadwood) {
BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();
mutablePos.set(placePos);
if (seedReader.isEmptyBlock(mutablePos) && seedReader.getBlockState(mutablePos.below()).getBlock() == AtumBlocks.SAND) {
config.blockPlacer.place(seedReader, mutablePos, state, rand);
if (genLevel.isEmptyBlock(mutablePos) && genLevel.getBlockState(mutablePos.below()).getBlock() == AtumBlocks.STRANGE_SAND.get()) {
genLevel.setBlock(mutablePos, state, 2);
return true;
}
}
return false;
}
}*/
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,57 @@
/*
package com.teammetallurgy.atum.world.gen.feature;

import com.mojang.serialization.Codec;
import com.teammetallurgy.atum.init.AtumBlocks;
import com.teammetallurgy.atum.init.AtumLootTables;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;

import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class BonusCrateFeature extends Feature<NoneFeatureConfiguration> { //TODO
public class BonusCrateFeature extends Feature<NoneFeatureConfiguration> { //TODO Water seems to generate on two of the sides of it?? Apparently vanilla bug - look into how to fix

public BonusCrateFeature(Codec<NoneFeatureConfiguration> config) {
super(config);
}

@Override
public boolean place(@Nonnull WorldGenLevel seedReader, @Nonnull ChunkGenerator generator, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull NoneFeatureConfiguration config) {
ChunkPos chunkpos = new ChunkPos(pos);
List<Integer> xPositions = IntStream.rangeClosed(chunkpos.getMinBlockX(), chunkpos.getMaxBlockX()).boxed().collect(Collectors.toList());
Collections.shuffle(xPositions, rand);
List<Integer> zPositions = IntStream.rangeClosed(chunkpos.getMinBlockZ(), chunkpos.getMaxBlockZ()).boxed().collect(Collectors.toList());
Collections.shuffle(zPositions, rand);
public boolean place(@Nonnull FeaturePlaceContext<NoneFeatureConfiguration> placeContext) {
WorldGenLevel genLevel = placeContext.level();
RandomSource random = placeContext.random();
ChunkPos chunkpos = new ChunkPos(placeContext.origin());
IntArrayList xPositions = Util.toShuffledList(IntStream.rangeClosed(chunkpos.getMinBlockX(), chunkpos.getMaxBlockX()), random);
IntArrayList zPositions = Util.toShuffledList(IntStream.rangeClosed(chunkpos.getMinBlockZ(), chunkpos.getMaxBlockZ()), random);
BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();

for (Integer x : xPositions) {
for (Integer z : zPositions) {
mutablePos.set(x, 0, z);
BlockPos posHeight = seedReader.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, mutablePos);
if (seedReader.isEmptyBlock(posHeight) || seedReader.getBlockState(posHeight).getCollisionShape(seedReader, posHeight).isEmpty()) {
seedReader.setBlock(posHeight, AtumBlocks.DEADWOOD_CRATE.defaultBlockState(), 2);
RandomizableContainerBlockEntity.setLootTable(seedReader, rand, posHeight, AtumLootTables.CRATE_BONUS);
BlockState torch = AtumBlocks.DEADWOOD_TORCH.defaultBlockState();
BlockPos posHeight = genLevel.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, mutablePos);
if (genLevel.isEmptyBlock(posHeight) || genLevel.getBlockState(posHeight).getCollisionShape(genLevel, posHeight).isEmpty()) {
genLevel.setBlock(posHeight, AtumBlocks.DEADWOOD_CRATE.get().defaultBlockState(), 2);
RandomizableContainerBlockEntity.setLootTable(genLevel, random, posHeight, AtumLootTables.CRATE_BONUS);
BlockState torch = AtumBlocks.DEADWOOD_TORCH.get().defaultBlockState();

for (Direction horizontal : Direction.Plane.HORIZONTAL) {
BlockPos neighborPos = posHeight.relative(horizontal);
if (torch.canSurvive(seedReader, neighborPos)) {
seedReader.setBlock(neighborPos, torch, 2);
if (torch.canSurvive(genLevel, neighborPos)) {
genLevel.setBlock(neighborPos, torch, 2);
}
}
return true;
Expand All @@ -58,4 +60,4 @@ public boolean place(@Nonnull WorldGenLevel seedReader, @Nonnull ChunkGenerator
}
return false;
}
}*/
}

0 comments on commit ff310d0

Please sign in to comment.