A tribute to Jesse
Dieser Commit ist enthalten in:
MattBDev 2019-09-20 21:52:35 -04:00
Ursprung 68c8fca672
Commit 8b96cdc9a5
121 geänderte Dateien mit 1196 neuen und 1130 gelöschten Zeilen

Datei anzeigen

@ -21,7 +21,8 @@ fun Project.applyCommonConfiguration() {
}
configurations.all {
resolutionStrategy {
cacheChangingModulesFor(5, "minutes")
cacheChangingModulesFor(10, "minutes")
}
}
}

Datei anzeigen

@ -33,6 +33,7 @@ fun Project.applyLibrariesConfiguration() {
exclude(dependency("com.google.guava:guava"))
exclude(dependency("com.google.code.gson:gson"))
exclude(dependency("org.checkerframework:checker-qual"))
exclude(dependency("org.slf4j:slf4j-api"))
}
relocate("net.kyori.text", "com.sk89q.worldedit.util.formatting.text")

Datei anzeigen

@ -42,6 +42,7 @@
<allow pkg="org.mozilla.javascript"/>
<allow pkg="de.schlichtherle"/>
<allow pkg="com.google.auto"/>
<allow pkg="it.unimi.dsi.fastutil"/>
<subpackage name="bukkit">
<allow pkg="org.bukkit"/>

Datei anzeigen

@ -40,9 +40,7 @@ dependencies {
"implementation"("io.papermc:paperlib:1.0.2")
"compileOnly"("com.sk89q:dummypermscompat:1.10")
"implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
"testCompile"("org.mockito:mockito-core:1.9.0-rc1") {
exclude("junit", "junit")
}
"testCompile"("org.mockito:mockito-core:1.9.0-rc1")
"compileOnly"("com.sk89q.worldguard:worldguard-bukkit:7.0.0") {
exclude("com.sk89q.worldedit", "worldedit-bukkit")
exclude("com.sk89q.worldedit", "worldedit-core")
@ -61,6 +59,9 @@ dependencies {
"implementation"("com.thevoxelbox.voxelsniper:voxelsniper:5.171.0") { isTransitive = false }
"implementation"("com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT") { 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") {

Datei anzeigen

@ -20,6 +20,7 @@ import com.boydti.fawe.bukkit.regions.ResidenceFeature;
import com.boydti.fawe.bukkit.regions.TownyFeature;
import com.boydti.fawe.bukkit.regions.Worldguard;
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.ItemUtil;
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.util.Jars;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.WEManager;
import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
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) {
new RenderListener(plugin);
}
WEManager.IMP.managers.add(new PlotSquaredFeature());
} catch (final Throwable e) {
e.printStackTrace();
Bukkit.getServer().shutdown();
@ -205,6 +208,15 @@ public class FaweBukkit implements IFawe, Listener {
Player player = Bukkit.getPlayer(name);
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;
}

Datei anzeigen

@ -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;
import com.google.common.collect.Lists;
@ -2708,4 +2727,4 @@ public class DataConverters_1_14_R4 extends DataFixerBuilder implements com.sk89
return cmp;
}
}
}
}

Datei anzeigen

@ -21,7 +21,7 @@ import com.sk89q.worldedit.event.platform.BlockInteractEvent;
import com.sk89q.worldedit.event.platform.Interaction;
import com.sk89q.worldedit.extension.platform.PlatformManager;
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 org.bukkit.Location;
import org.bukkit.entity.Player;
@ -239,14 +239,14 @@ public class CFIPacketListener implements Listener {
platform.handleBlockInteract(toCall);
if (toCall.isCancelled() || action == Interaction.OPEN) {
BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint());
BlockStateHolder block = gen.getBlock(pt);
BlockState block = gen.getBlock(pt);
sendBlockChange(plr, realPos, block);
return true;
}
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));
}

Datei anzeigen

@ -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.CommandDeclaration;

Datei anzeigen

@ -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.TaskManager;

Datei anzeigen

@ -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.FaweAPI;

Datei anzeigen

@ -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.object.clipboard.ReadOnlyClipboard;

Datei anzeigen

@ -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.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.SubCommand;
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.util.WorldUtil;

Datei anzeigen

@ -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.plot.commands.CommandCategory;

Datei anzeigen

@ -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;

Datei anzeigen

@ -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.util.EditSessionBuilder;
@ -20,6 +20,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
@ -31,6 +32,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Bukkit;
@CommandDeclaration(
command = "generatebiome",
@ -65,34 +67,28 @@ public class PlotSetBiome extends Command {
MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.toString() + biomes);
return CompletableFuture.completedFuture(false);
}
confirm.run(this, new Runnable() {
@Override
public void run() {
if (plot.getRunning() != 0) {
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();
}
});
confirm.run(this, () -> {
if (plot.getRunning() != 0) {
Captions.WAIT_FOR_TIMER.send(player);
return;
}
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);
return CompletableFuture.completedFuture(true);

Datei anzeigen

@ -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.FaweAPI;
import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.regions.SimpleRegion;
import com.boydti.fawe.regions.general.RegionFilter;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
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.block.GlobalBlockQueue;
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.math.BlockVector3;
import com.sk89q.worldedit.regions.AbstractRegion;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;
import java.util.HashSet;
import java.util.UUID;
import org.bukkit.Bukkit;
public class PlotSquaredFeature extends FaweMaskManager {
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) {
return false;
}
@ -114,14 +116,14 @@ public class PlotSquaredFeature extends FaweMaskManager {
}
}
}
if (regions.size() == 0) {
if (regions.isEmpty()) {
return null;
}
PlotArea area = pp.getApplicablePlotArea();
int min = area != null ? area.MIN_BUILD_HEIGHT : 0;
int max = area != null ? Math.min(255, area.MAX_BUILD_HEIGHT) : 255;
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));
}
final RegionWrapper region = regions.iterator().next();
@ -136,7 +138,27 @@ public class PlotSquaredFeature extends FaweMaskManager {
if (regions.size() == 1) {
maskedRegion = new CuboidRegion(pos1, pos2);
} 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
public boolean contains(int x, int y, int z) {
return WEManager.maskContains(regions, x, y, z);
@ -146,12 +168,17 @@ public class PlotSquaredFeature extends FaweMaskManager {
public boolean contains(int x, int 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) {
@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)) {
return false;
}

Datei anzeigen

@ -34,12 +34,22 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
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.BlockStateHolder;
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.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.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.block.Biome;
import org.bukkit.block.data.BlockData;
@ -82,7 +92,7 @@ public enum BukkitAdapter {
* @return If they are equal
*/
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
*/
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
*/
public static World adapt(org.bukkit.World world) {
return getAdapter().adapt(world);
}
public static org.bukkit.World adapt(World world) {
return getAdapter().adapt(world);
checkNotNull(world);
return new BukkitWorld(world);
}
/**
@ -119,7 +134,7 @@ public enum BukkitAdapter {
* @return The WorldEdit 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
*/
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) {
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) {
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
*/
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) {
checkNotNull(world);
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) {
checkNotNull(world);
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) {
checkNotNull(entity);
return getAdapter().adapt(entity);
return new BukkitEntity(entity);
}
/**
@ -232,7 +287,10 @@ public enum BukkitAdapter {
*/
public static Material adapt(ItemType 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
* @return The Bukkit Material
*/
public static Material adapt(@NotNull BlockType blockType) {
return getAdapter().adapt(blockType);
public static Material adapt(BlockType 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) {
checkNotNull(gameMode);
return getAdapter().adapt(gameMode);
return GameModes.get(gameMode.name().toLowerCase(Locale.ROOT));
}
/**
@ -263,11 +325,18 @@ public enum BukkitAdapter {
* @return WorldEdit BiomeType
*/
public static BiomeType adapt(Biome biome) {
return getAdapter().adapt(biome);
return BiomeTypes.get(biome.name().toLowerCase(Locale.ROOT));
}
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
*/
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) {
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
* @return The blocktype
*/
public static BlockType asBlockType(@NotNull Material material) {
return getAdapter().asBlockType(material);
public static BlockType asBlockType(Material 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) {
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
@ -320,6 +404,8 @@ public enum BukkitAdapter {
return getAdapter().adapt(material);
}
private static Map<String, BlockData> blockDataCache = new HashMap<>();
/**
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder
*
@ -339,7 +425,7 @@ public enum BukkitAdapter {
public static BlockState asBlockState(ItemStack itemStack) throws WorldEditException {
checkNotNull(itemStack);
if (itemStack.getType().isBlock()) {
return getAdapter().asBlockState(itemStack);
return adapt(itemStack.getType().createBlockData());
} else {
throw new NotABlockException();
}
@ -353,7 +439,10 @@ public enum BukkitAdapter {
*/
public static BaseItemStack adapt(ItemStack 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) {
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());
}
}

Datei anzeigen

@ -164,7 +164,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements
@Override
public boolean isPersistent() {
return true;
return false;
}
@Override

Datei anzeigen

@ -35,8 +35,9 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import java.util.Map;
import java.util.OptionalInt;
import javax.annotation.Nullable;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
@ -45,11 +46,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
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.
*/
@ -202,7 +198,6 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
* @param state The block state
* @return the internal ID of the state
*/
default OptionalInt getInternalBlockStateId(BlockState state) {
return OptionalInt.empty();
}

Datei anzeigen

@ -2,7 +2,6 @@ package com.sk89q.worldedit.bukkit.adapter;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.BukkitEntity;
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.BlockTypes;
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 java.util.Locale;
import org.bukkit.Bukkit;
@ -35,17 +31,6 @@ import org.bukkit.inventory.ItemStack;
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.
*
@ -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.
*
@ -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.
*
@ -228,27 +170,6 @@ public interface IBukkitAdapter {
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) {
if (!entityType.getId().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
@ -303,21 +224,6 @@ public interface IBukkitAdapter {
*/
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
*

Datei anzeigen

@ -33,10 +33,6 @@ dependencies {
"annotationProcessor"("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}")
"compile"("co.aikar:fastutil-lite:1.0")
"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")
}

Datei anzeigen

@ -4,7 +4,6 @@ import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
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.CleanTextureUtil;
import com.boydti.fawe.util.FaweTimer;
@ -186,7 +185,6 @@ public class Fawe {
transformParser = new DefaultTransformParser(getWorldEdit());
visualQueue = new VisualQueue(3);
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
WEManager.IMP.managers.add(new PlotSquaredFeature());
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
} catch (Throwable ignored) {}
try {

Datei anzeigen

@ -24,6 +24,7 @@ public interface IChunkSet extends IBlocks, OutputExtent {
boolean isEmpty();
@Override
boolean setTile(int x, int y, int z, CompoundTag tile);
void setEntity(CompoundTag tag);

Datei anzeigen

@ -104,7 +104,7 @@ public class CFICommands {
desc = "Start CFI with a height map as a base"
)
@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) {
int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData();
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()));
setup(generator, fp);
setup(generator, player);
}
@Command(
@ -126,9 +126,9 @@ public class CFICommands {
desc = "Start CFI with an empty map as a base"
)
@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()));
setup(generator, fp);
setup(generator, player);
}
private String generateName() {
@ -136,13 +136,13 @@ public class CFICommands {
return df.format(new Date());
}
private void setup(HeightMapMCAGenerator generator, Player fp) {
CFISettings settings = getSettings(fp).remove();
generator.setPacketViewer(fp);
private void setup(HeightMapMCAGenerator generator, Player player) {
CFISettings settings = getSettings(player).remove();
generator.setPacketViewer(player);
settings.setGenerator(generator).bind();
generator.setImageViewer(Fawe.imp().getImageViewer(fp));
generator.setImageViewer(Fawe.imp().getImageViewer(player));
generator.update();
mainMenu(fp);
mainMenu(player);
}
@Command(
@ -172,9 +172,9 @@ public class CFICommands {
desc = "Cancel creation"
)
@CommandPermissions("worldedit.anvil.cfi")
public void cancel(Player fp) {
getSettings(fp).remove();
fp.print("Cancelled!");
public void cancel(Player player) {
getSettings(player).remove();
player.print("Cancelled!");
}
@Command(
@ -238,8 +238,8 @@ public class CFICommands {
desc = "Set the floor and main block"
)
@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){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
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(player).getGenerator();
if (image != null) {
gen.setColumn(load(image), patternArg, !disableWhiteOnly);
} else if (maskOpt != null) {
@ -247,9 +247,9 @@ public class CFICommands {
} else {
gen.setColumn(patternArg);
}
fp.print("Set column!");
assertSettings(fp).resetComponent();
component(fp);
player.print("Set column!");
assertSettings(player).resetComponent();
component(player);
}
@Command(
@ -257,15 +257,15 @@ public class CFICommands {
desc = "Set the floor (default: grass)"
)
@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){
floor(fp, patternArg, image, maskOpt, disableWhiteOnly);
fp.print("Set floor!");
assertSettings(fp).resetComponent();
component(fp);
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(player, patternArg, image, maskOpt, disableWhiteOnly);
player.print("Set floor!");
assertSettings(player).resetComponent();
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) {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
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(player).getGenerator();
if (image != null) {
gen.setFloor(load(image), patternArg, !disableWhiteOnly);
} else if (maskOpt != null) {
@ -280,15 +280,15 @@ public class CFICommands {
desc = "Set the main block (default: stone)"
)
@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){
main(fp, patternArg, image, maskOpt, disableWhiteOnly);
fp.print("Set main!");
assertSettings(fp).resetComponent();
component(fp);
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(player, patternArg, image, maskOpt, disableWhiteOnly);
player.print("Set main!");
assertSettings(player).resetComponent();
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){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
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(player).getGenerator();
if (image != null) {
gen.setMain(load(image), patternArg, !disableWhiteOnly);
} else if (maskOpt != null) {
@ -306,8 +306,8 @@ public class CFICommands {
"e.g. Tallgrass"
)
@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){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
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(player).getGenerator();
if (image != null) {
gen.setOverlay(load(image), patternArg, !disableWhiteOnly);
} else if (maskOpt != null) {
@ -315,8 +315,8 @@ public class CFICommands {
} else {
gen.setOverlay(patternArg);
}
fp.print("Set overlay!");
component(fp);
player.print("Set overlay!");
component(player);
}
@Command(
@ -328,14 +328,14 @@ public class CFICommands {
" - A good value for radius and iterations would be 1 8."
)
@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){
smooth(fp, radius, iterations, image, maskOpt, disableWhiteOnly);
assertSettings(fp).resetComponent();
component(fp);
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(player, radius, iterations, image, maskOpt, disableWhiteOnly);
assertSettings(player).resetComponent();
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){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
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(player).getGenerator();
if (image != null) {
gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
} else {
@ -348,14 +348,14 @@ public class CFICommands {
desc = "Create some snow"
)
@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){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly);
main(fp, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly);
smooth(fp, 1, 8, image, maskOpt, disableWhiteOnly);
fp.print(TextComponent.of("Added snow!"));
assertSettings(fp).resetComponent();
component(fp);
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(player).getGenerator();
floor(player, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, maskOpt, disableWhiteOnly);
main(player, BlockTypes.SNOW_BLOCK, image, maskOpt, disableWhiteOnly);
smooth(player, 1, 8, image, maskOpt, disableWhiteOnly);
player.print(TextComponent.of("Added snow!"));
assertSettings(player).resetComponent();
component(player);
}
@Command(

Datei anzeigen

@ -1,16 +1,13 @@
package com.boydti.fawe.object.brush;
import com.google.common.collect.Maps;
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;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Arrays;
import java.util.Map;
public class BlendBall implements Brush {
@ -38,8 +35,8 @@ public class BlendBall implements Brush {
}
int z0 = z + tz;
int highest = 1;
BlockStateHolder currentState = editSession.getBlock(x0, y0, z0);
BlockStateHolder highestState = currentState;
BlockState currentState = editSession.getBlock(x0, y0, z0);
BlockState highestState = currentState;
Arrays.fill(frequency, 0);
boolean tie = false;
for (int ox = -1; ox <= 1; ox++) {
@ -48,13 +45,9 @@ public class BlendBall implements Brush {
if (oy + y0 < 0 || oy + y0 > maxY) {
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()];
if (count == null) {
count = 1;
} else {
count++;
}
count++;
if (count > highest) {
highest = count;
highestState = state;

Datei anzeigen

@ -67,9 +67,9 @@ public class BlobBrush implements Brush {
.rotateY(ThreadLocalRandom.current().nextInt(360))
.rotateZ(ThreadLocalRandom.current().nextInt(360));
double manScaleX = (1.25 + seedX * 0.5);
double manScaleY = (1.25 + seedY * 0.5);
double manScaleZ = (1.25 + seedZ * 0.5);
double manScaleX = 1.25 + seedX * 0.5;
double manScaleY = 1.25 + seedY * 0.5;
double manScaleZ = 1.25 + seedZ * 0.5;
MutableVector3 mutable = new MutableVector3();
double roughness = 1 - sphericity;
@ -103,4 +103,4 @@ public class BlobBrush implements Brush {
}
}
}
}
}

Datei anzeigen

@ -5,7 +5,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.brush.scroll.ScrollAction;
import com.boydti.fawe.object.extent.ResettableExtent;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.tool.BrushTool;
@ -42,10 +41,10 @@ public class BrushSettings {
private final Map<SettingType, Object> constructor = new ConcurrentHashMap<>();
private Brush brush = null;
private Mask mask = null;
private Mask sourceMask = null;
private ResettableExtent transform = null;
private Brush brush;
private Mask mask;
private Mask sourceMask;
private ResettableExtent transform;
private Pattern material;
private Expression size = new Expression(1);
private Set<String> permissions;
@ -57,7 +56,7 @@ public class BrushSettings {
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();
String constructor = (String) settings.get(SettingType.BRUSH.name());
if (constructor == null) {

Datei anzeigen

@ -31,7 +31,7 @@ public class CatenaryBrush implements Brush, ResettableTool {
@Override
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 (!visual) {
pos1 = pos2;
@ -64,9 +64,8 @@ public class CatenaryBrush implements Brush, ResettableTool {
if (!select) {
pos1 = null;
return;
} else {
pos1 = pos2;
}
pos1 = pos2;
}
}
@ -87,7 +86,7 @@ public class CatenaryBrush implements Brush, ResettableTool {
double a = 0.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 z = (dh/2)/a;
double z = (dh / 2) / a;
double oY = (dy - curveLen * (Math.cosh(z) / Math.sinh(z))) / 2;
double vertY = a * 1 + oY;
return pos1.add(pos2.subtract(pos1).multiply(vertX / dh).add(0, vertY, 0)).round().toBlockPoint();

Datei anzeigen

@ -9,23 +9,23 @@ import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
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.BlockTypes;
import java.util.Arrays;
import java.util.function.Function;
import java.util.stream.Stream;
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
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 brushSizeSquared = (int) (size * size);
int dimension = brushSize * 2 + 1;
@ -42,7 +42,7 @@ public class ErodeBrush implements Brush {
int y0 = y + by;
for (int z = -brushSize; z <= brushSize; z++) {
int z0 = z + bz;
BlockStateHolder state = es.getBlock(x0, y0, z0);
BlockState state = es.getBlock(x0, y0, z0);
buffer1.setBlock(x, y, z, state);
buffer2.setBlock(x, y, z, state);
}
@ -55,7 +55,7 @@ public class ErodeBrush implements Brush {
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);
swap++;
}
@ -69,7 +69,8 @@ public class ErodeBrush implements Brush {
}, 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;
for (int x = -brushSize; x <= brushSize; x++) {
int x2 = x * x;
@ -81,20 +82,20 @@ public class ErodeBrush implements Brush {
if (cube >= brushSizeSquared) {
continue;
}
BlockStateHolder state = current.getBlock(x, y, z);
BaseBlock state = current.getBlock(x, y, z);
if (state.getBlockType().getMaterial().isMovementBlocker()) {
continue;
}
int total = 0;
int highest = 1;
BlockStateHolder highestState = state;
BaseBlock highestState = state;
if (frequency == null) {
frequency = new int[BlockTypes.size()];
} else {
Arrays.fill(frequency, 0);
}
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()) {
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;
for (int x = -brushSize; x <= brushSize; x++) {
int x2 = x * x;
@ -125,20 +127,20 @@ public class ErodeBrush implements Brush {
if (cube >= brushSizeSquared) {
continue;
}
BlockStateHolder state = current.getBlock(x, y, z);
BaseBlock state = current.getBlock(x, y, z);
if (!state.getBlockType().getMaterial().isMovementBlocker()) {
continue;
}
int total = 0;
int highest = 1;
BlockStateHolder highestState = state;
BaseBlock highestState = state;
if (frequency == null) {
frequency = new int[BlockTypes.size()];
} else {
Arrays.fill(frequency, 0);
}
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()) {
continue;
}

Datei anzeigen

@ -47,7 +47,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
}
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) {
Location face = player.getBlockTraceFace(range, true);
return face.add(face.getDirection());

Datei anzeigen

@ -1,7 +1,5 @@
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.mask.AdjacentAnyMask;
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.command.tool.brush.Brush;
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.operation.Operations;
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.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Arrays;
public class LayerBrush implements Brush {
@ -44,32 +39,29 @@ public class LayerBrush implements Brush {
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
Operations.completeBlindly(visitor);
BlockVectorSet visited = visitor.getVisited();
visitor = new RecursiveVisitor(new Mask() {
@Override
public boolean test(BlockVector3 pos) {
int depth = visitor.getDepth() + 1;
if (depth > 1) {
boolean found = false;
BlockState previous = layers[depth - 1];
BlockState previous2 = layers[depth - 2];
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
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()) == previous2) {
found = true;
break;
} else {
return false;
}
visitor = new RecursiveVisitor(pos -> {
int depth = visitor.getDepth() + 1;
if (depth > 1) {
boolean found = false;
BlockState previous = layers[depth - 1];
BlockState previous2 = layers[depth - 2];
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
if (visitor.isVisited(mutable) && editSession.getBlock(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
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()) == previous2) {
found = true;
break;
} else {
return false;
}
}
if (!found) {
return false;
}
}
return !adjacent.test(pos);
if (!found) {
return false;
}
}
return !adjacent.test(pos);
}, pos -> {
int depth = visitor.getDepth();
BlockStateHolder currentPattern = layers[depth];

Datei anzeigen

@ -20,8 +20,8 @@ public class LineBrush implements Brush, ResettableTool {
}
@Override
public void build(EditSession editSession, BlockVector3 position, final Pattern pattern, double size) throws MaxChangedBlocksException {
boolean visual = (editSession.getExtent() instanceof VisualExtent);
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
boolean visual = editSession.getExtent() instanceof VisualExtent;
if (pos1 == null) {
if (!visual) {
pos1 = position;
@ -34,7 +34,6 @@ public class LineBrush implements Brush, ResettableTool {
BBC.BRUSH_LINE_SECONDARY.send(editSession.getPlayer());
if (!select) {
pos1 = null;
return;
} else {
pos1 = position;
}

Datei anzeigen

@ -8,6 +8,6 @@ import com.sk89q.worldedit.math.BlockVector3;
public class RaiseBrush extends ErodeBrush {
@Override
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);
}
}
}

Datei anzeigen

@ -4,7 +4,6 @@ import com.boydti.fawe.object.mask.RadiusMask;
import com.boydti.fawe.object.visitor.DFSRecursiveVisitor;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.mask.Mask;
@ -24,7 +23,7 @@ public class RecurseBrush implements Brush {
}
@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();
if (mask == null) {
mask = Masks.alwaysTrue();
@ -35,7 +34,7 @@ public class RecurseBrush implements Brush {
return;
}
final BlockReplace replace = new BlockReplace(editSession, to);
editSession.setMask((Mask) null);
editSession.setMask(null);
final int maxY = editSession.getMaxY();
if (dfs) {
final Mask radMask = new RadiusMask(0, (int) size);
@ -43,7 +42,7 @@ public class RecurseBrush implements Brush {
@Override
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
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);
@ -53,7 +52,7 @@ public class RecurseBrush implements Brush {
@Override
public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
int y = to.getBlockY();
return y >= y && y < maxY && super.isVisitable(from, to);
return y < maxY && super.isVisitable(from, to);
}
};
visitor.visit(position);

Datei anzeigen

@ -17,7 +17,6 @@ public class ScatterOverlayBrush extends ScatterBrush {
int y = pt.getBlockY();
int z = pt.getBlockZ();
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);
}
}
}

Datei anzeigen

@ -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 {
}
}

Datei anzeigen

@ -5,13 +5,11 @@ import com.boydti.fawe.object.mask.SurfaceMask;
import com.boydti.fawe.object.pattern.BiomePattern;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.math.BlockVector3;
import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;
@ -32,8 +30,8 @@ public class SplatterBrush extends ScatterBrush {
Pattern tmp;
try {
tmp = p.apply(position);
} catch (BiomePattern.BiomePatternException ignore) {
tmp = ignore.getPattern();
} catch (BiomePattern.BiomePatternException e) {
tmp = e.getPattern();
}
finalPattern = tmp;
} else {
@ -44,7 +42,8 @@ public class SplatterBrush extends ScatterBrush {
RecursiveVisitor visitor = new RecursiveVisitor(vector -> {
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);
return true;
}

Datei anzeigen

@ -28,12 +28,10 @@ public class SplineBrush implements Brush, ResettableTool {
private ArrayList<ArrayList<BlockVector3>> positionSets;
private int numSplines;
private final LocalSession session;
private final Player player;
private BlockVector3 position;
public SplineBrush(Player player, LocalSession session) {
this.session = session;
this.player = player;
this.positionSets = new ArrayList<>();
}

Datei anzeigen

@ -16,9 +16,12 @@ import java.util.ArrayList;
import java.util.List;
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.bias = bias;
this.continuity = continuity;
@ -43,7 +46,7 @@ public class SurfaceSpline implements Brush {
final List<Node> nodes = new ArrayList<>(path.size());
final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();
for (final BlockVector3 nodevector : path) {
for (BlockVector3 nodevector : path) {
final Node n = new Node(nodevector.toVector3());
n.setTension(tension);
n.setBias(bias);
@ -72,13 +75,13 @@ public class SurfaceSpline implements Brush {
}
}
if (radius != 0) {
double radius2 = (radius * radius);
double radius2 = radius * radius;
LocalBlockVectorSet newSet = new LocalBlockVectorSet();
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();
for (int loopx = tipx - ceilrad; loopx <= (tipx + ceilrad); loopx++) {
for (int loopz = tipz - ceilrad; loopz <= (tipz + ceilrad); loopz++) {
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) {
int y = editSession.getNearestSurfaceTerrainBlock(loopx, loopz, v.getBlockY(), 0, maxY);
if (y == -1) continue;

Datei anzeigen

@ -139,23 +139,23 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
enttFile.delete();
}
public void undo(Player fp, Region[] regions) {
EditSession session = toEditSession(fp, regions);
public void undo(Player player, Region[] regions) {
EditSession session = toEditSession(player, regions);
session.undo(session);
deleteFiles();
}
public void undo(Player fp) {
undo(fp, null);
public void undo(Player player) {
undo(player, null);
}
public void redo(Player fp, Region[] regions) {
EditSession session = toEditSession(fp, regions);
public void redo(Player player, Region[] regions) {
EditSession session = toEditSession(player, regions);
session.redo(session);
}
public void redo(Player fp) {
undo(fp, null);
public void redo(Player player) {
undo(player, null);
}
public UUID getUUID() {

Datei anzeigen

@ -140,8 +140,7 @@ public final class MemBlockSet extends BlockSet {
@Override
public int size() {
int size = 0;
for (int X = 0;X < rows.length; X++) {
IRow nullRowX = rows[X];
for (IRow nullRowX : rows) {
if (nullRowX instanceof RowX) {
RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) {
@ -238,8 +237,7 @@ public final class MemBlockSet extends BlockSet {
@Override
public int size() {
int size = 0;
for (int X = 0;X < rows.length; X++) {
IRow nullRowX = rows[X];
for (IRow nullRowX : rows) {
if (nullRowX instanceof RowX) {
RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) {
@ -286,18 +284,20 @@ public final class MemBlockSet extends BlockSet {
int maxY = 15;
int maxy = 16;
int by = Integer.MAX_VALUE;
for (int X = 0; X < rows.length; X++) {
IRow nullRowX = rows[X];
if (!(nullRowX instanceof RowX)) continue;
for (IRow nullRowX : rows) {
if (!(nullRowX instanceof RowX))
continue;
RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) {
IRow nullRowZ = rowx.rows[Z];
if (!(nullRowZ instanceof RowZ)) continue;
if (!(nullRowZ instanceof RowZ))
continue;
RowZ rowz = (RowZ) nullRowZ;
outer:
for (int Y = 0; Y <= maxY; Y++) {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
if (!(nullRowY instanceof RowY))
continue;
RowY rowY = (RowY) nullRowY;
int localMaxy = Y == maxY ? maxy : 15;
for (int y = 0, i = 0; y < localMaxy; y++) {
@ -312,7 +312,8 @@ public final class MemBlockSet extends BlockSet {
maxy = y;
}
by = (Y << 4) + y;
if (by == 0) return 0;
if (by == 0)
return 0;
break outer;
}
}
@ -328,18 +329,20 @@ public final class MemBlockSet extends BlockSet {
int maxY = 0;
int maxy = 0;
int by = Integer.MIN_VALUE;
for (int X = 0; X < rows.length; X++) {
IRow nullRowX = rows[X];
if (!(nullRowX instanceof RowX)) continue;
for (IRow nullRowX : rows) {
if (!(nullRowX instanceof RowX))
continue;
RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) {
IRow nullRowZ = rowx.rows[Z];
if (!(nullRowZ instanceof RowZ)) continue;
if (!(nullRowZ instanceof RowZ))
continue;
RowZ rowz = (RowZ) nullRowZ;
outer:
for (int Y = 15; Y >= maxY; Y--) {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
if (!(nullRowY instanceof RowY))
continue;
RowY rowY = (RowY) nullRowY;
int localMaxy = Y == maxY ? maxy : 0;
for (int y = 15, i = 63; y >= localMaxy; y--) {
@ -354,7 +357,8 @@ public final class MemBlockSet extends BlockSet {
maxy = y + 1;
}
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;
}
}
@ -425,9 +429,7 @@ public final class MemBlockSet extends BlockSet {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
RowY rowY = (RowY) nullRowY;
for (long value : rowY.bits) {
or |= value;
}
or |= Arrays.stream(rowY.bits).reduce(0, (a, b) -> a | b);
or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF);
if (highestBit(or) == 15) return tx + 15;
}
@ -444,14 +446,15 @@ public final class MemBlockSet extends BlockSet {
int maxChunkZ = rows.length - 1;
int maxz = 16;
int bz = Integer.MAX_VALUE;
for (int X = 0; X < rows.length; X++) {
IRow nullRowX = rows[X];
if (!(nullRowX instanceof RowX)) continue;
for (IRow nullRowX : rows) {
if (!(nullRowX instanceof RowX))
continue;
RowX rowx = (RowX) nullRowX;
outer:
for (int Z = 0; Z <= maxChunkZ; Z++) {
IRow nullRowZ = rowx.rows[Z];
if (!(nullRowZ instanceof RowZ)) continue;
if (!(nullRowZ instanceof RowZ))
continue;
RowZ rowz = (RowZ) nullRowZ;
if (Z != maxChunkZ) {
maxChunkZ = Z;
@ -459,7 +462,8 @@ public final class MemBlockSet extends BlockSet {
}
for (int Y = 0; Y < rowz.rows.length; Y++) {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
if (!(nullRowY instanceof RowY))
continue;
RowY rowY = (RowY) nullRowY;
for (int y = 0, i1 = 0; y < 16; y++, i1 += 4) {
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];
if (!(nullRowY instanceof RowY)) continue;
RowY rowY = (RowY) nullRowY;
for (long value : rowY.bits) {
or |= value;
}
or |= Arrays.stream(rowY.bits).reduce(0, (a, b) -> a | b);
or = (or & 0xFFFF) | ((or >> 16) & 0xFFFF) | ((or >> 32) & 0xFFFF) | ((or >> 48) & 0xFFFF);
if (lowestBit(or) == 0) return bx;
}
@ -566,7 +568,6 @@ public final class MemBlockSet extends BlockSet {
private int bx, by, bz, zz, yy;
private RowX rowX;
private RowZ rowZ;
private RowY rowY;
private long[] bits;
private int bitsIndex = 0;
private int yIndex = 0;
@ -618,7 +619,7 @@ public final class MemBlockSet extends BlockSet {
by = yIndex << 4;
IRow nullRowY = rowZ.rows[yIndex++];
if (nullRowY instanceof RowY) {
rowY = (RowY) nullRowY;
RowY rowY = (RowY) nullRowY;
bits = rowY.bits;
return true;
}
@ -656,9 +657,7 @@ public final class MemBlockSet extends BlockSet {
public BlockVector3 next() {
final long lowBit = Long.lowestOneBit(bitBuffer);
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;
nextLong();
return mutable;
@ -674,20 +673,23 @@ public final class MemBlockSet extends BlockSet {
@Override
public boolean isEmpty() {
for (int X = 0; X < rows.length; X++) {
IRow nullRowX = rows[X];
if (!(nullRowX instanceof RowX)) continue;
for (IRow nullRowX : rows) {
if (!(nullRowX instanceof RowX))
continue;
RowX rowx = (RowX) nullRowX;
for (int Z = 0; Z < rowx.rows.length; Z++) {
IRow nullRowZ = rowx.rows[Z];
if (!(nullRowZ instanceof RowZ)) continue;
if (!(nullRowZ instanceof RowZ))
continue;
RowZ rowz = (RowZ) nullRowZ;
for (int Y = 0; Y < 16; Y++) {
IRow nullRowY = rowz.rows[Y];
if (!(nullRowY instanceof RowY)) continue;
if (!(nullRowY instanceof RowY))
continue;
RowY rowY = (RowY) nullRowY;
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 lastBit = 0;
int lastCount = 0;
for (int x = 0; x < rows.length; x++) {
IRow nullRowX = rows[x];
if (!(nullRowX instanceof RowX)) continue;
for (IRow nullRowX : rows) {
if (!(nullRowX instanceof RowX))
continue;
RowX rowx = (RowX) nullRowX;
for (int z = 0; z < rowx.rows.length; z++) {
IRow nullRowZ = rowx.rows[z];
if (!(nullRowZ instanceof RowZ)) continue;
if (!(nullRowZ instanceof RowZ))
continue;
RowZ rowz = (RowZ) nullRowZ;
for (int y = 0; y < 16; y++) {
IRow nullRowY = rowz.rows[y];
@ -755,7 +758,8 @@ public final class MemBlockSet extends BlockSet {
remove(rows, x, y, z);
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 {

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent;
@ -30,7 +29,7 @@ public class ExtentHeightCacher extends PassthroughExtent {
int rx = x - cacheBotX + 16;
int rz = z - cacheBotZ + 16;
int index;
if (((rx & 0xFF) != rx || (rz & 0xFF) != rz)) {
if ((rx & 0xFF) != rx || (rz & 0xFF) != rz) {
cacheBotX = x - 16;
cacheBotZ = z - 16;
lastY = y;

Datei anzeigen

@ -1,12 +1,9 @@
package com.boydti.fawe.object.extent;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.WEManager;
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.Entity;
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.util.Location;
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.BlockTypes;
import java.util.Collection;
import javax.annotation.Nullable;
@ -41,12 +39,7 @@ public abstract class FaweRegionExtent extends ResettableExtent {
public abstract Collection<Region> getRegions();
public boolean isGlobal() {
for (Region region : getRegions()) {
if (region.isGlobal()) {
return true;
}
}
return false;
return getRegions().stream().anyMatch(Region::isGlobal);
}
@Override

Datei anzeigen

@ -30,12 +30,12 @@ public class OffsetExtent extends ResettableExtent {
}
@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);
}
@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);
}

Datei anzeigen

@ -51,13 +51,13 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) {
min = pos;
}
mutable1.mutX(((pos.getX() - min.getX())));
mutable1.mutY(((pos.getY() - min.getY())));
mutable1.mutZ(((pos.getZ() - min.getZ())));
mutable1.mutX(pos.getX() - min.getX());
mutable1.mutY(pos.getY() - min.getY());
mutable1.mutZ(pos.getZ() - min.getZ());
Vector3 tmp = getTransform().apply(mutable1);
mutable2.mutX((tmp.getX() + min.getX()));
mutable2.mutY((tmp.getY() + min.getY()));
mutable2.mutZ((tmp.getZ() + min.getZ()));
mutable2.mutX(tmp.getX() + min.getX());
mutable2.mutY(tmp.getY() + min.getY());
mutable2.mutZ(tmp.getZ() + min.getZ());
return mutable2;
}
@ -65,13 +65,13 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) {
min = BlockVector3.at(x, y, z);
}
mutable1.mutX(((x - min.getX())));
mutable1.mutY(((y - min.getY())));
mutable1.mutZ(((z - min.getZ())));
mutable1.mutX(x - min.getX());
mutable1.mutY(y - min.getY());
mutable1.mutZ(z - min.getZ());
Vector3 tmp = getTransform().apply(mutable1);
mutable2.mutX((tmp.getX() + min.getX()));
mutable2.mutY((tmp.getY() + min.getY()));
mutable2.mutZ((tmp.getZ() + min.getZ()));
mutable2.mutX(tmp.getX() + min.getX());
mutable2.mutY(tmp.getY() + min.getY());
mutable2.mutZ(tmp.getZ() + min.getZ());
return tmp.toBlockPoint();
}
@ -93,13 +93,13 @@ public class TransformExtent extends BlockTransformExtent {
}
@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));
}
@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));
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -23,9 +23,9 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
if (origin == null) {
origin = pos;
}
mutable.mutX((pos.getX() - origin.getX()));
mutable.mutY((pos.getY() - origin.getY()));
mutable.mutZ((pos.getZ() - origin.getZ()));
mutable.mutX(pos.getX() - origin.getX());
mutable.mutY(pos.getY() - origin.getY());
mutable.mutZ(pos.getZ() - origin.getZ());
return pattern.apply(mutable);
}
@ -34,9 +34,9 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
if (origin == null) {
origin = set;
}
mutable.mutX((set.getX() - origin.getX()));
mutable.mutY((set.getY() - origin.getY()));
mutable.mutZ((set.getZ() - origin.getZ()));
mutable.mutX(set.getX() - origin.getX());
mutable.mutY(set.getY() - origin.getY());
mutable.mutZ(set.getZ() - origin.getZ());
return pattern.apply(extent, get, mutable);
}

Datei anzeigen

@ -1,9 +1,10 @@
package com.boydti.fawe.object.random;
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);
return (int) (val * len);
}

Datei anzeigen

@ -3,19 +3,16 @@ package com.boydti.fawe.object.random;
import java.util.SplittableRandom;
public class TrueRandom implements SimpleRandom {
private final SplittableRandom r;
public TrueRandom() {
this.r = new SplittableRandom();
}
private final SplittableRandom random = new SplittableRandom();
@Override
public double nextDouble(int x, int y, int z) {
return r.nextDouble();
return random.nextDouble();
}
@Override
public int nextInt(int x, int y, int z, int len) {
return r.nextInt(len);
return random.nextInt(len);
}
}

Datei anzeigen

@ -35,7 +35,8 @@ public class Triangle {
radius[1] = RADIUS;
radius[2] = RADIUS;
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) {
@ -45,9 +46,14 @@ public class Triangle {
public Edge getEdge(int index) {
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 {
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) {
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[][]) {
double min, max, p0, p1, p2, rad, fex, fey, fez;
private boolean overlaps(double[] boxcenter, double[] boxhalfsize, double[][] triverts) {
double min, max, fex, fey, fez;
sub(v0, triverts[0], boxcenter);
sub(v1, triverts[1], boxcenter);
sub(v2, triverts[2], boxcenter);
@ -188,48 +194,71 @@ public class Triangle {
fey = Math.abs(e0[1]);
fez = Math.abs(e0[2]);
if (!axisTestX01(e0[2], e0[1], fez, fey)) return false;
if (!axisTestY02(e0[2], e0[0], fez, fex)) return false;
if (!axisTestZ12(e0[1], e0[0], fey, fex)) return false;
if (!axisTestX01(e0[2], e0[1], fez, fey)) {
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]);
fey = Math.abs(e1[1]);
fez = Math.abs(e1[2]);
if (!axisTestX01(e1[2], e1[1], fez, fey)) return false;
if (!axisTestY02(e1[2], e1[0], fez, fex)) return false;
if (!axisTestZ0(e1[1], e1[0], fey, fex)) return false;
if (!axisTestX01(e1[2], e1[1], fez, fey)) {
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]);
fey = Math.abs(e2[1]);
fez = Math.abs(e2[2]);
if (!axisTestX2(e2[2], e2[1], fez, fey)) return false;
if (!axisTestY1(e2[2], e2[0], fez, fex)) return false;
if (!axisTestZ12(e2[1], e2[0], fey, fex)) return false;
if (!axisTestX2(e2[2], e2[1], fez, fey)) {
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]);
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]);
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]);
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);
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++) {
double v = vert[q];
if (normal[q] > 0.0f) {
@ -240,8 +269,9 @@ public class Triangle {
vmax[q] = -maxbox[q] - v;
}
}
if (dot(normal, vmin) > 0.0f) return false;
if (dot(normal, vmax) >= 0.0f) return true;
return false;
if (dot(normal, vmin) > 0.0f) {
return false;
}
return dot(normal, vmax) >= 0.0f;
}
}

Datei anzeigen

@ -19,6 +19,8 @@
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.Triangle;
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.selector.limit.SelectorLimits;
import com.sk89q.worldedit.world.World;
import java.util.*;
import java.util.ArrayList;
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 static com.google.common.base.Preconditions.checkNotNull;
/**
* 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.
*/
public PolyhedralRegionSelector() {
this((World) null);
this(null);
}
/**

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -1,7 +1,8 @@
package com.boydti.fawe.regions.general;
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);
}

Datei anzeigen

@ -372,8 +372,8 @@ public class LocalSession implements TextureHolder {
public void remember(EditSession editSession) {
checkNotNull(editSession);
Player fp = editSession.getPlayer();
int limit = fp == null ? Integer.MAX_VALUE : fp.getLimit().MAX_HISTORY;
Player player = editSession.getPlayer();
int limit = player == null ? Integer.MAX_VALUE : player.getLimit().MAX_HISTORY;
remember(editSession, true, limit);
}
@ -507,7 +507,6 @@ public class LocalSession implements TextureHolder {
*/
public EditSession undo(@Nullable BlockBag newBlockBag, Actor actor) {
checkNotNull(actor);
//TODO This method needs to be modified to use actors instead of FAWEPlayer
loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player) actor).getWorldForEditing());
if (getHistoryNegativeIndex() < history.size()) {
FaweChangeSet changeSet = getChangeSet(history.get(getHistoryIndex()));
@ -544,7 +543,6 @@ public class LocalSession implements TextureHolder {
*/
public EditSession redo(@Nullable BlockBag newBlockBag, Actor actor) {
checkNotNull(actor);
//TODO This method needs to be modified to use actors instead of FAWEPlayer
loadSessionHistoryFromDisk(actor.getUniqueId(), ((Player)actor).getWorldForEditing());
if (getHistoryNegativeIndex() > 0) {
setDirty();
@ -622,16 +620,12 @@ public class LocalSession implements TextureHolder {
*/
public RegionSelector getRegionSelector(World world) {
checkNotNull(world);
try {
if (selector.getWorld() == null || !selector.getWorld().equals(world)) {
selector.setWorld(world);
selector.clear();
if (hasWorldOverride() && !world.equals(getWorldOverride())) {
setWorldOverride(null);
}
}
} catch (Throwable ignore) {
if (selector.getWorld() == null || !selector.getWorld().equals(world)) {
selector.setWorld(world);
selector.clear();
if (hasWorldOverride() && !world.equals(getWorldOverride())) {
setWorldOverride(null);
}
}
return selector;
}
@ -1044,6 +1038,7 @@ public class LocalSession implements TextureHolder {
} else if (type.getId().equalsIgnoreCase(config.navigationWand)) {
throw new InvalidToolBindException(type, "Already used for the navigation wand");
}
Tool previous;
if (player != null && (tool instanceof BrushTool || tool == null) && Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && item.getNativeItem() != null) {
previous = BrushCache.getCachedTool(item);
@ -1350,23 +1345,25 @@ public class LocalSession implements TextureHolder {
*/
public EditSession createEditSession(Actor actor) {
checkNotNull(actor);
BlockBag blockBag = null;
if (actor.isPlayer() && actor instanceof Player) {
blockBag = getBlockBag((Player) actor);
}
World world = null;
if (hasWorldOverride()) {
world = getWorldOverride();
} else if (actor instanceof Locatable && ((Locatable) actor).getExtent() instanceof World) {
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
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) {
editSession.setMask(mask);

Datei anzeigen

@ -41,7 +41,6 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.annotation.Direction;
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
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.util.TreeGenerator;
import com.sk89q.worldedit.util.formatting.text.TextComponent;

Datei anzeigen

@ -132,7 +132,6 @@ import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.enginehub.piston.inject.Key;
/**
* Commands to set brush shape.
@ -162,9 +161,9 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.blendball")
public void blendBallBrush(Player player, LocalSession session,
@Arg(desc = "The radius to sample for blending", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new BlendBall()).setSize(radius);
set(player, session, new BlendBall()).setSize(radius);
}
@Command(
@ -174,9 +173,9 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.erode")
public void erodeBrush(Player player, LocalSession session,
@Arg(desc = "The radius for eroding", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new ErodeBrush()).setSize(radius);
set(player, session, new ErodeBrush()).setSize(radius);
}
@Command(
@ -186,9 +185,9 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.pull")
public void pullBrush(Player player, LocalSession session,
@Arg(desc = "The radius to sample for blending", def = "5")
Expression radius, InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new RaiseBrush()).setSize(radius);
set(player, session, new RaiseBrush()).setSize(radius);
}
@Command(
@ -196,11 +195,12 @@ public class BrushCommands {
desc = "Creates a circle which revolves around your facing direction"
)
@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")
Expression radius, InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new CircleBrush(player)).setSize(radius).setFill(fill);
set(player, session, new CircleBrush(player)).setSize(radius).setFill(fill);
}
@Command(
@ -211,14 +211,14 @@ public class BrushCommands {
"Note: Set a mask to recurse along specific blocks"
)
@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")
Expression radius,
@Switch(name = 'd', desc = "Apply in depth first order")
boolean depthFirst,
InjectedValueAccess context) throws WorldEditException {
boolean depthFirst) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new RecurseBrush(depthFirst))
set(player, session, new RecurseBrush(depthFirst))
.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")
boolean select,
@Switch(name = 'f', desc = "Create a flat line")
boolean flat, InjectedValueAccess context) throws WorldEditException {
boolean flat) throws WorldEditException {
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(
@ -252,13 +252,14 @@ public class BrushCommands {
"Tutorial: https://www.planetminecraft.com/blog/fawe-tutorial/"
)
@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")
Expression radius, InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
player.print(BBC.BRUSH_SPLINE.format(radius));
set(session, context,
new SplineBrush(player, session))
set(player, session,
new SplineBrush(player, session))
.setSize(radius)
.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"
)
@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());
set(session, context, new SweepBrush(copies));
set(player, session, new SweepBrush(copies));
}
@Command(
@ -283,7 +285,8 @@ public class BrushCommands {
desc = "Create a hanging line between two points"
)
@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")
Expression radius,
@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")
boolean select,
@Switch(name = 'd', desc = "sags the catenary toward the facing direction")
boolean facingDirection,
InjectedValueAccess context) throws WorldEditException {
boolean facingDirection) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor);
set(session, context,
new CatenaryBrush(shell, select, facingDirection, lengthFactor))
set(player, session,
new CatenaryBrush(shell, select, facingDirection, lengthFactor))
.setSize(radius)
.setFill(fill);
}
@ -311,11 +313,14 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.surfacespline") // 0, 0, 0, 10, 0,
public void surfaceSpline(Player player, LocalSession session, Pattern fill,
@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));
worldEdit.checkMaxBrushRadius(radius);
set(session, context,
new SurfaceSpline(tension, bias, continuity, quality))
set(player, session,
new SurfaceSpline(tension, bias, continuity, quality))
.setSize(radius)
.setFill(fill);
}
@ -326,11 +331,19 @@ public class BrushCommands {
desc = "Creates a distorted sphere"
)
@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());
worldEdit.checkMaxBrushRadius(max);
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(
@ -347,7 +360,7 @@ public class BrushCommands {
@Switch(name = 'h', desc = "Create hollow spheres instead")
boolean hollow,
@Switch(name = 'f', desc = "Create falling spheres instead")
boolean falling, InjectedValueAccess context) throws WorldEditException {
boolean falling) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
Brush brush;
if (hollow) {
@ -369,10 +382,7 @@ public class BrushCommands {
}
}
set(session, context,
brush)
.setSize(radius)
.setFill(pattern);
set(player, session, brush).setSize(radius).setFill(pattern);
}
@Command(
@ -383,13 +393,14 @@ public class BrushCommands {
"Pic: https://i.imgur.com/2xKsZf2.png"
)
@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")
Expression radius,
@Arg(desc = "Lines", def = "10") int count, InjectedValueAccess context) throws WorldEditException {
Expression radius,
@Arg(desc = "Lines", def = "10") int count) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context,
new ShatterBrush(count))
set(player, session,
new ShatterBrush(count))
.setSize(radius)
.setFill(fill)
.setMask(new ExistingBlockMask(editSession));
@ -402,13 +413,12 @@ public class BrushCommands {
)
@CommandPermissions("worldedit.brush.stencil")
public void stencilBrush(Player player, LocalSession session, Pattern fill,
@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 = 'w', desc = "Apply at maximum saturation") boolean onlyWhite,
@Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate,
InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
@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 = 'w', desc = "Apply at maximum saturation") boolean onlyWhite,
@Switch(name = 'r', desc = "Apply random rotation") boolean randomRotate) throws WorldEditException, FileNotFoundException {
worldEdit.checkMaxBrushRadius(radius);
InputStream stream = getHeightmapStream(image);
HeightBrush brush;
@ -420,8 +430,8 @@ public class BrushCommands {
if (randomRotate) {
brush.setRandomRotate(true);
}
set(session, context,
brush)
set(player, session,
brush)
.setSize(radius)
.setFill(fill);
}
@ -432,12 +442,16 @@ public class BrushCommands {
desc = "Use a height map to paint a surface",
descFooter = "Use a height map to paint any surface.\n")
@CommandPermissions("worldedit.brush.stencil")
public void imageBrush(LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
ProvideBindings.ImageUri imageUri,
@Arg(def = "1", desc = "scale height") @Range(min = Double.MIN_NORMAL) double yscale,
@Switch(name = 'a', desc = "Use image Alpha") boolean alpha,
@Switch(name = 'f', desc = "Blend the image with existing terrain") boolean fadeOut,
InjectedValueAccess context) throws WorldEditException, IOException {
public void imageBrush(Player player, LocalSession session,
@Arg(name = "radius", desc = "Expression", def = "5")
Expression radius,
ProvideBindings.ImageUri imageUri,
@Arg(def = "1", desc = "scale height") @Range(min = Double.MIN_NORMAL)
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();
worldEdit.checkMaxBrushRadius(radius);
if (yscale != 1) {
@ -449,9 +463,7 @@ public class BrushCommands {
alpha = true;
}
ImageBrush brush = new ImageBrush(image, session, alpha);
set(session, context,
brush)
.setSize(radius);
set(player, session, brush).setSize(radius);
}
@Command(
@ -463,12 +475,11 @@ public class BrushCommands {
"The -r flag will apply random rotation"
)
@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")
Expression radius,
InjectedValueAccess context) throws WorldEditException {
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radius);
set(player, session, new SurfaceSphereBrush()).setFill(fill).setSize(radius);
}
@Command(
@ -478,7 +489,11 @@ public class BrushCommands {
"Video: https://youtu.be/RPZIaTbqoZw?t=34s"
)
@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);
Brush brush;
if (overlay) {
@ -486,10 +501,7 @@ public class BrushCommands {
} else {
brush = new ScatterBrush((int) pointsOpt, (int) distanceOpt);
}
set(session, context,
brush)
.setSize(radius)
.setFill(fill);
set(player, session, brush).setSize(radius).setFill(fill);
}
@Command(
@ -498,7 +510,11 @@ public class BrushCommands {
desc = "Scatter a schematic on a surface"
)
@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);
try {
MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true);
@ -512,8 +528,8 @@ public class BrushCommands {
return;
}
set(session, context,
new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius);
set(player, session,
new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius);
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -527,9 +543,10 @@ public class BrushCommands {
"Pic: https://i.imgur.com/XV0vYoX.png"
)
@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);
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(
@ -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."
)
@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);
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(
@ -557,10 +578,12 @@ public class BrushCommands {
" - Placeholders: {x}, {y}, {z}, {world}, {size}"
)
@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);
set(session, context,
new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " ")))
set(player, session,
new ScatterCommand((int) points, (int) distance, StringMan.join(commandStr, " ")))
.setSize(radius);
}
@ -578,19 +601,17 @@ public class BrushCommands {
@Arg(desc = "The height of the cylinder", def = "1")
int height,
@Switch(name = 'h', desc = "Create hollow cylinders instead")
boolean hollow,
InjectedValueAccess context) throws WorldEditException {
boolean hollow) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(height);
BrushSettings settings;
if (hollow) {
settings = set(session, context, new HollowCylinderBrush(height));
settings = set(player, session, new HollowCylinderBrush(height));
} else {
settings = set(session, context, new CylinderBrush(height));
settings = set(player, session, new CylinderBrush(height));
}
settings.setSize(radius)
.setFill(pattern);
settings.setSize(radius).setFill(pattern);
}
@Command(
@ -603,20 +624,20 @@ public class BrushCommands {
)
@Deprecated
@CommandPermissions("worldedit.brush.clipboard")
public void clipboardBrush(Player player,LocalSession session,
@Switch(name = 'a', desc = "Don't paste air from the clipboard")
boolean ignoreAir,
@Switch(name = 'o', desc = "Paste starting at the target location, instead of centering on it")
boolean usingOrigin,
@Switch(name = 'e', desc = "Skip paste entities if available")
boolean skipEntities,
@Switch(name = 'b', desc = "Paste biomes if available")
boolean pasteBiomes,
@ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard", def = "")
@ClipboardMask
Mask sourceMask,
InjectedValueAccess context) throws WorldEditException {
public void clipboardBrush(Player player, LocalSession session,
@Switch(name = 'a', desc = "Don't paste air from the clipboard")
boolean ignoreAir,
@Switch(name = 'o', desc = "Paste starting at the target location, instead of centering on it")
boolean usingOrigin,
@Switch(name = 'e', desc = "Skip paste entities if available")
boolean skipEntities,
@Switch(name = 'b', desc = "Paste biomes if available")
boolean pasteBiomes,
@ArgFlag(name = 'm', desc = "Skip blocks matching this mask in the clipboard", def = "")
@ClipboardMask
Mask sourceMask) throws WorldEditException {
ClipboardHolder holder = session.getClipboard();
Clipboard clipboard = holder.getClipboard();
ClipboardHolder newHolder = new ClipboardHolder(clipboard);
newHolder.setTransform(holder.getTransform());
@ -627,7 +648,8 @@ public class BrushCommands {
worldEdit.checkMaxBrushRadius(size.getBlockY() / 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(
@ -637,19 +659,19 @@ public class BrushCommands {
)
@CommandPermissions("worldedit.brush.smooth")
public void smoothBrush(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The radius to sample for softening", def = "2")
Expression radius,
@Arg(desc = "The number of iterations to perform", def = "4")
int iterations,
@Arg(desc = "The mask of blocks to use for the heightmap", def = "")
Mask maskOpt, InjectedValueAccess context) throws WorldEditException {
@Arg(desc = "The radius to sample for softening", def = "2")
Expression radius,
@Arg(desc = "The number of iterations to perform", def = "4")
int iterations,
@Arg(desc = "The mask of blocks to use for the heightmap", def = "")
Mask maskOpt) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
FaweLimit limit = Settings.IMP.getLimit(player);
iterations = Math.min(limit.MAX_ITERATIONS, iterations);
set(session, context,
new SmoothBrush(iterations, maskOpt))
set(player, session,
new SmoothBrush(iterations, maskOpt))
.setSize(radius);
}
@ -660,16 +682,14 @@ public class BrushCommands {
)
@CommandPermissions("worldedit.brush.ex")
public void extinguishBrush(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The radius to extinguish", def = "5")
Expression radius,
InjectedValueAccess context) throws WorldEditException {
@Arg(desc = "The radius to extinguish", def = "5")
Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
Pattern fill = BlockTypes.AIR.getDefaultState();
set(session, context,
new SphereBrush())
set(player, session,
new SphereBrush())
.setSize(radius)
.setFill(fill)
.setFill(BlockTypes.AIR.getDefaultState())
.setMask(new SingleBlockTypeMask(editSession, BlockTypes.FIRE));
}
@ -681,15 +701,12 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.gravity")
public void gravityBrush(Player player, LocalSession session,
@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")
boolean fromMaxY,
InjectedValueAccess context) throws WorldEditException {
boolean fromMaxY) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(session, context,
new GravityBrush(fromMaxY))
.setSize(radius);
set(player, session, new GravityBrush(fromMaxY)).setSize(radius);
}
@Command(
@ -705,7 +722,7 @@ public class BrushCommands {
)
@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 {
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(
@ -730,7 +747,7 @@ public class BrushCommands {
boolean layers,
@Switch(name = 's', desc = "Disables smoothing")
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(
@ -746,10 +763,13 @@ public class BrushCommands {
boolean layers,
@Switch(name = 's', desc = "Disables smoothing")
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);
InputStream stream = getHeightmapStream(image);
HeightBrush brush;
@ -769,7 +789,7 @@ public class BrushCommands {
if (randomRotate) {
brush.setRandomRotate(true);
}
set(session, context,
set(player, session,
brush)
.setSize(radius);
}
@ -794,12 +814,15 @@ public class BrushCommands {
"Video: https://www.youtube.com/watch?v=RPZIaTbqoZw"
)
@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);
player.print(BBC.BRUSH_COPY.format(radius));
set(session, context,
new CopyPastaBrush(player, session, randomRotate, autoRotate))
set(player, session,
new CopyPastaBrush(player, session, randomRotate, autoRotate))
.setSize(radius);
}
@ -812,11 +835,13 @@ public class BrushCommands {
" - Placeholders: {x}, {y}, {z}, {world}, {size}"
)
@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);
String cmd = StringMan.join(input, " ");
set(session, context,
new CommandBrush(cmd))
set(player, session,
new CommandBrush(cmd))
.setSize(radius);
}
@ -826,25 +851,25 @@ public class BrushCommands {
desc = "Butcher brush, kills mobs within a radius"
)
@CommandPermissions("worldedit.brush.butcher")
public void butcherBrush(Player player, LocalSession session, InjectedValueAccess context,
@Arg(desc = "Radius to kill mobs in", def = "5")
Expression radius,
@Switch(name = 'p', desc = "Also kill pets")
boolean killPets,
@Switch(name = 'n', desc = "Also kill NPCs")
boolean killNpcs,
@Switch(name = 'g', desc = "Also kill golems")
boolean killGolems,
@Switch(name = 'a', desc = "Also kill animals")
boolean killAnimals,
@Switch(name = 'b', desc = "Also kill ambient mobs")
boolean killAmbient,
@Switch(name = 't', desc = "Also kill mobs with name tags")
boolean killWithName,
@Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)")
boolean killFriendly,
@Switch(name = 'r', desc = "Also destroy armor stands")
boolean killArmorStands) throws WorldEditException {
public void butcherBrush(Player player, LocalSession session,
@Arg(desc = "Radius to kill mobs in", def = "5")
Expression radius,
@Switch(name = 'p', desc = "Also kill pets")
boolean killPets,
@Switch(name = 'n', desc = "Also kill NPCs")
boolean killNpcs,
@Switch(name = 'g', desc = "Also kill golems")
boolean killGolems,
@Switch(name = 'a', desc = "Also kill animals")
boolean killAnimals,
@Switch(name = 'b', desc = "Also kill ambient mobs")
boolean killAmbient,
@Switch(name = 't', desc = "Also kill mobs with name tags")
boolean killWithName,
@Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)")
boolean killFriendly,
@Switch(name = 'r', desc = "Also destroy armor stands")
boolean killArmorStands) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
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.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 {
@ -873,11 +898,10 @@ public class BrushCommands {
return null;
}
public BrushSettings set(LocalSession session, InjectedValueAccess context, Brush brush) throws InvalidToolBindException {
Player plr = context.injectedValue(Key.of(Player.class))
.orElseThrow(() -> new IllegalStateException("No player"));
public BrushSettings set(Player player, LocalSession session,
Brush brush) throws InvalidToolBindException {
BrushSettings bs = new BrushSettings();
BrushTool tool = session.getBrushTool(plr, false);
BrushTool tool = session.getBrushTool(player, false);
if (tool != null) {
BrushSettings currentContext = tool.getContext();
if (currentContext != null) {
@ -896,14 +920,14 @@ public class BrushCommands {
)
@CommandPermissions("worldedit.brush.forest")
public void forest(Player player, LocalSession localSession,
@Arg(desc = "The shape of the region")
RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5")
Expression radius,
@Arg(desc = "The density of the brush", def = "20")
double density,
@Arg(desc = "The type of tree to use")
TreeGenerator.TreeType type) throws WorldEditException, EvaluationException {
@Arg(desc = "The shape of the region")
RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5")
Expression radius,
@Arg(desc = "The density of the brush", def = "20")
double density,
@Arg(desc = "The type of tree to use")
TreeGenerator.TreeType type) throws WorldEditException, EvaluationException {
setOperationBasedBrush(player, localSession, radius,
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")
RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5")
Expression radius) throws WorldEditException, EvaluationException {
Expression radius) throws WorldEditException, EvaluationException {
setOperationBasedBrush(player, localSession, radius,
new Deform("y+=1"), shape, "worldedit.brush.lower");
}

Datei anzeigen

@ -47,6 +47,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import java.io.File;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import org.enginehub.piston.annotation.Command;
@ -93,45 +94,51 @@ public class HistoryCommands {
return;
}
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY);
if (!folder.exists()) {
return;
}
for (File worldFolder : folder.listFiles()) {
if (!worldFolder.isDirectory()) {
continue;
}
String worldName = worldFolder.getName();
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")) {
if (folder.exists()) {
for (File worldFolder : Objects.requireNonNull(folder.listFiles())) {
if (worldFolder != null && worldFolder.isDirectory()) {
String worldName = worldFolder.getName();
World world = FaweAPI.getWorld(worldName);
if (world != null) {
for (File userFolder : worldFolder.listFiles()) {
if (!userFolder.isDirectory()) {
continue;
}
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);
String userUUID = userFolder.getName();
try {
UUID uuid = UUID.fromString(userUUID);
for (File historyFile : userFolder.listFiles()) {
String name = historyFile.getName();
if (!name.endsWith(".bd")) {
continue;
}
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;
}
String toParse = user.substring(1);

Datei anzeigen

@ -110,6 +110,9 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
parserContext.setWorld((World) extent);
}
parserContext.setExtent(new RequestExtent());
} else if (session.hasWorldOverride()) {
parserContext.setWorld(session.getWorldOverride());
parserContext.setExtent(new RequestExtent());
}
parserContext.setSession(session);
parserContext.setRestricted(true);

Datei anzeigen

@ -30,7 +30,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
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.
@ -55,7 +55,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
try (EditSession editSession = session.createEditSession(player)) {
try {
BlockVector3 position = clicked.toVector().toBlockPoint();
editSession.setBlock(position, pattern.apply(position));
editSession.setBlock(position, pattern);
} catch (MaxChangedBlocksException ignored) {
} finally {
session.remember(editSession);
@ -72,8 +72,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
EditSession editSession = session.createEditSession(player);
BlockState targetBlock = editSession.getBlock(clicked.toVector().toBlockPoint());
BaseBlock targetBlock = player.getWorld().getFullBlock(clicked.toVector().toBlockPoint());
if (targetBlock != null) {
pattern = targetBlock;

Datei anzeigen

@ -91,7 +91,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
}
protected static int MAX_RANGE = 500;
protected static int DEFAULT_RANGE = 240;
protected int range = -1;
private VisualMode visualMode = VisualMode.NONE;
private TargetMode targetMode = TargetMode.TARGET_BLOCK_RANGE;
@ -178,7 +177,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
if (targetMode != TargetMode.TARGET_BLOCK_RANGE) {
map.put("target", targetMode);
}
if (range != -1 && range != DEFAULT_RANGE) {
if (range != -1 && range != MAX_RANGE) {
map.put("range", range);
}
if (targetOffset != 0) {
@ -312,7 +311,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
* @return the mask used to stop block traces
*/
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
*/
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
*/
public void setRange(int range) {
if (range == DEFAULT_RANGE) {
this.range = -1;
} else {
this.range = range;
}
this.range = range;
}
@Override
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) {
@ -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) {
case PRIMARY:
setContext(primary);
@ -499,14 +494,14 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
return false;
}
try (EditSession editSession = session.createEditSession(player)) {
BlockVector3 target = getPosition(editSession, player);
Location target = player.getBlockTrace(getRange(), true, traceMask);
if (target == null) {
editSession.cancel();
BBC.NO_BLOCK.send(player);
player.print(BBC.NO_BLOCK.s());
return true;
}
BlockBag bag = editSession.getBlockBag();
BlockBag bag = session.getBlockBag(player);
Request.request().setEditSession(editSession);
Mask mask = current.getMask();
@ -536,7 +531,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
new PatternTraverser(current).reset(editSession);
double size = current.getSize();
WorldEdit.getInstance().checkMaxBrushRadius(size);
brush.build(editSession, target, current.getMaterial(), size);
brush.build(editSession, target.toBlockPoint(), current.getMaterial(), size);
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
@ -554,7 +549,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
@Override
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;
}
public void queueVisualization(Player fp) {
Fawe.get().getVisualQueue().queue(fp);
public void queueVisualization(Player player) {
Fawe.get().getVisualQueue().queue(player);
}
@Deprecated

Datei anzeigen

@ -27,42 +27,42 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.Location;
public class NavigationWand implements DoubleActionTraceTool {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
return false;
}
final int maxDist = config.navigationWandMaxDistance;
if (maxDist <= 0) {
return false;
}
Location pos = player.getSolidBlockTrace(maxDist);
if (pos != null) {
player.findFreePosition(pos);
} else {
player.printError("No block in sight (or too far)!");
}
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;
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
return false;
}
final int maxDist = config.navigationWandMaxDistance;
if (maxDist <= 0) {
return false;
}
Location pos = player.getSolidBlockTrace(maxDist);
if (pos != null) {
player.findFreePosition(pos);
} else {
player.printError("No block in sight (or too far)!");
}
return true;
}
if (!player.passThroughForwardWall(Math.max(1, maxDist - 10))) {
player.printError("Nothing to pass through (or too far)!");
}
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;
}
@Override
public boolean canUse(Actor actor) {
return true; // skip check here - checked separately for primary/secondary
}
if (!player.passThroughForwardWall(Math.max(1, maxDist - 10))) {
player.printError("Nothing to pass through (or too far)!");
}
return true;
}
@Override
public boolean canUse(Actor actor) {
return true; // skip check here - checked separately for primary/secondary
}
}

Datei anzeigen

@ -55,7 +55,7 @@ public class QueryTool implements BlockTool {
builder.append(TextComponent.of("@" + clicked.toVector().toBlockPoint() + ": ", TextColor.BLUE));
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW));
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());
if (internalId.isPresent()) {
@ -64,8 +64,8 @@ public class QueryTool implements BlockTool {
}
*/
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/"
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above"))));
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above"))));
player.print(builder.build());

Datei anzeigen

@ -20,11 +20,9 @@
package com.sk89q.worldedit.command.tool;
import com.boydti.fawe.object.mask.IdMask;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
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.BlockTypes;
import java.util.Set;
/**
* A pickaxe mode that recursively finds adjacent blocks within range of
* an initial block and of the same type.

Datei anzeigen

@ -34,8 +34,8 @@ public class SelectionWand implements DoubleActionBlockTool {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
RegionSelector selector = session.getRegionSelector(player.getWorld());
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
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) {
RegionSelector selector = session.getRegionSelector(player.getWorld());
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
selector.explainSecondarySelection(player, session, blockPoint);
}

Datei anzeigen

@ -64,10 +64,10 @@ public class TreePlanter implements BlockTool {
}
if (!successful) {
BBC.TOOL_TREE_ERROR_BLOCK.send(player);
player.printError(BBC.TOOL_TREE_ERROR_BLOCK.s());
}
} catch (MaxChangedBlocksException e) {
BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES.send(player);
player.printError(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES.s());
} finally {
session.remember(editSession);
}

Datei anzeigen

@ -21,7 +21,6 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockTypes;

Datei anzeigen

@ -21,7 +21,6 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockTypes;

Datei anzeigen

@ -19,6 +19,9 @@
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.NamespacedRegistry;
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.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@ -37,9 +39,6 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
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.
*/
@ -140,12 +139,12 @@ public final class SuggestionHelper {
public static <V extends Keyed> Stream<String> getRegistrySuggestions(Registry<V> registry, String input) {
if (registry instanceof NamespacedRegistry) {
return getNamespacedRegistrySuggestions(((NamespacedRegistry<?>) registry), input);
return getNamespacedRegistrySuggestions(((NamespacedRegistry<V>) registry), input);
}
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(":")) {
final Set<String> namespaces = registry.getKnownNamespaces();
if (namespaces.size() == 1) {

Datei anzeigen

@ -60,7 +60,9 @@ import com.sk89q.worldedit.world.block.FuzzyBlockState;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -73,10 +75,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
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) {
try {
return ((Player) actor).getBlockInHand(handSide).toImmutableState();
return ((Player) actor).getBlockInHand(handSide);
} catch (NotABlockException e) {
throw new InputParseException("You're not holding a block!");
} 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.
*
@ -163,7 +167,9 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
}
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]);
BlockState state = null;
@ -171,8 +177,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
// Legacy matcher
if (context.isTryingLegacy()) {
try {
String[] split = blockAndExtraData[0].split(":");
if (split.length == 1) {
String[] split = blockAndExtraData[0].split(":", 2);
if (split.length == 0) {
throw new InputParseException("Invalid colon.");
} else if (split.length == 1) {
state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]));
} else if (MathMan.isInteger(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);
}
}
} catch (NumberFormatException e) {
} catch (NumberFormatException ignored) {
}
}
@ -204,58 +212,83 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
typeString = blockAndExtraData[0];
} else {
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);
}
if (typeString.isEmpty()) {
throw new InputParseException("Invalid format");
}
// PosX
if (typeString.matches("pos[0-9]+")) {
String[] stateProperties = EMPTY_STRING_ARRAY;
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]+", ""));
// Get the block type from the "primary position"
final World world = context.requireWorld();
final BlockVector3 primaryPosition;
try {
primaryPosition = context.requireSession().getRegionSelector(world).getVertices().get(index - 1);
primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
} catch (IncompleteRegionException e) {
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 {
if ("hand".equalsIgnoreCase(typeString)) {
// 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);
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT));
if (!item.getType().hasBlockType()) {
throw new InputParseException("You're not holding a block!");
}
state = item.getType().getBlockType().getDefaultState();
nbt = item.getNbtData();
} else {
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 (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();

Datei anzeigen

@ -26,7 +26,6 @@ import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.BlockCategoryMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.session.request.RequestExtent;
import com.sk89q.worldedit.world.block.BlockCategory;
import java.util.Locale;

Datei anzeigen

@ -26,7 +26,6 @@ import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.session.request.RequestExtent;
import com.sk89q.worldedit.world.block.BaseBlock;
import java.util.Set;

Datei anzeigen

@ -24,8 +24,6 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector2;
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.block.BlockStateHolder;
@ -52,16 +50,12 @@ public interface OutputExtent {
* @param block block to set
* @return true if the block was successfully set (return value may not be accurate)
* @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
default <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
return setBlock(position.getX(), position.getY(), position.getZ(), block);
}
<T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException;
default <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return setBlock(MutableBlockVector3.get(x, y, z), block);
}
<T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) 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
* @return true if the biome was successfully set (return value may not be accurate)
*/
default boolean setBiome(BlockVector2 position, BiomeType biome) {
return setBiome(position.getX(), 0, position.getBlockZ(), biome);
}
boolean setBiome(BlockVector2 position, BiomeType biome);
default boolean setBiome(int x, int y, int z, BiomeType biome) {
return setBiome(MutableBlockVector2.get(x, z), biome);
}
boolean setBiome(int x, int y, int z, BiomeType biome);
/**
* Return an {@link Operation} that should be called to tie up loose ends

Datei anzeigen

@ -175,6 +175,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
return getExtent().getBlockDistributionWithData(region);
}
@Override
@Nullable
public Operation commit() {
return getExtent().commit();
@ -271,6 +272,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
return getExtent().setBlock(position, block);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return getExtent().setBlock(x, y, z, block);
}
@ -285,6 +287,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
return getExtent().setBiome(position, biome);
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
return getExtent().setBiome(x, y, z, biome);
}

Datei anzeigen

@ -25,16 +25,20 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
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.pattern.BiomePattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.AbstractRegion;
import com.sk89q.worldedit.regions.Region;
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.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Iterator;
import java.util.LinkedHashMap;
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
* 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<BlockVector2, BiomeType> biomeBuffer = new LinkedHashMap<>();
private final Mask mask;
private final Mask2D biomeMask;
private BlockVector3 min = null;
private BlockVector2 min2d = null;
private BlockVector3 max = null;
private BlockVector2 max2d = null;
/**
* Create a new extent buffer that will buffer every change.
@ -79,6 +87,8 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
checkNotNull(delegate);
checkNotNull(mask);
this.mask = mask;
Mask2D bmask = mask.toMask2D();
this.biomeMask = bmask == null ? Masks.alwaysTrue2D() : bmask;
}
@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
public BaseBlock apply(BlockVector3 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.
*
@ -151,6 +219,10 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat
public Iterator<BlockVector3> iterator() {
return buffer.keySet().iterator();
}
public Iterable<BlockVector2> asFlatRegion() {
return biomeBuffer.keySet();
}
};
}
}

Datei anzeigen

@ -216,6 +216,7 @@ public class BlockArrayClipboard implements Clipboard, Closeable {
return false;
}
@Override
public boolean setTile(int x, int y, int z, CompoundTag tag) {
x -= mx;
y -= my;

Datei anzeigen

@ -19,10 +19,27 @@
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.util.ReflectionUtils;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag;
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.PropertyKey;
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.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
/**
* 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) {
long mask = 0;
for (Direction dir : directions) {
mask = mask | (1L << dir.ordinal());
}
return mask;
return Arrays.stream(directions).mapToLong(dir -> (1L << dir.ordinal()))
.reduce(0, (a, b) -> a | b);
}
private static long[] adapt(Direction... dirs) {
@ -497,7 +509,7 @@ public class BlockTransformExtent extends ResettableExtent {
}
@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));
}
}

Datei anzeigen

@ -23,11 +23,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.math.BlockVector3;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* Executes several region functions in order.
@ -49,7 +47,7 @@ public class CombinedRegionFunction implements RegionFunction {
*/
public CombinedRegionFunction(Collection<RegionFunction> 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);
ArrayList<RegionFunction> functionsList = new ArrayList<>(Arrays.asList(this.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;
}
}
}

Datei anzeigen

@ -35,4 +35,5 @@ public interface RegionFunction {
* @throws WorldEditException thrown on an error
*/
boolean apply(BlockVector3 position) throws WorldEditException;
}

Datei anzeigen

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.pattern.BiomePattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.world.biome.BiomeType;
@ -33,7 +34,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
public class BiomeReplace implements FlatRegionFunction {
private final Extent extent;
private BiomeType biome;
private BiomePattern biome;
/**
* Create a new instance.
@ -42,15 +43,25 @@ public class BiomeReplace implements FlatRegionFunction {
* @param biome a 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(biome);
checkNotNull(pattern);
this.extent = extent;
this.biome = biome;
this.biome = pattern;
}
@Override
public boolean apply(BlockVector2 position) throws WorldEditException {
return extent.setBiome(position, biome);
return extent.setBiome(position, biome.apply(position));
}
}

Datei anzeigen

@ -50,7 +50,7 @@ public class BlockReplace implements RegionFunction {
@Override
public boolean apply(BlockVector3 position) throws WorldEditException {
return pattern.apply(extent, position, position);
return extent.setBlock(position, pattern.apply(position));
}
}

Datei anzeigen

@ -80,7 +80,14 @@ public class Naturalizer implements LayerFunction {
}
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

Datei anzeigen

@ -157,10 +157,10 @@ public class ExtentEntityCopy implements EntityFunction {
BlockVector3 newLeash = transform.apply(tilePosition.subtract(from)).add(to).toBlockPoint();
return new BaseEntity(state.getType(), tag.createBuilder()
.put("Leash", leashCompound.createBuilder()
.putInt("X", newLeash.getBlockX())
.putInt("Y", newLeash.getBlockY())
.putInt("Z", newLeash.getBlockZ())
.build()
.putInt("X", newLeash.getBlockX())
.putInt("Y", newLeash.getBlockY())
.putInt("Z", newLeash.getBlockZ())
.build()
).build());
}
}

Datei anzeigen

@ -53,7 +53,7 @@ public class ForestGenerator implements RegionFunction {
BlockState block = editSession.getBlock(position);
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));
} else if (t.getMaterial().isReplacedDuringPlacement()) {
// since the implementation's tree generators generally don't generate in non-air spots,

Datei anzeigen

@ -69,6 +69,7 @@ public class BlockMask extends ABlockMask {
@Deprecated
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
this(extent);
checkNotNull(blocks);
add(blocks);
}
@ -149,9 +150,8 @@ public class BlockMask extends ABlockMask {
*/
@Deprecated
public void add(Collection<BaseBlock> blocks) {
for (BaseBlock block : blocks) {
add(block.toBlockState());
}
checkNotNull(blocks);
blocks.forEach(baseBlock -> add(baseBlock.toBlockState()));
}
/**
@ -235,7 +235,7 @@ public class BlockMask extends ABlockMask {
setType = type;
setStates += all.size();
setState = type.getDefaultState();
} else if (hasAny) {
} else {
for (BlockState state : all) {
if (test(state)) {
setStates++;
@ -244,8 +244,6 @@ public class BlockMask extends ABlockMask {
unsetState = state;
}
}
} else {
unsetType = type;
}
}
}
@ -269,11 +267,7 @@ public class BlockMask extends ABlockMask {
}
if (setTypes == totalTypes - 1) {
if (unsetType != null) {
return new InverseSingleBlockTypeMask(getExtent(), unsetType);
} else {
throw new IllegalArgumentException("unsetType cannot be null when passed to InverseSingleBlockTypeMask");
}
throw new IllegalArgumentException("unsetType cannot be null when passed to InverseSingleBlockTypeMask");
}
return null;

Datei anzeigen

@ -55,4 +55,5 @@ public class BoundedHeightMask extends AbstractMask {
public Mask2D toMask2D() {
return null;
}
}

Datei anzeigen

@ -40,7 +40,7 @@ public class ExistingBlockMask extends AbstractExtentMask {
@Override
public boolean test(BlockVector3 vector) {
return !vector.getBlock(getExtent()).getMaterial().isAir();
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
}
@Nullable

Datei anzeigen

@ -38,17 +38,6 @@ public interface Mask {
*/
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) {
return new DelegateFilter<T>(filter) {
@Override

Datei anzeigen

@ -37,7 +37,6 @@ import java.util.Set;
import java.util.function.Function;
import javax.annotation.Nullable;
/**
* Combines several masks and requires that all masks return true
* when a certain position is tested. It serves as a logical AND operation
@ -223,6 +222,10 @@ public class MaskIntersection extends AbstractMask {
@Override
public boolean test(BlockVector3 vector) {
if (masksArray.length == 0) {
return false;
}
for (Mask mask : masksArray) {
if (!mask.test(vector)) {
return false;

Datei anzeigen

@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.mask;
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.BlockVector3;
@ -32,8 +31,8 @@ import javax.annotation.Nullable;
*/
public final class Masks {
protected static final AlwaysTrue ALWAYS_TRUE = new AlwaysTrue();
protected static final AlwaysFalse ALWAYS_FALSE = new AlwaysFalse();
static final AlwaysTrue ALWAYS_TRUE = new AlwaysTrue();
static final AlwaysFalse ALWAYS_FALSE = new AlwaysFalse();
private Masks() {
}

Datei anzeigen

@ -21,7 +21,6 @@ package com.sk89q.worldedit.function.mask;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;

Datei anzeigen

@ -70,4 +70,5 @@ public class RegionMask extends AbstractMask {
public Mask2D toMask2D() {
return null;
}
}

Datei anzeigen

@ -66,16 +66,15 @@ public class ChangeSetExecutor implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
Change change = iterator.next();
if (type == Type.UNDO) {
while (iterator.hasNext()) {
while (iterator.hasNext()) {
Change change = iterator.next();
if (type == Type.UNDO) {
change.undo(context);
}
} else {
while (iterator.hasNext()) {
} else {
change.redo(context);
}
}
return null;
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -67,4 +67,5 @@ public class BlockPattern extends AbstractPattern {
public BaseBlock apply(BlockVector3 position) {
return block;
}
}

Datei anzeigen

@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.pattern;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -64,9 +65,10 @@ public class WaterloggedRemover extends AbstractExtentPattern {
@Override
public BaseBlock apply(BlockVector3 position) {
BaseBlock block = getExtent().getFullBlock(position);
BlockState newState = remap[block.getOrdinal()];
if (newState != null) {
return newState.toBaseBlock(block.getNbtData());
@SuppressWarnings("unchecked")
Property<Object> prop = (Property<Object>) remap[block.getOrdinal()].getBlockType().getPropertyMap().getOrDefault("waterlogged", null);
if (prop != null) {
return block.with(prop, false);
}
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}

Datei anzeigen

@ -78,9 +78,9 @@ public abstract class BreadthFirstSearch implements Operation {
}
private final RegionFunction function;
private BlockVectorSet queue = new BlockVectorSet();
private BlockVectorSet visited = new BlockVectorSet();
private BlockVector3[] directions;
private BlockVectorSet visited;
private BlockVectorSet queue;
private int affected = 0;
private int currentDepth = 0;
private final int maxDepth;
@ -98,8 +98,6 @@ public abstract class BreadthFirstSearch implements Operation {
public BreadthFirstSearch(RegionFunction function, int maxDepth) {
checkNotNull(function);
this.queue = new BlockVectorSet();
this.visited = new BlockVectorSet();
this.function = function;
this.directions = DEFAULT_DIRECTIONS;
this.maxDepth = maxDepth;
@ -121,6 +119,8 @@ public abstract class BreadthFirstSearch implements Operation {
* unit vectors. An example of a valid direction is
* {@code BlockVector3.at(1, 0, 1)}.</p>
*
* <p>The list of directions can be cleared.</p>
*
* @return the list of directions
*/
public Collection<BlockVector3> getDirections() {
@ -260,6 +260,7 @@ public abstract class BreadthFirstSearch implements Operation {
tmp.clear();
tempQueue = tmp;
}
return null;
}

Datei anzeigen

@ -70,6 +70,7 @@ public class FlatRegionVisitor implements Operation {
affected++;
}
}
return null;
}

Datei anzeigen

@ -20,14 +20,12 @@
package com.sk89q.worldedit.function.visitor;
import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.RunContext;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import java.util.List;
/**
@ -42,17 +40,12 @@ public class RegionVisitor implements Operation {
public int affected = 0;
public final Iterable<? extends BlockVector3> iterable;
/**
* Deprecated in favor of the other constructors which will preload chunks during iteration
*
* @param region
* @param function
*/
@Deprecated
public RegionVisitor(Region region, RegionFunction function) {
this((Iterable<BlockVector3>) region, function);
}
@Deprecated
public RegionVisitor(Iterable<BlockVector3> iterable, RegionFunction function) {
this.region = iterable instanceof Region ? (Region) iterable : null;
this.function = function;
@ -75,6 +68,7 @@ public class RegionVisitor implements Operation {
affected++;
}
}
return null;
}

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen