mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 04:23:54 +00:00
Implement biome-specific regen
- initial biome-specific regen implementation - RegenOptions modified to include biomeType option (null if not specified) - Matched upstream's regen command
This commit is contained in:
@ -29,6 +29,7 @@ import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.RegenOptions;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
@ -242,6 +243,11 @@ public class WorldWrapper extends AbstractWorld {
|
||||
return parent.regenerate(region, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerate(Region region, Extent extent, RegenOptions options) {
|
||||
return parent.regenerate(region, extent, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
||||
return TaskManager.IMP.sync(() -> {
|
||||
|
@ -63,7 +63,9 @@ import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.world.RegenOptions;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
@ -609,15 +611,26 @@ public class RegionCommands {
|
||||
@CommandPermissions("worldedit.regen")
|
||||
@Logging(REGION)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public void regenerateChunk(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||
@Selection Region region) throws WorldEditException {
|
||||
void regenerate(Actor actor, World world, LocalSession session, EditSession editSession,
|
||||
@Selection Region region,
|
||||
@Arg(desc = "The seed to regenerate with, otherwise uses world seed", def = "")
|
||||
Long seed,
|
||||
@Switch(name = 'b', desc = "Regenerate biomes as well")
|
||||
boolean regenBiomes,
|
||||
@Arg(desc = "Biome to apply for this regeneration (only works in overworld)", def = "")
|
||||
BiomeType biomeType) throws WorldEditException {
|
||||
Mask mask = session.getMask();
|
||||
boolean success;
|
||||
try {
|
||||
session.setMask((Mask) null);
|
||||
session.setSourceMask((Mask) null);
|
||||
session.setMask(null);
|
||||
session.setSourceMask(null);
|
||||
actor.printInfo(TranslatableComponent.of("fawe.regen.time"));
|
||||
success = world.regenerate(region, editSession);
|
||||
RegenOptions options = RegenOptions.builder()
|
||||
.seed(seed)
|
||||
.regenBiomes(regenBiomes)
|
||||
.biomeType(biomeType)
|
||||
.build();
|
||||
success = world.regenerate(region, editSession, options);
|
||||
} finally {
|
||||
session.setMask(mask);
|
||||
session.setSourceMask(mask);
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.world;
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
||||
import java.util.OptionalLong;
|
||||
import javax.annotation.Nullable;
|
||||
@ -38,7 +39,7 @@ public abstract class RegenOptions {
|
||||
* @return the builder
|
||||
*/
|
||||
public static Builder builder() {
|
||||
return new AutoValue_RegenOptions.Builder().seed(OptionalLong.empty()).regenBiomes(false);
|
||||
return new AutoValue_RegenOptions.Builder().seed(OptionalLong.empty()).regenBiomes(false).biomeType(null);
|
||||
}
|
||||
|
||||
@AutoValue.Builder
|
||||
@ -69,6 +70,13 @@ public abstract class RegenOptions {
|
||||
*/
|
||||
public abstract Builder regenBiomes(boolean regenBiomes);
|
||||
|
||||
/**
|
||||
* Defines the {@code BiomeType} the regenerator should use for regeneration. Defaults to {@code null}.
|
||||
* @param biomeType the {@code BiomeType} to be used for regeneration
|
||||
* @return this builder
|
||||
*/
|
||||
public abstract Builder biomeType(@Nullable BiomeType biomeType);
|
||||
|
||||
/**
|
||||
* Build the options object.
|
||||
*
|
||||
@ -99,4 +107,10 @@ public abstract class RegenOptions {
|
||||
return isRegenBiomes();
|
||||
}
|
||||
|
||||
@Nullable public abstract BiomeType getBiomeType();
|
||||
|
||||
public boolean hasBiomeType() {
|
||||
return getBiomeType() != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user