mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-15 04:41:37 +08:00
[Forge] Fixed tree generation but undo is not yet supported.
This commit is contained in:
parent
7945b5ce25
commit
b19cd9bec4
@ -49,12 +49,26 @@
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderServer;
|
||||
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
|
||||
import net.minecraft.world.gen.feature.WorldGenBigTree;
|
||||
import net.minecraft.world.gen.feature.WorldGenCanopyTree;
|
||||
import net.minecraft.world.gen.feature.WorldGenForest;
|
||||
import net.minecraft.world.gen.feature.WorldGenMegaJungle;
|
||||
import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
|
||||
import net.minecraft.world.gen.feature.WorldGenSavannaTree;
|
||||
import net.minecraft.world.gen.feature.WorldGenShrub;
|
||||
import net.minecraft.world.gen.feature.WorldGenSwamp;
|
||||
import net.minecraft.world.gen.feature.WorldGenTaiga1;
|
||||
import net.minecraft.world.gen.feature.WorldGenTaiga2;
|
||||
import net.minecraft.world.gen.feature.WorldGenTrees;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -67,6 +81,7 @@
|
||||
public class ForgeWorld extends AbstractWorld {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ForgeWorld.class.getCanonicalName());
|
||||
private static final Random random = new Random();
|
||||
private final WeakReference<World> worldRef;
|
||||
|
||||
/**
|
||||
@ -310,9 +325,37 @@ public boolean regenerate(Region region, EditSession editSession) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static WorldGenerator createWorldGenerator(TreeType type) {
|
||||
switch (type) {
|
||||
case TREE: return new WorldGenTrees(true);
|
||||
case BIG_TREE: return new WorldGenBigTree(true);
|
||||
case REDWOOD: return new WorldGenTaiga2(true);
|
||||
case TALL_REDWOOD: return new WorldGenTaiga1();
|
||||
case BIRCH: return new WorldGenForest(true, false);
|
||||
case JUNGLE: return new WorldGenMegaJungle(true, 10, 20, 3, 3);
|
||||
case SMALL_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), 3, 3, false);
|
||||
case SHORT_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), 3, 3, true);
|
||||
case JUNGLE_BUSH: return new WorldGenShrub(3, 0);
|
||||
case RED_MUSHROOM: return new WorldGenBigMushroom(1);
|
||||
case BROWN_MUSHROOM: return new WorldGenBigMushroom(0);
|
||||
case SWAMP: return new WorldGenSwamp();
|
||||
case ACACIA: return new WorldGenSavannaTree(true);
|
||||
case DARK_OAK: return new WorldGenCanopyTree(true);
|
||||
case MEGA_REDWOOD: return new WorldGenMegaPineTree(false, random.nextBoolean());
|
||||
case TALL_BIRCH: return new WorldGenForest(true, true);
|
||||
case RANDOM:
|
||||
case PINE:
|
||||
case RANDOM_REDWOOD:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException {
|
||||
return false;
|
||||
WorldGenerator generator = createWorldGenerator(type);
|
||||
return generator != null ? generator.generate(getWorld(), random, position.getBlockX(), position.getBlockY(), position.getBlockZ()) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -424,4 +467,4 @@ private WorldReferenceLostException(String message) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user