Skip to content

Commit

Permalink
Fixed Deadwood Forest generation
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Oct 27, 2020
1 parent bc2498d commit 9ef5fbb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
minecraft_version=1.16.3
forge_version=34.1.25
forge_version=34.1.32
mappings=20200916-1.16.2
mod_version=2.2.0
jei_version=7.6.0.49
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
import java.util.*;
import java.util.function.BiPredicate;

public class SunspeakerEntity extends EfreetBaseEntity implements IReputationTracking, IMerchant { //TODO Change Relics trading/buying to same system as Piglins
public class SunspeakerEntity extends EfreetBaseEntity implements IReputationTracking, IMerchant { //TODO consider changing Relics trading/buying to same system as Piglins
private static final DataParameter<SunspeakerData> SUNSPEAKER_DATA = EntityDataManager.createKey(SunspeakerEntity.class, AtumDataSerializer.SUNSPEAKER_DATA);
@Nullable
private PlayerEntity customer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class AtumFeatures {
public static final StartStructureFeature START_STRUCTURE = register("start_structure", new StartStructureFeature(NoFeatureConfig.field_236558_a_));
public static final DirtyBoneFossilsFeature DIRTY_BONE_FOSSILS = register("dirty_bone_fossil", new DirtyBoneFossilsFeature(NoFeatureConfig.field_236558_a_));
public static final LimestoneDungeonsFeature LIMESTONE_DUNGEONS = register("limestone_dungeon", new LimestoneDungeonsFeature(NoFeatureConfig.field_236558_a_));
public static final DeadwoodFeature DEADWOOD_FEATURE = register("deadwood_tree", new DeadwoodFeature(BaseTreeFeatureConfig.CODEC));
public static final DeadwoodFeature DEADWOOD_FEATURE = register("deadwood_tree", new DeadwoodFeature(NoFeatureConfig.field_236558_a_));
public static final Feature<NoFeatureConfig> LIMESTONE_SPIKE = register("limestone_spike", new LimestoneSpikeFeature(NoFeatureConfig.field_236558_a_));
public static final Feature<BlockClusterFeatureConfig> ANPUTS_FINGERS = register("anputs_fingers", new AnputsFingersFeature(BlockClusterFeatureConfig.field_236587_a_));
public static final Feature<NoFeatureConfig> SAND_LAYER = register("sand_layer", new SandLayerFeature(NoFeatureConfig.field_236558_a_));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static void addDungeon(BiomeGenerationSettings.Builder builder) {
}

public static void addDeadwoodTrees(BiomeGenerationSettings.Builder builder, int count, float extraChance, int extraCount) {
builder.withFeature(VEGETAL_DECORATION, AtumFeatures.DEADWOOD_FEATURE.withConfiguration((new BaseTreeFeatureConfig.Builder(new SimpleBlockStateProvider(AtumBlocks.DEADWOOD_LOG.getDefaultState().with(DeadwoodLogBlock.HAS_SCARAB, true)), new SimpleBlockStateProvider(AtumBlocks.DEADWOOD_BRANCH.getDefaultState()), new BlobFoliagePlacer(FeatureSpread.func_242252_a(0), FeatureSpread.func_242252_a(0), 0), new StraightTrunkPlacer(0, 0, 0), new TwoLayerFeature(0, 0, 0)).build())).withPlacement(Placement.field_242902_f.configure(new AtSurfaceWithExtraConfig(count, extraChance, extraCount))));
builder.withFeature(VEGETAL_DECORATION, AtumFeatures.DEADWOOD_FEATURE.withConfiguration(NoFeatureConfig.field_236559_b_).withPlacement(Features.Placements.HEIGHTMAP_PLACEMENT).withPlacement(Placement.field_242902_f.configure(new AtSurfaceWithExtraConfig(count, extraChance, extraCount))));
}

public static void addTomb(BiomeGenerationSettings.Builder builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,36 @@
import net.minecraft.world.ISeedReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.gen.IWorldGenerationReader;
import net.minecraft.world.gen.WorldGenRegion;
import net.minecraft.world.gen.feature.BaseTreeFeatureConfig;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.minecraft.world.gen.feature.TreeFeature;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;

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

public class DeadwoodFeature extends Feature<BaseTreeFeatureConfig> {
public class DeadwoodFeature extends Feature<NoFeatureConfig> {
private static final BlockState LOG = AtumBlocks.DEADWOOD_LOG.getDefaultState().with(DeadwoodLogBlock.HAS_SCARAB, true);
private static final BlockState BRANCH = AtumBlocks.DEADWOOD_BRANCH.getDefaultState();

public DeadwoodFeature(Codec<BaseTreeFeatureConfig> config) {
public DeadwoodFeature(Codec<NoFeatureConfig> config) {
super(config);
}

@Override
public boolean func_241855_a(@Nonnull ISeedReader genReader, @Nonnull ChunkGenerator generator, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull BaseTreeFeatureConfig config) {
public boolean func_241855_a(@Nonnull ISeedReader genReader, @Nonnull ChunkGenerator generator, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull NoFeatureConfig config) {
if (genReader instanceof WorldGenRegion) {
WorldGenRegion world = (WorldGenRegion) genReader;
Set<BlockPos> logs = Sets.newHashSet();
int baseHeight = rand.nextInt(3) + 5;
boolean doNotGenerate = true;
boolean generate = true;

if (pos.getY() >= 1 && pos.getY() + baseHeight + 1 <= world.getHeight()) {
if (pos.getY() >= 0 && pos.getY() + baseHeight + 1 <= world.getHeight()) {
for (int y = pos.getY(); y <= pos.getY() + 1 + baseHeight; ++y) {
int k = 1;

Expand All @@ -52,32 +54,32 @@ public boolean func_241855_a(@Nonnull ISeedReader genReader, @Nonnull ChunkGener
}
BlockPos.Mutable mutable = new BlockPos.Mutable();

for (int x = pos.getX() - k; x <= pos.getX() + k && doNotGenerate; ++x) {
for (int z = pos.getZ() - k; z <= pos.getZ() + k && doNotGenerate; ++z) {
for (int x = pos.getX() - k; x <= pos.getX() + k && generate; ++x) {
for (int z = pos.getZ() - k; z <= pos.getZ() + k && generate; ++z) {
if (y >= 0 && y < world.getHeight()) {
if (!TreeFeature.func_236410_c_(world, mutable.setPos(x, y, z))) { //TODO Test
doNotGenerate = false;
if (!TreeFeature.func_236410_c_(world, mutable.setPos(x, y, z))) {
generate = false;
}
} else {
doNotGenerate = false;
generate = false;
}
}
}
}

if (!doNotGenerate) {
if (!generate) {
return false;
} else {
BlockPos down = pos.down();
BlockState state = world.getBlockState(down);
boolean isSoil = state.getBlock() == AtumBlocks.SAND;

if (isSoil && pos.getY() < world.getHeight() - baseHeight - 1) {
if (genReader.isAreaLoaded(pos, 2) && isSoil && pos.getY() < world.getHeight() - baseHeight - 1) {
for (int height = 0; height < baseHeight; ++height) {
BlockPos upN = pos.up(height);

if (TreeFeature.isAirOrLeavesAt(genReader, upN)) {
this.setBlockState(genReader, pos.up(height), LOG);
genReader.setBlockState(pos.up(height), LOG, 19);
if (height > 1) {
logs.add(pos.up(height));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@

import java.util.function.Function;

public class TeleporterAtumStart implements ITeleporter {
public class TeleporterAtumStart implements ITeleporter { //TODO Improve start position, when not spawning in portal

@Override
public Entity placeEntity(Entity entity, ServerWorld currentWorld, ServerWorld destWorld, float yaw, Function<Boolean, Entity> repositionEntity) {
System.out.println("HAS START STRUCTURE SPAWNED: " + DimensionHelper.DATA.hasStartStructureSpawned());
if (!DimensionHelper.DATA.hasStartStructureSpawned()) { //TODO Test
this.onAtumJoining(destWorld, entity, yaw);
DimensionHelper.DATA.setHasStartStructureSpawned(true);
destWorld.func_241124_a__(entity.getPosition(), yaw); //Set world spawn pos //TODO Test
destWorld.func_241124_a__(entity.getPosition(), yaw); //Set world spawn pos //TODO Make work
return repositionEntity.apply(false);
}
this.onAtumJoining(destWorld, entity, yaw);
return repositionEntity.apply(false);
return entity;
}

private void onAtumJoining(ServerWorld world, Entity entity, float yaw) {
Expand Down

0 comments on commit 9ef5fbb

Please sign in to comment.