13
0
geforkt von Mirrors/Paper

net.minecraft.world.level.block.grower

Dieser Commit ist enthalten in:
Jake Potrebic 2024-12-14 13:03:13 -08:00
Ursprung 636e4ccaf2
Commit 8ec3dedfbd
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: ECE0B3C133C016C5
2 geänderte Dateien mit 70 neuen und 126 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,70 @@
--- a/net/minecraft/world/level/block/grower/TreeGrower.java
+++ b/net/minecraft/world/level/block/grower/TreeGrower.java
@@ -164,6 +_,7 @@
if (holder1 == null) {
return false;
} else {
+ this.setTreeType(holder1); // CraftBukkit
ConfiguredFeature<?, ?> configuredFeature2 = holder1.value();
BlockState blockState1 = level.getFluidState(pos).createLegacyBlock();
level.setBlock(pos, blockState1, 4);
@@ -198,4 +_,59 @@
return false;
}
+
+ // CraftBukkit start
+ private void setTreeType(Holder<ConfiguredFeature<?, ?>> holder) {
+ ResourceKey<ConfiguredFeature<?, ?>> treeFeature = holder.unwrapKey().get();
+ if (treeFeature == TreeFeatures.OAK || treeFeature == TreeFeatures.OAK_BEES_005) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TREE;
+ } else if (treeFeature == TreeFeatures.HUGE_RED_MUSHROOM) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.RED_MUSHROOM;
+ } else if (treeFeature == TreeFeatures.HUGE_BROWN_MUSHROOM) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.BROWN_MUSHROOM;
+ } else if (treeFeature == TreeFeatures.JUNGLE_TREE) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.COCOA_TREE;
+ } else if (treeFeature == TreeFeatures.JUNGLE_TREE_NO_VINE) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.SMALL_JUNGLE;
+ } else if (treeFeature == TreeFeatures.PINE) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TALL_REDWOOD;
+ } else if (treeFeature == TreeFeatures.SPRUCE) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.REDWOOD;
+ } else if (treeFeature == TreeFeatures.ACACIA) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.ACACIA;
+ } else if (treeFeature == TreeFeatures.BIRCH || treeFeature == TreeFeatures.BIRCH_BEES_005) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.BIRCH;
+ } else if (treeFeature == TreeFeatures.SUPER_BIRCH_BEES_0002) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TALL_BIRCH;
+ } else if (treeFeature == TreeFeatures.SWAMP_OAK) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.SWAMP;
+ } else if (treeFeature == TreeFeatures.FANCY_OAK || treeFeature == TreeFeatures.FANCY_OAK_BEES_005) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.BIG_TREE;
+ } else if (treeFeature == TreeFeatures.JUNGLE_BUSH) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.JUNGLE_BUSH;
+ } else if (treeFeature == TreeFeatures.DARK_OAK) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.DARK_OAK;
+ } else if (treeFeature == TreeFeatures.MEGA_SPRUCE) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.MEGA_REDWOOD;
+ } else if (treeFeature == TreeFeatures.MEGA_PINE) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.MEGA_PINE;
+ } else if (treeFeature == TreeFeatures.MEGA_JUNGLE_TREE) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.JUNGLE;
+ } else if (treeFeature == TreeFeatures.AZALEA_TREE) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.AZALEA;
+ } else if (treeFeature == TreeFeatures.MANGROVE) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.MANGROVE;
+ } else if (treeFeature == TreeFeatures.TALL_MANGROVE) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TALL_MANGROVE;
+ } else if (treeFeature == TreeFeatures.CHERRY || treeFeature == TreeFeatures.CHERRY_BEES_005) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.CHERRY;
+ } else if (treeFeature == TreeFeatures.PALE_OAK || treeFeature == TreeFeatures.PALE_OAK_BONEMEAL) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.PALE_OAK;
+ } else if (treeFeature == TreeFeatures.PALE_OAK_CREAKING) {
+ net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.PALE_OAK_CREAKING;
+ } else {
+ throw new IllegalArgumentException("Unknown tree generator " + treeFeature);
+ }
+ }
+ // CraftBukkit end
}

Datei anzeigen

@ -1,126 +0,0 @@
--- a/net/minecraft/world/level/block/grower/TreeGrower.java
+++ b/net/minecraft/world/level/block/grower/TreeGrower.java
@@ -20,9 +20,14 @@
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
+import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
+// CraftBukkit start
+import net.minecraft.data.worldgen.features.TreeFeatures;
+import org.bukkit.TreeType;
+// CraftBukkit end
public final class TreeGrower {
@@ -75,21 +80,22 @@
}
}
- return flowersNearby && this.flowers.isPresent() ? (ResourceKey) this.flowers.get() : (ResourceKey) this.tree.orElse((Object) null);
+ return flowersNearby && this.flowers.isPresent() ? (ResourceKey) this.flowers.get() : (ResourceKey) this.tree.orElse(null); // CraftBukkit - decompile error
}
@Nullable
private ResourceKey<ConfiguredFeature<?, ?>> getConfiguredMegaFeature(RandomSource random) {
- return this.secondaryMegaTree.isPresent() && random.nextFloat() < this.secondaryChance ? (ResourceKey) this.secondaryMegaTree.get() : (ResourceKey) this.megaTree.orElse((Object) null);
+ return this.secondaryMegaTree.isPresent() && random.nextFloat() < this.secondaryChance ? (ResourceKey) this.secondaryMegaTree.get() : (ResourceKey) this.megaTree.orElse(null); // CraftBukkit - decompile error
}
public boolean growTree(ServerLevel world, ChunkGenerator chunkGenerator, BlockPos pos, BlockState state, RandomSource random) {
ResourceKey<ConfiguredFeature<?, ?>> resourcekey = this.getConfiguredMegaFeature(random);
if (resourcekey != null) {
- Holder<ConfiguredFeature<?, ?>> holder = (Holder) world.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey).orElse((Object) null);
+ Holder<ConfiguredFeature<?, ?>> holder = (Holder) world.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey).orElse(null); // CraftBukkit - decompile error
if (holder != null) {
+ this.setTreeType(holder); // CraftBukkit
for (int i = 0; i >= -1; --i) {
for (int j = 0; j >= -1; --j) {
if (TreeGrower.isTwoByTwoSapling(state, world, pos, i, j)) {
@@ -120,11 +126,12 @@
if (resourcekey1 == null) {
return false;
} else {
- Holder<ConfiguredFeature<?, ?>> holder1 = (Holder) world.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey1).orElse((Object) null);
+ Holder<ConfiguredFeature<?, ?>> holder1 = (Holder) world.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).get(resourcekey1).orElse(null); // CraftBukkit - decompile error
if (holder1 == null) {
return false;
} else {
+ this.setTreeType(holder1); // CraftBukkit
ConfiguredFeature<?, ?> worldgenfeatureconfigured1 = (ConfiguredFeature) holder1.value();
BlockState iblockdata2 = world.getFluidState(pos).createLegacyBlock();
@@ -165,11 +172,66 @@
return true;
}
+ // CraftBukkit start
+ private void setTreeType(Holder<ConfiguredFeature<?, ?>> holder) {
+ ResourceKey<ConfiguredFeature<?, ?>> worldgentreeabstract = holder.unwrapKey().get();
+ if (worldgentreeabstract == TreeFeatures.OAK || worldgentreeabstract == TreeFeatures.OAK_BEES_005) {
+ SaplingBlock.treeType = TreeType.TREE;
+ } else if (worldgentreeabstract == TreeFeatures.HUGE_RED_MUSHROOM) {
+ SaplingBlock.treeType = TreeType.RED_MUSHROOM;
+ } else if (worldgentreeabstract == TreeFeatures.HUGE_BROWN_MUSHROOM) {
+ SaplingBlock.treeType = TreeType.BROWN_MUSHROOM;
+ } else if (worldgentreeabstract == TreeFeatures.JUNGLE_TREE) {
+ SaplingBlock.treeType = TreeType.COCOA_TREE;
+ } else if (worldgentreeabstract == TreeFeatures.JUNGLE_TREE_NO_VINE) {
+ SaplingBlock.treeType = TreeType.SMALL_JUNGLE;
+ } else if (worldgentreeabstract == TreeFeatures.PINE) {
+ SaplingBlock.treeType = TreeType.TALL_REDWOOD;
+ } else if (worldgentreeabstract == TreeFeatures.SPRUCE) {
+ SaplingBlock.treeType = TreeType.REDWOOD;
+ } else if (worldgentreeabstract == TreeFeatures.ACACIA) {
+ SaplingBlock.treeType = TreeType.ACACIA;
+ } else if (worldgentreeabstract == TreeFeatures.BIRCH || worldgentreeabstract == TreeFeatures.BIRCH_BEES_005) {
+ SaplingBlock.treeType = TreeType.BIRCH;
+ } else if (worldgentreeabstract == TreeFeatures.SUPER_BIRCH_BEES_0002) {
+ SaplingBlock.treeType = TreeType.TALL_BIRCH;
+ } else if (worldgentreeabstract == TreeFeatures.SWAMP_OAK) {
+ SaplingBlock.treeType = TreeType.SWAMP;
+ } else if (worldgentreeabstract == TreeFeatures.FANCY_OAK || worldgentreeabstract == TreeFeatures.FANCY_OAK_BEES_005) {
+ SaplingBlock.treeType = TreeType.BIG_TREE;
+ } else if (worldgentreeabstract == TreeFeatures.JUNGLE_BUSH) {
+ SaplingBlock.treeType = TreeType.JUNGLE_BUSH;
+ } else if (worldgentreeabstract == TreeFeatures.DARK_OAK) {
+ SaplingBlock.treeType = TreeType.DARK_OAK;
+ } else if (worldgentreeabstract == TreeFeatures.MEGA_SPRUCE) {
+ SaplingBlock.treeType = TreeType.MEGA_REDWOOD;
+ } else if (worldgentreeabstract == TreeFeatures.MEGA_PINE) {
+ SaplingBlock.treeType = TreeType.MEGA_PINE;
+ } else if (worldgentreeabstract == TreeFeatures.MEGA_JUNGLE_TREE) {
+ SaplingBlock.treeType = TreeType.JUNGLE;
+ } else if (worldgentreeabstract == TreeFeatures.AZALEA_TREE) {
+ SaplingBlock.treeType = TreeType.AZALEA;
+ } else if (worldgentreeabstract == TreeFeatures.MANGROVE) {
+ SaplingBlock.treeType = TreeType.MANGROVE;
+ } else if (worldgentreeabstract == TreeFeatures.TALL_MANGROVE) {
+ SaplingBlock.treeType = TreeType.TALL_MANGROVE;
+ } else if (worldgentreeabstract == TreeFeatures.CHERRY || worldgentreeabstract == TreeFeatures.CHERRY_BEES_005) {
+ SaplingBlock.treeType = TreeType.CHERRY;
+ } else if (worldgentreeabstract == TreeFeatures.PALE_OAK || worldgentreeabstract == TreeFeatures.PALE_OAK_BONEMEAL) {
+ SaplingBlock.treeType = TreeType.PALE_OAK;
+ } else if (worldgentreeabstract == TreeFeatures.PALE_OAK_CREAKING) {
+ SaplingBlock.treeType = TreeType.PALE_OAK_CREAKING;
+ } else {
+ throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract);
+ }
+ }
+ // CraftBukkit end
+
static {
- Function function = (worldgentreeprovider) -> {
+ Function<TreeGrower, String> function = (worldgentreeprovider) -> { // CraftBukkit - decompile error
return worldgentreeprovider.name;
};
- Map map = TreeGrower.GROWERS;
+ Map<String, TreeGrower> map = TreeGrower.GROWERS; // CraftBukkit - decompile error
Objects.requireNonNull(map);
CODEC = Codec.stringResolver(function, map::get);