mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-15 04:41:37 +08:00
parent
22acd2b486
commit
9d9aaac15a
@ -22,11 +22,11 @@
|
||||
dependencies {
|
||||
"api"(project(":worldedit-core"))
|
||||
"api"(project(":worldedit-libs:bukkit"))
|
||||
"api"("org.bukkit:bukkit:1.15.2-R0.1-SNAPSHOT") {
|
||||
"api"("org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT") {
|
||||
exclude("junit", "junit")
|
||||
}
|
||||
"compileOnly"("org.jetbrains:annotations:19.0.0")
|
||||
"compileOnly"("com.destroystokyo.paper:paper-api:1.15.2-R0.1-SNAPSHOT")
|
||||
"compileOnly"("com.destroystokyo.paper:paper-api:1.16.1-R0.1-SNAPSHOT")
|
||||
"implementation"("io.papermc:paperlib:1.0.2")
|
||||
"compileOnly"("com.sk89q:dummypermscompat:1.10")
|
||||
"implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||
|
@ -310,6 +310,9 @@ public static TreeType toBukkitTreeType(TreeGenerator.TreeType type) {
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 pt) {
|
||||
World world = getWorld();
|
||||
TreeType bukkitType = toBukkitTreeType(type);
|
||||
if (bukkitType == TreeType.CHORUS_PLANT) {
|
||||
pt = pt.add(0, 1, 0); // bukkit skips the feature gen which does this offset normally, so we have to add it back
|
||||
}
|
||||
return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType,
|
||||
new EditSessionBlockChangeDelegate(editSession));
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BlockState block = editSession.getBlock(position);
|
||||
BlockType t = block.getBlockType();
|
||||
|
||||
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT || t == BlockTypes.PODZOL || t == BlockTypes.COARSE_DIRT) {
|
||||
if (t.getMaterial().isSolid()) {
|
||||
return treeType.generate(editSession, position.add(0, 1, 0));
|
||||
} else if (t.getMaterial().isReplacedDuringPlacement()) {
|
||||
// since the implementation's tree generators generally don't generate in non-air spots,
|
||||
|
@ -40,7 +40,7 @@
|
||||
/**
|
||||
* Tree generator.
|
||||
*/
|
||||
public class TreeGenerator {
|
||||
public final class TreeGenerator {
|
||||
|
||||
public enum TreeType {
|
||||
TREE("Oak tree", "oak", "tree", "regular"),
|
||||
@ -82,10 +82,12 @@ public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxCha
|
||||
JUNGLE_BUSH("Jungle bush", "junglebush", "jungleshrub"),
|
||||
RED_MUSHROOM("Red mushroom", "redmushroom", "redgiantmushroom"),
|
||||
BROWN_MUSHROOM("Brown mushroom", "brownmushroom", "browngiantmushroom"),
|
||||
CRIMSON_FUNGUS("Crimson fungus", "crimsonfungus", "rednethermushroom"),
|
||||
WARPED_FUNGUS("Warped fungus", "warpedfungus", "greennethermushroom"),
|
||||
RANDOM_MUSHROOM("Random mushroom", "randmushroom", "randommushroom") {
|
||||
@Override
|
||||
public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
|
||||
TreeType[] choices = { RED_MUSHROOM, BROWN_MUSHROOM };
|
||||
TreeType[] choices = { RED_MUSHROOM, BROWN_MUSHROOM, CRIMSON_FUNGUS, WARPED_FUNGUS };
|
||||
return choices[TreeGenerator.RANDOM.nextInt(choices.length)].generate(editSession, pos);
|
||||
}
|
||||
},
|
||||
@ -99,6 +101,13 @@ public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxCha
|
||||
return true;
|
||||
}
|
||||
},
|
||||
CHORUS_PLANT("Chorus plant", "chorusplant") {
|
||||
@Override
|
||||
public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
|
||||
// chorus plants have to generate starting in the end stone itself, not the air above the ground
|
||||
return editSession.getWorld().generateTree(this, editSession, pos.subtract(0, 1, 0));
|
||||
}
|
||||
},
|
||||
RANDOM("Random tree", "rand", "random") {
|
||||
@Override
|
||||
public boolean generate(EditSession editSession, BlockVector3 pos) throws MaxChangedBlocksException {
|
||||
|
@ -92,7 +92,9 @@
|
||||
import net.minecraft.world.gen.GeneratorOptions;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.DefaultBiomeFeatures;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.HugeFungusFeatureConfig;
|
||||
import net.minecraft.world.level.ServerWorldProperties;
|
||||
import net.minecraft.world.level.storage.LevelStorage;
|
||||
|
||||
@ -445,6 +447,9 @@ private List<CompletableFuture<Chunk>> submitChunkLoadTasks(Region region, Serve
|
||||
case TALL_BIRCH: return Feature.TREE.configure(DefaultBiomeFeatures.LARGE_BIRCH_TREE_CONFIG);
|
||||
case RED_MUSHROOM: return Feature.HUGE_RED_MUSHROOM.configure(DefaultBiomeFeatures.HUGE_RED_MUSHROOM_CONFIG);
|
||||
case BROWN_MUSHROOM: return Feature.HUGE_BROWN_MUSHROOM.configure(DefaultBiomeFeatures.HUGE_BROWN_MUSHROOM_CONFIG);
|
||||
case WARPED_FUNGUS: return Feature.HUGE_FUNGUS.configure(HugeFungusFeatureConfig.WARPED_FUNGUS_CONFIG);
|
||||
case CRIMSON_FUNGUS: return Feature.HUGE_FUNGUS.configure(HugeFungusFeatureConfig.CRIMSON_FUNGUS_CONFIG);
|
||||
case CHORUS_PLANT: return Feature.CHORUS_PLANT.configure(DefaultFeatureConfig.INSTANCE);
|
||||
case RANDOM: return createTreeFeatureGenerator(TreeType.values()[ThreadLocalRandom.current().nextInt(TreeType.values().length)]);
|
||||
default:
|
||||
return null;
|
||||
|
@ -89,6 +89,8 @@
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.HugeFungusConfig;
|
||||
import net.minecraft.world.gen.feature.NoFeatureConfig;
|
||||
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
|
||||
import net.minecraft.world.server.ServerChunkProvider;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
@ -457,6 +459,9 @@ private List<CompletableFuture<IChunk>> submitChunkLoadTasks(Region region, Serv
|
||||
case TALL_BIRCH: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.field_230130_i_);
|
||||
case RED_MUSHROOM: return Feature.HUGE_RED_MUSHROOM.withConfiguration(DefaultBiomeFeatures.BIG_RED_MUSHROOM);
|
||||
case BROWN_MUSHROOM: return Feature.HUGE_BROWN_MUSHROOM.withConfiguration(DefaultBiomeFeatures.BIG_BROWN_MUSHROOM);
|
||||
case WARPED_FUNGUS: return Feature.field_236281_L_.withConfiguration(HugeFungusConfig.field_236299_b_);
|
||||
case CRIMSON_FUNGUS: return Feature.field_236281_L_.withConfiguration(HugeFungusConfig.field_236301_d_);
|
||||
case CHORUS_PLANT: return Feature.CHORUS_PLANT.withConfiguration(NoFeatureConfig.field_236559_b_);
|
||||
case RANDOM: return createTreeFeatureGenerator(TreeType.values()[ThreadLocalRandom.current().nextInt(TreeType.values().length)]);
|
||||
default:
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user