Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
feat: Add a bunch of new types to the flora generator
Dieser Commit ist enthalten in:
Ursprung
3b24a8ae8a
Commit
0c8db1e1fe
@ -20,10 +20,13 @@
|
||||
package com.sk89q.worldedit.function.generator;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.internal.Constants;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -40,6 +43,11 @@ public class FloraGenerator implements RegionFunction {
|
||||
private final boolean biomeAware = false;
|
||||
private final Pattern desertPattern = getDesertPattern();
|
||||
private final Pattern temperatePattern = getTemperatePattern();
|
||||
//FAWE start
|
||||
private final Pattern mushroomPattern = mushroomPattern();
|
||||
private final Pattern netherPattern = netherPattern();
|
||||
private final Pattern warpedNyliumPattern = warpedNyliumPattern();
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Create a new flora generator.
|
||||
@ -101,17 +109,75 @@ public class FloraGenerator implements RegionFunction {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Get a pattern for plants to place inside a mushroom environment.
|
||||
*
|
||||
* @return a pattern that places flora
|
||||
*/
|
||||
public static Pattern mushroomPattern() {
|
||||
RandomPattern pattern = new RandomPattern();
|
||||
pattern.add(BlockTypes.RED_MUSHROOM.getDefaultState(), 10);
|
||||
pattern.add(BlockTypes.BROWN_MUSHROOM.getDefaultState(), 10);
|
||||
return pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pattern for plants to place inside a nether environment.
|
||||
*
|
||||
* @return a pattern that places flora
|
||||
*/
|
||||
public static Pattern netherPattern() {
|
||||
RandomPattern pattern = new RandomPattern();
|
||||
pattern.add(BlockTypes.CRIMSON_ROOTS.getDefaultState(), 10);
|
||||
pattern.add(BlockTypes.CRIMSON_FUNGUS.getDefaultState(), 20);
|
||||
pattern.add(BlockTypes.WARPED_FUNGUS.getDefaultState(), 5);
|
||||
return pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pattern for plants to place inside a nether environment.
|
||||
*
|
||||
* @return a pattern that places flora
|
||||
*/
|
||||
public static Pattern warpedNyliumPattern() {
|
||||
RandomPattern pattern = new RandomPattern();
|
||||
pattern.add(BlockTypes.WARPED_ROOTS.getDefaultState(), 15);
|
||||
pattern.add(BlockTypes.NETHER_SPROUTS.getDefaultState(), 20);
|
||||
pattern.add(BlockTypes.WARPED_FUNGUS.getDefaultState(), 7);
|
||||
pattern.add(BlockTypes.CRIMSON_ROOTS.getDefaultState(), 10);
|
||||
return pattern;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
//FAWE start
|
||||
int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getDataVersion();
|
||||
//FAWE end
|
||||
BlockState block = editSession.getBlock(position);
|
||||
|
||||
if (block.getBlockType() == BlockTypes.GRASS_BLOCK) {
|
||||
editSession.setBlock(position.add(0, 1, 0), temperatePattern.applyBlock(position));
|
||||
return true;
|
||||
} else if (block.getBlockType() == BlockTypes.SAND) {
|
||||
//FAWE start - add red sand
|
||||
} else if (block.getBlockType() == BlockTypes.SAND || block.getBlockType() == BlockTypes.RED_SAND) {
|
||||
//FAWE end
|
||||
editSession.setBlock(position.add(0, 1, 0), desertPattern.applyBlock(position));
|
||||
return true;
|
||||
//FAWE start - add new types
|
||||
} else if (block.getBlockType() == BlockTypes.MYCELIUM || block.getBlockType() == BlockTypes.NETHERRACK) {
|
||||
editSession.setBlock(position.add(0, 1, 0), mushroomPattern.applyBlock(position));
|
||||
return true;
|
||||
} else if (dataVersion >= Constants.DATA_VERSION_MC_1_16) {
|
||||
if (block.getBlockType() == BlockTypes.SOUL_SOIL || block.getBlockType() == BlockTypes.CRIMSON_NYLIUM) {
|
||||
editSession.setBlock(position.add(0, 1, 0), netherPattern.applyBlock(position));
|
||||
return true;
|
||||
} else if (block.getBlockType() == BlockTypes.WARPED_NYLIUM) {
|
||||
editSession.setBlock(position.add(0, 1, 0), warpedNyliumPattern.applyBlock(position));
|
||||
}
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren