Skip to content

Commit

Permalink
Added worldgen
Browse files Browse the repository at this point in the history
  • Loading branch information
supermassimo committed Jul 4, 2023
1 parent c301b7a commit 71d85e3
Show file tree
Hide file tree
Showing 21 changed files with 686 additions and 633 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
modName=DynamicTreesPHC2
modId=dtphc2
modVersion=1.0.0
modVersion=1.1.0
group=maxhyper.dtphc2

mcVersion=1.18.2
Expand Down
113 changes: 53 additions & 60 deletions src/main/java/maxhyper/dtphc2/DynamicTreesPHC2.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.ferreusveritas.dynamictrees.systems.pod.Pod;
import com.ferreusveritas.dynamictrees.tree.family.Family;
import com.ferreusveritas.dynamictrees.tree.species.Species;
import com.pam.pamhc2trees.config.EnableConfig;
import com.pam.pamhc2trees.init.WorldGenRegistry;
import com.pam.pamhc2trees.init.ItemRegistry;
import maxhyper.dtphc2.init.DTPHC2Blocks;
import maxhyper.dtphc2.compat.DTPConfig;
Expand Down Expand Up @@ -62,64 +62,57 @@ public DynamicTreesPHC2() {
}

private void commonSetup(final FMLConstructModEvent event) {
if (DTConfigs.WORLD_GEN.get()) {
ForgeConfigSpec.BooleanValue[] test = {
EnableConfig.apple_worldgen,
EnableConfig.avocado_worldgen,
EnableConfig.candlenut_worldgen,
EnableConfig.cherry_worldgen,
EnableConfig.chestnut_worldgen,
EnableConfig.gooseberry_worldgen,
EnableConfig.lemon_worldgen,
EnableConfig.nutmeg_worldgen,
EnableConfig.orange_worldgen,
EnableConfig.peach_worldgen,
EnableConfig.pear_worldgen,
EnableConfig.plum_worldgen,
EnableConfig.walnut_worldgen,
EnableConfig.spiderweb_worldgen,
EnableConfig.hazelnut_worldgen,
EnableConfig.pawpaw_worldgen,
EnableConfig.soursop_worldgen,
EnableConfig.almond_worldgen,
EnableConfig.apricot_worldgen,
EnableConfig.banana_worldgen,
EnableConfig.cashew_worldgen,
EnableConfig.cinnamon_worldgen,
EnableConfig.coconut_worldgen,
EnableConfig.date_worldgen,
EnableConfig.dragonfruit_worldgen,
EnableConfig.durian_worldgen,
EnableConfig.fig_worldgen,
EnableConfig.grapefruit_worldgen,
EnableConfig.lime_worldgen,
EnableConfig.mango_worldgen,
EnableConfig.olive_worldgen,
EnableConfig.papaya_worldgen,
EnableConfig.paperbark_worldgen,
EnableConfig.pecan_worldgen,
EnableConfig.peppercorn_worldgen,
EnableConfig.persimmon_worldgen,
EnableConfig.pistachio_worldgen,
EnableConfig.pomegranate_worldgen,
EnableConfig.starfruit_worldgen,
EnableConfig.vanillabean_worldgen,
EnableConfig.breadfruit_worldgen,
EnableConfig.guava_worldgen,
EnableConfig.jackfruit_worldgen,
EnableConfig.lychee_worldgen,
EnableConfig.passionfruit_worldgen,
EnableConfig.rambutan_worldgen,
EnableConfig.tamarind_worldgen,
EnableConfig.maple_worldgen,
EnableConfig.pinenut_worldgen,
};

for (ForgeConfigSpec.BooleanValue v : test) {
//v.set(false);
//v.save();
}
}
// if (DTConfigs.WORLD_GEN.get()) {
// WorldGenRegistry.apple_worldgen = null;
// WorldGenRegistry.avocado_worldgen = null;
// WorldGenRegistry.candlenut_worldgen = null;
// WorldGenRegistry.cherry_worldgen = null;
// WorldGenRegistry.chestnut_worldgen = null;
// WorldGenRegistry.gooseberry_worldgen = null;
// WorldGenRegistry.lemon_worldgen = null;
// WorldGenRegistry.nutmeg_worldgen = null;
// WorldGenRegistry.orange_worldgen = null;
// WorldGenRegistry.peach_worldgen = null;
// WorldGenRegistry.pear_worldgen = null;
// WorldGenRegistry.plum_worldgen = null;
// WorldGenRegistry.walnut_worldgen = null;
// WorldGenRegistry.spiderweb_worldgen = null;
// WorldGenRegistry.hazelnut_worldgen = null;
// WorldGenRegistry.pawpaw_worldgen = null;
// WorldGenRegistry.soursop_worldgen = null;
// WorldGenRegistry.almond_worldgen = null;
// WorldGenRegistry.apricot_worldgen = null;
// WorldGenRegistry.banana_worldgen = null;
// WorldGenRegistry.cashew_worldgen = null;
// WorldGenRegistry.cinnamon_worldgen = null;
// WorldGenRegistry.coconut_worldgen = null;
// WorldGenRegistry.date_worldgen = null;
// WorldGenRegistry.dragonfruit_worldgen = null;
// WorldGenRegistry.durian_worldgen = null;
// WorldGenRegistry.fig_worldgen = null;
// WorldGenRegistry.grapefruit_worldgen = null;
// WorldGenRegistry.lime_worldgen = null;
// WorldGenRegistry.mango_worldgen = null;
// WorldGenRegistry.olive_worldgen = null;
// WorldGenRegistry.papaya_worldgen = null;
// WorldGenRegistry.paperbark_worldgen = null;
// WorldGenRegistry.pecan_worldgen = null;
// WorldGenRegistry.peppercorn_worldgen = null;
// WorldGenRegistry.persimmon_worldgen = null;
// WorldGenRegistry.pistachio_worldgen = null;
// WorldGenRegistry.pomegranate_worldgen = null;
// WorldGenRegistry.starfruit_worldgen = null;
// WorldGenRegistry.vanillabean_worldgen = null;
// WorldGenRegistry.breadfruit_worldgen = null;
// WorldGenRegistry.guava_worldgen = null;
// WorldGenRegistry.jackfruit_worldgen = null;
// WorldGenRegistry.lychee_worldgen = null;
// WorldGenRegistry.passionfruit_worldgen = null;
// WorldGenRegistry.rambutan_worldgen = null;
// WorldGenRegistry.tamarind_worldgen = null;
// WorldGenRegistry.maple_worldgen = null;
// WorldGenRegistry.pinenut_worldgen = null;
// }
}

private void clientSetup(final FMLClientSetupEvent event) {
Expand All @@ -140,7 +133,7 @@ private void gatherData(final GatherDataEvent event) {
);
}

public static ResourceLocation resLoc(final String path) {
public static ResourceLocation location(final String path) {
return new ResourceLocation(MOD_ID, path);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos,

@Override
public Item asItem() {
Item item = ForgeRegistries.ITEMS.getValue(DynamicTreesPHC2.resLoc("banana_seed"));
Item item = ForgeRegistries.ITEMS.getValue(DynamicTreesPHC2.location("banana_seed"));
if (item == null) return Items.AIR;
return item;
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/maxhyper/dtphc2/blocks/FruitVineBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -61,7 +63,7 @@ public class FruitVineBlock extends VineBlock {

public FruitVineBlock() {
super(BlockBehaviour.Properties.of(Material.REPLACEABLE_PLANT).noCollission().randomTicks().strength(0.2F).sound(SoundType.VINE));
this.registerDefaultState(this.stateDefinition.any().setValue(ageProperty, 0));
this.registerDefaultState(defaultBlockState().setValue(ageProperty, 0));
}

public void setAge(Level world, BlockPos pos, BlockState state, int age, boolean destroy) {
Expand Down Expand Up @@ -275,7 +277,7 @@ public boolean canSupportAtFace(BlockGetter pLevel, BlockPos pPos, Direction pDi

public static boolean isAcceptableNeighbour(BlockGetter pBlockReader, BlockPos pLevel, Direction pNeighborPos) {
BlockState blockstate = pBlockReader.getBlockState(pLevel);
return Block.isFaceFull(blockstate.getCollisionShape(pBlockReader, pLevel), pNeighborPos.getOpposite()) || TreeHelper.isBranch(blockstate);
return Block.isFaceFull(blockstate.getCollisionShape(pBlockReader, pLevel), pNeighborPos.getOpposite()) || blockstate.is(BlockTags.LEAVES) || TreeHelper.isBranch(blockstate);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package maxhyper.dtphc2.canceller;

import com.ferreusveritas.dynamictrees.api.worldgen.FeatureCanceller;
import net.minecraft.resources.ResourceLocation;
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.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.RandomFeatureConfiguration;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;

import java.util.Objects;
import java.util.Set;

public class DTPHC2TreeFeatureCanceller extends FeatureCanceller {

private final Class<?>[] treeFeatureClasses;

public DTPHC2TreeFeatureCanceller(final ResourceLocation registryName, Class<?>... treeFeatureClass) {
super(registryName);
this.treeFeatureClasses = treeFeatureClass;
}

@Override
public boolean shouldCancel(ConfiguredFeature<?, ?> configuredFeature, Set<String> namespaces) {
Feature<?> feature = configuredFeature.feature();
if (namespaces.contains(Objects.requireNonNull(feature.getRegistryName()).getNamespace())) {
for (Class<?> treeFeatureClass : treeFeatureClasses){
if (treeFeatureClass.isInstance(feature))
return true;
}
}
return false;
}

}
Loading

0 comments on commit 71d85e3

Please sign in to comment.