tutorial:trees
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:trees [2022/09/10 19:34] – [Creating the TreeDecorator] nexus-dino | tutorial:trees [2022/12/21 01:40] (current) – 1.19.3 haykam | ||
---|---|---|---|
Line 27: | Line 27: | ||
<code java> | <code java> | ||
- | public static final RegistryEntry< | + | public static final RegistryEntry< |
// Configure the feature using the builder | // Configure the feature using the builder | ||
new TreeFeatureConfig.Builder( | new TreeFeatureConfig.Builder( | ||
Line 76: | Line 76: | ||
public static void register() { | public static void register() { | ||
- | Registry.register(Registry.BLOCK, new Identifier(" | + | Registry.register(Registries.BLOCK, new Identifier(" |
- | Registry.register(Registry.ITEM, new Identifier(" | + | Registry.register(Registries.ITEM, new Identifier(" |
} | } | ||
Line 163: | Line 163: | ||
<code java> | <code java> | ||
- | public static final TrunkPlacerType< | + | public static final TrunkPlacerType< |
</ | </ | ||
Line 220: | Line 220: | ||
public static final Codec< | public static final Codec< | ||
fillFoliagePlacerFields(instance) | fillFoliagePlacerFields(instance) | ||
- | .and(IntProvider.createValidatingCodec(1, | + | .and(IntProvider.createValidatingCodec(1, |
.apply(instance, | .apply(instance, | ||
Line 277: | Line 277: | ||
<code java> | <code java> | ||
- | public static final FoliagePlacerType< | + | public static final FoliagePlacerType< |
</ | </ | ||
Line 371: | Line 371: | ||
<code java> | <code java> | ||
- | public static final TreeDecoratorType< | + | public static final TreeDecoratorType< |
</ | </ | ||
Line 388: | Line 388: | ||
<code java> | <code java> | ||
public class RichSaplingGenerator extends SaplingGenerator { | public class RichSaplingGenerator extends SaplingGenerator { | ||
- | private final ConfiguredFeature< | ||
- | |||
- | public RichSaplingGenerator(ConfiguredFeature<?, | ||
- | this.feature = (ConfiguredFeature< | ||
- | } | ||
- | |||
@Nullable | @Nullable | ||
@Override | @Override | ||
- | protected ConfiguredFeature< | + | protected |
int chance = random.nextInt(100); | int chance = random.nextInt(100); | ||
| | ||
// Each tree has a 10% chance | // Each tree has a 10% chance | ||
- | | + | |
- | | + | case 10 -> TreeConfiguredFeatures.OAK; |
- | } else if (chance < 20) { | + | |
- | return ConfiguredFeatures.BIRCH; | + | case 30 -> TreeConfiguredFeatures.MEGA_SPRUCE; |
- | } else if (chance < 60) { | + | |
- | return ConfiguredFeatures.SPRUCE; | + | |
- | } else if (chance < 40) { | + | |
- | return ConfiguredFeatures.MEGA_SPRUCE; | + | |
- | } else if (chance < 50) { | + | |
- | return ConfiguredFeatures.PINE; | + | |
- | } else if (chance < 60) { | + | |
- | return ConfiguredFeatures.MEGA_PINE; | + | |
- | } else if (chance < 70) { | + | |
- | return ConfiguredFeatures.MEGA_JUNGLE_TREE; | + | |
} | } | ||
- | + | } | |
- | // If none of that happened (the random value was between 70 and 100), create the actual tree | + | |
- | return feature; | + | |
- | } | + | |
} | } | ||
</ | </ | ||
Line 433: | Line 418: | ||
<code java> | <code java> | ||
[...] | [...] | ||
- | .dirtProvider(new SimpleBlockStateProvider(Blocks.IRON_BLOCK.getDefaultState())) | + | .dirtProvider(BlockStateProvider.of(Blocks.IRON_BLOCK)) |
[...] | [...] | ||
</ | </ |
tutorial/trees.1662838487.txt.gz · Last modified: 2022/09/10 19:34 by nexus-dino