org.bukkit.BlockChangeDelegate Java Examples
The following examples show how to use
org.bukkit.BlockChangeDelegate.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean generateTree(final Location loc, final TreeType type, final BlockChangeDelegate delegate) { return TaskManager.IMP.sync(new RunnableVal<Boolean>() { @Override public void run(Boolean value) { this.value = parent.generateTree(loc, type, delegate); } }); }
Example #2
Source File: CraftWorld.java From Thermos with GNU General Public License v3.0 | 4 votes |
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { net.minecraft.world.gen.feature.WorldGenerator gen; switch (type) { case BIG_TREE: gen = new net.minecraft.world.gen.feature.WorldGenBigTree(true); break; case BIRCH: gen = new net.minecraft.world.gen.feature.WorldGenForest(true, false); break; case REDWOOD: gen = new net.minecraft.world.gen.feature.WorldGenTaiga2(true); break; case TALL_REDWOOD: gen = new net.minecraft.world.gen.feature.WorldGenTaiga1(); break; case JUNGLE: gen = new net.minecraft.world.gen.feature.WorldGenMegaJungle(true, 10, 20, 3, 3); // Magic values as in BlockSapling break; case SMALL_JUNGLE: gen = new net.minecraft.world.gen.feature.WorldGenTrees(true, 4 + rand.nextInt(7), 3, 3, false); break; case JUNGLE_BUSH: gen = new net.minecraft.world.gen.feature.WorldGenShrub(3, 0); break; case RED_MUSHROOM: gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(1); break; case BROWN_MUSHROOM: gen = new net.minecraft.world.gen.feature.WorldGenBigMushroom(0); break; case SWAMP: gen = new net.minecraft.world.gen.feature.WorldGenSwamp(); break; case ACACIA: gen = new net.minecraft.world.gen.feature.WorldGenSavannaTree(true); break; case DARK_OAK: gen = new net.minecraft.world.gen.feature.WorldGenCanopyTree(true); break; case MEGA_REDWOOD: gen = new net.minecraft.world.gen.feature.WorldGenMegaPineTree(true, rand.nextBoolean()); break; case TALL_BIRCH: gen = new net.minecraft.world.gen.feature.WorldGenForest(true, true); break; case TREE: default: gen = new net.minecraft.world.gen.feature.WorldGenTrees(true); break; } world.captureTreeGeneration = true; world.captureBlockSnapshots = true; boolean grownTree = gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); world.captureBlockSnapshots = false; world.captureTreeGeneration = false; if (grownTree) { // Copy block data to delegate for (BlockSnapshot blocksnapshot : world.capturedBlockSnapshots) { int x = blocksnapshot.x; int y = blocksnapshot.y; int z = blocksnapshot.z; net.minecraft.block.Block oldBlock = world.getBlock(x, y, z); int newId = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock); int data = blocksnapshot.meta; int flag = blocksnapshot.flag; delegate.setTypeIdAndData(x, y, z, newId, data); net.minecraft.block.Block newBlock = world.getBlock(x, y, z); world.markAndNotifyBlock(x, y, z, null, oldBlock, newBlock, flag); } world.capturedBlockSnapshots.clear(); return true; } else { world.capturedBlockSnapshots.clear(); return false; } }