From 5b4a771a34b50d98380afd64bb9d2580c6e3fa90 Mon Sep 17 00:00:00 2001 From: Mrbysco Date: Tue, 25 Jul 2023 20:26:42 +0200 Subject: [PATCH] Re-add Oak Gen replacement --- .../naturesaura/blocks/BlockOakGenerator.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java index bd071bd7..52589924 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java @@ -10,6 +10,7 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.data.worldgen.features.TreeFeatures; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SaplingBlock; import net.minecraft.world.level.block.SoundType; @@ -38,11 +39,11 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab Helper.getBlockEntitiesInArea(level, pos, 10, tile -> { if (!(tile instanceof BlockEntityOakGenerator oak)) return false; - /* var replacement = BlockOakGenerator.getReplacement(event.getFeature()); + var replacement = BlockOakGenerator.getReplacement(event.getFeature()); if (replacement != null) { oak.scheduledBigTrees.add(pos); event.setFeature(replacement); - }*/ + } return true; }); } @@ -68,8 +69,11 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab generator.modLoc("block/" + this.getBaseName() + "_top"))); } - // TODO oak gen replacements - /*private static Holder> getReplacement(Holder> feature) { + private static ResourceKey> getReplacement(Holder> holder) { + if(holder == null || !holder.unwrapKey().isPresent()) + return null; + + ResourceKey> feature = holder.unwrapKey().get(); if (feature == TreeFeatures.FANCY_OAK || feature == TreeFeatures.FANCY_OAK_BEES) { return TreeFeatures.OAK; } else if (feature == TreeFeatures.FANCY_OAK_BEES_002) { @@ -81,5 +85,5 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab } else { return null; } - }*/ + } }