summaryrefslogtreecommitdiffstats
path: root/nms-patches/WorldGenTreeProvider.patch
blob: ba2116c74c6040e8249d7e90316072de3e5dc29d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--- a/net/minecraft/server/WorldGenTreeProvider.java
+++ b/net/minecraft/server/WorldGenTreeProvider.java
@@ -2,6 +2,7 @@
 
 import java.util.Random;
 import javax.annotation.Nullable;
+import org.bukkit.TreeType; // CraftBukkit
 
 public abstract class WorldGenTreeProvider {
 
@@ -16,6 +17,7 @@
         if (worldgentreeabstract == null) {
             return false;
         } else {
+            setTreeType(worldgentreeabstract); // CraftBukkit
             generatoraccess.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 4);
             if (worldgentreeabstract.generate(generatoraccess, generatoraccess.getChunkProvider().getChunkGenerator(), random, blockposition, WorldGenFeatureConfiguration.e)) {
                 return true;
@@ -25,4 +27,30 @@
             }
         }
     }
+
+    // CraftBukkit start
+    protected void setTreeType(WorldGenTreeAbstract worldgentreeabstract) {
+        if (worldgentreeabstract instanceof WorldGenAcaciaTree) {
+            BlockSapling.treeType = TreeType.ACACIA;
+        } else if (worldgentreeabstract instanceof WorldGenBigTree) {
+            BlockSapling.treeType = TreeType.BIG_TREE;
+        } else if (worldgentreeabstract instanceof WorldGenForest) {
+            BlockSapling.treeType = TreeType.BIRCH;
+        } else if (worldgentreeabstract instanceof WorldGenForestTree) {
+            BlockSapling.treeType = TreeType.DARK_OAK;
+        } else if (worldgentreeabstract instanceof WorldGenJungleTree) {
+            BlockSapling.treeType = TreeType.JUNGLE;
+        } else if (worldgentreeabstract instanceof WorldGenMegaTree) {
+            BlockSapling.treeType = TreeType.MEGA_REDWOOD;
+        } else if (worldgentreeabstract instanceof WorldGenTaiga1) {
+            BlockSapling.treeType = TreeType.REDWOOD;
+        } else if (worldgentreeabstract instanceof WorldGenTaiga2) {
+            BlockSapling.treeType = TreeType.REDWOOD;
+        } else if (worldgentreeabstract instanceof WorldGenTrees) {
+            BlockSapling.treeType = TreeType.TREE;
+        } else {
+            throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract);
+        }
+    }
+    // CraftBukkit end
 }