mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
*
A tribute to Jesse
This commit is contained in:
parent
68c8fca672
commit
8b96cdc9a5
@ -21,7 +21,8 @@ fun Project.applyCommonConfiguration() {
|
|||||||
}
|
}
|
||||||
configurations.all {
|
configurations.all {
|
||||||
resolutionStrategy {
|
resolutionStrategy {
|
||||||
cacheChangingModulesFor(5, "minutes")
|
cacheChangingModulesFor(10, "minutes")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ fun Project.applyLibrariesConfiguration() {
|
|||||||
exclude(dependency("com.google.guava:guava"))
|
exclude(dependency("com.google.guava:guava"))
|
||||||
exclude(dependency("com.google.code.gson:gson"))
|
exclude(dependency("com.google.code.gson:gson"))
|
||||||
exclude(dependency("org.checkerframework:checker-qual"))
|
exclude(dependency("org.checkerframework:checker-qual"))
|
||||||
|
exclude(dependency("org.slf4j:slf4j-api"))
|
||||||
}
|
}
|
||||||
|
|
||||||
relocate("net.kyori.text", "com.sk89q.worldedit.util.formatting.text")
|
relocate("net.kyori.text", "com.sk89q.worldedit.util.formatting.text")
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
<allow pkg="org.mozilla.javascript"/>
|
<allow pkg="org.mozilla.javascript"/>
|
||||||
<allow pkg="de.schlichtherle"/>
|
<allow pkg="de.schlichtherle"/>
|
||||||
<allow pkg="com.google.auto"/>
|
<allow pkg="com.google.auto"/>
|
||||||
|
<allow pkg="it.unimi.dsi.fastutil"/>
|
||||||
|
|
||||||
<subpackage name="bukkit">
|
<subpackage name="bukkit">
|
||||||
<allow pkg="org.bukkit"/>
|
<allow pkg="org.bukkit"/>
|
||||||
|
@ -40,9 +40,7 @@ dependencies {
|
|||||||
"implementation"("io.papermc:paperlib:1.0.2")
|
"implementation"("io.papermc:paperlib:1.0.2")
|
||||||
"compileOnly"("com.sk89q:dummypermscompat:1.10")
|
"compileOnly"("com.sk89q:dummypermscompat:1.10")
|
||||||
"implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
"implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||||
"testCompile"("org.mockito:mockito-core:1.9.0-rc1") {
|
"testCompile"("org.mockito:mockito-core:1.9.0-rc1")
|
||||||
exclude("junit", "junit")
|
|
||||||
}
|
|
||||||
"compileOnly"("com.sk89q.worldguard:worldguard-bukkit:7.0.0") {
|
"compileOnly"("com.sk89q.worldguard:worldguard-bukkit:7.0.0") {
|
||||||
exclude("com.sk89q.worldedit", "worldedit-bukkit")
|
exclude("com.sk89q.worldedit", "worldedit-bukkit")
|
||||||
exclude("com.sk89q.worldedit", "worldedit-core")
|
exclude("com.sk89q.worldedit", "worldedit-core")
|
||||||
@ -61,6 +59,9 @@ dependencies {
|
|||||||
"implementation"("com.thevoxelbox.voxelsniper:voxelsniper:5.171.0") { isTransitive = false }
|
"implementation"("com.thevoxelbox.voxelsniper:voxelsniper:5.171.0") { isTransitive = false }
|
||||||
"implementation"("com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT") { isTransitive = false }
|
"implementation"("com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT") { isTransitive = false }
|
||||||
"implementation"("com.wasteofplastic:askyblock:3.0.8.2") { isTransitive = false }
|
"implementation"("com.wasteofplastic:askyblock:3.0.8.2") { isTransitive = false }
|
||||||
|
"compileOnly"("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") {
|
||||||
|
isTransitive = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named<Copy>("processResources") {
|
tasks.named<Copy>("processResources") {
|
||||||
|
@ -20,6 +20,7 @@ import com.boydti.fawe.bukkit.regions.ResidenceFeature;
|
|||||||
import com.boydti.fawe.bukkit.regions.TownyFeature;
|
import com.boydti.fawe.bukkit.regions.TownyFeature;
|
||||||
import com.boydti.fawe.bukkit.regions.Worldguard;
|
import com.boydti.fawe.bukkit.regions.Worldguard;
|
||||||
import com.boydti.fawe.bukkit.regions.WorldguardFlag;
|
import com.boydti.fawe.bukkit.regions.WorldguardFlag;
|
||||||
|
import com.boydti.fawe.bukkit.regions.plotquared.PlotSquaredFeature;
|
||||||
import com.boydti.fawe.bukkit.util.BukkitTaskMan;
|
import com.boydti.fawe.bukkit.util.BukkitTaskMan;
|
||||||
import com.boydti.fawe.bukkit.util.ItemUtil;
|
import com.boydti.fawe.bukkit.util.ItemUtil;
|
||||||
import com.boydti.fawe.bukkit.util.VaultUtil;
|
import com.boydti.fawe.bukkit.util.VaultUtil;
|
||||||
@ -29,6 +30,7 @@ import com.boydti.fawe.object.FaweCommand;
|
|||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
import com.boydti.fawe.util.Jars;
|
import com.boydti.fawe.util.Jars;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
import com.boydti.fawe.util.WEManager;
|
||||||
import com.boydti.fawe.util.image.ImageViewer;
|
import com.boydti.fawe.util.image.ImageViewer;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -84,6 +86,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) {
|
if (PaperLib.isPaper() && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) {
|
||||||
new RenderListener(plugin);
|
new RenderListener(plugin);
|
||||||
}
|
}
|
||||||
|
WEManager.IMP.managers.add(new PlotSquaredFeature());
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Bukkit.getServer().shutdown();
|
Bukkit.getServer().shutdown();
|
||||||
@ -205,6 +208,15 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
Player player = Bukkit.getPlayer(name);
|
Player player = Bukkit.getPlayer(name);
|
||||||
return player != null ? BukkitAdapter.adapt(player) : null;
|
return player != null ? BukkitAdapter.adapt(player) : null;
|
||||||
}
|
}
|
||||||
|
if (obj.getClass() == UUID.class) {
|
||||||
|
UUID uuid = (UUID) obj;
|
||||||
|
com.sk89q.worldedit.entity.Player existing = Fawe.get().getCachedPlayer(uuid);
|
||||||
|
if (existing != null) {
|
||||||
|
return existing;
|
||||||
|
}
|
||||||
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
|
return player != null ? BukkitAdapter.adapt(player) : null;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.boydti.fawe.bukkit.adapter.mc1_14;
|
package com.boydti.fawe.bukkit.adapter.mc1_14;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@ -2708,4 +2727,4 @@ public class DataConverters_1_14_R4 extends DataFixerBuilder implements com.sk89
|
|||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import com.sk89q.worldedit.event.platform.BlockInteractEvent;
|
|||||||
import com.sk89q.worldedit.event.platform.Interaction;
|
import com.sk89q.worldedit.event.platform.Interaction;
|
||||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -239,14 +239,14 @@ public class CFIPacketListener implements Listener {
|
|||||||
platform.handleBlockInteract(toCall);
|
platform.handleBlockInteract(toCall);
|
||||||
if (toCall.isCancelled() || action == Interaction.OPEN) {
|
if (toCall.isCancelled() || action == Interaction.OPEN) {
|
||||||
BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint());
|
BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint());
|
||||||
BlockStateHolder block = gen.getBlock(pt);
|
BlockState block = gen.getBlock(pt);
|
||||||
sendBlockChange(plr, realPos, block);
|
sendBlockChange(plr, realPos, block);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendBlockChange(Player plr, BlockVector3 pt, BlockStateHolder block) {
|
private void sendBlockChange(Player plr, BlockVector3 pt, BlockState block) {
|
||||||
plr.sendBlockChange(new Location(plr.getWorld(), pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()), BukkitAdapter.adapt(block));
|
plr.sendBlockChange(new Location(plr.getWorld(), pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()), BukkitAdapter.adapt(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.boydti.fawe.regions.general.plot;
|
package com.boydti.fawe.bukkit.regions.plotquared;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
@ -1,4 +1,4 @@
|
|||||||
package com.boydti.fawe.regions.general.plot;
|
package com.boydti.fawe.bukkit.regions.plotquared;
|
||||||
|
|
||||||
import com.boydti.fawe.util.EditSessionBuilder;
|
import com.boydti.fawe.util.EditSessionBuilder;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
@ -1,4 +1,4 @@
|
|||||||
package com.boydti.fawe.regions.general.plot;
|
package com.boydti.fawe.bukkit.regions.plotquared;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
@ -1,4 +1,4 @@
|
|||||||
package com.boydti.fawe.regions.general.plot;
|
package com.boydti.fawe.bukkit.regions.plotquared;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
|
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
|
@ -1,4 +1,4 @@
|
|||||||
package com.boydti.fawe.regions.general.plot;
|
package com.boydti.fawe.bukkit.regions.plotquared;
|
||||||
|
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
@ -6,7 +6,6 @@ import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.SubCommand;
|
import com.github.intellectualsites.plotsquared.plot.commands.SubCommand;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.boydti.fawe.regions.general.plot;
|
package com.boydti.fawe.bukkit.regions.plotquared;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
@ -1,4 +1,4 @@
|
|||||||
package com.boydti.fawe.regions.general.plot;
|
package com.boydti.fawe.bukkit.regions.plotquared;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.boydti.fawe.regions.general.plot;
|
package com.boydti.fawe.bukkit.regions.plotquared;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.util.EditSessionBuilder;
|
import com.boydti.fawe.util.EditSessionBuilder;
|
||||||
@ -20,6 +20,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
@ -31,6 +32,7 @@ import java.util.Collection;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "generatebiome",
|
command = "generatebiome",
|
||||||
@ -65,34 +67,28 @@ public class PlotSetBiome extends Command {
|
|||||||
MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.toString() + biomes);
|
MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.toString() + biomes);
|
||||||
return CompletableFuture.completedFuture(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
}
|
}
|
||||||
confirm.run(this, new Runnable() {
|
confirm.run(this, () -> {
|
||||||
@Override
|
if (plot.getRunning() != 0) {
|
||||||
public void run() {
|
Captions.WAIT_FOR_TIMER.send(player);
|
||||||
if (plot.getRunning() != 0) {
|
return;
|
||||||
Captions.WAIT_FOR_TIMER.send(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
plot.addRunning();
|
|
||||||
TaskManager.IMP.async(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
EditSession session = new EditSessionBuilder(plot.getArea().worldname)
|
|
||||||
.autoQueue(false)
|
|
||||||
.checkMemory(false)
|
|
||||||
.allowedRegionsEverywhere()
|
|
||||||
.player(Fawe.imp().wrap(player.getName()))
|
|
||||||
.limitUnlimited()
|
|
||||||
.build();
|
|
||||||
long seed = ThreadLocalRandom.current().nextLong();
|
|
||||||
for (RegionWrapper region : regions) {
|
|
||||||
CuboidRegion cuboid = new CuboidRegion(BlockVector3.at(region.minX, 0, region.minZ), BlockVector3.at(region.maxX, 256, region.maxZ));
|
|
||||||
session.regenerate(cuboid, biome, seed);
|
|
||||||
}
|
|
||||||
session.flushQueue();
|
|
||||||
plot.removeRunning();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
plot.addRunning();
|
||||||
|
TaskManager.IMP.async(() -> {
|
||||||
|
EditSession session = new EditSessionBuilder(BukkitAdapter.adapt(Bukkit.getWorld(plot.getArea().worldname)))
|
||||||
|
.autoQueue(false)
|
||||||
|
.checkMemory(false)
|
||||||
|
.allowedRegionsEverywhere()
|
||||||
|
.player(Fawe.imp().wrap(player.getUUID()))
|
||||||
|
.limitUnlimited()
|
||||||
|
.build();
|
||||||
|
long seed = ThreadLocalRandom.current().nextLong();
|
||||||
|
for (RegionWrapper region : regions) {
|
||||||
|
CuboidRegion cuboid = new CuboidRegion(BlockVector3.at(region.minX, 0, region.minZ), BlockVector3.at(region.maxX, 256, region.maxZ));
|
||||||
|
session.regenerate(cuboid, biome, seed);
|
||||||
|
}
|
||||||
|
session.flushQueue();
|
||||||
|
plot.removeRunning();
|
||||||
|
});
|
||||||
}, null);
|
}, null);
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(true);
|
return CompletableFuture.completedFuture(true);
|
@ -1,10 +1,8 @@
|
|||||||
package com.boydti.fawe.regions.general.plot;
|
package com.boydti.fawe.bukkit.regions.plotquared;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweAPI;
|
|
||||||
import com.boydti.fawe.regions.FaweMask;
|
import com.boydti.fawe.regions.FaweMask;
|
||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
import com.boydti.fawe.regions.SimpleRegion;
|
|
||||||
import com.boydti.fawe.regions.general.RegionFilter;
|
import com.boydti.fawe.regions.general.RegionFilter;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
||||||
@ -22,12 +20,16 @@ import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
|
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class PlotSquaredFeature extends FaweMaskManager {
|
public class PlotSquaredFeature extends FaweMaskManager {
|
||||||
public PlotSquaredFeature() {
|
public PlotSquaredFeature() {
|
||||||
@ -89,7 +91,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowed(com.sk89q.worldedit.entity.Player player, Plot plot, MaskType type) {
|
public boolean isAllowed(Player player, Plot plot, MaskType type) {
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -114,14 +116,14 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (regions.size() == 0) {
|
if (regions.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
PlotArea area = pp.getApplicablePlotArea();
|
PlotArea area = pp.getApplicablePlotArea();
|
||||||
int min = area != null ? area.MIN_BUILD_HEIGHT : 0;
|
int min = area != null ? area.MIN_BUILD_HEIGHT : 0;
|
||||||
int max = area != null ? Math.min(255, area.MAX_BUILD_HEIGHT) : 255;
|
int max = area != null ? Math.min(255, area.MAX_BUILD_HEIGHT) : 255;
|
||||||
final HashSet<com.boydti.fawe.object.RegionWrapper> faweRegions = new HashSet<>();
|
final HashSet<com.boydti.fawe.object.RegionWrapper> faweRegions = new HashSet<>();
|
||||||
for (final RegionWrapper current : regions) {
|
for (RegionWrapper current : regions) {
|
||||||
faweRegions.add(new com.boydti.fawe.object.RegionWrapper(current.minX, current.maxX, min, max, current.minZ, current.maxZ));
|
faweRegions.add(new com.boydti.fawe.object.RegionWrapper(current.minX, current.maxX, min, max, current.minZ, current.maxZ));
|
||||||
}
|
}
|
||||||
final RegionWrapper region = regions.iterator().next();
|
final RegionWrapper region = regions.iterator().next();
|
||||||
@ -136,7 +138,27 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
if (regions.size() == 1) {
|
if (regions.size() == 1) {
|
||||||
maskedRegion = new CuboidRegion(pos1, pos2);
|
maskedRegion = new CuboidRegion(pos1, pos2);
|
||||||
} else {
|
} else {
|
||||||
maskedRegion = new SimpleRegion(FaweAPI.getWorld(area.worldname), pos1, pos2) {
|
maskedRegion = new AbstractRegion(BukkitAdapter.adapt(Bukkit.getWorld(area.worldname))) {
|
||||||
|
@Override
|
||||||
|
public BlockVector3 getMinimumPoint() {
|
||||||
|
return pos1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 getMaximumPoint() {
|
||||||
|
return pos2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||||
|
throw new UnsupportedOperationException("Region is immutable");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||||
|
throw new UnsupportedOperationException("Region is immutable");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(int x, int y, int z) {
|
public boolean contains(int x, int y, int z) {
|
||||||
return WEManager.maskContains(regions, x, y, z);
|
return WEManager.maskContains(regions, x, y, z);
|
||||||
@ -146,12 +168,17 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
public boolean contains(int x, int z) {
|
public boolean contains(int x, int z) {
|
||||||
return WEManager.maskContains(regions, x, z);
|
return WEManager.maskContains(regions, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(BlockVector3 position) {
|
||||||
|
return contains(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FaweMask(maskedRegion) {
|
return new FaweMask(maskedRegion) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(com.sk89q.worldedit.entity.Player player, MaskType type) {
|
public boolean isValid(Player player, MaskType type) {
|
||||||
if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot)) {
|
if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(finalPlot)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -34,12 +34,22 @@ import com.sk89q.worldedit.math.Vector3;
|
|||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
|
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@ -82,7 +92,7 @@ public enum BukkitAdapter {
|
|||||||
* @return If they are equal
|
* @return If they are equal
|
||||||
*/
|
*/
|
||||||
public static boolean equals(BlockType blockType, Material type) {
|
public static boolean equals(BlockType blockType, Material type) {
|
||||||
return getAdapter().equals(blockType, type);
|
return Objects.equals(blockType.getId(), type.getKey().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +105,15 @@ public enum BukkitAdapter {
|
|||||||
* @return a wrapped Bukkit world
|
* @return a wrapped Bukkit world
|
||||||
*/
|
*/
|
||||||
public static BukkitWorld asBukkitWorld(World world) {
|
public static BukkitWorld asBukkitWorld(World world) {
|
||||||
return getAdapter().asBukkitWorld(world);
|
if (world instanceof BukkitWorld) {
|
||||||
|
return (BukkitWorld) world;
|
||||||
|
} else {
|
||||||
|
BukkitWorld bukkitWorld = WorldEditPlugin.getInstance().getInternalPlatform().matchWorld(world);
|
||||||
|
if (bukkitWorld == null) {
|
||||||
|
throw new RuntimeException("World '" + world.getName() + "' has no matching version in Bukkit");
|
||||||
|
}
|
||||||
|
return bukkitWorld;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,11 +123,8 @@ public enum BukkitAdapter {
|
|||||||
* @return a WorldEdit world
|
* @return a WorldEdit world
|
||||||
*/
|
*/
|
||||||
public static World adapt(org.bukkit.World world) {
|
public static World adapt(org.bukkit.World world) {
|
||||||
return getAdapter().adapt(world);
|
checkNotNull(world);
|
||||||
}
|
return new BukkitWorld(world);
|
||||||
|
|
||||||
public static org.bukkit.World adapt(World world) {
|
|
||||||
return getAdapter().adapt(world);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,7 +134,7 @@ public enum BukkitAdapter {
|
|||||||
* @return The WorldEdit player
|
* @return The WorldEdit player
|
||||||
*/
|
*/
|
||||||
public static BukkitPlayer adapt(Player player) {
|
public static BukkitPlayer adapt(Player player) {
|
||||||
return getAdapter().adapt(player);
|
return WorldEditPlugin.getInstance().wrapPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,7 +144,27 @@ public enum BukkitAdapter {
|
|||||||
* @return The Bukkit player
|
* @return The Bukkit player
|
||||||
*/
|
*/
|
||||||
public static Player adapt(com.sk89q.worldedit.entity.Player player) {
|
public static Player adapt(com.sk89q.worldedit.entity.Player player) {
|
||||||
return getAdapter().adapt(player);
|
return ((BukkitPlayer) player).getPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Bukkit world from a WorldEdit world.
|
||||||
|
*
|
||||||
|
* @param world the WorldEdit world
|
||||||
|
* @return a Bukkit world
|
||||||
|
*/
|
||||||
|
public static org.bukkit.World adapt(World world) {
|
||||||
|
checkNotNull(world);
|
||||||
|
if (world instanceof BukkitWorld) {
|
||||||
|
return ((BukkitWorld) world).getWorld();
|
||||||
|
} else {
|
||||||
|
org.bukkit.World match = Bukkit.getServer().getWorld(world.getName());
|
||||||
|
if (match != null) {
|
||||||
|
return match;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Can't find a Bukkit world for " + world.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,7 +175,12 @@ public enum BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static Location adapt(org.bukkit.Location location) {
|
public static Location adapt(org.bukkit.Location location) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
return getAdapter().adapt(location);
|
Vector3 position = asVector(location);
|
||||||
|
return new com.sk89q.worldedit.util.Location(
|
||||||
|
adapt(location.getWorld()),
|
||||||
|
position,
|
||||||
|
location.getYaw(),
|
||||||
|
location.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,7 +191,12 @@ public enum BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static org.bukkit.Location adapt(Location location) {
|
public static org.bukkit.Location adapt(Location location) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
return getAdapter().adapt(location);
|
Vector3 position = location;
|
||||||
|
return new org.bukkit.Location(
|
||||||
|
adapt((World) location.getExtent()),
|
||||||
|
position.getX(), position.getY(), position.getZ(),
|
||||||
|
location.getYaw(),
|
||||||
|
location.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,7 +207,11 @@ public enum BukkitAdapter {
|
|||||||
* @return a Bukkit location
|
* @return a Bukkit location
|
||||||
*/
|
*/
|
||||||
public static org.bukkit.Location adapt(org.bukkit.World world, Vector3 position) {
|
public static org.bukkit.Location adapt(org.bukkit.World world, Vector3 position) {
|
||||||
return getAdapter().adapt(world, position);
|
checkNotNull(world);
|
||||||
|
checkNotNull(position);
|
||||||
|
return new org.bukkit.Location(
|
||||||
|
world,
|
||||||
|
position.getX(), position.getY(), position.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,7 +224,9 @@ public enum BukkitAdapter {
|
|||||||
public static org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position) {
|
public static org.bukkit.Location adapt(org.bukkit.World world, BlockVector3 position) {
|
||||||
checkNotNull(world);
|
checkNotNull(world);
|
||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
return getAdapter().adapt(world, position);
|
return new org.bukkit.Location(
|
||||||
|
world,
|
||||||
|
position.getX(), position.getY(), position.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,7 +239,11 @@ public enum BukkitAdapter {
|
|||||||
public static org.bukkit.Location adapt(org.bukkit.World world, Location location) {
|
public static org.bukkit.Location adapt(org.bukkit.World world, Location location) {
|
||||||
checkNotNull(world);
|
checkNotNull(world);
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
return getAdapter().adapt(world, location);
|
return new org.bukkit.Location(
|
||||||
|
world,
|
||||||
|
location.getX(), location.getY(), location.getZ(),
|
||||||
|
location.getYaw(),
|
||||||
|
location.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,7 +276,7 @@ public enum BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static Entity adapt(org.bukkit.entity.Entity entity) {
|
public static Entity adapt(org.bukkit.entity.Entity entity) {
|
||||||
checkNotNull(entity);
|
checkNotNull(entity);
|
||||||
return getAdapter().adapt(entity);
|
return new BukkitEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -232,7 +287,10 @@ public enum BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static Material adapt(ItemType itemType) {
|
public static Material adapt(ItemType itemType) {
|
||||||
checkNotNull(itemType);
|
checkNotNull(itemType);
|
||||||
return getAdapter().adapt(itemType);
|
if (!itemType.getId().startsWith("minecraft:")) {
|
||||||
|
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
|
||||||
|
}
|
||||||
|
return Material.getMaterial(itemType.getId().substring(10).toUpperCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,8 +299,12 @@ public enum BukkitAdapter {
|
|||||||
* @param blockType The WorldEdit BlockType
|
* @param blockType The WorldEdit BlockType
|
||||||
* @return The Bukkit Material
|
* @return The Bukkit Material
|
||||||
*/
|
*/
|
||||||
public static Material adapt(@NotNull BlockType blockType) {
|
public static Material adapt(BlockType blockType) {
|
||||||
return getAdapter().adapt(blockType);
|
checkNotNull(blockType);
|
||||||
|
if (!blockType.getId().startsWith("minecraft:")) {
|
||||||
|
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
|
||||||
|
}
|
||||||
|
return Material.getMaterial(blockType.getId().substring(10).toUpperCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -253,7 +315,7 @@ public enum BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static GameMode adapt(org.bukkit.GameMode gameMode) {
|
public static GameMode adapt(org.bukkit.GameMode gameMode) {
|
||||||
checkNotNull(gameMode);
|
checkNotNull(gameMode);
|
||||||
return getAdapter().adapt(gameMode);
|
return GameModes.get(gameMode.name().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -263,11 +325,18 @@ public enum BukkitAdapter {
|
|||||||
* @return WorldEdit BiomeType
|
* @return WorldEdit BiomeType
|
||||||
*/
|
*/
|
||||||
public static BiomeType adapt(Biome biome) {
|
public static BiomeType adapt(Biome biome) {
|
||||||
return getAdapter().adapt(biome);
|
return BiomeTypes.get(biome.name().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Biome adapt(BiomeType biomeType) {
|
public static Biome adapt(BiomeType biomeType) {
|
||||||
return getAdapter().adapt(biomeType);
|
if (!biomeType.getId().startsWith("minecraft:")) {
|
||||||
|
throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Biome.valueOf(biomeType.getId().substring(10).toUpperCase(Locale.ROOT));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -277,11 +346,18 @@ public enum BukkitAdapter {
|
|||||||
* @return WorldEdit EntityType
|
* @return WorldEdit EntityType
|
||||||
*/
|
*/
|
||||||
public static EntityType adapt(org.bukkit.entity.EntityType entityType) {
|
public static EntityType adapt(org.bukkit.entity.EntityType entityType) {
|
||||||
return getAdapter().adapt(entityType);
|
final String name = entityType.getName();
|
||||||
|
if (name == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return EntityTypes.get(name.toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static org.bukkit.entity.EntityType adapt(EntityType entityType) {
|
public static org.bukkit.entity.EntityType adapt(EntityType entityType) {
|
||||||
return getAdapter().adapt(entityType);
|
if (!entityType.getId().startsWith("minecraft:")) {
|
||||||
|
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
|
||||||
|
}
|
||||||
|
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -290,8 +366,12 @@ public enum BukkitAdapter {
|
|||||||
* @param material The material
|
* @param material The material
|
||||||
* @return The blocktype
|
* @return The blocktype
|
||||||
*/
|
*/
|
||||||
public static BlockType asBlockType(@NotNull Material material) {
|
public static BlockType asBlockType(Material material) {
|
||||||
return getAdapter().asBlockType(material);
|
checkNotNull(material);
|
||||||
|
if (!material.isBlock()) {
|
||||||
|
throw new IllegalArgumentException(material.getKey().toString() + " is not a block!");
|
||||||
|
}
|
||||||
|
return BlockTypes.get(material.getKey().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -302,9 +382,13 @@ public enum BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static ItemType asItemType(Material material) {
|
public static ItemType asItemType(Material material) {
|
||||||
checkNotNull(material);
|
checkNotNull(material);
|
||||||
return getAdapter().asItemType(material);
|
if (!material.isItem()) {
|
||||||
|
throw new IllegalArgumentException(material.getKey().toString() + " is not an item!");
|
||||||
|
}
|
||||||
|
return ItemTypes.get(material.getKey().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Map<String, BlockState> blockStateCache = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WorldEdit BlockState from a Bukkit BlockData
|
* Create a WorldEdit BlockState from a Bukkit BlockData
|
||||||
@ -320,6 +404,8 @@ public enum BukkitAdapter {
|
|||||||
return getAdapter().adapt(material);
|
return getAdapter().adapt(material);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Map<String, BlockData> blockDataCache = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder
|
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder
|
||||||
*
|
*
|
||||||
@ -339,7 +425,7 @@ public enum BukkitAdapter {
|
|||||||
public static BlockState asBlockState(ItemStack itemStack) throws WorldEditException {
|
public static BlockState asBlockState(ItemStack itemStack) throws WorldEditException {
|
||||||
checkNotNull(itemStack);
|
checkNotNull(itemStack);
|
||||||
if (itemStack.getType().isBlock()) {
|
if (itemStack.getType().isBlock()) {
|
||||||
return getAdapter().asBlockState(itemStack);
|
return adapt(itemStack.getType().createBlockData());
|
||||||
} else {
|
} else {
|
||||||
throw new NotABlockException();
|
throw new NotABlockException();
|
||||||
}
|
}
|
||||||
@ -353,7 +439,10 @@ public enum BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static BaseItemStack adapt(ItemStack itemStack) {
|
public static BaseItemStack adapt(ItemStack itemStack) {
|
||||||
checkNotNull(itemStack);
|
checkNotNull(itemStack);
|
||||||
return getAdapter().adapt(itemStack);
|
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
|
||||||
|
return WorldEditPlugin.getInstance().getBukkitImplAdapter().adapt(itemStack);
|
||||||
|
}
|
||||||
|
return new BaseItemStack(ItemTypes.get(itemStack.getType().getKey().toString()), itemStack.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -364,6 +453,9 @@ public enum BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static ItemStack adapt(BaseItemStack item) {
|
public static ItemStack adapt(BaseItemStack item) {
|
||||||
checkNotNull(item);
|
checkNotNull(item);
|
||||||
return getAdapter().adapt(item);
|
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
|
||||||
|
return WorldEditPlugin.getInstance().getBukkitImplAdapter().adapt(item);
|
||||||
|
}
|
||||||
|
return new ItemStack(adapt(item.getType()), item.getAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPersistent() {
|
public boolean isPersistent() {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,8 +35,9 @@ import com.sk89q.worldedit.world.block.BlockState;
|
|||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -45,11 +46,6 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.OptionalInt;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for adapters of various Bukkit implementations.
|
* An interface for adapters of various Bukkit implementations.
|
||||||
*/
|
*/
|
||||||
@ -202,7 +198,6 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
|||||||
* @param state The block state
|
* @param state The block state
|
||||||
* @return the internal ID of the state
|
* @return the internal ID of the state
|
||||||
*/
|
*/
|
||||||
|
|
||||||
default OptionalInt getInternalBlockStateId(BlockState state) {
|
default OptionalInt getInternalBlockStateId(BlockState state) {
|
||||||
return OptionalInt.empty();
|
return OptionalInt.empty();
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package com.sk89q.worldedit.bukkit.adapter;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.NotABlockException;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitEntity;
|
import com.sk89q.worldedit.bukkit.BukkitEntity;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitItemStack;
|
import com.sk89q.worldedit.bukkit.BukkitItemStack;
|
||||||
@ -21,9 +20,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
|
||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
|
||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -35,17 +31,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public interface IBukkitAdapter {
|
public interface IBukkitAdapter {
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks equality between a WorldEdit BlockType and a Bukkit Material
|
|
||||||
*
|
|
||||||
* @param blockType The WorldEdit BlockType
|
|
||||||
* @param type The Bukkit Material
|
|
||||||
* @return If they are equal
|
|
||||||
*/
|
|
||||||
default boolean equals(BlockType blockType, Material type) {
|
|
||||||
return blockType == asItemType(type).getBlockType();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert any WorldEdit world into an equivalent wrapped Bukkit world.
|
* Convert any WorldEdit world into an equivalent wrapped Bukkit world.
|
||||||
*
|
*
|
||||||
@ -67,17 +52,6 @@ public interface IBukkitAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a WorldEdit world from a Bukkit world.
|
|
||||||
*
|
|
||||||
* @param world the Bukkit world
|
|
||||||
* @return a WorldEdit world
|
|
||||||
*/
|
|
||||||
default World adapt(org.bukkit.World world) {
|
|
||||||
checkNotNull(world);
|
|
||||||
return new BukkitWorld(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Bukkit world from a WorldEdit world.
|
* Create a Bukkit world from a WorldEdit world.
|
||||||
*
|
*
|
||||||
@ -98,38 +72,6 @@ public interface IBukkitAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a WorldEdit location from a Bukkit location.
|
|
||||||
*
|
|
||||||
* @param location the Bukkit location
|
|
||||||
* @return a WorldEdit location
|
|
||||||
*/
|
|
||||||
default Location adapt(org.bukkit.Location location) {
|
|
||||||
checkNotNull(location);
|
|
||||||
Vector3 position = asVector(location);
|
|
||||||
return new Location(
|
|
||||||
adapt(location.getWorld()),
|
|
||||||
position,
|
|
||||||
location.getYaw(),
|
|
||||||
location.getPitch());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a Bukkit location from a WorldEdit location.
|
|
||||||
*
|
|
||||||
* @param location the WorldEdit location
|
|
||||||
* @return a Bukkit location
|
|
||||||
*/
|
|
||||||
default org.bukkit.Location adapt(Location location) {
|
|
||||||
checkNotNull(location);
|
|
||||||
Vector3 position = location;
|
|
||||||
return new org.bukkit.Location(
|
|
||||||
adapt((World) location.getExtent()),
|
|
||||||
position.getX(), position.getY(), position.getZ(),
|
|
||||||
location.getYaw(),
|
|
||||||
location.getPitch());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Bukkit location from a WorldEdit position with a Bukkit world.
|
* Create a Bukkit location from a WorldEdit position with a Bukkit world.
|
||||||
*
|
*
|
||||||
@ -228,27 +170,6 @@ public interface IBukkitAdapter {
|
|||||||
return Material.getMaterial(id);
|
return Material.getMaterial(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a WorldEdit GameMode from a Bukkit one.
|
|
||||||
*
|
|
||||||
* @param gameMode Bukkit GameMode
|
|
||||||
* @return WorldEdit GameMode
|
|
||||||
*/
|
|
||||||
default GameMode adapt(org.bukkit.GameMode gameMode) {
|
|
||||||
checkNotNull(gameMode);
|
|
||||||
return GameModes.get(gameMode.name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a WorldEdit EntityType from a Bukkit one.
|
|
||||||
*
|
|
||||||
* @param entityType Bukkit EntityType
|
|
||||||
* @return WorldEdit EntityType
|
|
||||||
*/
|
|
||||||
default EntityType adapt(org.bukkit.entity.EntityType entityType) {
|
|
||||||
return EntityTypes.get(entityType.getName().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
default org.bukkit.entity.EntityType adapt(EntityType entityType) {
|
default org.bukkit.entity.EntityType adapt(EntityType entityType) {
|
||||||
if (!entityType.getId().startsWith("minecraft:")) {
|
if (!entityType.getId().startsWith("minecraft:")) {
|
||||||
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
|
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
|
||||||
@ -303,21 +224,6 @@ public interface IBukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
BlockData adapt(BlockStateHolder block);
|
BlockData adapt(BlockStateHolder block);
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a WorldEdit BlockStateHolder from a Bukkit ItemStack
|
|
||||||
*
|
|
||||||
* @param itemStack The Bukkit ItemStack
|
|
||||||
* @return The WorldEdit BlockState
|
|
||||||
*/
|
|
||||||
default BlockState asBlockState(ItemStack itemStack) {
|
|
||||||
checkNotNull(itemStack);
|
|
||||||
if (itemStack.getType().isBlock()) {
|
|
||||||
return adapt(itemStack.getType().createBlockData());
|
|
||||||
} else {
|
|
||||||
throw new NotABlockException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WorldEdit BaseItemStack from a Bukkit ItemStack
|
* Create a WorldEdit BaseItemStack from a Bukkit ItemStack
|
||||||
*
|
*
|
||||||
|
@ -33,10 +33,6 @@ dependencies {
|
|||||||
"annotationProcessor"("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}")
|
"annotationProcessor"("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}")
|
||||||
"compile"("co.aikar:fastutil-lite:1.0")
|
"compile"("co.aikar:fastutil-lite:1.0")
|
||||||
"compile"("com.github.luben:zstd-jni:1.4.3-1")
|
"compile"("com.github.luben:zstd-jni:1.4.3-1")
|
||||||
//"compile"("com.mojang:datafixerupper:1.0.20")
|
|
||||||
"compileOnly"("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") {
|
|
||||||
isTransitive = false
|
|
||||||
}
|
|
||||||
"compileOnly"("net.fabiozumbi12:redprotect:1.9.6")
|
"compileOnly"("net.fabiozumbi12:redprotect:1.9.6")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.beta.implementation.QueueHandler;
|
|||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.brush.visualization.VisualQueue;
|
import com.boydti.fawe.object.brush.visualization.VisualQueue;
|
||||||
import com.boydti.fawe.regions.general.plot.PlotSquaredFeature;
|
|
||||||
import com.boydti.fawe.util.CachedTextureUtil;
|
import com.boydti.fawe.util.CachedTextureUtil;
|
||||||
import com.boydti.fawe.util.CleanTextureUtil;
|
import com.boydti.fawe.util.CleanTextureUtil;
|
||||||
import com.boydti.fawe.util.FaweTimer;
|
import com.boydti.fawe.util.FaweTimer;
|
||||||
@ -186,7 +185,6 @@ public class Fawe {
|
|||||||
transformParser = new DefaultTransformParser(getWorldEdit());
|
transformParser = new DefaultTransformParser(getWorldEdit());
|
||||||
visualQueue = new VisualQueue(3);
|
visualQueue = new VisualQueue(3);
|
||||||
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
|
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
|
||||||
WEManager.IMP.managers.add(new PlotSquaredFeature());
|
|
||||||
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
|
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
|
||||||
} catch (Throwable ignored) {}
|
} catch (Throwable ignored) {}
|
||||||
try {
|
try {
|
||||||
|
@ -24,6 +24,7 @@ public interface IChunkSet extends IBlocks, OutputExtent {
|
|||||||
|
|
||||||
boolean isEmpty();
|
boolean isEmpty();
|
||||||
|
|
||||||
|
@Override
|
||||||
boolean setTile(int x, int y, int z, CompoundTag tile);
|
boolean setTile(int x, int y, int z, CompoundTag tile);
|
||||||
|
|
||||||
void setEntity(CompoundTag tag);
|
void setEntity(CompoundTag tag);
|
||||||
|
@ -104,7 +104,7 @@ public class CFICommands {
|
|||||||
desc = "Start CFI with a height map as a base"
|
desc = "Start CFI with a height map as a base"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void heightmap(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "yscale", desc = "double", def = "1") double yscale) {
|
public void heightmap(Player player, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "yscale", desc = "double", def = "1") double yscale) {
|
||||||
if (yscale != 0) {
|
if (yscale != 0) {
|
||||||
int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData();
|
int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData();
|
||||||
int[] table = IntStream.range(0, 256).map(i -> Math.min(255, (int) (i * yscale)))
|
int[] table = IntStream.range(0, 256).map(i -> Math.min(255, (int) (i * yscale)))
|
||||||
@ -118,7 +118,7 @@ public class CFICommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
HeightMapMCAGenerator generator = new HeightMapMCAGenerator(image.load(), getFolder(generateName()));
|
HeightMapMCAGenerator generator = new HeightMapMCAGenerator(image.load(), getFolder(generateName()));
|
||||||
setup(generator, fp);
|
setup(generator, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -126,9 +126,9 @@ public class CFICommands {
|
|||||||
desc = "Start CFI with an empty map as a base"
|
desc = "Start CFI with an empty map as a base"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void heightMap(Player fp, int width, int length) {
|
public void heightMap(Player player, int width, int length) {
|
||||||
HeightMapMCAGenerator generator = new HeightMapMCAGenerator(width, length, getFolder(generateName()));
|
HeightMapMCAGenerator generator = new HeightMapMCAGenerator(width, length, getFolder(generateName()));
|
||||||
setup(generator, fp);
|
setup(generator, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateName() {
|
private String generateName() {
|
||||||
@ -136,13 +136,13 @@ public class CFICommands {
|
|||||||
return df.format(new Date());
|
return df.format(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup(HeightMapMCAGenerator generator, Player fp) {
|
private void setup(HeightMapMCAGenerator generator, Player player) {
|
||||||
CFISettings settings = getSettings(fp).remove();
|
CFISettings settings = getSettings(player).remove();
|
||||||
generator.setPacketViewer(fp);
|
generator.setPacketViewer(player);
|
||||||
settings.setGenerator(generator).bind();
|
settings.setGenerator(generator).bind();
|
||||||
generator.setImageViewer(Fawe.imp().getImageViewer(fp));
|
generator.setImageViewer(Fawe.imp().getImageViewer(player));
|
||||||
generator.update();
|
generator.update();
|
||||||
mainMenu(fp);
|
mainMenu(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -172,9 +172,9 @@ public class CFICommands {
|
|||||||
desc = "Cancel creation"
|
desc = "Cancel creation"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void cancel(Player fp) {
|
public void cancel(Player player) {
|
||||||
getSettings(fp).remove();
|
getSettings(player).remove();
|
||||||
fp.print("Cancelled!");
|
player.print("Cancelled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -238,8 +238,8 @@ public class CFICommands {
|
|||||||
desc = "Set the floor and main block"
|
desc = "Set the floor and main block"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void column(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
public void column(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
gen.setColumn(load(image), patternArg, !disableWhiteOnly);
|
gen.setColumn(load(image), patternArg, !disableWhiteOnly);
|
||||||
} else if (maskOpt != null) {
|
} else if (maskOpt != null) {
|
||||||
@ -247,9 +247,9 @@ public class CFICommands {
|
|||||||
} else {
|
} else {
|
||||||
gen.setColumn(patternArg);
|
gen.setColumn(patternArg);
|
||||||
}
|
}
|
||||||
fp.print("Set column!");
|
player.print("Set column!");
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(player).resetComponent();
|
||||||
component(fp);
|
component(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -257,15 +257,15 @@ public class CFICommands {
|
|||||||
desc = "Set the floor (default: grass)"
|
desc = "Set the floor (default: grass)"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void floorCmd(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
public void floorCmd(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||||
floor(fp, patternArg, image, maskOpt, disableWhiteOnly);
|
floor(player, patternArg, image, maskOpt, disableWhiteOnly);
|
||||||
fp.print("Set floor!");
|
player.print("Set floor!");
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(player).resetComponent();
|
||||||
component(fp);
|
component(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void floor(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
private void floor(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) {
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
gen.setFloor(load(image), patternArg, !disableWhiteOnly);
|
gen.setFloor(load(image), patternArg, !disableWhiteOnly);
|
||||||
} else if (maskOpt != null) {
|
} else if (maskOpt != null) {
|
||||||
@ -280,15 +280,15 @@ public class CFICommands {
|
|||||||
desc = "Set the main block (default: stone)"
|
desc = "Set the main block (default: stone)"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void mainCmd(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
public void mainCmd(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||||
main(fp, patternArg, image, maskOpt, disableWhiteOnly);
|
main(player, patternArg, image, maskOpt, disableWhiteOnly);
|
||||||
fp.print("Set main!");
|
player.print("Set main!");
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(player).resetComponent();
|
||||||
component(fp);
|
component(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void main(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
public void main(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
gen.setMain(load(image), patternArg, !disableWhiteOnly);
|
gen.setMain(load(image), patternArg, !disableWhiteOnly);
|
||||||
} else if (maskOpt != null) {
|
} else if (maskOpt != null) {
|
||||||
@ -306,8 +306,8 @@ public class CFICommands {
|
|||||||
"e.g. Tallgrass"
|
"e.g. Tallgrass"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void overlay(Player fp, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
public void overlay(Player player, @Arg(name = "pattern", desc = "Pattern") Pattern patternArg, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
gen.setOverlay(load(image), patternArg, !disableWhiteOnly);
|
gen.setOverlay(load(image), patternArg, !disableWhiteOnly);
|
||||||
} else if (maskOpt != null) {
|
} else if (maskOpt != null) {
|
||||||
@ -315,8 +315,8 @@ public class CFICommands {
|
|||||||
} else {
|
} else {
|
||||||
gen.setOverlay(patternArg);
|
gen.setOverlay(patternArg);
|
||||||
}
|
}
|
||||||
fp.print("Set overlay!");
|
player.print("Set overlay!");
|
||||||
component(fp);
|
component(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -328,14 +328,14 @@ public class CFICommands {
|
|||||||
" - A good value for radius and iterations would be 1 8."
|
" - A good value for radius and iterations would be 1 8."
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void smoothCmd(Player fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
public void smoothCmd(Player player, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||||
smooth(fp, radius, iterations, image, maskOpt, disableWhiteOnly);
|
smooth(player, radius, iterations, image, maskOpt, disableWhiteOnly);
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(player).resetComponent();
|
||||||
component(fp);
|
component(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void smooth(Player fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
private void smooth(Player player, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
|
gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
|
||||||
} else {
|
} else {
|
||||||
@ -348,14 +348,14 @@ public class CFICommands {
|
|||||||
desc = "Create some snow"
|
desc = "Create some snow"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void snow(Player fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
public void snow(Player player, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask maskOpt, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(player).getGenerator();
|
||||||
floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly);
|
floor(player, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly);
|
||||||
main(fp, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly);
|
main(player, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly);
|
||||||
smooth(fp, 1, 8, image, maskOpt, disableWhiteOnly);
|
smooth(player, 1, 8, image, maskOpt, disableWhiteOnly);
|
||||||
fp.print(TextComponent.of("Added snow!"));
|
player.print(TextComponent.of("Added snow!"));
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(player).resetComponent();
|
||||||
component(fp);
|
component(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
package com.boydti.fawe.object.brush;
|
package com.boydti.fawe.object.brush;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class BlendBall implements Brush {
|
public class BlendBall implements Brush {
|
||||||
|
|
||||||
@ -38,8 +35,8 @@ public class BlendBall implements Brush {
|
|||||||
}
|
}
|
||||||
int z0 = z + tz;
|
int z0 = z + tz;
|
||||||
int highest = 1;
|
int highest = 1;
|
||||||
BlockStateHolder currentState = editSession.getBlock(x0, y0, z0);
|
BlockState currentState = editSession.getBlock(x0, y0, z0);
|
||||||
BlockStateHolder highestState = currentState;
|
BlockState highestState = currentState;
|
||||||
Arrays.fill(frequency, 0);
|
Arrays.fill(frequency, 0);
|
||||||
boolean tie = false;
|
boolean tie = false;
|
||||||
for (int ox = -1; ox <= 1; ox++) {
|
for (int ox = -1; ox <= 1; ox++) {
|
||||||
@ -48,13 +45,9 @@ public class BlendBall implements Brush {
|
|||||||
if (oy + y0 < 0 || oy + y0 > maxY) {
|
if (oy + y0 < 0 || oy + y0 > maxY) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BlockStateHolder state = editSession.getBlock(x0 + ox, y0 + oy, z0 + oz);
|
BlockState state = editSession.getBlock(x0 + ox, y0 + oy, z0 + oz);
|
||||||
Integer count = frequency[state.getInternalBlockTypeId()];
|
Integer count = frequency[state.getInternalBlockTypeId()];
|
||||||
if (count == null) {
|
count++;
|
||||||
count = 1;
|
|
||||||
} else {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
if (count > highest) {
|
if (count > highest) {
|
||||||
highest = count;
|
highest = count;
|
||||||
highestState = state;
|
highestState = state;
|
||||||
|
@ -67,9 +67,9 @@ public class BlobBrush implements Brush {
|
|||||||
.rotateY(ThreadLocalRandom.current().nextInt(360))
|
.rotateY(ThreadLocalRandom.current().nextInt(360))
|
||||||
.rotateZ(ThreadLocalRandom.current().nextInt(360));
|
.rotateZ(ThreadLocalRandom.current().nextInt(360));
|
||||||
|
|
||||||
double manScaleX = (1.25 + seedX * 0.5);
|
double manScaleX = 1.25 + seedX * 0.5;
|
||||||
double manScaleY = (1.25 + seedY * 0.5);
|
double manScaleY = 1.25 + seedY * 0.5;
|
||||||
double manScaleZ = (1.25 + seedZ * 0.5);
|
double manScaleZ = 1.25 + seedZ * 0.5;
|
||||||
|
|
||||||
MutableVector3 mutable = new MutableVector3();
|
MutableVector3 mutable = new MutableVector3();
|
||||||
double roughness = 1 - sphericity;
|
double roughness = 1 - sphericity;
|
||||||
@ -103,4 +103,4 @@ public class BlobBrush implements Brush {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.object.brush.scroll.ScrollAction;
|
import com.boydti.fawe.object.brush.scroll.ScrollAction;
|
||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||||
@ -42,10 +41,10 @@ public class BrushSettings {
|
|||||||
|
|
||||||
private final Map<SettingType, Object> constructor = new ConcurrentHashMap<>();
|
private final Map<SettingType, Object> constructor = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private Brush brush = null;
|
private Brush brush;
|
||||||
private Mask mask = null;
|
private Mask mask;
|
||||||
private Mask sourceMask = null;
|
private Mask sourceMask;
|
||||||
private ResettableExtent transform = null;
|
private ResettableExtent transform;
|
||||||
private Pattern material;
|
private Pattern material;
|
||||||
private Expression size = new Expression(1);
|
private Expression size = new Expression(1);
|
||||||
private Set<String> permissions;
|
private Set<String> permissions;
|
||||||
@ -57,7 +56,7 @@ public class BrushSettings {
|
|||||||
this.constructor.put(SettingType.PERMISSIONS, permissions);
|
this.constructor.put(SettingType.PERMISSIONS, permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map<String, Object> settings) throws CommandException, InputParseException {
|
public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map<String, Object> settings) throws InputParseException {
|
||||||
PlatformCommandManager manager = PlatformCommandManager.getInstance();
|
PlatformCommandManager manager = PlatformCommandManager.getInstance();
|
||||||
String constructor = (String) settings.get(SettingType.BRUSH.name());
|
String constructor = (String) settings.get(SettingType.BRUSH.name());
|
||||||
if (constructor == null) {
|
if (constructor == null) {
|
||||||
|
@ -31,7 +31,7 @@ public class CatenaryBrush implements Brush, ResettableTool {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 pos2, final Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 pos2, final Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
boolean visual = (editSession.getExtent() instanceof VisualExtent);
|
boolean visual = editSession.getExtent() instanceof VisualExtent;
|
||||||
if (pos1 == null || pos2.equals(pos1)) {
|
if (pos1 == null || pos2.equals(pos1)) {
|
||||||
if (!visual) {
|
if (!visual) {
|
||||||
pos1 = pos2;
|
pos1 = pos2;
|
||||||
@ -64,9 +64,8 @@ public class CatenaryBrush implements Brush, ResettableTool {
|
|||||||
if (!select) {
|
if (!select) {
|
||||||
pos1 = null;
|
pos1 = null;
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
pos1 = pos2;
|
|
||||||
}
|
}
|
||||||
|
pos1 = pos2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +86,7 @@ public class CatenaryBrush implements Brush, ResettableTool {
|
|||||||
double a = 0.00001;
|
double a = 0.00001;
|
||||||
for (;g < a * Math.sinh(dh/(2 * a)); a *= 1.00001);
|
for (;g < a * Math.sinh(dh/(2 * a)); a *= 1.00001);
|
||||||
double vertX = (dh-a*Math.log((curveLen + dy)/(curveLen - dy)))/2.0;
|
double vertX = (dh-a*Math.log((curveLen + dy)/(curveLen - dy)))/2.0;
|
||||||
double z = (dh/2)/a;
|
double z = (dh / 2) / a;
|
||||||
double oY = (dy - curveLen * (Math.cosh(z) / Math.sinh(z))) / 2;
|
double oY = (dy - curveLen * (Math.cosh(z) / Math.sinh(z))) / 2;
|
||||||
double vertY = a * 1 + oY;
|
double vertY = a * 1 + oY;
|
||||||
return pos1.add(pos2.subtract(pos1).multiply(vertX / dh).add(0, vertY, 0)).round().toBlockPoint();
|
return pos1.add(pos2.subtract(pos1).multiply(vertX / dh).add(0, vertY, 0)).round().toBlockPoint();
|
||||||
|
@ -9,23 +9,23 @@ import com.sk89q.worldedit.command.tool.brush.Brush;
|
|||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class ErodeBrush implements Brush {
|
public class ErodeBrush implements Brush {
|
||||||
|
|
||||||
private static final BlockVector3[] FACES_TO_CHECK = Direction.valuesOf(Direction.Flag.CARDINAL).stream().map(direction -> direction.toBlockVector()).toArray(size -> new BlockVector3[size]);
|
private static final BlockVector3[] FACES_TO_CHECK = Direction.valuesOf(Direction.Flag.CARDINAL).stream().map(Direction::toBlockVector).toArray(BlockVector3[]::new);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
this.erosion(editSession, 2, 1, 5, 1, position, size);
|
this.erosion(editSession, 2, 1, 5, position, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void erosion(final EditSession es, int erodeFaces, int erodeRec, int fillFaces, int fillRec, BlockVector3 target, double size) {
|
void erosion(EditSession es, int erodeFaces, int erodeRec, int fillFaces,
|
||||||
|
BlockVector3 target, double size) {
|
||||||
int brushSize = (int) size + 1;
|
int brushSize = (int) size + 1;
|
||||||
int brushSizeSquared = (int) (size * size);
|
int brushSizeSquared = (int) (size * size);
|
||||||
int dimension = brushSize * 2 + 1;
|
int dimension = brushSize * 2 + 1;
|
||||||
@ -42,7 +42,7 @@ public class ErodeBrush implements Brush {
|
|||||||
int y0 = y + by;
|
int y0 = y + by;
|
||||||
for (int z = -brushSize; z <= brushSize; z++) {
|
for (int z = -brushSize; z <= brushSize; z++) {
|
||||||
int z0 = z + bz;
|
int z0 = z + bz;
|
||||||
BlockStateHolder state = es.getBlock(x0, y0, z0);
|
BlockState state = es.getBlock(x0, y0, z0);
|
||||||
buffer1.setBlock(x, y, z, state);
|
buffer1.setBlock(x, y, z, state);
|
||||||
buffer2.setBlock(x, y, z, state);
|
buffer2.setBlock(x, y, z, state);
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ public class ErodeBrush implements Brush {
|
|||||||
swap++;
|
swap++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < fillRec; ++i) {
|
for (int i = 0; i < 1; ++i) {
|
||||||
fillIteration(brushSize, brushSizeSquared, fillFaces, swap % 2 == 0 ? buffer1 : buffer2, swap % 2 == 1 ? buffer1 : buffer2);
|
fillIteration(brushSize, brushSizeSquared, fillFaces, swap % 2 == 0 ? buffer1 : buffer2, swap % 2 == 1 ? buffer1 : buffer2);
|
||||||
swap++;
|
swap++;
|
||||||
}
|
}
|
||||||
@ -69,7 +69,8 @@ public class ErodeBrush implements Brush {
|
|||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillIteration(int brushSize, int brushSizeSquared, int fillFaces, FaweClipboard current, FaweClipboard target) {
|
private void fillIteration(int brushSize, int brushSizeSquared, int fillFaces,
|
||||||
|
FaweClipboard current, FaweClipboard target) {
|
||||||
int[] frequency = null;
|
int[] frequency = null;
|
||||||
for (int x = -brushSize; x <= brushSize; x++) {
|
for (int x = -brushSize; x <= brushSize; x++) {
|
||||||
int x2 = x * x;
|
int x2 = x * x;
|
||||||
@ -81,20 +82,20 @@ public class ErodeBrush implements Brush {
|
|||||||
if (cube >= brushSizeSquared) {
|
if (cube >= brushSizeSquared) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BlockStateHolder state = current.getBlock(x, y, z);
|
BaseBlock state = current.getBlock(x, y, z);
|
||||||
if (state.getBlockType().getMaterial().isMovementBlocker()) {
|
if (state.getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int total = 0;
|
int total = 0;
|
||||||
int highest = 1;
|
int highest = 1;
|
||||||
BlockStateHolder highestState = state;
|
BaseBlock highestState = state;
|
||||||
if (frequency == null) {
|
if (frequency == null) {
|
||||||
frequency = new int[BlockTypes.size()];
|
frequency = new int[BlockTypes.size()];
|
||||||
} else {
|
} else {
|
||||||
Arrays.fill(frequency, 0);
|
Arrays.fill(frequency, 0);
|
||||||
}
|
}
|
||||||
for (BlockVector3 offs : FACES_TO_CHECK) {
|
for (BlockVector3 offs : FACES_TO_CHECK) {
|
||||||
BlockStateHolder next = current.getBlock(x + offs.getBlockX(), y + offs.getBlockY(), z + offs.getBlockZ());
|
BaseBlock next = current.getBlock(x + offs.getBlockX(), y + offs.getBlockY(), z + offs.getBlockZ());
|
||||||
if (!next.getBlockType().getMaterial().isMovementBlocker()) {
|
if (!next.getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -113,7 +114,8 @@ public class ErodeBrush implements Brush {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void erosionIteration(int brushSize, int brushSizeSquared, int erodeFaces, FaweClipboard current, FaweClipboard target) {
|
private void erosionIteration(int brushSize, int brushSizeSquared, int erodeFaces,
|
||||||
|
FaweClipboard current, FaweClipboard target) {
|
||||||
int[] frequency = null;
|
int[] frequency = null;
|
||||||
for (int x = -brushSize; x <= brushSize; x++) {
|
for (int x = -brushSize; x <= brushSize; x++) {
|
||||||
int x2 = x * x;
|
int x2 = x * x;
|
||||||
@ -125,20 +127,20 @@ public class ErodeBrush implements Brush {
|
|||||||
if (cube >= brushSizeSquared) {
|
if (cube >= brushSizeSquared) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BlockStateHolder state = current.getBlock(x, y, z);
|
BaseBlock state = current.getBlock(x, y, z);
|
||||||
if (!state.getBlockType().getMaterial().isMovementBlocker()) {
|
if (!state.getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int total = 0;
|
int total = 0;
|
||||||
int highest = 1;
|
int highest = 1;
|
||||||
BlockStateHolder highestState = state;
|
BaseBlock highestState = state;
|
||||||
if (frequency == null) {
|
if (frequency == null) {
|
||||||
frequency = new int[BlockTypes.size()];
|
frequency = new int[BlockTypes.size()];
|
||||||
} else {
|
} else {
|
||||||
Arrays.fill(frequency, 0);
|
Arrays.fill(frequency, 0);
|
||||||
}
|
}
|
||||||
for (BlockVector3 offs : FACES_TO_CHECK) {
|
for (BlockVector3 offs : FACES_TO_CHECK) {
|
||||||
BlockStateHolder next = current.getBlock(x + offs.getBlockX(), y + offs.getBlockY(), z + offs.getBlockZ());
|
BaseBlock next = current.getBlock(x + offs.getBlockX(), y + offs.getBlockY(), z + offs.getBlockZ());
|
||||||
if (next.getBlockType().getMaterial().isMovementBlocker()) {
|
if (next.getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 getTarget(Player player, boolean adjacent) {
|
public Vector3 getTarget(Player player, boolean adjacent) {
|
||||||
int range = this.range > -1 ? getRange() : DEFAULT_RANGE;
|
int range = this.range > -1 ? getRange() : MAX_RANGE;
|
||||||
if (adjacent) {
|
if (adjacent) {
|
||||||
Location face = player.getBlockTraceFace(range, true);
|
Location face = player.getBlockTraceFace(range, true);
|
||||||
return face.add(face.getDirection());
|
return face.add(face.getDirection());
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.boydti.fawe.object.brush;
|
package com.boydti.fawe.object.brush;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.FilterBlock;
|
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
|
||||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||||
import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
||||||
import com.boydti.fawe.object.mask.RadiusMask;
|
import com.boydti.fawe.object.mask.RadiusMask;
|
||||||
@ -9,8 +7,6 @@ import com.sk89q.worldedit.EditSession;
|
|||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
@ -21,7 +17,6 @@ import com.sk89q.worldedit.math.MutableBlockVector3;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class LayerBrush implements Brush {
|
public class LayerBrush implements Brush {
|
||||||
@ -44,32 +39,29 @@ public class LayerBrush implements Brush {
|
|||||||
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
BlockVectorSet visited = visitor.getVisited();
|
BlockVectorSet visited = visitor.getVisited();
|
||||||
visitor = new RecursiveVisitor(new Mask() {
|
visitor = new RecursiveVisitor(pos -> {
|
||||||
@Override
|
int depth = visitor.getDepth() + 1;
|
||||||
public boolean test(BlockVector3 pos) {
|
if (depth > 1) {
|
||||||
int depth = visitor.getDepth() + 1;
|
boolean found = false;
|
||||||
if (depth > 1) {
|
BlockState previous = layers[depth - 1];
|
||||||
boolean found = false;
|
BlockState previous2 = layers[depth - 2];
|
||||||
BlockState previous = layers[depth - 1];
|
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
|
||||||
BlockState previous2 = layers[depth - 2];
|
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
|
||||||
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
|
if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
|
||||||
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
|
mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2);
|
||||||
if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
|
if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) {
|
||||||
mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2);
|
found = true;
|
||||||
if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) {
|
break;
|
||||||
found = true;
|
} else {
|
||||||
break;
|
return false;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return !adjacent.test(pos);
|
if (!found) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return !adjacent.test(pos);
|
||||||
}, pos -> {
|
}, pos -> {
|
||||||
int depth = visitor.getDepth();
|
int depth = visitor.getDepth();
|
||||||
BlockStateHolder currentPattern = layers[depth];
|
BlockStateHolder currentPattern = layers[depth];
|
||||||
|
@ -20,8 +20,8 @@ public class LineBrush implements Brush, ResettableTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 position, final Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
boolean visual = (editSession.getExtent() instanceof VisualExtent);
|
boolean visual = editSession.getExtent() instanceof VisualExtent;
|
||||||
if (pos1 == null) {
|
if (pos1 == null) {
|
||||||
if (!visual) {
|
if (!visual) {
|
||||||
pos1 = position;
|
pos1 = position;
|
||||||
@ -34,7 +34,6 @@ public class LineBrush implements Brush, ResettableTool {
|
|||||||
BBC.BRUSH_LINE_SECONDARY.send(editSession.getPlayer());
|
BBC.BRUSH_LINE_SECONDARY.send(editSession.getPlayer());
|
||||||
if (!select) {
|
if (!select) {
|
||||||
pos1 = null;
|
pos1 = null;
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
pos1 = position;
|
pos1 = position;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
public class RaiseBrush extends ErodeBrush {
|
public class RaiseBrush extends ErodeBrush {
|
||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
this.erosion(editSession, 6, 0, 1, 1, position, size);
|
this.erosion(editSession, 6, 0, 1, position, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.object.mask.RadiusMask;
|
|||||||
import com.boydti.fawe.object.visitor.DFSRecursiveVisitor;
|
import com.boydti.fawe.object.visitor.DFSRecursiveVisitor;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
import com.sk89q.worldedit.function.block.BlockReplace;
|
import com.sk89q.worldedit.function.block.BlockReplace;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
@ -24,7 +23,7 @@ public class RecurseBrush implements Brush {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(final EditSession editSession, final BlockVector3 position, Pattern to, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern to, double size) throws MaxChangedBlocksException {
|
||||||
Mask mask = editSession.getMask();
|
Mask mask = editSession.getMask();
|
||||||
if (mask == null) {
|
if (mask == null) {
|
||||||
mask = Masks.alwaysTrue();
|
mask = Masks.alwaysTrue();
|
||||||
@ -35,7 +34,7 @@ public class RecurseBrush implements Brush {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final BlockReplace replace = new BlockReplace(editSession, to);
|
final BlockReplace replace = new BlockReplace(editSession, to);
|
||||||
editSession.setMask((Mask) null);
|
editSession.setMask(null);
|
||||||
final int maxY = editSession.getMaxY();
|
final int maxY = editSession.getMaxY();
|
||||||
if (dfs) {
|
if (dfs) {
|
||||||
final Mask radMask = new RadiusMask(0, (int) size);
|
final Mask radMask = new RadiusMask(0, (int) size);
|
||||||
@ -43,7 +42,7 @@ public class RecurseBrush implements Brush {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
||||||
int y = to.getBlockY();
|
int y = to.getBlockY();
|
||||||
return y >= y && y < maxY && radMask.test(to) && super.isVisitable(from, to);
|
return y < maxY && radMask.test(to) && super.isVisitable(from, to);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
visitor.visit(position);
|
visitor.visit(position);
|
||||||
@ -53,7 +52,7 @@ public class RecurseBrush implements Brush {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
||||||
int y = to.getBlockY();
|
int y = to.getBlockY();
|
||||||
return y >= y && y < maxY && super.isVisitable(from, to);
|
return y < maxY && super.isVisitable(from, to);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
visitor.visit(position);
|
visitor.visit(position);
|
||||||
|
@ -17,7 +17,6 @@ public class ScatterOverlayBrush extends ScatterBrush {
|
|||||||
int y = pt.getBlockY();
|
int y = pt.getBlockY();
|
||||||
int z = pt.getBlockZ();
|
int z = pt.getBlockZ();
|
||||||
BlockVector3 dir = getDirection(pt);
|
BlockVector3 dir = getDirection(pt);
|
||||||
// dir.setComponents(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ());
|
|
||||||
editSession.setBlock(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ(), p);
|
editSession.setBlock(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package com.boydti.fawe.object.brush;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
|
|
||||||
public class SpikeBrush implements Brush {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,13 +5,11 @@ import com.boydti.fawe.object.mask.SurfaceMask;
|
|||||||
import com.boydti.fawe.object.pattern.BiomePattern;
|
import com.boydti.fawe.object.pattern.BiomePattern;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
|
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
|
||||||
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
@ -32,8 +30,8 @@ public class SplatterBrush extends ScatterBrush {
|
|||||||
Pattern tmp;
|
Pattern tmp;
|
||||||
try {
|
try {
|
||||||
tmp = p.apply(position);
|
tmp = p.apply(position);
|
||||||
} catch (BiomePattern.BiomePatternException ignore) {
|
} catch (BiomePattern.BiomePatternException e) {
|
||||||
tmp = ignore.getPattern();
|
tmp = e.getPattern();
|
||||||
}
|
}
|
||||||
finalPattern = tmp;
|
finalPattern = tmp;
|
||||||
} else {
|
} else {
|
||||||
@ -44,7 +42,8 @@ public class SplatterBrush extends ScatterBrush {
|
|||||||
|
|
||||||
RecursiveVisitor visitor = new RecursiveVisitor(vector -> {
|
RecursiveVisitor visitor = new RecursiveVisitor(vector -> {
|
||||||
double dist = vector.distanceSq(position);
|
double dist = vector.distanceSq(position);
|
||||||
if (dist < size2 && !placed.contains(vector) && (ThreadLocalRandom.current().nextInt(5) < 2) && surface.test(vector)) {
|
if (dist < size2 && !placed.contains(vector) && ThreadLocalRandom.current().nextInt(5) < 2
|
||||||
|
&& surface.test(vector)) {
|
||||||
placed.add(vector);
|
placed.add(vector);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,10 @@ public class SplineBrush implements Brush, ResettableTool {
|
|||||||
private ArrayList<ArrayList<BlockVector3>> positionSets;
|
private ArrayList<ArrayList<BlockVector3>> positionSets;
|
||||||
private int numSplines;
|
private int numSplines;
|
||||||
|
|
||||||
private final LocalSession session;
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private BlockVector3 position;
|
private BlockVector3 position;
|
||||||
|
|
||||||
public SplineBrush(Player player, LocalSession session) {
|
public SplineBrush(Player player, LocalSession session) {
|
||||||
this.session = session;
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.positionSets = new ArrayList<>();
|
this.positionSets = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SurfaceSpline implements Brush {
|
public class SurfaceSpline implements Brush {
|
||||||
final double tension, bias, continuity, quality;
|
private final double tension;
|
||||||
|
private final double bias;
|
||||||
|
private final double continuity;
|
||||||
|
private final double quality;
|
||||||
|
|
||||||
public SurfaceSpline(final double tension, final double bias, final double continuity, final double quality) {
|
public SurfaceSpline(double tension, double bias, double continuity, double quality) {
|
||||||
this.tension = tension;
|
this.tension = tension;
|
||||||
this.bias = bias;
|
this.bias = bias;
|
||||||
this.continuity = continuity;
|
this.continuity = continuity;
|
||||||
@ -43,7 +46,7 @@ public class SurfaceSpline implements Brush {
|
|||||||
final List<Node> nodes = new ArrayList<>(path.size());
|
final List<Node> nodes = new ArrayList<>(path.size());
|
||||||
final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();
|
final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();
|
||||||
|
|
||||||
for (final BlockVector3 nodevector : path) {
|
for (BlockVector3 nodevector : path) {
|
||||||
final Node n = new Node(nodevector.toVector3());
|
final Node n = new Node(nodevector.toVector3());
|
||||||
n.setTension(tension);
|
n.setTension(tension);
|
||||||
n.setBias(bias);
|
n.setBias(bias);
|
||||||
@ -72,13 +75,13 @@ public class SurfaceSpline implements Brush {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (radius != 0) {
|
if (radius != 0) {
|
||||||
double radius2 = (radius * radius);
|
double radius2 = radius * radius;
|
||||||
LocalBlockVectorSet newSet = new LocalBlockVectorSet();
|
LocalBlockVectorSet newSet = new LocalBlockVectorSet();
|
||||||
final int ceilrad = (int) Math.ceil(radius);
|
final int ceilrad = (int) Math.ceil(radius);
|
||||||
for (final BlockVector3 v : vset) {
|
for (BlockVector3 v : vset) {
|
||||||
final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
||||||
for (int loopx = tipx - ceilrad; loopx <= (tipx + ceilrad); loopx++) {
|
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||||
for (int loopz = tipz - ceilrad; loopz <= (tipz + ceilrad); loopz++) {
|
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
||||||
if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) {
|
if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) {
|
||||||
int y = editSession.getNearestSurfaceTerrainBlock(loopx, loopz, v.getBlockY(), 0, maxY);
|
int y = editSession.getNearestSurfaceTerrainBlock(loopx, loopz, v.getBlockY(), 0, maxY);
|
||||||
if (y == -1) continue;
|
if (y == -1) continue;
|
||||||
|
@ -139,23 +139,23 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
|||||||
enttFile.delete();
|
enttFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void undo(Player fp, Region[] regions) {
|
public void undo(Player player, Region[] regions) {
|
||||||
EditSession session = toEditSession(fp, regions);
|
EditSession session = toEditSession(player, regions);
|
||||||
session.undo(session);
|
session.undo(session);
|
||||||
deleteFiles();
|
deleteFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void undo(Player fp) {
|
public void undo(Player player) {
|
||||||
undo(fp, null);
|
undo(player, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void redo(Player fp, Region[] regions) {
|
public void redo(Player player, Region[] regions) {
|
||||||
EditSession session = toEditSession(fp, regions);
|
EditSession session = toEditSession(player, regions);
|
||||||
session.redo(session);
|
session.redo(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void redo(Player fp) {
|
public void redo(Player player) {
|
||||||
undo(fp, null);
|
undo(player, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUUID() {
|
public UUID getUUID() {
|
||||||
|
@ -140,8 +140,7 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (int X = 0;X < rows.length; X++) {
|
for (IRow nullRowX : rows) {
|
||||||
IRow nullRowX = rows[X];
|
|
||||||
if (nullRowX instanceof RowX) {
|
if (nullRowX instanceof RowX) {
|
||||||
RowX rowx = (RowX) nullRowX;
|
RowX rowx = (RowX) nullRowX;
|
||||||
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
||||||
@ -238,8 +237,7 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (int X = 0;X < rows.length; X++) {
|
for (IRow nullRowX : rows) {
|
||||||
IRow nullRowX = rows[X];
|
|
||||||
if (nullRowX instanceof RowX) {
|
if (nullRowX instanceof RowX) {
|
||||||
RowX rowx = (RowX) nullRowX;
|
RowX rowx = (RowX) nullRowX;
|
||||||
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
||||||
@ -286,18 +284,20 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
int maxY = 15;
|
int maxY = 15;
|
||||||
int maxy = 16;
|
int maxy = 16;
|
||||||
int by = Integer.MAX_VALUE;
|
int by = Integer.MAX_VALUE;
|
||||||
for (int X = 0; X < rows.length; X++) {
|
for (IRow nullRowX : rows) {
|
||||||
IRow nullRowX = rows[X];
|
if (!(nullRowX instanceof RowX))
|
||||||
if (!(nullRowX instanceof RowX)) continue;
|
continue;
|
||||||
RowX rowx = (RowX) nullRowX;
|
RowX rowx = (RowX) nullRowX;
|
||||||
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
||||||
IRow nullRowZ = rowx.rows[Z];
|
IRow nullRowZ = rowx.rows[Z];
|
||||||
if (!(nullRowZ instanceof RowZ)) continue;
|
if (!(nullRowZ instanceof RowZ))
|
||||||
|
continue;
|
||||||
RowZ rowz = (RowZ) nullRowZ;
|
RowZ rowz = (RowZ) nullRowZ;
|
||||||
outer:
|
outer:
|
||||||
for (int Y = 0; Y <= maxY; Y++) {
|
for (int Y = 0; Y <= maxY; Y++) {
|
||||||
IRow nullRowY = rowz.rows[Y];
|
IRow nullRowY = rowz.rows[Y];
|
||||||
if (!(nullRowY instanceof RowY)) continue;
|
if (!(nullRowY instanceof RowY))
|
||||||
|
continue;
|
||||||
RowY rowY = (RowY) nullRowY;
|
RowY rowY = (RowY) nullRowY;
|
||||||
int localMaxy = Y == maxY ? maxy : 15;
|
int localMaxy = Y == maxY ? maxy : 15;
|
||||||
for (int y = 0, i = 0; y < localMaxy; y++) {
|
for (int y = 0, i = 0; y < localMaxy; y++) {
|
||||||
@ -312,7 +312,8 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
maxy = y;
|
maxy = y;
|
||||||
}
|
}
|
||||||
by = (Y << 4) + y;
|
by = (Y << 4) + y;
|
||||||
if (by == 0) return 0;
|
if (by == 0)
|
||||||
|
return 0;
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -328,18 +329,20 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
int maxY = 0;
|
int maxY = 0;
|
||||||
int maxy = 0;
|
int maxy = 0;
|
||||||
int by = Integer.MIN_VALUE;
|
int by = Integer.MIN_VALUE;
|
||||||
for (int X = 0; X < rows.length; X++) {
|
for (IRow nullRowX : rows) {
|
||||||
IRow nullRowX = rows[X];
|
if (!(nullRowX instanceof RowX))
|
||||||
if (!(nullRowX instanceof RowX)) continue;
|
continue;
|
||||||
RowX rowx = (RowX) nullRowX;
|
RowX rowx = (RowX) nullRowX;
|
||||||
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
||||||
IRow nullRowZ = rowx.rows[Z];
|
IRow nullRowZ = rowx.rows[Z];
|
||||||
if (!(nullRowZ instanceof RowZ)) continue;
|
if (!(nullRowZ instanceof RowZ))
|
||||||
|
continue;
|
||||||
RowZ rowz = (RowZ) nullRowZ;
|
RowZ rowz = (RowZ) nullRowZ;
|
||||||
outer:
|
outer:
|
||||||
for (int Y = 15; Y >= maxY; Y--) {
|
for (int Y = 15; Y >= maxY; Y--) {
|
||||||
IRow nullRowY = rowz.rows[Y];
|
IRow nullRowY = rowz.rows[Y];
|
||||||
if (!(nullRowY instanceof RowY)) continue;
|
if (!(nullRowY instanceof RowY))
|
||||||
|
continue;
|
||||||
RowY rowY = (RowY) nullRowY;
|
RowY rowY = (RowY) nullRowY;
|
||||||
int localMaxy = Y == maxY ? maxy : 0;
|
int localMaxy = Y == maxY ? maxy : 0;
|
||||||
for (int y = 15, i = 63; y >= localMaxy; y--) {
|
for (int y = 15, i = 63; y >= localMaxy; y--) {
|
||||||
@ -354,7 +357,8 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
maxy = y + 1;
|
maxy = y + 1;
|
||||||
}
|
}
|
||||||
by = (Y << 4) + y;
|
by = (Y << 4) + y;
|
||||||
if (by == FaweCache.IMP.WORLD_MAX_Y) return FaweCache.IMP.WORLD_MAX_Y;
|
if (by == FaweCache.IMP.WORLD_MAX_Y)
|
||||||
|
return FaweCache.IMP.WORLD_MAX_Y;
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -425,9 +429,7 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
IRow nullRowY = rowz.rows[Y];
|
IRow nullRowY = rowz.rows[Y];
|
||||||
if (!(nullRowY instanceof RowY)) continue;
|
if (!(nullRowY instanceof RowY)) continue;
|
||||||
RowY rowY = (RowY) nullRowY;
|
RowY rowY = (RowY) nullRowY;
|
||||||
for (long value : rowY.bits) {
|
or |= Arrays.stream(rowY.bits).reduce(0, (a, b) -> a | b);
|
||||||
or |= value;
|
|
||||||
}
|
|
||||||
or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF);
|
or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF);
|
||||||
if (highestBit(or) == 15) return tx + 15;
|
if (highestBit(or) == 15) return tx + 15;
|
||||||
}
|
}
|
||||||
@ -444,14 +446,15 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
int maxChunkZ = rows.length - 1;
|
int maxChunkZ = rows.length - 1;
|
||||||
int maxz = 16;
|
int maxz = 16;
|
||||||
int bz = Integer.MAX_VALUE;
|
int bz = Integer.MAX_VALUE;
|
||||||
for (int X = 0; X < rows.length; X++) {
|
for (IRow nullRowX : rows) {
|
||||||
IRow nullRowX = rows[X];
|
if (!(nullRowX instanceof RowX))
|
||||||
if (!(nullRowX instanceof RowX)) continue;
|
continue;
|
||||||
RowX rowx = (RowX) nullRowX;
|
RowX rowx = (RowX) nullRowX;
|
||||||
outer:
|
outer:
|
||||||
for (int Z = 0; Z <= maxChunkZ; Z++) {
|
for (int Z = 0; Z <= maxChunkZ; Z++) {
|
||||||
IRow nullRowZ = rowx.rows[Z];
|
IRow nullRowZ = rowx.rows[Z];
|
||||||
if (!(nullRowZ instanceof RowZ)) continue;
|
if (!(nullRowZ instanceof RowZ))
|
||||||
|
continue;
|
||||||
RowZ rowz = (RowZ) nullRowZ;
|
RowZ rowz = (RowZ) nullRowZ;
|
||||||
if (Z != maxChunkZ) {
|
if (Z != maxChunkZ) {
|
||||||
maxChunkZ = Z;
|
maxChunkZ = Z;
|
||||||
@ -459,7 +462,8 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
}
|
}
|
||||||
for (int Y = 0; Y < rowz.rows.length; Y++) {
|
for (int Y = 0; Y < rowz.rows.length; Y++) {
|
||||||
IRow nullRowY = rowz.rows[Y];
|
IRow nullRowY = rowz.rows[Y];
|
||||||
if (!(nullRowY instanceof RowY)) continue;
|
if (!(nullRowY instanceof RowY))
|
||||||
|
continue;
|
||||||
RowY rowY = (RowY) nullRowY;
|
RowY rowY = (RowY) nullRowY;
|
||||||
for (int y = 0, i1 = 0; y < 16; y++, i1 += 4) {
|
for (int y = 0, i1 = 0; y < 16; y++, i1 += 4) {
|
||||||
for (int z = 0, i = i1; z < maxz; z += 4, i++) {
|
for (int z = 0, i = i1; z < maxz; z += 4, i++) {
|
||||||
@ -500,9 +504,7 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
IRow nullRowY = rowz.rows[Y];
|
IRow nullRowY = rowz.rows[Y];
|
||||||
if (!(nullRowY instanceof RowY)) continue;
|
if (!(nullRowY instanceof RowY)) continue;
|
||||||
RowY rowY = (RowY) nullRowY;
|
RowY rowY = (RowY) nullRowY;
|
||||||
for (long value : rowY.bits) {
|
or |= Arrays.stream(rowY.bits).reduce(0, (a, b) -> a | b);
|
||||||
or |= value;
|
|
||||||
}
|
|
||||||
or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF);
|
or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF);
|
||||||
if (lowestBit(or) == 0) return bx;
|
if (lowestBit(or) == 0) return bx;
|
||||||
}
|
}
|
||||||
@ -566,7 +568,6 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
private int bx, by, bz, zz, yy;
|
private int bx, by, bz, zz, yy;
|
||||||
private RowX rowX;
|
private RowX rowX;
|
||||||
private RowZ rowZ;
|
private RowZ rowZ;
|
||||||
private RowY rowY;
|
|
||||||
private long[] bits;
|
private long[] bits;
|
||||||
private int bitsIndex = 0;
|
private int bitsIndex = 0;
|
||||||
private int yIndex = 0;
|
private int yIndex = 0;
|
||||||
@ -618,7 +619,7 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
by = yIndex << 4;
|
by = yIndex << 4;
|
||||||
IRow nullRowY = rowZ.rows[yIndex++];
|
IRow nullRowY = rowZ.rows[yIndex++];
|
||||||
if (nullRowY instanceof RowY) {
|
if (nullRowY instanceof RowY) {
|
||||||
rowY = (RowY) nullRowY;
|
RowY rowY = (RowY) nullRowY;
|
||||||
bits = rowY.bits;
|
bits = rowY.bits;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -656,9 +657,7 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
public BlockVector3 next() {
|
public BlockVector3 next() {
|
||||||
final long lowBit = Long.lowestOneBit(bitBuffer);
|
final long lowBit = Long.lowestOneBit(bitBuffer);
|
||||||
final int bitIndex = Long.bitCount(lowBit-1);
|
final int bitIndex = Long.bitCount(lowBit-1);
|
||||||
{
|
mutable.setComponents((bx) + (bitIndex & 15), yy, (zz) + (bitIndex));
|
||||||
mutable.setComponents((bx) + (bitIndex & 15), yy, (zz) + (bitIndex));
|
|
||||||
}
|
|
||||||
bitBuffer = bitBuffer ^ lowBit;
|
bitBuffer = bitBuffer ^ lowBit;
|
||||||
nextLong();
|
nextLong();
|
||||||
return mutable;
|
return mutable;
|
||||||
@ -674,20 +673,23 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
for (int X = 0; X < rows.length; X++) {
|
for (IRow nullRowX : rows) {
|
||||||
IRow nullRowX = rows[X];
|
if (!(nullRowX instanceof RowX))
|
||||||
if (!(nullRowX instanceof RowX)) continue;
|
continue;
|
||||||
RowX rowx = (RowX) nullRowX;
|
RowX rowx = (RowX) nullRowX;
|
||||||
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
for (int Z = 0; Z < rowx.rows.length; Z++) {
|
||||||
IRow nullRowZ = rowx.rows[Z];
|
IRow nullRowZ = rowx.rows[Z];
|
||||||
if (!(nullRowZ instanceof RowZ)) continue;
|
if (!(nullRowZ instanceof RowZ))
|
||||||
|
continue;
|
||||||
RowZ rowz = (RowZ) nullRowZ;
|
RowZ rowz = (RowZ) nullRowZ;
|
||||||
for (int Y = 0; Y < 16; Y++) {
|
for (int Y = 0; Y < 16; Y++) {
|
||||||
IRow nullRowY = rowz.rows[Y];
|
IRow nullRowY = rowz.rows[Y];
|
||||||
if (!(nullRowY instanceof RowY)) continue;
|
if (!(nullRowY instanceof RowY))
|
||||||
|
continue;
|
||||||
RowY rowY = (RowY) nullRowY;
|
RowY rowY = (RowY) nullRowY;
|
||||||
for (long bit : rowY.bits) {
|
for (long bit : rowY.bits) {
|
||||||
if (bit != 0) return true;
|
if (bit != 0)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -704,13 +706,14 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
long total = 0;
|
long total = 0;
|
||||||
long lastBit = 0;
|
long lastBit = 0;
|
||||||
int lastCount = 0;
|
int lastCount = 0;
|
||||||
for (int x = 0; x < rows.length; x++) {
|
for (IRow nullRowX : rows) {
|
||||||
IRow nullRowX = rows[x];
|
if (!(nullRowX instanceof RowX))
|
||||||
if (!(nullRowX instanceof RowX)) continue;
|
continue;
|
||||||
RowX rowx = (RowX) nullRowX;
|
RowX rowx = (RowX) nullRowX;
|
||||||
for (int z = 0; z < rowx.rows.length; z++) {
|
for (int z = 0; z < rowx.rows.length; z++) {
|
||||||
IRow nullRowZ = rowx.rows[z];
|
IRow nullRowZ = rowx.rows[z];
|
||||||
if (!(nullRowZ instanceof RowZ)) continue;
|
if (!(nullRowZ instanceof RowZ))
|
||||||
|
continue;
|
||||||
RowZ rowz = (RowZ) nullRowZ;
|
RowZ rowz = (RowZ) nullRowZ;
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
IRow nullRowY = rowz.rows[y];
|
IRow nullRowY = rowz.rows[y];
|
||||||
@ -755,7 +758,8 @@ public final class MemBlockSet extends BlockSet {
|
|||||||
remove(rows, x, y, z);
|
remove(rows, x, y, z);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default void clear(IRow[] rows, int x, int y, int z) { return; }
|
default void clear(IRow[] rows, int x, int y, int z) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class NullRowX implements IRow {
|
public static final class NullRowX implements IRow {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.object.extent;
|
package com.boydti.fawe.object.extent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.PassthroughExtent;
|
import com.sk89q.worldedit.extent.PassthroughExtent;
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ public class ExtentHeightCacher extends PassthroughExtent {
|
|||||||
int rx = x - cacheBotX + 16;
|
int rx = x - cacheBotX + 16;
|
||||||
int rz = z - cacheBotZ + 16;
|
int rz = z - cacheBotZ + 16;
|
||||||
int index;
|
int index;
|
||||||
if (((rx & 0xFF) != rx || (rz & 0xFF) != rz)) {
|
if ((rx & 0xFF) != rx || (rz & 0xFF) != rz) {
|
||||||
cacheBotX = x - 16;
|
cacheBotX = x - 16;
|
||||||
cacheBotZ = z - 16;
|
cacheBotZ = z - 16;
|
||||||
lastY = y;
|
lastY = y;
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package com.boydti.fawe.object.extent;
|
package com.boydti.fawe.object.extent;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
|
||||||
import com.boydti.fawe.object.FaweLimit;
|
import com.boydti.fawe.object.FaweLimit;
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.boydti.fawe.util.WEManager;
|
import com.boydti.fawe.util.WEManager;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -15,9 +12,10 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -41,12 +39,7 @@ public abstract class FaweRegionExtent extends ResettableExtent {
|
|||||||
public abstract Collection<Region> getRegions();
|
public abstract Collection<Region> getRegions();
|
||||||
|
|
||||||
public boolean isGlobal() {
|
public boolean isGlobal() {
|
||||||
for (Region region : getRegions()) {
|
return getRegions().stream().anyMatch(Region::isGlobal);
|
||||||
if (region.isGlobal()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,12 +30,12 @@ public class OffsetExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||||
return getExtent().setBlock(location.getBlockX() + dx, location.getBlockY() + dy, location.getBlockZ() + dz, block);
|
return getExtent().setBlock(location.getBlockX() + dx, location.getBlockY() + dy, location.getBlockZ() + dz, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
return getExtent().setBlock(x + dx, y + dy, z + dz, block);
|
return getExtent().setBlock(x + dx, y + dy, z + dz, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,13 +51,13 @@ public class TransformExtent extends BlockTransformExtent {
|
|||||||
if (min == null) {
|
if (min == null) {
|
||||||
min = pos;
|
min = pos;
|
||||||
}
|
}
|
||||||
mutable1.mutX(((pos.getX() - min.getX())));
|
mutable1.mutX(pos.getX() - min.getX());
|
||||||
mutable1.mutY(((pos.getY() - min.getY())));
|
mutable1.mutY(pos.getY() - min.getY());
|
||||||
mutable1.mutZ(((pos.getZ() - min.getZ())));
|
mutable1.mutZ(pos.getZ() - min.getZ());
|
||||||
Vector3 tmp = getTransform().apply(mutable1);
|
Vector3 tmp = getTransform().apply(mutable1);
|
||||||
mutable2.mutX((tmp.getX() + min.getX()));
|
mutable2.mutX(tmp.getX() + min.getX());
|
||||||
mutable2.mutY((tmp.getY() + min.getY()));
|
mutable2.mutY(tmp.getY() + min.getY());
|
||||||
mutable2.mutZ((tmp.getZ() + min.getZ()));
|
mutable2.mutZ(tmp.getZ() + min.getZ());
|
||||||
return mutable2;
|
return mutable2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,13 +65,13 @@ public class TransformExtent extends BlockTransformExtent {
|
|||||||
if (min == null) {
|
if (min == null) {
|
||||||
min = BlockVector3.at(x, y, z);
|
min = BlockVector3.at(x, y, z);
|
||||||
}
|
}
|
||||||
mutable1.mutX(((x - min.getX())));
|
mutable1.mutX(x - min.getX());
|
||||||
mutable1.mutY(((y - min.getY())));
|
mutable1.mutY(y - min.getY());
|
||||||
mutable1.mutZ(((z - min.getZ())));
|
mutable1.mutZ(z - min.getZ());
|
||||||
Vector3 tmp = getTransform().apply(mutable1);
|
Vector3 tmp = getTransform().apply(mutable1);
|
||||||
mutable2.mutX((tmp.getX() + min.getX()));
|
mutable2.mutX(tmp.getX() + min.getX());
|
||||||
mutable2.mutY((tmp.getY() + min.getY()));
|
mutable2.mutY(tmp.getY() + min.getY());
|
||||||
mutable2.mutZ((tmp.getZ() + min.getZ()));
|
mutable2.mutZ(tmp.getZ() + min.getZ());
|
||||||
return tmp.toBlockPoint();
|
return tmp.toBlockPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,13 +93,13 @@ public class TransformExtent extends BlockTransformExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
return super.setBlock(getPos(x, y, z), transformInverse(block));
|
return super.setBlock(getPos(x, y, z), transformInverse(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||||
return super.setBlock(getPos(location), transformInverse(block));
|
return super.setBlock(getPos(location), transformInverse(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
|
|
||||||
public class AdjacentAnyMask2 extends AbstractMask {
|
|
||||||
@Override
|
|
||||||
public boolean test(BlockVector3 vector) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package com.boydti.fawe.object.number;
|
|
||||||
|
|
||||||
public final class MutableLong {
|
|
||||||
private long value;
|
|
||||||
|
|
||||||
public final void increment() {
|
|
||||||
value++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set(long value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long get() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(long amount) {
|
|
||||||
this.value += amount;
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,9 +23,9 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
|
|||||||
if (origin == null) {
|
if (origin == null) {
|
||||||
origin = pos;
|
origin = pos;
|
||||||
}
|
}
|
||||||
mutable.mutX((pos.getX() - origin.getX()));
|
mutable.mutX(pos.getX() - origin.getX());
|
||||||
mutable.mutY((pos.getY() - origin.getY()));
|
mutable.mutY(pos.getY() - origin.getY());
|
||||||
mutable.mutZ((pos.getZ() - origin.getZ()));
|
mutable.mutZ(pos.getZ() - origin.getZ());
|
||||||
return pattern.apply(mutable);
|
return pattern.apply(mutable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,9 +34,9 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
|
|||||||
if (origin == null) {
|
if (origin == null) {
|
||||||
origin = set;
|
origin = set;
|
||||||
}
|
}
|
||||||
mutable.mutX((set.getX() - origin.getX()));
|
mutable.mutX(set.getX() - origin.getX());
|
||||||
mutable.mutY((set.getY() - origin.getY()));
|
mutable.mutY(set.getY() - origin.getY());
|
||||||
mutable.mutZ((set.getZ() - origin.getZ()));
|
mutable.mutZ(set.getZ() - origin.getZ());
|
||||||
return pattern.apply(extent, get, mutable);
|
return pattern.apply(extent, get, mutable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package com.boydti.fawe.object.random;
|
package com.boydti.fawe.object.random;
|
||||||
|
|
||||||
public interface SimpleRandom {
|
public interface SimpleRandom {
|
||||||
public double nextDouble(int x, int y, int z);
|
|
||||||
|
|
||||||
public default int nextInt(int x, int y, int z, int len) {
|
double nextDouble(int x, int y, int z);
|
||||||
|
|
||||||
|
default int nextInt(int x, int y, int z, int len) {
|
||||||
double val = nextDouble(x, y, z);
|
double val = nextDouble(x, y, z);
|
||||||
return (int) (val * len);
|
return (int) (val * len);
|
||||||
}
|
}
|
||||||
|
@ -3,19 +3,16 @@ package com.boydti.fawe.object.random;
|
|||||||
import java.util.SplittableRandom;
|
import java.util.SplittableRandom;
|
||||||
|
|
||||||
public class TrueRandom implements SimpleRandom {
|
public class TrueRandom implements SimpleRandom {
|
||||||
private final SplittableRandom r;
|
|
||||||
|
|
||||||
public TrueRandom() {
|
private final SplittableRandom random = new SplittableRandom();
|
||||||
this.r = new SplittableRandom();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double nextDouble(int x, int y, int z) {
|
public double nextDouble(int x, int y, int z) {
|
||||||
return r.nextDouble();
|
return random.nextDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int nextInt(int x, int y, int z, int len) {
|
public int nextInt(int x, int y, int z, int len) {
|
||||||
return r.nextInt(len);
|
return random.nextInt(len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,8 @@ public class Triangle {
|
|||||||
radius[1] = RADIUS;
|
radius[1] = RADIUS;
|
||||||
radius[2] = RADIUS;
|
radius[2] = RADIUS;
|
||||||
this.normalVec = pos2.subtract(pos1).cross(pos3.subtract(pos1)).normalize();
|
this.normalVec = pos2.subtract(pos1).cross(pos3.subtract(pos1)).normalize();
|
||||||
this.b = Math.max(Math.max(this.normalVec.dot(pos1), this.normalVec.dot(pos2)), this.normalVec.dot(pos3));
|
this.b = Math.max(Math.max(this.normalVec.dot(pos1), this.normalVec.dot(pos2)),
|
||||||
|
this.normalVec.dot(pos3));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean above(BlockVector3 pt) {
|
public boolean above(BlockVector3 pt) {
|
||||||
@ -45,9 +46,14 @@ public class Triangle {
|
|||||||
|
|
||||||
public Edge getEdge(int index) {
|
public Edge getEdge(int index) {
|
||||||
if (index == this.verts.length - 1) {
|
if (index == this.verts.length - 1) {
|
||||||
return new Edge(Vector3.at(this.verts[index][0], this.verts[index][1],this.verts[index][2]), Vector3.at(this.verts[0][0], this.verts[0][1], this.verts[0][2]));
|
return new Edge(
|
||||||
|
Vector3.at(this.verts[index][0], this.verts[index][1], this.verts[index][2]),
|
||||||
|
Vector3.at(this.verts[0][0], this.verts[0][1], this.verts[0][2]));
|
||||||
} else {
|
} else {
|
||||||
return new Edge(Vector3.at(this.verts[index][0], this.verts[index][1],this.verts[index][2]), Vector3.at(this.verts[index + 1][0], this.verts[index + 1][1], this.verts[index + 1][2]));
|
return new Edge(
|
||||||
|
Vector3.at(this.verts[index][0], this.verts[index][1], this.verts[index][2]),
|
||||||
|
Vector3.at(this.verts[index + 1][0], this.verts[index + 1][1],
|
||||||
|
this.verts[index + 1][2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +86,7 @@ public class Triangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double dot(double[] v1, double[] v2) {
|
private double dot(double[] v1, double[] v2) {
|
||||||
return (v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]);
|
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -175,8 +181,8 @@ public class Triangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean overlaps(double boxcenter[], double boxhalfsize[], double triverts[][]) {
|
private boolean overlaps(double[] boxcenter, double[] boxhalfsize, double[][] triverts) {
|
||||||
double min, max, p0, p1, p2, rad, fex, fey, fez;
|
double min, max, fex, fey, fez;
|
||||||
sub(v0, triverts[0], boxcenter);
|
sub(v0, triverts[0], boxcenter);
|
||||||
sub(v1, triverts[1], boxcenter);
|
sub(v1, triverts[1], boxcenter);
|
||||||
sub(v2, triverts[2], boxcenter);
|
sub(v2, triverts[2], boxcenter);
|
||||||
@ -188,48 +194,71 @@ public class Triangle {
|
|||||||
fey = Math.abs(e0[1]);
|
fey = Math.abs(e0[1]);
|
||||||
fez = Math.abs(e0[2]);
|
fez = Math.abs(e0[2]);
|
||||||
|
|
||||||
if (!axisTestX01(e0[2], e0[1], fez, fey)) return false;
|
if (!axisTestX01(e0[2], e0[1], fez, fey)) {
|
||||||
if (!axisTestY02(e0[2], e0[0], fez, fex)) return false;
|
return false;
|
||||||
if (!axisTestZ12(e0[1], e0[0], fey, fex)) return false;
|
}
|
||||||
|
if (!axisTestY02(e0[2], e0[0], fez, fex)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!axisTestZ12(e0[1], e0[0], fey, fex)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
fex = Math.abs(e1[0]);
|
fex = Math.abs(e1[0]);
|
||||||
fey = Math.abs(e1[1]);
|
fey = Math.abs(e1[1]);
|
||||||
fez = Math.abs(e1[2]);
|
fez = Math.abs(e1[2]);
|
||||||
|
|
||||||
if (!axisTestX01(e1[2], e1[1], fez, fey)) return false;
|
if (!axisTestX01(e1[2], e1[1], fez, fey)) {
|
||||||
if (!axisTestY02(e1[2], e1[0], fez, fex)) return false;
|
return false;
|
||||||
if (!axisTestZ0(e1[1], e1[0], fey, fex)) return false;
|
}
|
||||||
|
if (!axisTestY02(e1[2], e1[0], fez, fex)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!axisTestZ0(e1[1], e1[0], fey, fex)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
fex = Math.abs(e2[0]);
|
fex = Math.abs(e2[0]);
|
||||||
fey = Math.abs(e2[1]);
|
fey = Math.abs(e2[1]);
|
||||||
fez = Math.abs(e2[2]);
|
fez = Math.abs(e2[2]);
|
||||||
|
|
||||||
if (!axisTestX2(e2[2], e2[1], fez, fey)) return false;
|
if (!axisTestX2(e2[2], e2[1], fez, fey)) {
|
||||||
if (!axisTestY1(e2[2], e2[0], fez, fex)) return false;
|
return false;
|
||||||
if (!axisTestZ12(e2[1], e2[0], fey, fex)) return false;
|
}
|
||||||
|
if (!axisTestY1(e2[2], e2[0], fez, fex)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!axisTestZ12(e2[1], e2[0], fey, fex)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
max = MathMan.max(v0[0], v1[0], v2[0]);
|
max = MathMan.max(v0[0], v1[0], v2[0]);
|
||||||
min = MathMan.min(v0[0], v1[0], v2[0]);
|
min = MathMan.min(v0[0], v1[0], v2[0]);
|
||||||
|
|
||||||
if (min > boxhalfsize[0] || max < -boxhalfsize[0]) return false;
|
if (min > boxhalfsize[0] || max < -boxhalfsize[0]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
max = MathMan.max(v0[1], v1[1], v2[1]);
|
max = MathMan.max(v0[1], v1[1], v2[1]);
|
||||||
min = MathMan.min(v0[1], v1[1], v2[1]);
|
min = MathMan.min(v0[1], v1[1], v2[1]);
|
||||||
|
|
||||||
if (min > boxhalfsize[1] || max < -boxhalfsize[1]) return false;
|
if (min > boxhalfsize[1] || max < -boxhalfsize[1]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
max = MathMan.max(v0[2], v1[2], v2[2]);
|
max = MathMan.max(v0[2], v1[2], v2[2]);
|
||||||
min = MathMan.min(v0[2], v1[2], v2[2]);
|
min = MathMan.min(v0[2], v1[2], v2[2]);
|
||||||
|
|
||||||
if (min > boxhalfsize[2] || max < -boxhalfsize[2]) return false;
|
if (min > boxhalfsize[2] || max < -boxhalfsize[2]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
cross(normal, e0, e1);
|
cross(normal, e0, e1);
|
||||||
|
|
||||||
return (planeBoxOverlap(normal, v0, boxhalfsize));
|
return planeBoxOverlap(normal, v0, boxhalfsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean planeBoxOverlap(double normal[], double vert[], double maxbox[]) {
|
private boolean planeBoxOverlap(double[] normal, double[] vert, double[] maxbox) {
|
||||||
for (int q = 0; q <= 2; q++) {
|
for (int q = 0; q <= 2; q++) {
|
||||||
double v = vert[q];
|
double v = vert[q];
|
||||||
if (normal[q] > 0.0f) {
|
if (normal[q] > 0.0f) {
|
||||||
@ -240,8 +269,9 @@ public class Triangle {
|
|||||||
vmax[q] = -maxbox[q] - v;
|
vmax[q] = -maxbox[q] - v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dot(normal, vmin) > 0.0f) return false;
|
if (dot(normal, vmin) > 0.0f) {
|
||||||
if (dot(normal, vmax) >= 0.0f) return true;
|
return false;
|
||||||
return false;
|
}
|
||||||
|
return dot(normal, vmax) >= 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.boydti.fawe.object.regions.selector;
|
package com.boydti.fawe.object.regions.selector;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.boydti.fawe.object.regions.PolyhedralRegion;
|
import com.boydti.fawe.object.regions.PolyhedralRegion;
|
||||||
import com.boydti.fawe.object.regions.Triangle;
|
import com.boydti.fawe.object.regions.Triangle;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
@ -32,13 +34,14 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@code PolyhedralRegion} from a user's selections.
|
* Creates a {@code PolyhedralRegion} from a user's selections.
|
||||||
*/
|
*/
|
||||||
@ -51,7 +54,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
* Create a new selector with a {@code null} world.
|
* Create a new selector with a {@code null} world.
|
||||||
*/
|
*/
|
||||||
public PolyhedralRegionSelector() {
|
public PolyhedralRegionSelector() {
|
||||||
this((World) null);
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
package com.boydti.fawe.regions;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
|
||||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
|
||||||
import com.sk89q.worldedit.world.World;
|
|
||||||
|
|
||||||
public abstract class SimpleRegion extends AbstractRegion {
|
|
||||||
private final BlockVector3 max;
|
|
||||||
private final BlockVector3 min;
|
|
||||||
|
|
||||||
public SimpleRegion(World world, BlockVector3 min, BlockVector3 max) {
|
|
||||||
super(world);
|
|
||||||
this.min = min;
|
|
||||||
this.max = max;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockVector3 getMinimumPoint() {
|
|
||||||
return min;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockVector3 getMaximumPoint() {
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
|
||||||
throw new UnsupportedOperationException("Region is immutable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
|
||||||
throw new UnsupportedOperationException("Region is immutable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(BlockVector3 p) {
|
|
||||||
return contains(p.getBlockX(), p.getBlockY(), p.getBlockZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract boolean contains(int x, int y, int z);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract boolean contains(int x, int z);
|
|
||||||
}
|
|
@ -1,7 +1,8 @@
|
|||||||
package com.boydti.fawe.regions.general;
|
package com.boydti.fawe.regions.general;
|
||||||
|
|
||||||
public interface RegionFilter {
|
public interface RegionFilter {
|
||||||
public boolean containsRegion(int mcaX, int mcaZ);
|
|
||||||
|
|
||||||
public boolean containsChunk(int chunkX, int chunkZ);
|
boolean containsRegion(int mcaX, int mcaZ);
|
||||||
}
|
|
||||||
|
boolean containsChunk(int chunkX, int chunkZ);
|
||||||
|
}
|
||||||
|
@ -372,8 +372,8 @@ public class LocalSession implements TextureHolder {
|
|||||||
public void remember(EditSession editSession) {
|
public void remember(EditSession editSession) {
|
||||||
checkNotNull(editSession);
|
checkNotNull(editSession);
|
||||||
|
|
||||||
Player fp = editSession.getPlayer();
|
Player player = editSession.getPlayer();
|
||||||
int limit = fp == null ? Integer.MAX_VALUE : fp.getLimit().MAX_HISTORY;
|
int limit = player == null ? Integer.MAX_VALUE : player.getLimit().MAX_HISTORY;
|
||||||
remember(editSession, true, limit);
|
remember(editSession, true, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,7 +507,6 @@ public class LocalSession implements TextureHolder {
|
|||||||
*/
|
*/
|
||||||
public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) {
|
public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) {
|
||||||
checkNotNull(actor);
|
checkNotNull(actor);
|
||||||
//TODO This method needs to be modified to use actors instead of FAWEPlayer
|
|
||||||
loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player) actor).getWorldForEditing());
|
loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player) actor).getWorldForEditing());
|
||||||
if (getHistoryNegativeIndex() < history.size()) {
|
if (getHistoryNegativeIndex() < history.size()) {
|
||||||
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
|
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
|
||||||
@ -544,7 +543,6 @@ public class LocalSession implements TextureHolder {
|
|||||||
*/
|
*/
|
||||||
public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) {
|
public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) {
|
||||||
checkNotNull(actor);
|
checkNotNull(actor);
|
||||||
//TODO This method needs to be modified to use actors instead of FAWEPlayer
|
|
||||||
loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player)actor).getWorldForEditing());
|
loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player)actor).getWorldForEditing());
|
||||||
if (getHistoryNegativeIndex() > 0) {
|
if (getHistoryNegativeIndex() > 0) {
|
||||||
setDirty();
|
setDirty();
|
||||||
@ -622,16 +620,12 @@ public class LocalSession implements TextureHolder {
|
|||||||
*/
|
*/
|
||||||
public RegionSelector getRegionSelector(World world) {
|
public RegionSelector getRegionSelector(World world) {
|
||||||
checkNotNull(world);
|
checkNotNull(world);
|
||||||
try {
|
if (selector.getWorld() == null || !selector.getWorld().equals(world)) {
|
||||||
if (selector.getWorld() == null || !selector.getWorld().equals(world)) {
|
selector.setWorld(world);
|
||||||
selector.setWorld(world);
|
|
||||||
selector.clear();
|
|
||||||
if (hasWorldOverride() && !world.equals(getWorldOverride())) {
|
|
||||||
setWorldOverride(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable ignore) {
|
|
||||||
selector.clear();
|
selector.clear();
|
||||||
|
if (hasWorldOverride() && !world.equals(getWorldOverride())) {
|
||||||
|
setWorldOverride(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return selector;
|
return selector;
|
||||||
}
|
}
|
||||||
@ -1044,6 +1038,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
} else if (type.getId().equalsIgnoreCase(config.navigationWand)) {
|
} else if (type.getId().equalsIgnoreCase(config.navigationWand)) {
|
||||||
throw new InvalidToolBindException(type, "Already used for the navigation wand");
|
throw new InvalidToolBindException(type, "Already used for the navigation wand");
|
||||||
}
|
}
|
||||||
|
|
||||||
Tool previous;
|
Tool previous;
|
||||||
if (player != null && (tool instanceof BrushTool || tool == null) && Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
|
if (player != null && (tool instanceof BrushTool || tool == null) && Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
|
||||||
previous = BrushCache.getCachedTool(item);
|
previous = BrushCache.getCachedTool(item);
|
||||||
@ -1350,23 +1345,25 @@ public class LocalSession implements TextureHolder {
|
|||||||
*/
|
*/
|
||||||
public EditSession createEditSession(Actor actor) {
|
public EditSession createEditSession(Actor actor) {
|
||||||
checkNotNull(actor);
|
checkNotNull(actor);
|
||||||
BlockBag blockBag = null;
|
|
||||||
if (actor.isPlayer() && actor instanceof Player) {
|
|
||||||
blockBag = getBlockBag((Player) actor);
|
|
||||||
}
|
|
||||||
World world = null;
|
World world = null;
|
||||||
if (hasWorldOverride()) {
|
if (hasWorldOverride()) {
|
||||||
world = getWorldOverride();
|
world = getWorldOverride();
|
||||||
} else if (actor instanceof Locatable && ((Locatable) actor).getExtent() instanceof World) {
|
} else if (actor instanceof Locatable && ((Locatable) actor).getExtent() instanceof World) {
|
||||||
world = (World) ((Locatable) actor).getExtent();
|
world = (World) ((Locatable) actor).getExtent();
|
||||||
}
|
}
|
||||||
EditSessionBuilder builder = new EditSessionBuilder(world);
|
|
||||||
if (actor.isPlayer() && actor instanceof Player) builder.player((Player) actor);
|
|
||||||
builder.blockBag(blockBag);
|
|
||||||
builder.fastmode(fastMode);
|
|
||||||
|
|
||||||
// Create an edit session
|
// Create an edit session
|
||||||
EditSession editSession = builder.build();
|
EditSession editSession;
|
||||||
|
EditSessionBuilder builder = new EditSessionBuilder(world);
|
||||||
|
if (actor.isPlayer() && actor instanceof Player) {
|
||||||
|
BlockBag blockBag = getBlockBag((Player) actor);
|
||||||
|
builder.player((Player) actor);
|
||||||
|
builder.blockBag(blockBag);
|
||||||
|
}
|
||||||
|
builder.fastmode(fastMode);
|
||||||
|
|
||||||
|
editSession = builder.build();
|
||||||
|
|
||||||
if (mask != null) {
|
if (mask != null) {
|
||||||
editSession.setMask(mask);
|
editSession.setMask(mask);
|
||||||
|
@ -41,7 +41,6 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
|||||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||||
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.Constant;
|
|
||||||
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
|
@ -132,7 +132,6 @@ import org.enginehub.piston.annotation.param.Arg;
|
|||||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||||
import org.enginehub.piston.annotation.param.Switch;
|
import org.enginehub.piston.annotation.param.Switch;
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||||
import org.enginehub.piston.inject.Key;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commands to set brush shape.
|
* Commands to set brush shape.
|
||||||
@ -162,9 +161,9 @@ public class BrushCommands {
|
|||||||
@CommandPermissions("worldedit.brush.blendball")
|
@CommandPermissions("worldedit.brush.blendball")
|
||||||
public void blendBallBrush(Player player, LocalSession session,
|
public void blendBallBrush(Player player, LocalSession session,
|
||||||
@Arg(desc = "The radius to sample for blending", def = "5")
|
@Arg(desc = "The radius to sample for blending", def = "5")
|
||||||
Expression radius, InjectedValueAccess context) throws WorldEditException {
|
Expression radius) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context, new BlendBall()).setSize(radius);
|
set(player, session, new BlendBall()).setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -174,9 +173,9 @@ public class BrushCommands {
|
|||||||
@CommandPermissions("worldedit.brush.erode")
|
@CommandPermissions("worldedit.brush.erode")
|
||||||
public void erodeBrush(Player player, LocalSession session,
|
public void erodeBrush(Player player, LocalSession session,
|
||||||
@Arg(desc = "The radius for eroding", def = "5")
|
@Arg(desc = "The radius for eroding", def = "5")
|
||||||
Expression radius, InjectedValueAccess context) throws WorldEditException {
|
Expression radius) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context, new ErodeBrush()).setSize(radius);
|
set(player, session, new ErodeBrush()).setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -186,9 +185,9 @@ public class BrushCommands {
|
|||||||
@CommandPermissions("worldedit.brush.pull")
|
@CommandPermissions("worldedit.brush.pull")
|
||||||
public void pullBrush(Player player, LocalSession session,
|
public void pullBrush(Player player, LocalSession session,
|
||||||
@Arg(desc = "The radius to sample for blending", def = "5")
|
@Arg(desc = "The radius to sample for blending", def = "5")
|
||||||
Expression radius, InjectedValueAccess context) throws WorldEditException {
|
Expression radius) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context, new RaiseBrush()).setSize(radius);
|
set(player, session, new RaiseBrush()).setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -196,11 +195,12 @@ public class BrushCommands {
|
|||||||
desc = "Creates a circle which revolves around your facing direction"
|
desc = "Creates a circle which revolves around your facing direction"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.sphere")
|
@CommandPermissions("worldedit.brush.sphere")
|
||||||
public void circleBrush(Player player, EditSession editSession, LocalSession session, Pattern fill,
|
public void circleBrush(Player player, EditSession editSession, LocalSession session,
|
||||||
|
Pattern fill,
|
||||||
@Arg(desc = "The radius to sample for blending", def = "5")
|
@Arg(desc = "The radius to sample for blending", def = "5")
|
||||||
Expression radius, InjectedValueAccess context) throws WorldEditException {
|
Expression radius) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context, new CircleBrush(player)).setSize(radius).setFill(fill);
|
set(player, session, new CircleBrush(player)).setSize(radius).setFill(fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -211,14 +211,14 @@ public class BrushCommands {
|
|||||||
"Note: Set a mask to recurse along specific blocks"
|
"Note: Set a mask to recurse along specific blocks"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.recursive")
|
@CommandPermissions("worldedit.brush.recursive")
|
||||||
public void recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill,
|
public void recursiveBrush(Player player, LocalSession session, EditSession editSession,
|
||||||
|
Pattern fill,
|
||||||
@Arg(desc = "The radius to sample for blending", def = "5")
|
@Arg(desc = "The radius to sample for blending", def = "5")
|
||||||
Expression radius,
|
Expression radius,
|
||||||
@Switch(name = 'd', desc = "Apply in depth first order")
|
@Switch(name = 'd', desc = "Apply in depth first order")
|
||||||
boolean depthFirst,
|
boolean depthFirst) throws WorldEditException {
|
||||||
InjectedValueAccess context) throws WorldEditException {
|
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context, new RecurseBrush(depthFirst))
|
set(player, session, new RecurseBrush(depthFirst))
|
||||||
.setSize(radius).setFill(fill).setMask(new IdMask(editSession));
|
.setSize(radius).setFill(fill).setMask(new IdMask(editSession));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,9 +236,9 @@ public class BrushCommands {
|
|||||||
@Switch(name = 's', desc = "Selects the clicked point after drawing")
|
@Switch(name = 's', desc = "Selects the clicked point after drawing")
|
||||||
boolean select,
|
boolean select,
|
||||||
@Switch(name = 'f', desc = "Create a flat line")
|
@Switch(name = 'f', desc = "Create a flat line")
|
||||||
boolean flat, InjectedValueAccess context) throws WorldEditException {
|
boolean flat) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context, new LineBrush(shell, select, flat)).setSize(radius).setFill(fill);
|
set(player, session, new LineBrush(shell, select, flat)).setSize(radius).setFill(fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -252,13 +252,14 @@ public class BrushCommands {
|
|||||||
"Tutorial: https://www.planetminecraft.com/blog/fawe-tutorial/"
|
"Tutorial: https://www.planetminecraft.com/blog/fawe-tutorial/"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.spline")
|
@CommandPermissions("worldedit.brush.spline")
|
||||||
public void splineBrush(Player player, EditSession editSession, LocalSession session, Pattern fill,
|
public void splineBrush(Player player, EditSession editSession, LocalSession session,
|
||||||
|
Pattern fill,
|
||||||
@Arg(desc = "The radius to sample for blending", def = "25")
|
@Arg(desc = "The radius to sample for blending", def = "25")
|
||||||
Expression radius, InjectedValueAccess context) throws WorldEditException {
|
Expression radius) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
player.print(BBC.BRUSH_SPLINE.format(radius));
|
player.print(BBC.BRUSH_SPLINE.format(radius));
|
||||||
set(session, context,
|
set(player, session,
|
||||||
new SplineBrush(player, session))
|
new SplineBrush(player, session))
|
||||||
.setSize(radius)
|
.setSize(radius)
|
||||||
.setFill(fill);
|
.setFill(fill);
|
||||||
}
|
}
|
||||||
@ -272,9 +273,10 @@ public class BrushCommands {
|
|||||||
"Set [copies] to a value > 0 if you want to have your selection pasted a limited amount of times equally spaced on the curve"
|
"Set [copies] to a value > 0 if you want to have your selection pasted a limited amount of times equally spaced on the curve"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.sweep")
|
@CommandPermissions("worldedit.brush.sweep")
|
||||||
public void sweepBrush(Player player, LocalSession session, @Arg(name = "copies", desc = "int", def = "-1") int copies, InjectedValueAccess context) throws WorldEditException {
|
public void sweepBrush(Player player, LocalSession session,
|
||||||
|
@Arg(name = "copies", desc = "int", def = "-1") int copies) throws WorldEditException {
|
||||||
player.print(BBC.BRUSH_SPLINE.s());
|
player.print(BBC.BRUSH_SPLINE.s());
|
||||||
set(session, context, new SweepBrush(copies));
|
set(player, session, new SweepBrush(copies));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -283,7 +285,8 @@ public class BrushCommands {
|
|||||||
desc = "Create a hanging line between two points"
|
desc = "Create a hanging line between two points"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.spline")
|
@CommandPermissions("worldedit.brush.spline")
|
||||||
public void catenaryBrush(LocalSession session, Pattern fill, @Arg(def = "1.2", desc = "Length of wire compared to distance between points") @Range(min = 1) double lengthFactor,
|
public void catenaryBrush(Player player, LocalSession session, Pattern fill,
|
||||||
|
@Arg(def = "1.2", desc = "Length of wire compared to distance between points") @Range(min = 1) double lengthFactor,
|
||||||
@Arg(desc = "The radius to sample for blending", def = "0")
|
@Arg(desc = "The radius to sample for blending", def = "0")
|
||||||
Expression radius,
|
Expression radius,
|
||||||
@Switch(name = 'h', desc = "Create only a shell")
|
@Switch(name = 'h', desc = "Create only a shell")
|
||||||
@ -291,12 +294,11 @@ public class BrushCommands {
|
|||||||
@Switch(name = 's', desc = "Select the clicked point after drawing")
|
@Switch(name = 's', desc = "Select the clicked point after drawing")
|
||||||
boolean select,
|
boolean select,
|
||||||
@Switch(name = 'd', desc = "sags the catenary toward the facing direction")
|
@Switch(name = 'd', desc = "sags the catenary toward the facing direction")
|
||||||
boolean facingDirection,
|
boolean facingDirection) throws WorldEditException {
|
||||||
InjectedValueAccess context) throws WorldEditException {
|
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor);
|
Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor);
|
||||||
set(session, context,
|
set(player, session,
|
||||||
new CatenaryBrush(shell, select, facingDirection, lengthFactor))
|
new CatenaryBrush(shell, select, facingDirection, lengthFactor))
|
||||||
.setSize(radius)
|
.setSize(radius)
|
||||||
.setFill(fill);
|
.setFill(fill);
|
||||||
}
|
}
|
||||||
@ -311,11 +313,14 @@ public class BrushCommands {
|
|||||||
@CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0,
|
@CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0,
|
||||||
public void surfaceSpline(Player player, LocalSession session, Pattern fill,
|
public void surfaceSpline(Player player, LocalSession session, Pattern fill,
|
||||||
@Arg(desc = "The radius to sample for blending", def = "0")
|
@Arg(desc = "The radius to sample for blending", def = "0")
|
||||||
Expression radius, @Arg(name = "tension", desc = "double", def = "0") double tension, @Arg(name = "bias", desc = "double", def = "0") double bias, @Arg(name = "continuity", desc = "double", def = "0") double continuity, @Arg(name = "quality", desc = "double", def = "10") double quality, InjectedValueAccess context) throws WorldEditException {
|
Expression radius, @Arg(name = "tension", desc = "double", def = "0") double tension,
|
||||||
|
@Arg(name = "bias", desc = "double", def = "0") double bias,
|
||||||
|
@Arg(name = "continuity", desc = "double", def = "0") double continuity,
|
||||||
|
@Arg(name = "quality", desc = "double", def = "10") double quality) throws WorldEditException {
|
||||||
player.print(BBC.BRUSH_SPLINE.format(radius));
|
player.print(BBC.BRUSH_SPLINE.format(radius));
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context,
|
set(player, session,
|
||||||
new SurfaceSpline(tension, bias, continuity, quality))
|
new SurfaceSpline(tension, bias, continuity, quality))
|
||||||
.setSize(radius)
|
.setSize(radius)
|
||||||
.setFill(fill);
|
.setFill(fill);
|
||||||
}
|
}
|
||||||
@ -326,11 +331,19 @@ public class BrushCommands {
|
|||||||
desc = "Creates a distorted sphere"
|
desc = "Creates a distorted sphere"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.rock")
|
@CommandPermissions("worldedit.brush.rock")
|
||||||
public void blobBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Vector3", def = "10") Vector3 radius, @Arg(name = "sphericity", desc = "double", def = "100") double sphericity, @Arg(name = "frequency", desc = "double", def = "30") double frequency, @Arg(name = "amplitude", desc = "double", def = "50") double amplitude, InjectedValueAccess context) throws WorldEditException {
|
public void blobBrush(Player player, LocalSession session, Pattern fill,
|
||||||
|
@Arg(name = "radius", desc = "Vector3", def = "10")
|
||||||
|
Vector3 radius,
|
||||||
|
@Arg(name = "sphericity", desc = "double", def = "100")
|
||||||
|
double sphericity,
|
||||||
|
@Arg(name = "frequency", desc = "double", def = "30")
|
||||||
|
double frequency,
|
||||||
|
@Arg(name = "amplitude", desc = "double", def = "50")
|
||||||
|
double amplitude) throws WorldEditException {
|
||||||
double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ());
|
double max = MathMan.max(radius.getX(), radius.getY(), radius.getZ());
|
||||||
worldEdit.checkMaxBrushRadius(max);
|
worldEdit.checkMaxBrushRadius(max);
|
||||||
Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100);
|
Brush brush = new BlobBrush(radius.divide(max), frequency / 100, amplitude / 100, sphericity / 100);
|
||||||
set(session, context, brush).setSize(max).setFill(fill);
|
set(player, session, brush).setSize(max).setFill(fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -347,7 +360,7 @@ public class BrushCommands {
|
|||||||
@Switch(name = 'h', desc = "Create hollow spheres instead")
|
@Switch(name = 'h', desc = "Create hollow spheres instead")
|
||||||
boolean hollow,
|
boolean hollow,
|
||||||
@Switch(name = 'f', desc = "Create falling spheres instead")
|
@Switch(name = 'f', desc = "Create falling spheres instead")
|
||||||
boolean falling, InjectedValueAccess context) throws WorldEditException {
|
boolean falling) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
Brush brush;
|
Brush brush;
|
||||||
if (hollow) {
|
if (hollow) {
|
||||||
@ -369,10 +382,7 @@ public class BrushCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
set(session, context,
|
set(player, session, brush).setSize(radius).setFill(pattern);
|
||||||
brush)
|
|
||||||
.setSize(radius)
|
|
||||||
.setFill(pattern);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -383,13 +393,14 @@ public class BrushCommands {
|
|||||||
"Pic: https://i.imgur.com/2xKsZf2.png"
|
"Pic: https://i.imgur.com/2xKsZf2.png"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.shatter")
|
@CommandPermissions("worldedit.brush.shatter")
|
||||||
public void shatterBrush(Player player, EditSession editSession, LocalSession session, Pattern fill,
|
public void shatterBrush(Player player, EditSession editSession, LocalSession session,
|
||||||
|
Pattern fill,
|
||||||
@Arg(desc = "The radius to sample for blending", def = "10")
|
@Arg(desc = "The radius to sample for blending", def = "10")
|
||||||
Expression radius,
|
Expression radius,
|
||||||
@Arg(desc = "Lines", def = "10") int count, InjectedValueAccess context) throws WorldEditException {
|
@Arg(desc = "Lines", def = "10") int count) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context,
|
set(player, session,
|
||||||
new ShatterBrush(count))
|
new ShatterBrush(count))
|
||||||
.setSize(radius)
|
.setSize(radius)
|
||||||
.setFill(fill)
|
.setFill(fill)
|
||||||
.setMask(new ExistingBlockMask(editSession));
|
.setMask(new ExistingBlockMask(editSession));
|
||||||
@ -402,13 +413,12 @@ public class BrushCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.stencil")
|
@CommandPermissions("worldedit.brush.stencil")
|
||||||
public void stencilBrush(Player player, LocalSession session, Pattern fill,
|
public void stencilBrush(Player player, LocalSession session, Pattern fill,
|
||||||
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
|
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
|
||||||
@Arg(name = "image", desc = "String", def = "") String image,
|
@Arg(name = "image", desc = "String", def = "") String image,
|
||||||
@Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation,
|
@Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation,
|
||||||
@Arg(name = "yscale", desc = "double", def = "1") double yscale,
|
@Arg(name = "yscale", desc = "double", def = "1") double yscale,
|
||||||
@Switch(name = 'w', desc = "Apply at maximum saturation") boolean onlyWhite,
|
@Switch(name = 'w', desc = "Apply at maximum saturation") boolean onlyWhite,
|
||||||
@Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate,
|
@Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate) throws WorldEditException, FileNotFoundException {
|
||||||
InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
|
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
InputStream stream = getHeightmapStream(image);
|
InputStream stream = getHeightmapStream(image);
|
||||||
HeightBrush brush;
|
HeightBrush brush;
|
||||||
@ -420,8 +430,8 @@ public class BrushCommands {
|
|||||||
if (randomRotate) {
|
if (randomRotate) {
|
||||||
brush.setRandomRotate(true);
|
brush.setRandomRotate(true);
|
||||||
}
|
}
|
||||||
set(session, context,
|
set(player, session,
|
||||||
brush)
|
brush)
|
||||||
.setSize(radius)
|
.setSize(radius)
|
||||||
.setFill(fill);
|
.setFill(fill);
|
||||||
}
|
}
|
||||||
@ -432,12 +442,16 @@ public class BrushCommands {
|
|||||||
desc = "Use a height map to paint a surface",
|
desc = "Use a height map to paint a surface",
|
||||||
descFooter = "Use a height map to paint any surface.\n")
|
descFooter = "Use a height map to paint any surface.\n")
|
||||||
@CommandPermissions("worldedit.brush.stencil")
|
@CommandPermissions("worldedit.brush.stencil")
|
||||||
public void imageBrush(LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
|
public void imageBrush(Player player, LocalSession session,
|
||||||
ProvideBindings.ImageUri imageUri,
|
@Arg(name = "radius", desc = "Expression", def = "5")
|
||||||
@Arg(def = "1", desc = "scale height") @Range(min = Double.MIN_NORMAL) double yscale,
|
Expression radius,
|
||||||
@Switch(name = 'a', desc = "Use image Alpha") boolean alpha,
|
ProvideBindings.ImageUri imageUri,
|
||||||
@Switch(name = 'f', desc = "Blend the image with existing terrain") boolean fadeOut,
|
@Arg(def = "1", desc = "scale height") @Range(min = Double.MIN_NORMAL)
|
||||||
InjectedValueAccess context) throws WorldEditException, IOException {
|
double yscale,
|
||||||
|
@Switch(name = 'a', desc = "Use image Alpha")
|
||||||
|
boolean alpha,
|
||||||
|
@Switch(name = 'f', desc = "Blend the image with existing terrain")
|
||||||
|
boolean fadeOut) throws WorldEditException, IOException {
|
||||||
BufferedImage image = imageUri.load();
|
BufferedImage image = imageUri.load();
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
if (yscale != 1) {
|
if (yscale != 1) {
|
||||||
@ -449,9 +463,7 @@ public class BrushCommands {
|
|||||||
alpha = true;
|
alpha = true;
|
||||||
}
|
}
|
||||||
ImageBrush brush = new ImageBrush(image, session, alpha);
|
ImageBrush brush = new ImageBrush(image, session, alpha);
|
||||||
set(session, context,
|
set(player, session, brush).setSize(radius);
|
||||||
brush)
|
|
||||||
.setSize(radius);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -463,12 +475,11 @@ public class BrushCommands {
|
|||||||
"The -r flag will apply random rotation"
|
"The -r flag will apply random rotation"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.surface")
|
@CommandPermissions("worldedit.brush.surface")
|
||||||
public void surfaceBrush(LocalSession session, Pattern fill,
|
public void surfaceBrush(Player player, LocalSession session, Pattern fill,
|
||||||
@Arg(name = "radius", desc = "Expression", def = "5")
|
@Arg(name = "radius", desc = "Expression", def = "5")
|
||||||
Expression radius,
|
Expression radius) throws WorldEditException {
|
||||||
InjectedValueAccess context) throws WorldEditException {
|
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radius);
|
set(player, session, new SurfaceSphereBrush()).setFill(fill).setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -478,7 +489,11 @@ public class BrushCommands {
|
|||||||
"Video: https://youtu.be/RPZIaTbqoZw?t=34s"
|
"Video: https://youtu.be/RPZIaTbqoZw?t=34s"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.scatter")
|
@CommandPermissions("worldedit.brush.scatter")
|
||||||
public void scatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "5") double pointsOpt, @Arg(name = "distance", desc = "double", def = "1") double distanceOpt, @Switch(name = 'o', desc = "Overlay the block") boolean overlay, InjectedValueAccess context) throws WorldEditException {
|
public void scatterBrush(Player player, LocalSession session, Pattern fill,
|
||||||
|
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
|
||||||
|
@Arg(name = "points", desc = "double", def = "5") double pointsOpt,
|
||||||
|
@Arg(name = "distance", desc = "double", def = "1") double distanceOpt,
|
||||||
|
@Switch(name = 'o', desc = "Overlay the block") boolean overlay) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
Brush brush;
|
Brush brush;
|
||||||
if (overlay) {
|
if (overlay) {
|
||||||
@ -486,10 +501,7 @@ public class BrushCommands {
|
|||||||
} else {
|
} else {
|
||||||
brush = new ScatterBrush((int) pointsOpt, (int) distanceOpt);
|
brush = new ScatterBrush((int) pointsOpt, (int) distanceOpt);
|
||||||
}
|
}
|
||||||
set(session, context,
|
set(player, session, brush).setSize(radius).setFill(fill);
|
||||||
brush)
|
|
||||||
.setSize(radius)
|
|
||||||
.setFill(fill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -498,7 +510,11 @@ public class BrushCommands {
|
|||||||
desc = "Scatter a schematic on a surface"
|
desc = "Scatter a schematic on a surface"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.populateschematic")
|
@CommandPermissions("worldedit.brush.populateschematic")
|
||||||
public void scatterSchemBrush(Player player, LocalSession session, Mask mask, @Arg(name = "clipboard", desc = "Clipboard uri") String clipboardStr, @Arg(name = "radius", desc = "Expression", def = "30") Expression radius, @Arg(name = "density", desc = "double", def = "50") double density, @Switch(name = 'r', desc = "Apply random rotation") boolean rotate, InjectedValueAccess context) throws WorldEditException {
|
public void scatterSchemBrush(Player player, LocalSession session, Mask mask,
|
||||||
|
@Arg(name = "clipboard", desc = "Clipboard uri") String clipboardStr,
|
||||||
|
@Arg(name = "radius", desc = "Expression", def = "30") Expression radius,
|
||||||
|
@Arg(name = "density", desc = "double", def = "50") double density,
|
||||||
|
@Switch(name = 'r', desc = "Apply random rotation") boolean rotate) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
try {
|
try {
|
||||||
MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true);
|
MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true);
|
||||||
@ -512,8 +528,8 @@ public class BrushCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
set(session, context,
|
set(player, session,
|
||||||
new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius);
|
new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -527,9 +543,10 @@ public class BrushCommands {
|
|||||||
"Pic: https://i.imgur.com/XV0vYoX.png"
|
"Pic: https://i.imgur.com/XV0vYoX.png"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.layer")
|
@CommandPermissions("worldedit.brush.layer")
|
||||||
public void surfaceLayer(LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, List<BlockState> blockLayers, InjectedValueAccess context) throws WorldEditException {
|
public void surfaceLayer(Player player, LocalSession session,
|
||||||
|
@Arg(name = "radius", desc = "Expression") Expression radius, List<BlockState> blockLayers) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius);
|
set(player, session, new LayerBrush(blockLayers.toArray(new BlockState[0]))).setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -541,9 +558,13 @@ public class BrushCommands {
|
|||||||
"Note: The seeds define how many splotches there are, recursion defines how large, solid defines whether the pattern is applied per seed, else per block."
|
"Note: The seeds define how many splotches there are, recursion defines how large, solid defines whether the pattern is applied per seed, else per block."
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.splatter")
|
@CommandPermissions("worldedit.brush.splatter")
|
||||||
public void splatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "1") double pointsOpt, @Arg(name = "recursion", desc = "double", def = "5") double recursion, @Arg(name = "solid", desc = "boolean", def = "true") boolean solid, InjectedValueAccess context) throws WorldEditException {
|
public void splatterBrush(Player player, LocalSession session, Pattern fill,
|
||||||
|
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
|
||||||
|
@Arg(name = "points", desc = "double", def = "1") double pointsOpt,
|
||||||
|
@Arg(name = "recursion", desc = "double", def = "5") double recursion,
|
||||||
|
@Arg(name = "solid", desc = "boolean", def = "true") boolean solid) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context, new SplatterBrush((int) pointsOpt, (int) recursion, solid)).setSize(radius).setFill(fill);
|
set(player, session, new SplatterBrush((int) pointsOpt, (int) recursion, solid)).setSize(radius).setFill(fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -557,10 +578,12 @@ public class BrushCommands {
|
|||||||
" - Placeholders: {x}, {y}, {z}, {world}, {size}"
|
" - Placeholders: {x}, {y}, {z}, {world}, {size}"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.scattercommand")
|
@CommandPermissions("worldedit.brush.scattercommand")
|
||||||
public void scatterCommandBrush(Player player, EditSession editSession, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, double points, double distance, List<String> commandStr, InjectedValueAccess context) throws WorldEditException {
|
public void scatterCommandBrush(Player player, EditSession editSession, LocalSession session,
|
||||||
|
@Arg(name = "radius", desc = "Expression") Expression radius, double points,
|
||||||
|
double distance, List<String> commandStr) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
set(session, context,
|
set(player, session,
|
||||||
new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " ")))
|
new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " ")))
|
||||||
.setSize(radius);
|
.setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,19 +601,17 @@ public class BrushCommands {
|
|||||||
@Arg(desc = "The height of the cylinder", def = "1")
|
@Arg(desc = "The height of the cylinder", def = "1")
|
||||||
int height,
|
int height,
|
||||||
@Switch(name = 'h', desc = "Create hollow cylinders instead")
|
@Switch(name = 'h', desc = "Create hollow cylinders instead")
|
||||||
boolean hollow,
|
boolean hollow) throws WorldEditException {
|
||||||
InjectedValueAccess context) throws WorldEditException {
|
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
worldEdit.checkMaxBrushRadius(height);
|
worldEdit.checkMaxBrushRadius(height);
|
||||||
|
|
||||||
BrushSettings settings;
|
BrushSettings settings;
|
||||||
if (hollow) {
|
if (hollow) {
|
||||||
settings = set(session, context, new HollowCylinderBrush(height));
|
settings = set(player, session, new HollowCylinderBrush(height));
|
||||||
} else {
|
} else {
|
||||||
settings = set(session, context, new CylinderBrush(height));
|
settings = set(player, session, new CylinderBrush(height));
|
||||||
}
|
}
|
||||||
settings.setSize(radius)
|
settings.setSize(radius).setFill(pattern);
|
||||||
.setFill(pattern);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -603,20 +624,20 @@ public class BrushCommands {
|
|||||||
)
|
)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions("worldedit.brush.clipboard")
|
@CommandPermissions("worldedit.brush.clipboard")
|
||||||
public void clipboardBrush(Player player,LocalSession session,
|
public void clipboardBrush(Player player, LocalSession session,
|
||||||
@Switch(name = 'a', desc = "Don't paste air from the clipboard")
|
@Switch(name = 'a', desc = "Don't paste air from the clipboard")
|
||||||
boolean ignoreAir,
|
boolean ignoreAir,
|
||||||
@Switch(name = 'o', desc = "Paste starting at the target location, instead of centering on it")
|
@Switch(name = 'o', desc = "Paste starting at the target location, instead of centering on it")
|
||||||
boolean usingOrigin,
|
boolean usingOrigin,
|
||||||
@Switch(name = 'e', desc = "Skip paste entities if available")
|
@Switch(name = 'e', desc = "Skip paste entities if available")
|
||||||
boolean skipEntities,
|
boolean skipEntities,
|
||||||
@Switch(name = 'b', desc = "Paste biomes if available")
|
@Switch(name = 'b', desc = "Paste biomes if available")
|
||||||
boolean pasteBiomes,
|
boolean pasteBiomes,
|
||||||
@ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard", def = "")
|
@ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard", def = "")
|
||||||
@ClipboardMask
|
@ClipboardMask
|
||||||
Mask sourceMask,
|
Mask sourceMask) throws WorldEditException {
|
||||||
InjectedValueAccess context) throws WorldEditException {
|
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
|
|
||||||
Clipboard clipboard = holder.getClipboard();
|
Clipboard clipboard = holder.getClipboard();
|
||||||
ClipboardHolder newHolder = new ClipboardHolder(clipboard);
|
ClipboardHolder newHolder = new ClipboardHolder(clipboard);
|
||||||
newHolder.setTransform(holder.getTransform());
|
newHolder.setTransform(holder.getTransform());
|
||||||
@ -627,7 +648,8 @@ public class BrushCommands {
|
|||||||
worldEdit.checkMaxBrushRadius(size.getBlockY() / 2D - 1);
|
worldEdit.checkMaxBrushRadius(size.getBlockY() / 2D - 1);
|
||||||
worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1);
|
worldEdit.checkMaxBrushRadius(size.getBlockZ() / 2D - 1);
|
||||||
|
|
||||||
set(session, context, new ClipboardBrush(newHolder, ignoreAir, usingOrigin, !skipEntities, pasteBiomes, sourceMask));
|
set(player, session,
|
||||||
|
new ClipboardBrush(newHolder, ignoreAir, usingOrigin, !skipEntities, pasteBiomes, sourceMask));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -637,19 +659,19 @@ public class BrushCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.smooth")
|
@CommandPermissions("worldedit.brush.smooth")
|
||||||
public void smoothBrush(Player player, LocalSession session, EditSession editSession,
|
public void smoothBrush(Player player, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The radius to sample for softening", def = "2")
|
@Arg(desc = "The radius to sample for softening", def = "2")
|
||||||
Expression radius,
|
Expression radius,
|
||||||
@Arg(desc = "The number of iterations to perform", def = "4")
|
@Arg(desc = "The number of iterations to perform", def = "4")
|
||||||
int iterations,
|
int iterations,
|
||||||
@Arg(desc = "The mask of blocks to use for the heightmap", def = "")
|
@Arg(desc = "The mask of blocks to use for the heightmap", def = "")
|
||||||
Mask maskOpt, InjectedValueAccess context) throws WorldEditException {
|
Mask maskOpt) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
FaweLimit limit = Settings.IMP.getLimit(player);
|
FaweLimit limit = Settings.IMP.getLimit(player);
|
||||||
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
|
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
|
||||||
|
|
||||||
set(session, context,
|
set(player, session,
|
||||||
new SmoothBrush(iterations, maskOpt))
|
new SmoothBrush(iterations, maskOpt))
|
||||||
.setSize(radius);
|
.setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,16 +682,14 @@ public class BrushCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.ex")
|
@CommandPermissions("worldedit.brush.ex")
|
||||||
public void extinguishBrush(Player player, LocalSession session, EditSession editSession,
|
public void extinguishBrush(Player player, LocalSession session, EditSession editSession,
|
||||||
@Arg(desc = "The radius to extinguish", def = "5")
|
@Arg(desc = "The radius to extinguish", def = "5")
|
||||||
Expression radius,
|
Expression radius) throws WorldEditException {
|
||||||
InjectedValueAccess context) throws WorldEditException {
|
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
Pattern fill = BlockTypes.AIR.getDefaultState();
|
set(player, session,
|
||||||
set(session, context,
|
new SphereBrush())
|
||||||
new SphereBrush())
|
|
||||||
.setSize(radius)
|
.setSize(radius)
|
||||||
.setFill(fill)
|
.setFill(BlockTypes.AIR.getDefaultState())
|
||||||
.setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE));
|
.setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,15 +701,12 @@ public class BrushCommands {
|
|||||||
@CommandPermissions("worldedit.brush.gravity")
|
@CommandPermissions("worldedit.brush.gravity")
|
||||||
public void gravityBrush(Player player, LocalSession session,
|
public void gravityBrush(Player player, LocalSession session,
|
||||||
@Arg(desc = "The radius to apply gravity in", def = "5")
|
@Arg(desc = "The radius to apply gravity in", def = "5")
|
||||||
Expression radius,
|
Expression radius,
|
||||||
@Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius")
|
@Switch(name = 'h', desc = "Affect blocks starting at max Y, rather than the target location Y + radius")
|
||||||
boolean fromMaxY,
|
boolean fromMaxY) throws WorldEditException {
|
||||||
InjectedValueAccess context) throws WorldEditException {
|
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
set(session, context,
|
set(player, session, new GravityBrush(fromMaxY)).setSize(radius);
|
||||||
new GravityBrush(fromMaxY))
|
|
||||||
.setSize(radius);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -705,7 +722,7 @@ public class BrushCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.height")
|
@CommandPermissions("worldedit.brush.height")
|
||||||
public void heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name = 'r', desc = "TODO") boolean randomRotate, @Switch(name = 'l', desc = "TODO") boolean layers, @Switch(name = 's', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
|
public void heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min = 0, max = 360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name = 'r', desc = "TODO") boolean randomRotate, @Switch(name = 'l', desc = "TODO") boolean layers, @Switch(name = 's', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
|
||||||
terrainBrush(player, session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
|
terrainBrush(player, session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -730,7 +747,7 @@ public class BrushCommands {
|
|||||||
boolean layers,
|
boolean layers,
|
||||||
@Switch(name = 's', desc = "Disables smoothing")
|
@Switch(name = 's', desc = "Disables smoothing")
|
||||||
boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
|
boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
|
||||||
terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context);
|
terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -746,10 +763,13 @@ public class BrushCommands {
|
|||||||
boolean layers,
|
boolean layers,
|
||||||
@Switch(name = 's', desc = "Disables smoothing")
|
@Switch(name = 's', desc = "Disables smoothing")
|
||||||
boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
|
boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
|
||||||
terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
|
terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void terrainBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, String image, int rotation, double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth, Shape shape, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
|
private void terrainBrush(Player player, LocalSession session,
|
||||||
|
@Arg(name = "radius", desc = "Expression") Expression radius, String image, int rotation,
|
||||||
|
double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth,
|
||||||
|
Shape shape) throws WorldEditException, FileNotFoundException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
InputStream stream = getHeightmapStream(image);
|
InputStream stream = getHeightmapStream(image);
|
||||||
HeightBrush brush;
|
HeightBrush brush;
|
||||||
@ -769,7 +789,7 @@ public class BrushCommands {
|
|||||||
if (randomRotate) {
|
if (randomRotate) {
|
||||||
brush.setRandomRotate(true);
|
brush.setRandomRotate(true);
|
||||||
}
|
}
|
||||||
set(session, context,
|
set(player, session,
|
||||||
brush)
|
brush)
|
||||||
.setSize(radius);
|
.setSize(radius);
|
||||||
}
|
}
|
||||||
@ -794,12 +814,15 @@ public class BrushCommands {
|
|||||||
"Video: https://www.youtube.com/watch?v=RPZIaTbqoZw"
|
"Video: https://www.youtube.com/watch?v=RPZIaTbqoZw"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.copy")
|
@CommandPermissions("worldedit.brush.copy")
|
||||||
public void copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate, InjectedValueAccess context) throws WorldEditException {
|
public void copy(Player player, LocalSession session,
|
||||||
|
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
|
||||||
|
@Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate,
|
||||||
|
@Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
player.print(BBC.BRUSH_COPY.format(radius));
|
player.print(BBC.BRUSH_COPY.format(radius));
|
||||||
|
|
||||||
set(session, context,
|
set(player, session,
|
||||||
new CopyPastaBrush(player, session, randomRotate, autoRotate))
|
new CopyPastaBrush(player, session, randomRotate, autoRotate))
|
||||||
.setSize(radius);
|
.setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -812,11 +835,13 @@ public class BrushCommands {
|
|||||||
" - Placeholders: {x}, {y}, {z}, {world}, {size}"
|
" - Placeholders: {x}, {y}, {z}, {world}, {size}"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.command")
|
@CommandPermissions("worldedit.brush.command")
|
||||||
public void command(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression") Expression radius, @Arg(desc = "Command to run") List<String> input, InjectedValueAccess context) throws WorldEditException {
|
public void command(Player player, LocalSession session,
|
||||||
|
@Arg(name = "radius", desc = "Expression") Expression radius,
|
||||||
|
@Arg(desc = "Command to run") List<String> input) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
String cmd = StringMan.join(input, " ");
|
String cmd = StringMan.join(input, " ");
|
||||||
set(session, context,
|
set(player, session,
|
||||||
new CommandBrush(cmd))
|
new CommandBrush(cmd))
|
||||||
.setSize(radius);
|
.setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -826,25 +851,25 @@ public class BrushCommands {
|
|||||||
desc = "Butcher brush, kills mobs within a radius"
|
desc = "Butcher brush, kills mobs within a radius"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.butcher")
|
@CommandPermissions("worldedit.brush.butcher")
|
||||||
public void butcherBrush(Player player, LocalSession session, InjectedValueAccess context,
|
public void butcherBrush(Player player, LocalSession session,
|
||||||
@Arg(desc = "Radius to kill mobs in", def = "5")
|
@Arg(desc = "Radius to kill mobs in", def = "5")
|
||||||
Expression radius,
|
Expression radius,
|
||||||
@Switch(name = 'p', desc = "Also kill pets")
|
@Switch(name = 'p', desc = "Also kill pets")
|
||||||
boolean killPets,
|
boolean killPets,
|
||||||
@Switch(name = 'n', desc = "Also kill NPCs")
|
@Switch(name = 'n', desc = "Also kill NPCs")
|
||||||
boolean killNpcs,
|
boolean killNpcs,
|
||||||
@Switch(name = 'g', desc = "Also kill golems")
|
@Switch(name = 'g', desc = "Also kill golems")
|
||||||
boolean killGolems,
|
boolean killGolems,
|
||||||
@Switch(name = 'a', desc = "Also kill animals")
|
@Switch(name = 'a', desc = "Also kill animals")
|
||||||
boolean killAnimals,
|
boolean killAnimals,
|
||||||
@Switch(name = 'b', desc = "Also kill ambient mobs")
|
@Switch(name = 'b', desc = "Also kill ambient mobs")
|
||||||
boolean killAmbient,
|
boolean killAmbient,
|
||||||
@Switch(name = 't', desc = "Also kill mobs with name tags")
|
@Switch(name = 't', desc = "Also kill mobs with name tags")
|
||||||
boolean killWithName,
|
boolean killWithName,
|
||||||
@Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)")
|
@Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)")
|
||||||
boolean killFriendly,
|
boolean killFriendly,
|
||||||
@Switch(name = 'r', desc = "Also destroy armor stands")
|
@Switch(name = 'r', desc = "Also destroy armor stands")
|
||||||
boolean killArmorStands) throws WorldEditException {
|
boolean killArmorStands) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
CreatureButcher flags = new CreatureButcher(player);
|
CreatureButcher flags = new CreatureButcher(player);
|
||||||
@ -857,7 +882,7 @@ public class BrushCommands {
|
|||||||
flags.or(CreatureButcher.Flags.TAGGED , killWithName, "worldedit.butcher.tagged");
|
flags.or(CreatureButcher.Flags.TAGGED , killWithName, "worldedit.butcher.tagged");
|
||||||
flags.or(CreatureButcher.Flags.ARMOR_STAND , killArmorStands, "worldedit.butcher.armorstands");
|
flags.or(CreatureButcher.Flags.ARMOR_STAND , killArmorStands, "worldedit.butcher.armorstands");
|
||||||
|
|
||||||
set(session, context, new ButcherBrush(flags)).setSize(radius);
|
set(player, session, new ButcherBrush(flags)).setSize(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BrushSettings process(CommandLocals locals, BrushSettings settings) throws WorldEditException {
|
public BrushSettings process(CommandLocals locals, BrushSettings settings) throws WorldEditException {
|
||||||
@ -873,11 +898,10 @@ public class BrushCommands {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BrushSettings set(LocalSession session, InjectedValueAccess context, Brush brush) throws InvalidToolBindException {
|
public BrushSettings set(Player player, LocalSession session,
|
||||||
Player plr = context.injectedValue(Key.of(Player.class))
|
Brush brush) throws InvalidToolBindException {
|
||||||
.orElseThrow(() -> new IllegalStateException("No player"));
|
|
||||||
BrushSettings bs = new BrushSettings();
|
BrushSettings bs = new BrushSettings();
|
||||||
BrushTool tool = session.getBrushTool(plr, false);
|
BrushTool tool = session.getBrushTool(player, false);
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
BrushSettings currentContext = tool.getContext();
|
BrushSettings currentContext = tool.getContext();
|
||||||
if (currentContext != null) {
|
if (currentContext != null) {
|
||||||
@ -896,14 +920,14 @@ public class BrushCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.forest")
|
@CommandPermissions("worldedit.brush.forest")
|
||||||
public void forest(Player player, LocalSession localSession,
|
public void forest(Player player, LocalSession localSession,
|
||||||
@Arg(desc = "The shape of the region")
|
@Arg(desc = "The shape of the region")
|
||||||
RegionFactory shape,
|
RegionFactory shape,
|
||||||
@Arg(desc = "The size of the brush", def = "5")
|
@Arg(desc = "The size of the brush", def = "5")
|
||||||
Expression radius,
|
Expression radius,
|
||||||
@Arg(desc = "The density of the brush", def = "20")
|
@Arg(desc = "The density of the brush", def = "20")
|
||||||
double density,
|
double density,
|
||||||
@Arg(desc = "The type of tree to use")
|
@Arg(desc = "The type of tree to use")
|
||||||
TreeGenerator.TreeType type) throws WorldEditException, EvaluationException {
|
TreeGenerator.TreeType type) throws WorldEditException, EvaluationException {
|
||||||
setOperationBasedBrush(player, localSession, radius,
|
setOperationBasedBrush(player, localSession, radius,
|
||||||
new Paint(new TreeGeneratorFactory(type), density / 100), shape, "worldedit.brush.forest");
|
new Paint(new TreeGeneratorFactory(type), density / 100), shape, "worldedit.brush.forest");
|
||||||
}
|
}
|
||||||
@ -931,7 +955,7 @@ public class BrushCommands {
|
|||||||
@Arg(desc = "The shape of the region")
|
@Arg(desc = "The shape of the region")
|
||||||
RegionFactory shape,
|
RegionFactory shape,
|
||||||
@Arg(desc = "The size of the brush", def = "5")
|
@Arg(desc = "The size of the brush", def = "5")
|
||||||
Expression radius) throws WorldEditException, EvaluationException {
|
Expression radius) throws WorldEditException, EvaluationException {
|
||||||
setOperationBasedBrush(player, localSession, radius,
|
setOperationBasedBrush(player, localSession, radius,
|
||||||
new Deform("y+=1"), shape, "worldedit.brush.lower");
|
new Deform("y+=1"), shape, "worldedit.brush.lower");
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import org.enginehub.piston.annotation.Command;
|
import org.enginehub.piston.annotation.Command;
|
||||||
@ -93,45 +94,51 @@ public class HistoryCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY);
|
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY);
|
||||||
if (!folder.exists()) {
|
if (folder.exists()) {
|
||||||
return;
|
for (File worldFolder : Objects.requireNonNull(folder.listFiles())) {
|
||||||
}
|
if (worldFolder != null && worldFolder.isDirectory()) {
|
||||||
for (File worldFolder : folder.listFiles()) {
|
String worldName = worldFolder.getName();
|
||||||
if (!worldFolder.isDirectory()) {
|
World world = FaweAPI.getWorld(worldName);
|
||||||
continue;
|
if (world != null) {
|
||||||
}
|
for (File userFolder : worldFolder.listFiles()) {
|
||||||
String worldName = worldFolder.getName();
|
if (!userFolder.isDirectory()) {
|
||||||
World world = FaweAPI.getWorld(worldName);
|
|
||||||
if (world != null) {
|
|
||||||
for (File userFolder : worldFolder.listFiles()) {
|
|
||||||
if (!userFolder.isDirectory()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String userUUID = userFolder.getName();
|
|
||||||
try {
|
|
||||||
UUID uuid = UUID.fromString(userUUID);
|
|
||||||
for (File historyFile : userFolder.listFiles()) {
|
|
||||||
String name = historyFile.getName();
|
|
||||||
if (!name.endsWith(".bd")) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RollbackOptimizedHistory rollback = new RollbackOptimizedHistory(world, uuid, Integer.parseInt(name.substring(0, name.length() - 3)));
|
String userUUID = userFolder.getName();
|
||||||
DiskStorageHistory.DiskStorageSummary summary = rollback.summarize(RegionWrapper.GLOBAL(), false);
|
try {
|
||||||
if (summary != null) {
|
UUID uuid = UUID.fromString(userUUID);
|
||||||
rollback.setDimensions(BlockVector3.at(summary.minX, 0, summary.minZ), BlockVector3.at(summary.maxX, 255, summary.maxZ));
|
for (File historyFile : userFolder.listFiles()) {
|
||||||
rollback.setTime(historyFile.lastModified());
|
String name = historyFile.getName();
|
||||||
RollbackDatabase db = DBHandler.IMP.getDatabase(world);
|
if (!name.endsWith(".bd")) {
|
||||||
db.logEdit(rollback);
|
continue;
|
||||||
player.print("Logging: " + historyFile);
|
}
|
||||||
|
RollbackOptimizedHistory rollback = new RollbackOptimizedHistory(
|
||||||
|
world, uuid,
|
||||||
|
Integer.parseInt(
|
||||||
|
name.substring(0, name.length() - 3)));
|
||||||
|
DiskStorageHistory.DiskStorageSummary summary = rollback
|
||||||
|
.summarize(RegionWrapper.GLOBAL(), false);
|
||||||
|
if (summary != null) {
|
||||||
|
rollback.setDimensions(
|
||||||
|
BlockVector3.at(summary.minX, 0, summary.minZ),
|
||||||
|
BlockVector3
|
||||||
|
.at(summary.maxX, 255, summary.maxZ));
|
||||||
|
rollback.setTime(historyFile.lastModified());
|
||||||
|
RollbackDatabase db = DBHandler.IMP
|
||||||
|
.getDatabase(world);
|
||||||
|
db.logEdit(rollback);
|
||||||
|
player.print("Logging: " + historyFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
player.print("Done import!");
|
||||||
}
|
}
|
||||||
player.print("Done import!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String toParse = user.substring(1);
|
String toParse = user.substring(1);
|
||||||
|
@ -110,6 +110,9 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
|
|||||||
parserContext.setWorld((World) extent);
|
parserContext.setWorld((World) extent);
|
||||||
}
|
}
|
||||||
parserContext.setExtent(new RequestExtent());
|
parserContext.setExtent(new RequestExtent());
|
||||||
|
} else if (session.hasWorldOverride()) {
|
||||||
|
parserContext.setWorld(session.getWorldOverride());
|
||||||
|
parserContext.setExtent(new RequestExtent());
|
||||||
}
|
}
|
||||||
parserContext.setSession(session);
|
parserContext.setSession(session);
|
||||||
parserContext.setRestricted(true);
|
parserContext.setRestricted(true);
|
||||||
|
@ -30,7 +30,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
|
|||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mode that replaces one block.
|
* A mode that replaces one block.
|
||||||
@ -55,7 +55,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
|||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
try {
|
try {
|
||||||
BlockVector3 position = clicked.toVector().toBlockPoint();
|
BlockVector3 position = clicked.toVector().toBlockPoint();
|
||||||
editSession.setBlock(position, pattern.apply(position));
|
editSession.setBlock(position, pattern);
|
||||||
} catch (MaxChangedBlocksException ignored) {
|
} catch (MaxChangedBlocksException ignored) {
|
||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
@ -72,8 +72,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
EditSession editSession = session.createEditSession(player);
|
BaseBlock targetBlock = player.getWorld().getFullBlock(clicked.toVector().toBlockPoint());
|
||||||
BlockState targetBlock = editSession.getBlock(clicked.toVector().toBlockPoint());
|
|
||||||
|
|
||||||
if (targetBlock != null) {
|
if (targetBlock != null) {
|
||||||
pattern = targetBlock;
|
pattern = targetBlock;
|
||||||
|
@ -91,7 +91,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static int MAX_RANGE = 500;
|
protected static int MAX_RANGE = 500;
|
||||||
protected static int DEFAULT_RANGE = 240;
|
|
||||||
protected int range = -1;
|
protected int range = -1;
|
||||||
private VisualMode visualMode = VisualMode.NONE;
|
private VisualMode visualMode = VisualMode.NONE;
|
||||||
private TargetMode targetMode = TargetMode.TARGET_BLOCK_RANGE;
|
private TargetMode targetMode = TargetMode.TARGET_BLOCK_RANGE;
|
||||||
@ -178,7 +177,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
if (targetMode != TargetMode.TARGET_BLOCK_RANGE) {
|
if (targetMode != TargetMode.TARGET_BLOCK_RANGE) {
|
||||||
map.put("target", targetMode);
|
map.put("target", targetMode);
|
||||||
}
|
}
|
||||||
if (range != -1 && range != DEFAULT_RANGE) {
|
if (range != -1 && range != MAX_RANGE) {
|
||||||
map.put("range", range);
|
map.put("range", range);
|
||||||
}
|
}
|
||||||
if (targetOffset != 0) {
|
if (targetOffset != 0) {
|
||||||
@ -312,7 +311,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
* @return the mask used to stop block traces
|
* @return the mask used to stop block traces
|
||||||
*/
|
*/
|
||||||
public @Nullable Mask getTraceMask() {
|
public @Nullable Mask getTraceMask() {
|
||||||
return traceMask;
|
return this.traceMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -409,7 +408,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
* @return the range of the brush in blocks
|
* @return the range of the brush in blocks
|
||||||
*/
|
*/
|
||||||
public int getRange() {
|
public int getRange() {
|
||||||
return (range < 0) ? DEFAULT_RANGE : Math.min(range, MAX_RANGE);
|
return (range < 0) ? MAX_RANGE : Math.min(range, MAX_RANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -418,16 +417,12 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
* @param range the range of the brush in blocks
|
* @param range the range of the brush in blocks
|
||||||
*/
|
*/
|
||||||
public void setRange(int range) {
|
public void setRange(int range) {
|
||||||
if (range == DEFAULT_RANGE) {
|
this.range = range;
|
||||||
this.range = -1;
|
|
||||||
} else {
|
|
||||||
this.range = range;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
return act(BrushAction.PRIMARY, server, config, player, session);
|
return act(BrushAction.PRIMARY, player, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockVector3 getPosition(EditSession editSession, Player player) {
|
public BlockVector3 getPosition(EditSession editSession, Player player) {
|
||||||
@ -481,7 +476,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean act(BrushAction action, Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
public boolean act(BrushAction action, Player player, LocalSession session) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PRIMARY:
|
case PRIMARY:
|
||||||
setContext(primary);
|
setContext(primary);
|
||||||
@ -499,14 +494,14 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try (EditSession editSession = session.createEditSession(player)) {
|
try (EditSession editSession = session.createEditSession(player)) {
|
||||||
BlockVector3 target = getPosition(editSession, player);
|
Location target = player.getBlockTrace(getRange(), true, traceMask);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
editSession.cancel();
|
editSession.cancel();
|
||||||
BBC.NO_BLOCK.send(player);
|
player.print(BBC.NO_BLOCK.s());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
BlockBag bag = editSession.getBlockBag();
|
BlockBag bag = session.getBlockBag(player);
|
||||||
|
|
||||||
Request.request().setEditSession(editSession);
|
Request.request().setEditSession(editSession);
|
||||||
Mask mask = current.getMask();
|
Mask mask = current.getMask();
|
||||||
@ -536,7 +531,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
new PatternTraverser(current).reset(editSession);
|
new PatternTraverser(current).reset(editSession);
|
||||||
double size = current.getSize();
|
double size = current.getSize();
|
||||||
WorldEdit.getInstance().checkMaxBrushRadius(size);
|
WorldEdit.getInstance().checkMaxBrushRadius(size);
|
||||||
brush.build(editSession, target, current.getMaterial(), size);
|
brush.build(editSession, target.toBlockPoint(), current.getMaterial(), size);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
@ -554,7 +549,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
return act(BrushAction.SECONDARY, server, config, player, session);
|
return act(BrushAction.SECONDARY, player, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -627,8 +622,8 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queueVisualization(Player fp) {
|
public void queueVisualization(Player player) {
|
||||||
Fawe.get().getVisualQueue().queue(fp);
|
Fawe.get().getVisualQueue().queue(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -27,42 +27,42 @@ import com.sk89q.worldedit.extension.platform.Platform;
|
|||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
public class NavigationWand implements DoubleActionTraceTool {
|
public class NavigationWand implements DoubleActionTraceTool {
|
||||||
@Override
|
@Override
|
||||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
|
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int maxDist = config.navigationWandMaxDistance;
|
final int maxDist = config.navigationWandMaxDistance;
|
||||||
if (maxDist <= 0) {
|
if (maxDist <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location pos = player.getSolidBlockTrace(maxDist);
|
Location pos = player.getSolidBlockTrace(maxDist);
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
player.findFreePosition(pos);
|
player.findFreePosition(pos);
|
||||||
} else {
|
} else {
|
||||||
player.printError("No block in sight (or too far)!");
|
player.printError("No block in sight (or too far)!");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
|
||||||
if (!player.hasPermission("worldedit.navigation.thru.tool")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final int maxDist = config.navigationWandMaxDistance;
|
|
||||||
if (maxDist <= 0) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.passThroughForwardWall(Math.max(1, maxDist - 10))) {
|
@Override
|
||||||
player.printError("Nothing to pass through (or too far)!");
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
|
||||||
}
|
if (!player.hasPermission("worldedit.navigation.thru.tool")) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
final int maxDist = config.navigationWandMaxDistance;
|
||||||
|
if (maxDist <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
if (!player.passThroughForwardWall(Math.max(1, maxDist - 10))) {
|
||||||
public boolean canUse(Actor actor) {
|
player.printError("Nothing to pass through (or too far)!");
|
||||||
return true; // skip check here - checked separately for primary/secondary
|
}
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUse(Actor actor) {
|
||||||
|
return true; // skip check here - checked separately for primary/secondary
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public class QueryTool implements BlockTool {
|
|||||||
builder.append(TextComponent.of("@" + clicked.toVector().toBlockPoint() + ": ", TextColor.BLUE));
|
builder.append(TextComponent.of("@" + clicked.toVector().toBlockPoint() + ": ", TextColor.BLUE));
|
||||||
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW));
|
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW));
|
||||||
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY)
|
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY)
|
||||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state"))));
|
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state"))));
|
||||||
/*
|
/*
|
||||||
final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
|
final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
|
||||||
if (internalId.isPresent()) {
|
if (internalId.isPresent()) {
|
||||||
@ -64,8 +64,8 @@ public class QueryTool implements BlockTool {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
|
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
|
||||||
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
|
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
|
||||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above"))));
|
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above"))));
|
||||||
|
|
||||||
player.print(builder.build());
|
player.print(builder.build());
|
||||||
|
|
||||||
|
@ -20,11 +20,9 @@
|
|||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.boydti.fawe.object.mask.IdMask;
|
import com.boydti.fawe.object.mask.IdMask;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
@ -37,8 +35,6 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A pickaxe mode that recursively finds adjacent blocks within range of
|
* A pickaxe mode that recursively finds adjacent blocks within range of
|
||||||
* an initial block and of the same type.
|
* an initial block and of the same type.
|
||||||
|
@ -34,8 +34,8 @@ public class SelectionWand implements DoubleActionBlockTool {
|
|||||||
@Override
|
@Override
|
||||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
|
|
||||||
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||||
|
|
||||||
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||||
selector.explainPrimarySelection(player, session, blockPoint);
|
selector.explainPrimarySelection(player, session, blockPoint);
|
||||||
}
|
}
|
||||||
@ -46,6 +46,7 @@ public class SelectionWand implements DoubleActionBlockTool {
|
|||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
|
||||||
|
|
||||||
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
|
||||||
selector.explainSecondarySelection(player, session, blockPoint);
|
selector.explainSecondarySelection(player, session, blockPoint);
|
||||||
}
|
}
|
||||||
|
@ -64,10 +64,10 @@ public class TreePlanter implements BlockTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!successful) {
|
if (!successful) {
|
||||||
BBC.TOOL_TREE_ERROR_BLOCK.send(player);
|
player.printError(BBC.TOOL_TREE_ERROR_BLOCK.s());
|
||||||
}
|
}
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES.send(player);
|
player.printError(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES.s());
|
||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.command.tool.brush;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.util;
|
package com.sk89q.worldedit.command.util;
|
||||||
|
|
||||||
|
import static org.enginehub.piston.converter.SuggestionHelper.byPrefix;
|
||||||
|
import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix;
|
||||||
|
|
||||||
import com.sk89q.worldedit.registry.Keyed;
|
import com.sk89q.worldedit.registry.Keyed;
|
||||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||||
import com.sk89q.worldedit.registry.Registry;
|
import com.sk89q.worldedit.registry.Registry;
|
||||||
@ -26,7 +29,6 @@ import com.sk89q.worldedit.registry.state.Property;
|
|||||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -37,9 +39,6 @@ import java.util.function.Predicate;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.enginehub.piston.converter.SuggestionHelper.byPrefix;
|
|
||||||
import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal class for generating common command suggestions.
|
* Internal class for generating common command suggestions.
|
||||||
*/
|
*/
|
||||||
@ -140,12 +139,12 @@ public final class SuggestionHelper {
|
|||||||
|
|
||||||
public static <V extends Keyed> Stream<String> getRegistrySuggestions(Registry<V> registry, String input) {
|
public static <V extends Keyed> Stream<String> getRegistrySuggestions(Registry<V> registry, String input) {
|
||||||
if (registry instanceof NamespacedRegistry) {
|
if (registry instanceof NamespacedRegistry) {
|
||||||
return getNamespacedRegistrySuggestions(((NamespacedRegistry<?>) registry), input);
|
return getNamespacedRegistrySuggestions(((NamespacedRegistry<V>) registry), input);
|
||||||
}
|
}
|
||||||
return limitByPrefix(registry.keySet().stream(), input).stream();
|
return limitByPrefix(registry.keySet().stream(), input).stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <V extends Keyed> Stream<String> getNamespacedRegistrySuggestions(NamespacedRegistry<?> registry, String input) {
|
public static <V extends Keyed> Stream<String> getNamespacedRegistrySuggestions(NamespacedRegistry<V> registry, String input) {
|
||||||
if (input.isEmpty() || input.equals(":")) {
|
if (input.isEmpty() || input.equals(":")) {
|
||||||
final Set<String> namespaces = registry.getKnownNamespaces();
|
final Set<String> namespaces = registry.getKnownNamespaces();
|
||||||
if (namespaces.size() == 1) {
|
if (namespaces.size() == 1) {
|
||||||
|
@ -60,7 +60,9 @@ import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
|||||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -73,10 +75,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
super(worldEdit);
|
super(worldEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BlockState getBlockInHand(Actor actor, HandSide handSide) throws InputParseException {
|
private static BaseBlock getBlockInHand(Actor actor, HandSide handSide) throws InputParseException {
|
||||||
if (actor instanceof Player) {
|
if (actor instanceof Player) {
|
||||||
try {
|
try {
|
||||||
return ((Player) actor).getBlockInHand(handSide).toImmutableState();
|
return ((Player) actor).getBlockInHand(handSide);
|
||||||
} catch (NotABlockException e) {
|
} catch (NotABlockException e) {
|
||||||
throw new InputParseException("You're not holding a block!");
|
throw new InputParseException("You're not holding a block!");
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
@ -111,6 +113,8 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String[] EMPTY_STRING_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Backwards compatibility for wool colours in block syntax.
|
* Backwards compatibility for wool colours in block syntax.
|
||||||
*
|
*
|
||||||
@ -163,7 +167,9 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException {
|
private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException {
|
||||||
String[] blockAndExtraData = input.trim().split("\\|", 2);
|
BlockType blockType = null;
|
||||||
|
Map<Property<?>, Object> blockStates = new HashMap<>();
|
||||||
|
String[] blockAndExtraData = input.trim().split("\\|");
|
||||||
blockAndExtraData[0] = woolMapper(blockAndExtraData[0]);
|
blockAndExtraData[0] = woolMapper(blockAndExtraData[0]);
|
||||||
|
|
||||||
BlockState state = null;
|
BlockState state = null;
|
||||||
@ -171,8 +177,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
// Legacy matcher
|
// Legacy matcher
|
||||||
if (context.isTryingLegacy()) {
|
if (context.isTryingLegacy()) {
|
||||||
try {
|
try {
|
||||||
String[] split = blockAndExtraData[0].split(":");
|
String[] split = blockAndExtraData[0].split(":", 2);
|
||||||
if (split.length == 1) {
|
if (split.length == 0) {
|
||||||
|
throw new InputParseException("Invalid colon.");
|
||||||
|
} else if (split.length == 1) {
|
||||||
state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]));
|
state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]));
|
||||||
} else if (MathMan.isInteger(split[0])) {
|
} else if (MathMan.isInteger(split[0])) {
|
||||||
int id = Integer.parseInt(split[0]);
|
int id = Integer.parseInt(split[0]);
|
||||||
@ -191,7 +199,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
state = LegacyMapper.getInstance().getBlockFromLegacy(type.getLegacyCombinedId() >> 4, data);
|
state = LegacyMapper.getInstance().getBlockFromLegacy(type.getLegacyCombinedId() >> 4, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,58 +212,83 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
typeString = blockAndExtraData[0];
|
typeString = blockAndExtraData[0];
|
||||||
} else {
|
} else {
|
||||||
typeString = blockAndExtraData[0].substring(0, stateStart);
|
typeString = blockAndExtraData[0].substring(0, stateStart);
|
||||||
|
if (stateStart + 1 >= blockAndExtraData[0].length()) {
|
||||||
|
throw new InputParseException("Invalid format. Hanging bracket @ " + stateStart + ".");
|
||||||
|
}
|
||||||
|
int stateEnd = blockAndExtraData[0].lastIndexOf(']');
|
||||||
|
if (stateEnd < 0) {
|
||||||
|
throw new InputParseException("Invalid format. Unclosed property.");
|
||||||
|
}
|
||||||
stateString = blockAndExtraData[0].substring(stateStart + 1, blockAndExtraData[0].length() - 1);
|
stateString = blockAndExtraData[0].substring(stateStart + 1, blockAndExtraData[0].length() - 1);
|
||||||
}
|
}
|
||||||
if (typeString.isEmpty()) {
|
if (typeString.isEmpty()) {
|
||||||
throw new InputParseException("Invalid format");
|
throw new InputParseException("Invalid format");
|
||||||
}
|
}
|
||||||
// PosX
|
String[] stateProperties = EMPTY_STRING_ARRAY;
|
||||||
if (typeString.matches("pos[0-9]+")) {
|
if (stateString != null) {
|
||||||
|
stateProperties = stateString.split(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("hand".equalsIgnoreCase(typeString)) {
|
||||||
|
// Get the block type from the item in the user's hand.
|
||||||
|
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
|
||||||
|
if (blockInHand.getClass() != BaseBlock.class) {
|
||||||
|
return blockInHand;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockType = blockInHand.getBlockType();
|
||||||
|
blockStates.putAll(blockInHand.getStates());
|
||||||
|
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
||||||
|
// Get the block type from the item in the user's off hand.
|
||||||
|
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
|
||||||
|
if (blockInHand.getClass() != BaseBlock.class) {
|
||||||
|
return blockInHand;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockType = blockInHand.getBlockType();
|
||||||
|
blockStates.putAll(blockInHand.getStates());
|
||||||
|
} else if (typeString.matches("pos[0-9]+")) {
|
||||||
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
|
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
|
||||||
// Get the block type from the "primary position"
|
// Get the block type from the "primary position"
|
||||||
final World world = context.requireWorld();
|
final World world = context.requireWorld();
|
||||||
final BlockVector3 primaryPosition;
|
final BlockVector3 primaryPosition;
|
||||||
try {
|
try {
|
||||||
primaryPosition = context.requireSession().getRegionSelector(world).getVertices().get(index - 1);
|
primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
|
||||||
} catch (IncompleteRegionException e) {
|
} catch (IncompleteRegionException e) {
|
||||||
throw new InputParseException("Your selection is not complete.");
|
throw new InputParseException("Your selection is not complete.");
|
||||||
}
|
}
|
||||||
state = world.getBlock(primaryPosition);
|
final BlockState blockInHand = world.getBlock(primaryPosition);
|
||||||
|
|
||||||
|
blockType = blockInHand.getBlockType();
|
||||||
|
blockStates.putAll(blockInHand.getStates());
|
||||||
|
} else if (typeString.matches("slot[0-9]+")) {
|
||||||
|
int slot = Integer.parseInt(typeString.substring(4)) - 1;
|
||||||
|
Actor actor = context.requireActor();
|
||||||
|
if (!(actor instanceof Player)) {
|
||||||
|
throw new InputParseException("The user is not a player!");
|
||||||
|
}
|
||||||
|
Player player = (Player) actor;
|
||||||
|
BlockBag bag = player.getInventoryBlockBag();
|
||||||
|
if (true) {
|
||||||
|
throw new InputParseException("Unsupported!");
|
||||||
|
}
|
||||||
|
SlottableBlockBag slottable = (SlottableBlockBag) bag;
|
||||||
|
BaseItem item = slottable.getItem(slot);
|
||||||
|
|
||||||
|
if (!item.getType().hasBlockType()) {
|
||||||
|
throw new InputParseException("You're not holding a block!");
|
||||||
|
}
|
||||||
|
state = item.getType().getBlockType().getDefaultState();
|
||||||
|
nbt = item.getNbtData();
|
||||||
} else {
|
} else {
|
||||||
if ("hand".equalsIgnoreCase(typeString)) {
|
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT));
|
||||||
// Get the block type from the item in the user's hand.
|
|
||||||
state = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
|
|
||||||
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
|
||||||
// Get the block type from the item in the user's off hand.
|
|
||||||
state = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
|
|
||||||
} else if (typeString.matches("slot[0-9]+")) {
|
|
||||||
int slot = Integer.parseInt(typeString.substring(4)) - 1;
|
|
||||||
Actor actor = context.requireActor();
|
|
||||||
if (!(actor instanceof Player)) {
|
|
||||||
throw new InputParseException("The user is not a player!");
|
|
||||||
}
|
|
||||||
Player player = (Player) actor;
|
|
||||||
BlockBag bag = player.getInventoryBlockBag();
|
|
||||||
if (bag == null || !(bag instanceof SlottableBlockBag)) {
|
|
||||||
throw new InputParseException("Unsupported!");
|
|
||||||
}
|
|
||||||
SlottableBlockBag slottable = (SlottableBlockBag) bag;
|
|
||||||
BaseItem item = slottable.getItem(slot);
|
|
||||||
|
|
||||||
if (!item.getType().hasBlockType()) {
|
if (type != null) {
|
||||||
throw new InputParseException("You're not holding a block!");
|
state = type.getDefaultState();
|
||||||
}
|
}
|
||||||
state = item.getType().getBlockType().getDefaultState();
|
if (state == null) {
|
||||||
nbt = item.getNbtData();
|
throw new NoMatchException(
|
||||||
} else {
|
"Does not match a valid block type: '" + input + "'");
|
||||||
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT));
|
|
||||||
|
|
||||||
if (type != null) {
|
|
||||||
state = type.getDefaultState();
|
|
||||||
}
|
|
||||||
if (state == null) {
|
|
||||||
throw new NoMatchException("Does not match a valid block type: '" + input + "'");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nbt == null) nbt = state.getNbtData();
|
if (nbt == null) nbt = state.getNbtData();
|
||||||
|
@ -26,7 +26,6 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
|||||||
import com.sk89q.worldedit.function.mask.BlockCategoryMask;
|
import com.sk89q.worldedit.function.mask.BlockCategoryMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
import com.sk89q.worldedit.session.request.RequestExtent;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -26,7 +26,6 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
|||||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
import com.sk89q.worldedit.session.request.RequestExtent;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -24,8 +24,6 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
@ -52,16 +50,12 @@ public interface OutputExtent {
|
|||||||
* @param block block to set
|
* @param block block to set
|
||||||
* @return true if the block was successfully set (return value may not be accurate)
|
* @return true if the block was successfully set (return value may not be accurate)
|
||||||
* @throws WorldEditException thrown on an error
|
* @throws WorldEditException thrown on an error
|
||||||
* @deprecated Use {@link #setBlock(int, int, int, BlockStateHolder)}
|
* @deprecated It is recommended that you use {@link #setBlock(int, int, int, BlockStateHolder)} in FAWE
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
<T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException;
|
||||||
return setBlock(position.getX(), position.getY(), position.getZ(), block);
|
|
||||||
}
|
|
||||||
|
|
||||||
default <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
<T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException;
|
||||||
return setBlock(MutableBlockVector3.get(x, y, z), block);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException;
|
boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException;
|
||||||
|
|
||||||
@ -72,13 +66,9 @@ public interface OutputExtent {
|
|||||||
* @param biome the biome to set to
|
* @param biome the biome to set to
|
||||||
* @return true if the biome was successfully set (return value may not be accurate)
|
* @return true if the biome was successfully set (return value may not be accurate)
|
||||||
*/
|
*/
|
||||||
default boolean setBiome(BlockVector2 position, BiomeType biome) {
|
boolean setBiome(BlockVector2 position, BiomeType biome);
|
||||||
return setBiome(position.getX(), 0, position.getBlockZ(), biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
default boolean setBiome(int x, int y, int z, BiomeType biome) {
|
boolean setBiome(int x, int y, int z, BiomeType biome);
|
||||||
return setBiome(MutableBlockVector2.get(x, z), biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an {@link Operation} that should be called to tie up loose ends
|
* Return an {@link Operation} that should be called to tie up loose ends
|
||||||
|
@ -175,6 +175,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
|
|||||||
return getExtent().getBlockDistributionWithData(region);
|
return getExtent().getBlockDistributionWithData(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Operation commit() {
|
public Operation commit() {
|
||||||
return getExtent().commit();
|
return getExtent().commit();
|
||||||
@ -271,6 +272,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
|
|||||||
return getExtent().setBlock(position, block);
|
return getExtent().setBlock(position, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
return getExtent().setBlock(x, y, z, block);
|
return getExtent().setBlock(x, y, z, block);
|
||||||
}
|
}
|
||||||
@ -285,6 +287,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
|
|||||||
return getExtent().setBiome(position, biome);
|
return getExtent().setBiome(position, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
return getExtent().setBiome(x, y, z, biome);
|
return getExtent().setBiome(x, y, z, biome);
|
||||||
}
|
}
|
||||||
|
@ -25,16 +25,20 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
|
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||||
import com.sk89q.worldedit.function.mask.Masks;
|
import com.sk89q.worldedit.function.mask.Masks;
|
||||||
|
import com.sk89q.worldedit.function.pattern.BiomePattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -46,12 +50,16 @@ import java.util.Map;
|
|||||||
* <p>This buffer will not attempt to return results from the buffer when
|
* <p>This buffer will not attempt to return results from the buffer when
|
||||||
* accessor methods (such as {@link #getBlock(BlockVector3)}) are called.</p>
|
* accessor methods (such as {@link #getBlock(BlockVector3)}) are called.</p>
|
||||||
*/
|
*/
|
||||||
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern {
|
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern, BiomePattern {
|
||||||
|
|
||||||
private final Map<BlockVector3, BaseBlock> buffer = new LinkedHashMap<>();
|
private final Map<BlockVector3, BaseBlock> buffer = new LinkedHashMap<>();
|
||||||
|
private final Map<BlockVector2, BiomeType> biomeBuffer = new LinkedHashMap<>();
|
||||||
private final Mask mask;
|
private final Mask mask;
|
||||||
|
private final Mask2D biomeMask;
|
||||||
private BlockVector3 min = null;
|
private BlockVector3 min = null;
|
||||||
|
private BlockVector2 min2d = null;
|
||||||
private BlockVector3 max = null;
|
private BlockVector3 max = null;
|
||||||
|
private BlockVector2 max2d = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new extent buffer that will buffer every change.
|
* Create a new extent buffer that will buffer every change.
|
||||||
@ -79,6 +87,8 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
checkNotNull(delegate);
|
checkNotNull(delegate);
|
||||||
checkNotNull(mask);
|
checkNotNull(mask);
|
||||||
this.mask = mask;
|
this.mask = mask;
|
||||||
|
Mask2D bmask = mask.toMask2D();
|
||||||
|
this.biomeMask = bmask == null ? Masks.alwaysTrue2D() : bmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,6 +115,54 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||||
|
// Update minimum
|
||||||
|
if (min2d == null) {
|
||||||
|
min2d = position;
|
||||||
|
} else {
|
||||||
|
min2d = min2d.getMinimum(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update maximum
|
||||||
|
if (max2d == null) {
|
||||||
|
max2d = position;
|
||||||
|
} else {
|
||||||
|
max2d = max2d.getMaximum(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (biomeMask.test(position)) {
|
||||||
|
biomeBuffer.put(position, biome);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return getExtent().setBiome(position, biome);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
// Update minimum
|
||||||
|
if (min2d == null) {
|
||||||
|
min2d = BlockVector2.at(x, z);
|
||||||
|
} else {
|
||||||
|
min2d = min2d.getMinimum(BlockVector2.at(x,z));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update maximum
|
||||||
|
if (max2d == null) {
|
||||||
|
max2d = BlockVector2.at(x,z);
|
||||||
|
} else {
|
||||||
|
max2d = max2d.getMaximum(BlockVector2.at(x,z));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (biomeMask.test(BlockVector2.at(x,z))) {
|
||||||
|
biomeBuffer.put(BlockVector2.at(x,z), biome);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return getExtent().setBiome(x, y, z, biome);
|
||||||
|
} }
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock apply(BlockVector3 pos) {
|
public BaseBlock apply(BlockVector3 pos) {
|
||||||
BaseBlock block = buffer.get(pos);
|
BaseBlock block = buffer.get(pos);
|
||||||
@ -115,6 +173,16 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeType apply(BlockVector2 pos) {
|
||||||
|
BiomeType biome = biomeBuffer.get(pos);
|
||||||
|
if (biome != null) {
|
||||||
|
return biome;
|
||||||
|
} else {
|
||||||
|
return BiomeTypes.OCEAN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a region representation of this buffer.
|
* Return a region representation of this buffer.
|
||||||
*
|
*
|
||||||
@ -151,6 +219,10 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
|
|||||||
public Iterator<BlockVector3> iterator() {
|
public Iterator<BlockVector3> iterator() {
|
||||||
return buffer.keySet().iterator();
|
return buffer.keySet().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Iterable<BlockVector2> asFlatRegion() {
|
||||||
|
return biomeBuffer.keySet();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,6 +216,7 @@ public class BlockArrayClipboard implements Clipboard, Closeable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||||
x -= mx;
|
x -= mx;
|
||||||
y -= my;
|
y -= my;
|
||||||
|
@ -19,10 +19,27 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.transform;
|
package com.sk89q.worldedit.extent.transform;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.ASCENDING_EAST;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.ASCENDING_NORTH;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.ASCENDING_SOUTH;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.ASCENDING_WEST;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.DOWN;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.EAST;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.Flag;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.NORTH;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.NORTHEAST;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.NORTHWEST;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.SOUTH;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.SOUTHEAST;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.SOUTHWEST;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.UP;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.WEST;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.findClosest;
|
||||||
|
import static com.sk89q.worldedit.util.Direction.values;
|
||||||
|
|
||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import com.sk89q.jnbt.ByteTag;
|
import com.sk89q.jnbt.ByteTag;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
@ -38,21 +55,19 @@ import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
|||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import static com.sk89q.worldedit.util.Direction.*;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms blocks themselves (but not their position) according to a
|
* Transforms blocks themselves (but not their position) according to a
|
||||||
@ -87,11 +102,8 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
|
|
||||||
|
|
||||||
private static long combine(Direction... directions) {
|
private static long combine(Direction... directions) {
|
||||||
long mask = 0;
|
return Arrays.stream(directions).mapToLong(dir -> (1L << dir.ordinal()))
|
||||||
for (Direction dir : directions) {
|
.reduce(0, (a, b) -> a | b);
|
||||||
mask = mask | (1L << dir.ordinal());
|
|
||||||
}
|
|
||||||
return mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] adapt(Direction... dirs) {
|
private static long[] adapt(Direction... dirs) {
|
||||||
@ -497,7 +509,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
return super.setBlock(x, y, z, transformInverse(block));
|
return super.setBlock(x, y, z, transformInverse(block));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes several region functions in order.
|
* Executes several region functions in order.
|
||||||
@ -49,7 +47,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
|||||||
*/
|
*/
|
||||||
public CombinedRegionFunction(Collection<RegionFunction> functions) {
|
public CombinedRegionFunction(Collection<RegionFunction> functions) {
|
||||||
checkNotNull(functions);
|
checkNotNull(functions);
|
||||||
this.functions = functions.toArray(new RegionFunction[functions.size()]);
|
this.functions = functions.toArray(new RegionFunction[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,7 +82,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
|||||||
checkNotNull(functions);
|
checkNotNull(functions);
|
||||||
ArrayList<RegionFunction> functionsList = new ArrayList<>(Arrays.asList(this.functions));
|
ArrayList<RegionFunction> functionsList = new ArrayList<>(Arrays.asList(this.functions));
|
||||||
functionsList.addAll(functions);
|
functionsList.addAll(functions);
|
||||||
this.functions = functionsList.toArray(new RegionFunction[functionsList.size()]);
|
this.functions = functionsList.toArray(new RegionFunction[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,4 +103,4 @@ public class CombinedRegionFunction implements RegionFunction {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,4 +35,5 @@ public interface RegionFunction {
|
|||||||
* @throws WorldEditException thrown on an error
|
* @throws WorldEditException thrown on an error
|
||||||
*/
|
*/
|
||||||
boolean apply(BlockVector3 position) throws WorldEditException;
|
boolean apply(BlockVector3 position) throws WorldEditException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||||
|
import com.sk89q.worldedit.function.pattern.BiomePattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
public class BiomeReplace implements FlatRegionFunction {
|
public class BiomeReplace implements FlatRegionFunction {
|
||||||
|
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
private BiomeType biome;
|
private BiomePattern biome;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
@ -42,15 +43,25 @@ public class BiomeReplace implements FlatRegionFunction {
|
|||||||
* @param biome a biome
|
* @param biome a biome
|
||||||
*/
|
*/
|
||||||
public BiomeReplace(Extent extent, BiomeType biome) {
|
public BiomeReplace(Extent extent, BiomeType biome) {
|
||||||
|
this(extent, (BiomePattern) biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance.
|
||||||
|
*
|
||||||
|
* @param extent the extent to apply this function to
|
||||||
|
* @param pattern the biome pattern to set
|
||||||
|
*/
|
||||||
|
public BiomeReplace(Extent extent, BiomePattern pattern) {
|
||||||
checkNotNull(extent);
|
checkNotNull(extent);
|
||||||
checkNotNull(biome);
|
checkNotNull(pattern);
|
||||||
this.extent = extent;
|
this.extent = extent;
|
||||||
this.biome = biome;
|
this.biome = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(BlockVector2 position) throws WorldEditException {
|
public boolean apply(BlockVector2 position) throws WorldEditException {
|
||||||
return extent.setBiome(position, biome);
|
return extent.setBiome(position, biome.apply(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class BlockReplace implements RegionFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
return pattern.apply(extent, position, position);
|
return extent.setBlock(position, pattern.apply(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,14 @@ public class Naturalizer implements LayerFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean naturalize(BlockVector3 position, int depth) throws WorldEditException {
|
private boolean naturalize(BlockVector3 position, int depth) throws WorldEditException {
|
||||||
return editSession.setBlock(position, getTargetBlock(depth));
|
BlockState block = editSession.getBlock(position);
|
||||||
|
BlockState targetBlock = getTargetBlock(depth);
|
||||||
|
|
||||||
|
if (block.equalsFuzzy(targetBlock)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return editSession.setBlock(position, targetBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,10 +157,10 @@ public class ExtentEntityCopy implements EntityFunction {
|
|||||||
BlockVector3 newLeash = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint();
|
BlockVector3 newLeash = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint();
|
||||||
return new BaseEntity(state.getType(), tag.createBuilder()
|
return new BaseEntity(state.getType(), tag.createBuilder()
|
||||||
.put("Leash", leashCompound.createBuilder()
|
.put("Leash", leashCompound.createBuilder()
|
||||||
.putInt("X", newLeash.getBlockX())
|
.putInt("X", newLeash.getBlockX())
|
||||||
.putInt("Y", newLeash.getBlockY())
|
.putInt("Y", newLeash.getBlockY())
|
||||||
.putInt("Z", newLeash.getBlockZ())
|
.putInt("Z", newLeash.getBlockZ())
|
||||||
.build()
|
.build()
|
||||||
).build());
|
).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class ForestGenerator implements RegionFunction {
|
|||||||
BlockState block = editSession.getBlock(position);
|
BlockState block = editSession.getBlock(position);
|
||||||
BlockType t = block.getBlockType();
|
BlockType t = block.getBlockType();
|
||||||
|
|
||||||
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
|
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT || t == BlockTypes.PODZOL || t == BlockTypes.COARSE_DIRT) {
|
||||||
return treeType.generate(editSession, position.add(0, 1, 0));
|
return treeType.generate(editSession, position.add(0, 1, 0));
|
||||||
} else if (t.getMaterial().isReplacedDuringPlacement()) {
|
} else if (t.getMaterial().isReplacedDuringPlacement()) {
|
||||||
// since the implementation's tree generators generally don't generate in non-air spots,
|
// since the implementation's tree generators generally don't generate in non-air spots,
|
||||||
|
@ -69,6 +69,7 @@ public class BlockMask extends ABlockMask {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
||||||
this(extent);
|
this(extent);
|
||||||
|
checkNotNull(blocks);
|
||||||
add(blocks);
|
add(blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,9 +150,8 @@ public class BlockMask extends ABlockMask {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void add(Collection<BaseBlock> blocks) {
|
public void add(Collection<BaseBlock> blocks) {
|
||||||
for (BaseBlock block : blocks) {
|
checkNotNull(blocks);
|
||||||
add(block.toBlockState());
|
blocks.forEach(baseBlock -> add(baseBlock.toBlockState()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -235,7 +235,7 @@ public class BlockMask extends ABlockMask {
|
|||||||
setType = type;
|
setType = type;
|
||||||
setStates += all.size();
|
setStates += all.size();
|
||||||
setState = type.getDefaultState();
|
setState = type.getDefaultState();
|
||||||
} else if (hasAny) {
|
} else {
|
||||||
for (BlockState state : all) {
|
for (BlockState state : all) {
|
||||||
if (test(state)) {
|
if (test(state)) {
|
||||||
setStates++;
|
setStates++;
|
||||||
@ -244,8 +244,6 @@ public class BlockMask extends ABlockMask {
|
|||||||
unsetState = state;
|
unsetState = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
unsetType = type;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,11 +267,7 @@ public class BlockMask extends ABlockMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (setTypes == totalTypes - 1) {
|
if (setTypes == totalTypes - 1) {
|
||||||
if (unsetType != null) {
|
throw new IllegalArgumentException("unsetType cannot be null when passed to InverseSingleBlockTypeMask");
|
||||||
return new InverseSingleBlockTypeMask(getExtent(), unsetType);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("unsetType cannot be null when passed to InverseSingleBlockTypeMask");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -55,4 +55,5 @@ public class BoundedHeightMask extends AbstractMask {
|
|||||||
public Mask2D toMask2D() {
|
public Mask2D toMask2D() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return !vector.getBlock(getExtent()).getMaterial().isAir();
|
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -38,17 +38,6 @@ public interface Mask {
|
|||||||
*/
|
*/
|
||||||
boolean test(BlockVector3 vector);
|
boolean test(BlockVector3 vector);
|
||||||
|
|
||||||
default Filter toFilter(Runnable run) {
|
|
||||||
return new Filter() {
|
|
||||||
@Override
|
|
||||||
public void applyBlock(FilterBlock block) {
|
|
||||||
if (test(block)) {
|
|
||||||
run.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
default <T extends Filter> DelegateFilter<T> toFilter(T filter) {
|
default <T extends Filter> DelegateFilter<T> toFilter(T filter) {
|
||||||
return new DelegateFilter<T>(filter) {
|
return new DelegateFilter<T>(filter) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -37,7 +37,6 @@ import java.util.Set;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combines several masks and requires that all masks return true
|
* Combines several masks and requires that all masks return true
|
||||||
* when a certain position is tested. It serves as a logical AND operation
|
* when a certain position is tested. It serves as a logical AND operation
|
||||||
@ -223,6 +222,10 @@ public class MaskIntersection extends AbstractMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
|
if (masksArray.length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (Mask mask : masksArray) {
|
for (Mask mask : masksArray) {
|
||||||
if (!mask.test(vector)) {
|
if (!mask.test(vector)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.FilterBlock;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
@ -32,8 +31,8 @@ import javax.annotation.Nullable;
|
|||||||
*/
|
*/
|
||||||
public final class Masks {
|
public final class Masks {
|
||||||
|
|
||||||
protected static final AlwaysTrue ALWAYS_TRUE = new AlwaysTrue();
|
static final AlwaysTrue ALWAYS_TRUE = new AlwaysTrue();
|
||||||
protected static final AlwaysFalse ALWAYS_FALSE = new AlwaysFalse();
|
static final AlwaysFalse ALWAYS_FALSE = new AlwaysFalse();
|
||||||
|
|
||||||
private Masks() {
|
private Masks() {
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.FilterBlock;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -70,4 +70,5 @@ public class RegionMask extends AbstractMask {
|
|||||||
public Mask2D toMask2D() {
|
public Mask2D toMask2D() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,16 +66,15 @@ public class ChangeSetExecutor implements Operation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation resume(RunContext run) throws WorldEditException {
|
public Operation resume(RunContext run) throws WorldEditException {
|
||||||
Change change = iterator.next();
|
while (iterator.hasNext()) {
|
||||||
if (type == Type.UNDO) {
|
Change change = iterator.next();
|
||||||
while (iterator.hasNext()) {
|
if (type == Type.UNDO) {
|
||||||
change.undo(context);
|
change.undo(context);
|
||||||
}
|
} else {
|
||||||
} else {
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
change.redo(context);
|
change.redo(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.function.pattern;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link BiomeType} for a given position.
|
||||||
|
*/
|
||||||
|
public interface BiomePattern {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a {@link BiomeType} for the given position.
|
||||||
|
*
|
||||||
|
* @param position the position
|
||||||
|
* @return a block
|
||||||
|
*/
|
||||||
|
BiomeType apply(BlockVector2 position);
|
||||||
|
}
|
@ -67,4 +67,5 @@ public class BlockPattern extends AbstractPattern {
|
|||||||
public BaseBlock apply(BlockVector3 position) {
|
public BaseBlock apply(BlockVector3 position) {
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.pattern;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -64,9 +65,10 @@ public class WaterloggedRemover extends AbstractExtentPattern {
|
|||||||
@Override
|
@Override
|
||||||
public BaseBlock apply(BlockVector3 position) {
|
public BaseBlock apply(BlockVector3 position) {
|
||||||
BaseBlock block = getExtent().getFullBlock(position);
|
BaseBlock block = getExtent().getFullBlock(position);
|
||||||
BlockState newState = remap[block.getOrdinal()];
|
@SuppressWarnings("unchecked")
|
||||||
if (newState != null) {
|
Property<Object> prop = (Property<Object>) remap[block.getOrdinal()].getBlockType().getPropertyMap().getOrDefault("waterlogged", null);
|
||||||
return newState.toBaseBlock(block.getNbtData());
|
if (prop != null) {
|
||||||
|
return block.with(prop, false);
|
||||||
}
|
}
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,9 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final RegionFunction function;
|
private final RegionFunction function;
|
||||||
|
private BlockVectorSet queue = new BlockVectorSet();
|
||||||
|
private BlockVectorSet visited = new BlockVectorSet();
|
||||||
private BlockVector3[] directions;
|
private BlockVector3[] directions;
|
||||||
private BlockVectorSet visited;
|
|
||||||
private BlockVectorSet queue;
|
|
||||||
private int affected = 0;
|
private int affected = 0;
|
||||||
private int currentDepth = 0;
|
private int currentDepth = 0;
|
||||||
private final int maxDepth;
|
private final int maxDepth;
|
||||||
@ -98,8 +98,6 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
|
|
||||||
public BreadthFirstSearch(RegionFunction function, int maxDepth) {
|
public BreadthFirstSearch(RegionFunction function, int maxDepth) {
|
||||||
checkNotNull(function);
|
checkNotNull(function);
|
||||||
this.queue = new BlockVectorSet();
|
|
||||||
this.visited = new BlockVectorSet();
|
|
||||||
this.function = function;
|
this.function = function;
|
||||||
this.directions = DEFAULT_DIRECTIONS;
|
this.directions = DEFAULT_DIRECTIONS;
|
||||||
this.maxDepth = maxDepth;
|
this.maxDepth = maxDepth;
|
||||||
@ -121,6 +119,8 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
* unit vectors. An example of a valid direction is
|
* unit vectors. An example of a valid direction is
|
||||||
* {@code BlockVector3.at(1, 0, 1)}.</p>
|
* {@code BlockVector3.at(1, 0, 1)}.</p>
|
||||||
*
|
*
|
||||||
|
* <p>The list of directions can be cleared.</p>
|
||||||
|
*
|
||||||
* @return the list of directions
|
* @return the list of directions
|
||||||
*/
|
*/
|
||||||
public Collection<BlockVector3> getDirections() {
|
public Collection<BlockVector3> getDirections() {
|
||||||
@ -260,6 +260,7 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
tmp.clear();
|
tmp.clear();
|
||||||
tempQueue = tmp;
|
tempQueue = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ public class FlatRegionVisitor implements Operation {
|
|||||||
affected++;
|
affected++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,14 +20,12 @@
|
|||||||
package com.sk89q.worldedit.function.visitor;
|
package com.sk89q.worldedit.function.visitor;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.RunContext;
|
import com.sk89q.worldedit.function.operation.RunContext;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,17 +40,12 @@ public class RegionVisitor implements Operation {
|
|||||||
public int affected = 0;
|
public int affected = 0;
|
||||||
public final Iterable<? extends BlockVector3> iterable;
|
public final Iterable<? extends BlockVector3> iterable;
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated in favor of the other constructors which will preload chunks during iteration
|
@Deprecated
|
||||||
*
|
|
||||||
* @param region
|
|
||||||
* @param function
|
|
||||||
*/
|
|
||||||
public RegionVisitor(Region region, RegionFunction function) {
|
public RegionVisitor(Region region, RegionFunction function) {
|
||||||
this((Iterable<BlockVector3>) region, function);
|
this((Iterable<BlockVector3>) region, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public RegionVisitor(Iterable<BlockVector3> iterable, RegionFunction function) {
|
public RegionVisitor(Iterable<BlockVector3> iterable, RegionFunction function) {
|
||||||
this.region = iterable instanceof Region ? (Region) iterable : null;
|
this.region = iterable instanceof Region ? (Region) iterable : null;
|
||||||
this.function = function;
|
this.function = function;
|
||||||
@ -75,6 +68,7 @@ public class RegionVisitor implements Operation {
|
|||||||
affected++;
|
affected++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user