Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-08 04:20:06 +01:00
resolve conflicts
Dieser Commit ist enthalten in:
Ursprung
dd38cbe750
Commit
be8213d8ee
24
build.gradle
24
build.gradle
@ -38,14 +38,13 @@ println """
|
|||||||
*******************************************
|
*******************************************
|
||||||
"""
|
"""
|
||||||
|
|
||||||
allprojects {
|
group = 'com.boydti.fawe'
|
||||||
group = 'com.boydti.fawe'
|
|
||||||
|
|
||||||
def rootVersion = "1.13"
|
def rootVersion = "1.14"
|
||||||
def revision = ""
|
def revision = ""
|
||||||
def buildNumber = ""
|
def buildNumber = ""
|
||||||
def date = ""
|
def date = ""
|
||||||
ext {
|
ext {
|
||||||
git = Grgit.open(dir: '.git')
|
git = Grgit.open(dir: '.git')
|
||||||
date = git.head().getDate().format("yy.MM.dd")
|
date = git.head().getDate().format("yy.MM.dd")
|
||||||
revision = "-${git.head().abbreviatedId}"
|
revision = "-${git.head().abbreviatedId}"
|
||||||
@ -57,8 +56,6 @@ allprojects {
|
|||||||
for (; parents != null && !parents.isEmpty(); index++) {
|
for (; parents != null && !parents.isEmpty(); index++) {
|
||||||
parents = git.getResolve().toCommit(parents.get(0)).getParentIds()
|
parents = git.getResolve().toCommit(parents.get(0)).getParentIds()
|
||||||
}
|
}
|
||||||
buildNumber = "${index}"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version = String.format("%s.%s", rootVersion, buildNumber)
|
version = String.format("%s.%s", rootVersion, buildNumber)
|
||||||
@ -85,6 +82,12 @@ subprojects {
|
|||||||
maven { url "http://repo.spongepowered.org/maven" }
|
maven { url "http://repo.spongepowered.org/maven" }
|
||||||
maven { url "http://dl.bintray.com/tastybento/maven-repo" }
|
maven { url "http://dl.bintray.com/tastybento/maven-repo" }
|
||||||
maven { url "http://ci.emc.gs/nexus/content/groups/aikar/" }
|
maven { url "http://ci.emc.gs/nexus/content/groups/aikar/" }
|
||||||
|
ivy {
|
||||||
|
url 'https://ci.athion.net/job'
|
||||||
|
layout 'pattern', {
|
||||||
|
artifact '/[organisation]/[module]/artifact/[revision].[ext]'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
configurations.all {
|
configurations.all {
|
||||||
resolutionStrategy {
|
resolutionStrategy {
|
||||||
@ -165,6 +168,9 @@ configure(['bukkit'].collect { project(":worldedit-$it") }) {
|
|||||||
// include '**/*.java'
|
// include '**/*.java'
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
task aggregatedJavadocs(type: Javadoc, description: 'Generate javadocs from all child projects as if it was a single project', group: 'Documentation') {
|
task aggregatedJavadocs(type: Javadoc, description: 'Generate javadocs from all child projects as if it was a single project', group: 'Documentation') {
|
||||||
destinationDir = file("./docs/javadoc")
|
destinationDir = file("./docs/javadoc")
|
||||||
title = "$project.name $version API"
|
title = "$project.name $version API"
|
||||||
|
@ -16,27 +16,30 @@ configurations.all { Configuration it ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compile ('net.milkbowl.vault:VaultAPI:1.7')
|
||||||
api project(':worldedit-core')
|
api project(':worldedit-core')
|
||||||
api project(':worldedit-libs:bukkit')
|
api project(':worldedit-libs:bukkit')
|
||||||
compileOnly 'net.milkbowl.vault:VaultAPI:1.7'
|
|
||||||
compileOnly 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT'
|
|
||||||
implementation 'io.papermc:paperlib:1.0.2'
|
|
||||||
compileOnly 'com.sk89q:dummypermscompat:1.10'
|
compileOnly 'com.sk89q:dummypermscompat:1.10'
|
||||||
compileOnly 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT'
|
|
||||||
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.8.1'
|
|
||||||
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
||||||
compileOnly 'com.massivecraft:factions:2.8.0'
|
implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.8.1'){transitive = false}
|
||||||
compileOnly 'com.drtshock:factions:1.6.9.5'
|
compileOnly 'com.destroystokyo.paper:paper-api:1.14.3-R0.1-SNAPSHOT'
|
||||||
compileOnly 'com.factionsone:FactionsOne:1.2.2'
|
implementation('io.papermc:paperlib:1.0.2'){transitive = false}
|
||||||
compileOnly 'me.ryanhamshire:GriefPrevention:11.5.2'
|
compileOnly 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT'
|
||||||
compileOnly 'com.massivecraft:mcore:7.0.1'
|
compileOnly 'BuildTools:lastSuccessfulBuild:spigot-1.14.3@jar'
|
||||||
compileOnly 'net.sacredlabyrinth.Phaed:PreciousStones:10.0.4-SNAPSHOT'
|
implementation('com.sk89q.worldguard:worldguard-core:7.0.0-20190215.210421-39'){transitive = false}
|
||||||
compileOnly 'net.jzx7:regios:5.9.9'
|
implementation('com.sk89q.worldguard:worldguard-legacy:7.0.0-20190215.210421-39'){transitive = false}
|
||||||
compileOnly 'com.bekvon.bukkit.residence:Residence:4.5._13.1'
|
implementation('com.massivecraft:factions:2.8.0'){transitive = false}
|
||||||
compileOnly 'com.palmergames.bukkit:towny:0.84.0.9'
|
implementation('com.drtshock:factions:1.6.9.5'){transitive = false}
|
||||||
compileOnly 'com.thevoxelbox.voxelsniper:voxelsniper:5.171.0'
|
implementation('com.factionsone:FactionsOne:1.2.2'){transitive = false}
|
||||||
compileOnly 'com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT'
|
implementation('me.ryanhamshire:GriefPrevention:11.5.2'){transitive = false}
|
||||||
compileOnly 'com.wasteofplastic:askyblock:3.0.8.2'
|
implementation('com.massivecraft:mcore:7.0.1'){transitive = false}
|
||||||
|
implementation('net.sacredlabyrinth.Phaed:PreciousStones:10.0.4-SNAPSHOT'){transitive = false}
|
||||||
|
implementation('net.jzx7:regios:5.9.9'){transitive = false}
|
||||||
|
implementation('com.bekvon.bukkit.residence:Residence:4.5._13.1'){transitive = false}
|
||||||
|
implementation('com.palmergames.bukkit:towny:0.84.0.9'){transitive = false}
|
||||||
|
implementation('com.thevoxelbox.voxelsniper:voxelsniper:5.171.0'){transitive = false}
|
||||||
|
implementation('com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT'){transitive = false}
|
||||||
|
implementation('com.wasteofplastic:askyblock:3.0.8.2'){transitive = false}
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
@ -199,9 +199,9 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
|
|
||||||
// We have to restore the block if it was outside
|
// We have to restore the block if it was outside
|
||||||
if (!region.contains(pt)) {
|
if (!region.contains(pt)) {
|
||||||
editSession.smartSetBlock(pt, history[index]);
|
editSession.setBlock(pt, history[index]);
|
||||||
} else { // Otherwise fool with history
|
} else { // Otherwise fool with history
|
||||||
editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
|
editSession.setBlock().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -448,11 +448,6 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public com.sk89q.worldedit.world.block.BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return getBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||||
import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2;
|
import com.boydti.fawe.bukkit.v1_14.adapter.Spigot_v1_14_R1;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
@ -144,8 +144,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
|||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
if (lookupNames != null) {
|
if (lookupNames != null) {
|
||||||
lookupNames.putIfAbsent("FastAsyncWorldEdit".toLowerCase(Locale.ENGLISH), this);
|
lookupNames.putIfAbsent("FastAsyncWorldEdit".toLowerCase(Locale.ROOT), this);
|
||||||
lookupNames.putIfAbsent("WorldEdit".toLowerCase(Locale.ENGLISH), this);
|
lookupNames.putIfAbsent("WorldEdit".toLowerCase(Locale.ROOT), this);
|
||||||
lookupNames.putIfAbsent("FastAsyncWorldEdit", this);
|
lookupNames.putIfAbsent("FastAsyncWorldEdit", this);
|
||||||
lookupNames.putIfAbsent("WorldEdit", this);
|
lookupNames.putIfAbsent("WorldEdit", this);
|
||||||
rename();
|
rename();
|
||||||
@ -203,13 +203,13 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
|||||||
|
|
||||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
|
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
|
||||||
|
|
||||||
// Register 1.13 Material ids with LegacyMapper
|
// // Register 1.13 Material ids with LegacyMapper
|
||||||
LegacyMapper legacyMapper = LegacyMapper.getInstance();
|
// LegacyMapper legacyMapper = LegacyMapper.getInstance();
|
||||||
for (Material m : Material.values()) {
|
// for (Material m : Material.values()) {
|
||||||
if (!m.isLegacy() && m.isBlock()) {
|
// if (!m.isLegacy() && m.isBlock()) {
|
||||||
legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState());
|
// legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
PaperLib.suggestPaper(this);
|
PaperLib.suggestPaper(this);
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
|||||||
public void setupRegistries() {
|
public void setupRegistries() {
|
||||||
// Biome
|
// Biome
|
||||||
for (Biome biome : Biome.values()) {
|
for (Biome biome : Biome.values()) {
|
||||||
BiomeType.REGISTRY.register("minecraft:" + biome.name().toLowerCase(), new BiomeType("minecraft:" + biome.name().toLowerCase()));
|
BiomeType.REGISTRY.register("minecraft:" + biome.name().toLowerCase(Locale.ROOT), new BiomeType("minecraft:" + biome.name().toLowerCase(Locale.ROOT)));
|
||||||
}
|
}
|
||||||
// Block & Item
|
// Block & Item
|
||||||
for (Material material : Material.values()) {
|
for (Material material : Material.values()) {
|
||||||
@ -254,7 +254,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
|||||||
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
|
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
|
||||||
String mcid = entityType.getName();
|
String mcid = entityType.getName();
|
||||||
if (mcid != null) {
|
if (mcid != null) {
|
||||||
EntityType.REGISTRY.register("minecraft:" + mcid.toLowerCase(), new EntityType("minecraft:" + mcid.toLowerCase()));
|
EntityType.REGISTRY.register("minecraft:" + mcid.toLowerCase(Locale.ROOT), new EntityType("minecraft:" + mcid.toLowerCase(Locale.ROOT)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
|||||||
}
|
}
|
||||||
File pluginsFolder = MainUtil.getJarFile().getParentFile();
|
File pluginsFolder = MainUtil.getJarFile().getParentFile();
|
||||||
for (File file : pluginsFolder.listFiles()) {
|
for (File file : pluginsFolder.listFiles()) {
|
||||||
if (file.length() == 2016) return;
|
if (file.length() == 2009) return;
|
||||||
}
|
}
|
||||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit");
|
Plugin plugin = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit");
|
||||||
File dummy = MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "DummyFawe.jar");
|
File dummy = MainUtil.copyFile(MainUtil.getJarFile(), "DummyFawe.src", pluginsFolder, "DummyFawe.jar");
|
||||||
@ -330,7 +330,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
|||||||
// Attempt to load a Bukkit adapter
|
// Attempt to load a Bukkit adapter
|
||||||
BukkitImplLoader adapterLoader = new BukkitImplLoader();
|
BukkitImplLoader adapterLoader = new BukkitImplLoader();
|
||||||
try {
|
try {
|
||||||
adapterLoader.addClass(Spigot_v1_13_R2.class);
|
adapterLoader.addClass(Spigot_v1_14_R1.class);
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ import org.bukkit.block.data.BlockData;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public interface IBukkitAdapter {
|
public interface IBukkitAdapter {
|
||||||
@ -205,7 +207,7 @@ public interface IBukkitAdapter {
|
|||||||
if (!itemType.getId().startsWith("minecraft:")) {
|
if (!itemType.getId().startsWith("minecraft:")) {
|
||||||
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
|
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
|
||||||
}
|
}
|
||||||
return Material.getMaterial(itemType.getId().substring(10).toUpperCase());
|
return Material.getMaterial(itemType.getId().substring(10).toUpperCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,7 +221,7 @@ public interface IBukkitAdapter {
|
|||||||
if (!blockType.getId().startsWith("minecraft:")) {
|
if (!blockType.getId().startsWith("minecraft:")) {
|
||||||
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
|
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
|
||||||
}
|
}
|
||||||
String id = blockType.getId().substring(10).toUpperCase();
|
String id = blockType.getId().substring(10).toUpperCase(Locale.ROOT);
|
||||||
return Material.getMaterial(id);
|
return Material.getMaterial(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +233,7 @@ public interface IBukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
default GameMode adapt(org.bukkit.GameMode gameMode) {
|
default GameMode adapt(org.bukkit.GameMode gameMode) {
|
||||||
checkNotNull(gameMode);
|
checkNotNull(gameMode);
|
||||||
return GameModes.get(gameMode.name().toLowerCase());
|
return GameModes.get(gameMode.name().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,14 +243,14 @@ public interface IBukkitAdapter {
|
|||||||
* @return WorldEdit EntityType
|
* @return WorldEdit EntityType
|
||||||
*/
|
*/
|
||||||
default EntityType adapt(org.bukkit.entity.EntityType entityType) {
|
default EntityType adapt(org.bukkit.entity.EntityType entityType) {
|
||||||
return EntityTypes.get(entityType.getName().toLowerCase());
|
return EntityTypes.get(entityType.getName().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
default org.bukkit.entity.EntityType adapt(EntityType entityType) {
|
default org.bukkit.entity.EntityType adapt(EntityType entityType) {
|
||||||
if (!entityType.getId().startsWith("minecraft:")) {
|
if (!entityType.getId().startsWith("minecraft:")) {
|
||||||
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
|
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
|
||||||
}
|
}
|
||||||
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase());
|
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -364,13 +366,13 @@ public interface IBukkitAdapter {
|
|||||||
throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
|
throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return Biome.valueOf(biomeType.getId().substring(10).toUpperCase());
|
return Biome.valueOf(biomeType.getId().substring(10).toUpperCase(Locale.ROOT));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default BiomeType adapt(Biome biome) {
|
default BiomeType adapt(Biome biome) {
|
||||||
return BiomeTypes.register(biome.name().toLowerCase());
|
return BiomeTypes.get(biome.name().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,6 @@ import java.util.function.Consumer;
|
|||||||
@Command(aliases = {"/anvil"}, desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)")
|
@Command(aliases = {"/anvil"}, desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)")
|
||||||
public class AnvilCommands {
|
public class AnvilCommands {
|
||||||
|
|
||||||
private final WorldEdit worldEdit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
@ -62,7 +60,6 @@ public class AnvilCommands {
|
|||||||
*/
|
*/
|
||||||
public AnvilCommands(WorldEdit worldEdit) {
|
public AnvilCommands(WorldEdit worldEdit) {
|
||||||
checkNotNull(worldEdit);
|
checkNotNull(worldEdit);
|
||||||
this.worldEdit = worldEdit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,14 +168,15 @@ public class AnvilCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.remapall")
|
@CommandPermissions("worldedit.anvil.remapall")
|
||||||
public void remapall(Player player, String folder) throws WorldEditException {
|
public void remapall(Player player, String folder) throws WorldEditException {
|
||||||
ClipboardRemapper mapper;
|
|
||||||
ClipboardRemapper.RemapPlatform from;
|
ClipboardRemapper.RemapPlatform from;
|
||||||
ClipboardRemapper.RemapPlatform to;
|
ClipboardRemapper.RemapPlatform to;
|
||||||
from = ClipboardRemapper.RemapPlatform.PE;
|
from = ClipboardRemapper.RemapPlatform.PE;
|
||||||
to = ClipboardRemapper.RemapPlatform.PC;
|
to = ClipboardRemapper.RemapPlatform.PC;
|
||||||
RemapFilter filter = new RemapFilter(from, to);
|
RemapFilter filter = new RemapFilter(from, to);
|
||||||
RemapFilter result = runWithWorld(player, folder, filter, true);
|
RemapFilter result = runWithWorld(player, folder, filter, true);
|
||||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) {
|
||||||
|
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -195,7 +193,9 @@ public class AnvilCommands {
|
|||||||
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis) throws WorldEditException {
|
public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis) throws WorldEditException {
|
||||||
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||||
DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
|
DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true);
|
||||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) {
|
||||||
|
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -212,9 +212,13 @@ public class AnvilCommands {
|
|||||||
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis, @Switch(name='d', desc = "TODO") boolean debug) throws WorldEditException {
|
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis, @Switch(name='d', desc = "TODO") boolean debug) throws WorldEditException {
|
||||||
String folder = player.getWorld().getName();
|
String folder = player.getWorld().getName();
|
||||||
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||||
if (debug) filter.enableDebug();
|
if (debug) {
|
||||||
|
filter.enableDebug();
|
||||||
|
}
|
||||||
DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
|
DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
|
||||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) {
|
||||||
|
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -230,9 +234,13 @@ public class AnvilCommands {
|
|||||||
@CommandPermissions("worldedit.anvil.deleteunclaimed")
|
@CommandPermissions("worldedit.anvil.deleteunclaimed")
|
||||||
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis, @Switch(name='d', desc = "TODO") boolean debug) throws WorldEditException {
|
public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Arg(name = "filedurationmillis", desc = "int", def = "60000") int fileDurationMillis, @Switch(name='d', desc = "TODO") boolean debug) throws WorldEditException {
|
||||||
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis);
|
||||||
if (debug) filter.enableDebug();
|
if (debug) {
|
||||||
|
filter.enableDebug();
|
||||||
|
}
|
||||||
DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
|
DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter);
|
||||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) {
|
||||||
|
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -248,11 +256,14 @@ public class AnvilCommands {
|
|||||||
long duration = MainUtil.timeToSec(time) * 1000L;
|
long duration = MainUtil.timeToSec(time) * 1000L;
|
||||||
DeleteOldFilter filter = new DeleteOldFilter(duration);
|
DeleteOldFilter filter = new DeleteOldFilter(duration);
|
||||||
DeleteOldFilter result = runWithWorld(player, folder, filter, true);
|
DeleteOldFilter result = runWithWorld(player, folder, filter, true);
|
||||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) {
|
||||||
|
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "trimallplots",
|
name = "trimallplots",
|
||||||
|
|
||||||
desc = "Trim chunks in a Plot World",
|
desc = "Trim chunks in a Plot World",
|
||||||
descFooter = "Unclaimed chunks will be deleted\n" +
|
descFooter = "Unclaimed chunks will be deleted\n" +
|
||||||
"Unmodified chunks will be deleted\n" +
|
"Unmodified chunks will be deleted\n" +
|
||||||
@ -267,40 +278,51 @@ public class AnvilCommands {
|
|||||||
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
|
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(folder, true, false);
|
||||||
MCAQueue queue = new MCAQueue(defaultQueue);
|
MCAQueue queue = new MCAQueue(defaultQueue);
|
||||||
PlotTrimFilter result = queue.filterWorld(filter);
|
PlotTrimFilter result = queue.filterWorld(filter);
|
||||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) {
|
||||||
|
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "deletebiomechunks",
|
name = "deletebiomechunks",
|
||||||
|
|
||||||
desc = "Delete chunks matching a specific biome"
|
desc = "Delete chunks matching a specific biome"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.trimallair")
|
@CommandPermissions("worldedit.anvil.trimallair")
|
||||||
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch(name='u', desc = "TODO") boolean unsafe) {
|
public void deleteBiome(Player player, String folder, BiomeType biome, @Switch(name='u', desc = "TODO") boolean unsafe) {
|
||||||
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
|
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
|
||||||
DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
|
DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
|
||||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) {
|
||||||
|
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "trimallair",
|
name = "trimallair",
|
||||||
|
|
||||||
desc = "Trim all air in the world"
|
desc = "Trim all air in the world"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.trimallair")
|
@CommandPermissions("worldedit.anvil.trimallair")
|
||||||
public void trimAllAir(Player player, String folder, @Switch(name='u', desc = "TODO") boolean unsafe) throws WorldEditException {
|
public void trimAllAir(Player player, String folder, @Switch(name='u', desc = "TODO") boolean unsafe) throws WorldEditException {
|
||||||
TrimAirFilter filter = new TrimAirFilter();
|
TrimAirFilter filter = new TrimAirFilter();
|
||||||
TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
|
TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe);
|
||||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) {
|
||||||
|
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "debugfixroads",
|
name = "debugfixroads",
|
||||||
|
|
||||||
desc = "debug - do not use"
|
desc = "debug - do not use"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.debugfixroads")
|
@CommandPermissions("worldedit.anvil.debugfixroads")
|
||||||
public void debugfixroads(Player player, String folder) throws WorldEditException {
|
public void debugfixroads(Player player, String folder) throws WorldEditException {
|
||||||
DebugFixP2Roads filter = new DebugFixP2Roads();
|
DebugFixP2Roads filter = new DebugFixP2Roads();
|
||||||
DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true);
|
DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true);
|
||||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) {
|
||||||
|
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -310,6 +332,7 @@ public class AnvilCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.replaceall")
|
@CommandPermissions("worldedit.anvil.replaceall")
|
||||||
public void replaceAllPattern(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap) throws WorldEditException {
|
public void replaceAllPattern(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap) throws WorldEditException {
|
||||||
|
|
||||||
// MCAFilterCounter filter;
|
// MCAFilterCounter filter;
|
||||||
// if (useMap) {
|
// if (useMap) {
|
||||||
// if (to instanceof RandomPattern) {
|
// if (to instanceof RandomPattern) {
|
||||||
@ -331,7 +354,8 @@ public class AnvilCommands {
|
|||||||
// MCAFilterCounter result = runWithWorld(player, folder, filter, true);
|
// MCAFilterCounter result = runWithWorld(player, folder, filter, true);
|
||||||
// if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
// if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
//
|
||||||
@Command(
|
@Command(
|
||||||
name = "countall",
|
name = "countall",
|
||||||
desc = "Count all blocks in a world"
|
desc = "Count all blocks in a world"
|
||||||
@ -401,7 +425,9 @@ public class AnvilCommands {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
||||||
if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
if (result != null) {
|
||||||
|
player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -424,7 +450,8 @@ public class AnvilCommands {
|
|||||||
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
// MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
|
||||||
// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal()));
|
// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal()));
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
//
|
||||||
@Command(
|
@Command(
|
||||||
name = "distr",
|
name = "distr",
|
||||||
desc = "Replace all blocks in the selection with another"
|
desc = "Replace all blocks in the selection with another"
|
||||||
@ -501,7 +528,8 @@ public class AnvilCommands {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
//
|
||||||
@Command(
|
@Command(
|
||||||
name = "replace",
|
name = "replace",
|
||||||
aliases = {"r"},
|
aliases = {"r"},
|
||||||
@ -509,6 +537,7 @@ public class AnvilCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.replace")
|
@CommandPermissions("worldedit.anvil.replace")
|
||||||
public void replace(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, String to, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException {
|
public void replace(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, String to, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException {
|
||||||
|
|
||||||
// final FaweBlockMatcher matchFrom;
|
// final FaweBlockMatcher matchFrom;
|
||||||
// if (from == null) {
|
// if (from == null) {
|
||||||
// matchFrom = FaweBlockMatcher.NOT_AIR;
|
// matchFrom = FaweBlockMatcher.NOT_AIR;
|
||||||
@ -522,7 +551,8 @@ public class AnvilCommands {
|
|||||||
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
// player.print(BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
//
|
||||||
@Command(
|
@Command(
|
||||||
name = "replacepattern",
|
name = "replacepattern",
|
||||||
aliases = {"preplace", "rp"},
|
aliases = {"preplace", "rp"},
|
||||||
@ -531,6 +561,7 @@ public class AnvilCommands {
|
|||||||
@CommandPermissions("worldedit.anvil.replace")
|
@CommandPermissions("worldedit.anvil.replace")
|
||||||
// Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap
|
// Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap
|
||||||
public void replacePattern(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap) throws WorldEditException {
|
public void replacePattern(Player player, EditSession editSession, @Selection Region selection, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap) throws WorldEditException {
|
||||||
|
|
||||||
// MCAFilterCounter filter;
|
// MCAFilterCounter filter;
|
||||||
// if (useMap) {
|
// if (useMap) {
|
||||||
// if (to instanceof RandomPattern) {
|
// if (to instanceof RandomPattern) {
|
||||||
@ -618,6 +649,7 @@ public class AnvilCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.pastechunks")
|
@CommandPermissions("worldedit.anvil.pastechunks")
|
||||||
public void paste(Player player, LocalSession session, EditSession editSession, @Switch(name='c', desc = "TODO") boolean alignChunk) throws WorldEditException, IOException {
|
public void paste(Player player, LocalSession session, EditSession editSession, @Switch(name='c', desc = "TODO") boolean alignChunk) throws WorldEditException, IOException {
|
||||||
|
|
||||||
// FawePlayer fp = FawePlayer.wrap(player);
|
// FawePlayer fp = FawePlayer.wrap(player);
|
||||||
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
|
// MCAClipboard clipboard = fp.getMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD);
|
||||||
// if (clipboard == null) {
|
// if (clipboard == null) {
|
||||||
|
@ -13,6 +13,7 @@ import com.sk89q.worldedit.WorldEdit;
|
|||||||
import com.sk89q.worldedit.command.MethodCommands;
|
import com.sk89q.worldedit.command.MethodCommands;
|
||||||
import com.sk89q.worldedit.util.command.SimpleDispatcher;
|
import com.sk89q.worldedit.util.command.SimpleDispatcher;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
|
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CFICommand extends MethodCommands {
|
public class CFICommand extends MethodCommands {
|
||||||
@ -81,6 +82,10 @@ public class CFICommand extends MethodCommands {
|
|||||||
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case 2:
|
||||||
|
String cmd = Commands.getAlias(CFICommands.class, "empty") + " " + context.getJoinedStrings(0);
|
||||||
|
dispatcher.call(cmd, context.getLocals(), new String[0]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dispatcher.call(remaining, context.getLocals(), new String[0]);
|
dispatcher.call(remaining, context.getLocals(), new String[0]);
|
||||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.command;
|
|||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
|
import com.boydti.fawe.beta.SingleFilterBlock;
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.config.Commands;
|
import com.boydti.fawe.config.Commands;
|
||||||
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
|
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
|
||||||
@ -9,7 +10,6 @@ import com.boydti.fawe.object.FawePlayer;
|
|||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||||
import com.boydti.fawe.object.pattern.PatternExtent;
|
|
||||||
import com.boydti.fawe.util.CleanTextureUtil;
|
import com.boydti.fawe.util.CleanTextureUtil;
|
||||||
import com.boydti.fawe.util.FilteredTextureUtil;
|
import com.boydti.fawe.util.FilteredTextureUtil;
|
||||||
import com.boydti.fawe.util.ImgurUtility;
|
import com.boydti.fawe.util.ImgurUtility;
|
||||||
@ -39,7 +39,6 @@ import com.sk89q.worldedit.extension.platform.Platform;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
@ -72,7 +71,6 @@ import java.util.Date;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import org.enginehub.piston.annotation.CommandContainer;
|
import org.enginehub.piston.annotation.CommandContainer;
|
||||||
import org.enginehub.piston.annotation.param.Arg;
|
import org.enginehub.piston.annotation.param.Arg;
|
||||||
@ -91,7 +89,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
*/
|
*/
|
||||||
public CFICommands(WorldEdit worldEdit, Dispatcher dispatcher) {
|
public CFICommands(WorldEdit worldEdit, Dispatcher dispatcher) {
|
||||||
super(worldEdit);
|
super(worldEdit);
|
||||||
this.dispathcer= dispatcher;
|
this.dispathcer = dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getFolder(String worldName) {
|
public static File getFolder(String worldName) {
|
||||||
@ -152,7 +150,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
desc = "Info about using brushes with CFI"
|
desc = "Info about using brushes with CFI"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void brush(FawePlayer fp) throws ParameterException{
|
public void brush(FawePlayer fp) throws ParameterException {
|
||||||
CFISettings settings = assertSettings(fp);
|
CFISettings settings = assertSettings(fp);
|
||||||
settings.popMessages(fp);
|
settings.popMessages(fp);
|
||||||
Message msg;
|
Message msg;
|
||||||
@ -188,9 +186,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
CFISettings settings = assertSettings(fp);
|
CFISettings settings = assertSettings(fp);
|
||||||
HeightMapMCAGenerator generator = settings.getGenerator();
|
HeightMapMCAGenerator generator = settings.getGenerator();
|
||||||
|
|
||||||
Function<File, Boolean> function = new Function<File, Boolean>() {
|
Function<File, Boolean> function = folder -> {
|
||||||
@Override
|
|
||||||
public Boolean apply(File folder) {
|
|
||||||
if (folder != null) {
|
if (folder != null) {
|
||||||
try {
|
try {
|
||||||
generator.setFolder(folder);
|
generator.setFolder(folder);
|
||||||
@ -208,7 +204,6 @@ public class CFICommands extends MethodCommands {
|
|||||||
fp.sendMessage("Unable to generate world... (see console)?");
|
fp.sendMessage("Unable to generate world... (see console)?");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -244,9 +239,13 @@ public class CFICommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void column(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
|
public void column(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.setColumn(load(image), pattern, !disableWhiteOnly);
|
if (image != null) {
|
||||||
else if (mask != null) gen.setColumn(mask, pattern);
|
gen.setColumn(load(image), pattern, !disableWhiteOnly);
|
||||||
else gen.setColumn(pattern);
|
} else if (mask != null) {
|
||||||
|
gen.setColumn(mask, pattern);
|
||||||
|
} else {
|
||||||
|
gen.setColumn(pattern);
|
||||||
|
}
|
||||||
fp.sendMessage("Set column!");
|
fp.sendMessage("Set column!");
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(fp).resetComponent();
|
||||||
component(fp);
|
component(fp);
|
||||||
@ -266,9 +265,13 @@ public class CFICommands extends MethodCommands {
|
|||||||
|
|
||||||
private void floor(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException {
|
private void floor(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException {
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.setFloor(load(image), pattern, !disableWhiteOnly);
|
if (image != null) {
|
||||||
else if (mask != null) gen.setFloor(mask, pattern);
|
gen.setFloor(load(image), pattern, !disableWhiteOnly);
|
||||||
else gen.setFloor(pattern);
|
} else if (mask != null) {
|
||||||
|
gen.setFloor(mask, pattern);
|
||||||
|
} else {
|
||||||
|
gen.setFloor(pattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -285,13 +288,16 @@ public class CFICommands extends MethodCommands {
|
|||||||
|
|
||||||
public void main(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
|
public void main(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.setMain(load(image), pattern, !disableWhiteOnly);
|
if (image != null) {
|
||||||
else if (mask != null) gen.setMain(mask, pattern);
|
gen.setMain(load(image), pattern, !disableWhiteOnly);
|
||||||
else gen.setMain(pattern);
|
} else if (mask != null) {
|
||||||
|
gen.setMain(mask, pattern);
|
||||||
|
} else {
|
||||||
|
gen.setMain(pattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "overlay",
|
|
||||||
name = "overlay",
|
name = "overlay",
|
||||||
aliases = {"setoverlay"},
|
aliases = {"setoverlay"},
|
||||||
desc = "Set the overlay block",
|
desc = "Set the overlay block",
|
||||||
@ -301,9 +307,13 @@ public class CFICommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void overlay(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
|
public void overlay(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.setOverlay(load(image), pattern, !disableWhiteOnly);
|
if (image != null) {
|
||||||
else if (mask != null) gen.setOverlay(mask, pattern);
|
gen.setOverlay(load(image), pattern, !disableWhiteOnly);
|
||||||
else gen.setOverlay(pattern);
|
} else if (mask != null) {
|
||||||
|
gen.setOverlay(mask, pattern);
|
||||||
|
} else {
|
||||||
|
gen.setOverlay(pattern);
|
||||||
|
}
|
||||||
fp.sendMessage("Set overlay!");
|
fp.sendMessage("Set overlay!");
|
||||||
component(fp);
|
component(fp);
|
||||||
}
|
}
|
||||||
@ -325,8 +335,11 @@ public class CFICommands extends MethodCommands {
|
|||||||
|
|
||||||
private void smooth(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
|
private void smooth(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
|
if (image != null) {
|
||||||
else gen.smooth(mask, radius, iterations);
|
gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
|
||||||
|
} else {
|
||||||
|
gen.smooth(mask, radius, iterations);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -353,7 +366,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
"Below 50 will prefer to color with blocks"
|
"Below 50 will prefer to color with blocks"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void biomepriority(FawePlayer fp, int value) throws ParameterException{
|
public void biomepriority(FawePlayer fp, int value) throws ParameterException {
|
||||||
assertSettings(fp).getGenerator().setBiomePriority(value);
|
assertSettings(fp).getGenerator().setBiomePriority(value);
|
||||||
coloring(fp);
|
coloring(fp);
|
||||||
}
|
}
|
||||||
@ -405,15 +418,15 @@ public class CFICommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
blocks = new HashSet<>();
|
blocks = new HashSet<>();
|
||||||
for (int combined = 0; combined < ids.length; combined++) {
|
for (int combined = 0; combined < ids.length; combined++) {
|
||||||
if (ids[combined]) blocks.add(BlockTypes.get(combined));
|
if (ids[combined]) {
|
||||||
|
blocks.add(BlockTypes.get(combined));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
blocks = new HashSet<>();
|
blocks = new HashSet<>();
|
||||||
BlockPattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState());
|
SingleFilterBlock extent = new SingleFilterBlock();
|
||||||
PatternExtent extent = new PatternExtent(pattern);
|
|
||||||
|
|
||||||
ParserContext parserContext = new ParserContext();
|
ParserContext parserContext = new ParserContext();
|
||||||
parserContext.setActor(player);
|
parserContext.setActor(player);
|
||||||
parserContext.setWorld(player.getWorld());
|
parserContext.setWorld(player.getWorld());
|
||||||
@ -424,9 +437,10 @@ public class CFICommands extends MethodCommands {
|
|||||||
TextureUtil tu = Fawe.get().getTextureUtil();
|
TextureUtil tu = Fawe.get().getTextureUtil();
|
||||||
for (int typeId : tu.getValidBlockIds()) {
|
for (int typeId : tu.getValidBlockIds()) {
|
||||||
BlockType type = BlockTypes.get(typeId);
|
BlockType type = BlockTypes.get(typeId);
|
||||||
BlockStateHolder block = type.getDefaultState();
|
extent.init(0, 0, 0, type.getDefaultState().toBaseBlock());
|
||||||
pattern.setBlock(block);
|
if (mask.test(extent)) {
|
||||||
if (mask.test(BlockVector3.ZERO)) blocks.add(type);
|
blocks.add(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -459,8 +473,11 @@ public class CFICommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void complexity(FawePlayer fp, int min, int max) throws ParameterException, FileNotFoundException {
|
public void complexity(FawePlayer fp, int min, int max) throws ParameterException, FileNotFoundException {
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (min == 0 && max == 100) gen.setTextureUtil(Fawe.get().getTextureUtil());
|
if (min == 0 && max == 100) {
|
||||||
else gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max));
|
gen.setTextureUtil(Fawe.get().getTextureUtil());
|
||||||
|
} else {
|
||||||
|
gen.setTextureUtil(new CleanTextureUtil(Fawe.get().getTextureUtil(), min, max));
|
||||||
|
}
|
||||||
coloring(fp);
|
coloring(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,9 +518,13 @@ public class CFICommands extends MethodCommands {
|
|||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
|
public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
|
||||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||||
if (image != null) gen.setBiome(load(image), biome, !disableWhiteOnly);
|
if (image != null) {
|
||||||
else if (mask != null) gen.setBiome(mask, biome);
|
gen.setBiome(load(image), biome, !disableWhiteOnly);
|
||||||
else gen.setBiome(biome);
|
} else if (mask != null) {
|
||||||
|
gen.setBiome(mask, biome);
|
||||||
|
} else {
|
||||||
|
gen.setBiome(biome);
|
||||||
|
}
|
||||||
msg("Set biome!").send(fp);
|
msg("Set biome!").send(fp);
|
||||||
assertSettings(fp).resetComponent();
|
assertSettings(fp).resetComponent();
|
||||||
component(fp);
|
component(fp);
|
||||||
@ -682,9 +703,13 @@ public class CFICommands extends MethodCommands {
|
|||||||
public void color(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException {
|
public void color(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException {
|
||||||
CFISettings settings = assertSettings(fp);
|
CFISettings settings = assertSettings(fp);
|
||||||
HeightMapMCAGenerator gen = settings.getGenerator();
|
HeightMapMCAGenerator gen = settings.getGenerator();
|
||||||
if (imageMask != null) gen.setColor(load(image), load(imageMask), !disableWhiteOnly);
|
if (imageMask != null) {
|
||||||
else if (mask != null) gen.setColor(load(image), mask);
|
gen.setColor(load(image), load(imageMask), !disableWhiteOnly);
|
||||||
else gen.setColor(load(image));
|
} else if (mask != null) {
|
||||||
|
gen.setColor(load(image), mask);
|
||||||
|
} else {
|
||||||
|
gen.setColor(load(image));
|
||||||
|
}
|
||||||
settings.resetColoring();
|
settings.resetColoring();
|
||||||
msg("Set color with blocks!").send(fp);
|
msg("Set color with blocks!").send(fp);
|
||||||
mainMenu(fp);
|
mainMenu(fp);
|
||||||
@ -730,7 +755,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
desc = "Color the world using an image"
|
desc = "Color the world using an image"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void coloring(FawePlayer fp) throws ParameterException{
|
public void coloring(FawePlayer fp) throws ParameterException {
|
||||||
CFISettings settings = assertSettings(fp);
|
CFISettings settings = assertSettings(fp);
|
||||||
settings.popMessages(fp);
|
settings.popMessages(fp);
|
||||||
settings.setCategory("coloring");
|
settings.setCategory("coloring");
|
||||||
@ -762,7 +787,9 @@ public class CFICommands extends MethodCommands {
|
|||||||
for (int typeId : blockArray) {
|
for (int typeId : blockArray) {
|
||||||
BlockType type = BlockTypes.get(typeId);
|
BlockType type = BlockTypes.get(typeId);
|
||||||
String name = type.getName();
|
String name = type.getName();
|
||||||
if (name.contains(":")) name = name.split(":")[1];
|
if (name.contains(":")) {
|
||||||
|
name = name.split(":")[1];
|
||||||
|
}
|
||||||
materials.add(name);
|
materials.add(name);
|
||||||
}
|
}
|
||||||
String blockList = materials.size() > 100 ? materials.size() + " blocks" : StringMan.join(materials, ',');
|
String blockList = materials.size() > 100 ? materials.size() + " blocks" : StringMan.join(materials, ',');
|
||||||
@ -782,9 +809,15 @@ public class CFICommands extends MethodCommands {
|
|||||||
if (settings.image != null) {
|
if (settings.image != null) {
|
||||||
StringBuilder colorArgs = new StringBuilder();
|
StringBuilder colorArgs = new StringBuilder();
|
||||||
colorArgs.append(" " + settings.imageArg);
|
colorArgs.append(" " + settings.imageArg);
|
||||||
if (settings.imageMask != null) colorArgs.append(" " + settings.imageMaskArg);
|
if (settings.imageMask != null) {
|
||||||
if (settings.mask != null) colorArgs.append(" " + settings.maskArg);
|
colorArgs.append(" " + settings.imageMaskArg);
|
||||||
if (!settings.whiteOnly) colorArgs.append(" -w");
|
}
|
||||||
|
if (settings.mask != null) {
|
||||||
|
colorArgs.append(" " + settings.maskArg);
|
||||||
|
}
|
||||||
|
if (!settings.whiteOnly) {
|
||||||
|
colorArgs.append(" -w");
|
||||||
|
}
|
||||||
|
|
||||||
msg.text("Image: ")
|
msg.text("Image: ")
|
||||||
.text("[" + settings.imageArg + "]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "image"))
|
.text("[" + settings.imageArg + "]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "image"))
|
||||||
@ -859,7 +892,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
CFISettings settings = assertSettings(fp);
|
CFISettings settings = assertSettings(fp);
|
||||||
BufferedImage image = settings.getGenerator().draw();
|
BufferedImage image = settings.getGenerator().draw();
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
ImageIO.write(image, "jpg", baos );
|
ImageIO.write(image, "jpg", baos);
|
||||||
byte[] data = baos.toByteArray();
|
byte[] data = baos.toByteArray();
|
||||||
fp.sendMessage("Please wait...");
|
fp.sendMessage("Please wait...");
|
||||||
URL url = ImgurUtility.uploadImage(data);
|
URL url = ImgurUtility.uploadImage(data);
|
||||||
@ -904,7 +937,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
desc = ""
|
desc = ""
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void populate(FawePlayer fp) throws ParameterException{
|
public void populate(FawePlayer fp) throws ParameterException {
|
||||||
CFISettings settings = assertSettings(fp);
|
CFISettings settings = assertSettings(fp);
|
||||||
settings.popMessages(fp);
|
settings.popMessages(fp);
|
||||||
settings.setCategory("populate");
|
settings.setCategory("populate");
|
||||||
@ -921,7 +954,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
desc = "Components menu"
|
desc = "Components menu"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.anvil.cfi")
|
@CommandPermissions("worldedit.anvil.cfi")
|
||||||
public void component(FawePlayer fp) throws ParameterException{
|
public void component(FawePlayer fp) throws ParameterException {
|
||||||
CFISettings settings = assertSettings(fp);
|
CFISettings settings = assertSettings(fp);
|
||||||
settings.popMessages(fp);
|
settings.popMessages(fp);
|
||||||
settings.setCategory("component");
|
settings.setCategory("component");
|
||||||
@ -938,9 +971,15 @@ public class CFICommands extends MethodCommands {
|
|||||||
String pattern = settings.pattern == null ? "NONE" : settings.patternArg;
|
String pattern = settings.pattern == null ? "NONE" : settings.patternArg;
|
||||||
|
|
||||||
StringBuilder maskArgs = new StringBuilder();
|
StringBuilder maskArgs = new StringBuilder();
|
||||||
if (settings.imageMask != null) maskArgs.append(" " + settings.imageMaskArg);
|
if (settings.imageMask != null) {
|
||||||
if (settings.mask != null) maskArgs.append(" " + settings.maskArg);
|
maskArgs.append(" " + settings.imageMaskArg);
|
||||||
if (!settings.whiteOnly) maskArgs.append(" -w");
|
}
|
||||||
|
if (settings.mask != null) {
|
||||||
|
maskArgs.append(" " + settings.maskArg);
|
||||||
|
}
|
||||||
|
if (!settings.whiteOnly) {
|
||||||
|
maskArgs.append(" -w");
|
||||||
|
}
|
||||||
|
|
||||||
String height = Commands.getAlias(CFICommands.class, "height");
|
String height = Commands.getAlias(CFICommands.class, "height");
|
||||||
String waterHeight = Commands.getAlias(CFICommands.class, "waterheight");
|
String waterHeight = Commands.getAlias(CFICommands.class, "waterheight");
|
||||||
@ -993,10 +1032,11 @@ public class CFICommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private CFISettings assertSettings(FawePlayer fp) throws ParameterException {
|
private CFISettings assertSettings(FawePlayer fp) throws ParameterException {
|
||||||
CFISettings settings = getSettings(fp);
|
CFISettings settings = getSettings(fp);
|
||||||
if (!settings.hasGenerator()) throw new ParameterException("Please use /" + alias());
|
if (!settings.hasGenerator()) {
|
||||||
|
throw new ParameterException("Please use /" + alias());
|
||||||
|
}
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1083,12 +1123,16 @@ public class CFICommands extends MethodCommands {
|
|||||||
|
|
||||||
public CFISettings setGenerator(HeightMapMCAGenerator generator) {
|
public CFISettings setGenerator(HeightMapMCAGenerator generator) {
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
if (bound) fp.getSession().setVirtualWorld(generator);
|
if (bound) {
|
||||||
|
fp.getSession().setVirtualWorld(generator);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CFISettings bind() {
|
public CFISettings bind() {
|
||||||
if (generator != null) fp.getSession().setVirtualWorld(generator);
|
if (generator != null) {
|
||||||
|
fp.getSession().setVirtualWorld(generator);
|
||||||
|
}
|
||||||
bound = true;
|
bound = true;
|
||||||
fp.setMeta("CFISettings", this);
|
fp.setMeta("CFISettings", this);
|
||||||
return this;
|
return this;
|
||||||
|
@ -1,55 +1,75 @@
|
|||||||
package com.boydti.fawe.jnbt.anvil;
|
package com.boydti.fawe.jnbt.anvil;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.example.SimpleIntFaweChunk;
|
import com.boydti.fawe.object.FaweInputStream;
|
||||||
import com.boydti.fawe.object.*;
|
import com.boydti.fawe.object.FaweOutputStream;
|
||||||
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
|
import com.boydti.fawe.object.Metadatable;
|
||||||
|
import com.boydti.fawe.object.RunnableVal2;
|
||||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||||
import com.boydti.fawe.object.change.StreamChange;
|
import com.boydti.fawe.object.change.StreamChange;
|
||||||
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
||||||
import com.boydti.fawe.object.collection.*;
|
import com.boydti.fawe.object.collection.DifferentialArray;
|
||||||
|
import com.boydti.fawe.object.collection.DifferentialBlockBuffer;
|
||||||
|
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
||||||
|
import com.boydti.fawe.object.collection.LocalBlockVector2DSet;
|
||||||
|
import com.boydti.fawe.object.collection.SummedAreaTable;
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.boydti.fawe.object.queue.LazyFaweChunk;
|
import com.boydti.fawe.object.queue.LazyFaweChunk;
|
||||||
import com.boydti.fawe.object.schematic.Schematic;
|
import com.boydti.fawe.object.schematic.Schematic;
|
||||||
import com.boydti.fawe.util.*;
|
import com.boydti.fawe.util.CachedTextureUtil;
|
||||||
|
import com.boydti.fawe.util.RandomTextureUtil;
|
||||||
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
|
import com.boydti.fawe.util.SetQueue;
|
||||||
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
import com.boydti.fawe.util.TextureUtil;
|
||||||
import com.boydti.fawe.util.image.Drawable;
|
import com.boydti.fawe.util.image.Drawable;
|
||||||
import com.boydti.fawe.util.image.ImageViewer;
|
import com.boydti.fawe.util.image.ImageViewer;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockID;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockID;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
// TODO FIXME
|
// TODO FIXME
|
||||||
public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld {
|
public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld {
|
||||||
@ -190,11 +210,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
this.editSession = session;
|
this.editSession = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supports(Capability capability) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used for visualizing the world on a map
|
// Used for visualizing the world on a map
|
||||||
private ImageViewer viewer;
|
private ImageViewer viewer;
|
||||||
// Used for visualizing the world by sending chunk packets
|
// Used for visualizing the world by sending chunk packets
|
||||||
@ -229,11 +244,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
return metaData;
|
return metaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public FaweQueue getQueue() {
|
|
||||||
throw new UnsupportedOperationException("Not supported: Queue is not backed by a real world");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector3 getOrigin() {
|
public Vector3 getOrigin() {
|
||||||
return Vector3.at(chunkOffset.getBlockX() << 4, 0, chunkOffset.getBlockZ() << 4);
|
return Vector3.at(chunkOffset.getBlockX() << 4, 0, chunkOffset.getBlockZ() << 4);
|
||||||
@ -1019,7 +1029,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return getLazyBlock(position);
|
return getBlock(position.getX(), position.getY(), position.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockState getFloor(int x, int z) {
|
public BlockState getFloor(int x, int z) {
|
||||||
@ -1042,12 +1052,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
return getLazyBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
|
||||||
return BlockState.getFromInternalId(getCombinedId4Data(x, y, z));
|
return BlockState.getFromInternalId(getCombinedId4Data(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 getTarget(Player player, boolean adjacent) {
|
public Vector3 getTarget(Player player, boolean adjacent) {
|
||||||
Location target = null;
|
|
||||||
int range = this.range > -1 ? getRange() : DEFAULT_RANGE;
|
int range = this.range > -1 ? getRange() : DEFAULT_RANGE;
|
||||||
if (adjacent) {
|
if (adjacent) {
|
||||||
Location face = player.getBlockTraceFace(range, true);
|
Location face = player.getBlockTraceFace(range, true);
|
||||||
|
@ -46,9 +46,7 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
||||||
|
|
||||||
public static int COMPRESSION = 0;
|
private static int HEADER_SIZE = 14;
|
||||||
public static int MODE = 0;
|
|
||||||
public static int HEADER_SIZE = 14;
|
|
||||||
|
|
||||||
protected int length;
|
protected int length;
|
||||||
protected int height;
|
protected int height;
|
||||||
@ -61,9 +59,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
private final File file;
|
private final File file;
|
||||||
|
|
||||||
private RandomAccessFile braf;
|
private RandomAccessFile braf;
|
||||||
private MappedByteBuffer mbb;
|
private MappedByteBuffer byteBuffer;
|
||||||
|
|
||||||
private FileChannel fc;
|
private FileChannel fileChannel;
|
||||||
private boolean hasBiomes;
|
private boolean hasBiomes;
|
||||||
|
|
||||||
public DiskOptimizedClipboard(int width, int height, int length, UUID uuid) {
|
public DiskOptimizedClipboard(int width, int height, int length, UUID uuid) {
|
||||||
@ -78,9 +76,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
this.braf = new RandomAccessFile(file, "rw");
|
this.braf = new RandomAccessFile(file, "rw");
|
||||||
braf.setLength(file.length());
|
braf.setLength(file.length());
|
||||||
init();
|
init();
|
||||||
width = mbb.getChar(2);
|
width = byteBuffer.getChar(2);
|
||||||
height = mbb.getChar(4);
|
height = byteBuffer.getChar(4);
|
||||||
length = mbb.getChar(6);
|
length = byteBuffer.getChar(6);
|
||||||
area = width * length;
|
area = width * length;
|
||||||
this.volume = length * width * height;
|
this.volume = length * width * height;
|
||||||
|
|
||||||
@ -98,9 +96,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void init() throws IOException {
|
private void init() throws IOException {
|
||||||
if (this.fc == null) {
|
if (this.fileChannel == null) {
|
||||||
this.fc = braf.getChannel();
|
this.fileChannel = braf.getChannel();
|
||||||
this.mbb = fc.map(FileChannel.MapMode.READ_WRITE, 0, file.length());
|
this.byteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, file.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +132,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void setBiome(int index, BiomeType biome) {
|
public void setBiome(int index, BiomeType biome) {
|
||||||
if (initBiome()) {
|
if (initBiome()) {
|
||||||
mbb.put(HEADER_SIZE + (volume << 2) + index, (byte) biome.getInternalId());
|
byteBuffer.put(HEADER_SIZE + (volume << 2) + index, (byte) biome.getInternalId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,8 +141,8 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
if (!hasBiomes()) {
|
if (!hasBiomes()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int biomeId = mbb.get(HEADER_SIZE + (volume << 2) + index) & 0xFF;
|
int biomeId = byteBuffer.get(HEADER_SIZE + (volume << 2) + index) & 0xFF;
|
||||||
return BiomeTypes.register(biomeId);
|
return BiomeTypes.get(biomeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -154,7 +152,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
int mbbIndex = HEADER_SIZE + (volume << 2);
|
int mbbIndex = HEADER_SIZE + (volume << 2);
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, index++, mbbIndex++) {
|
for (int x = 0; x < width; x++, index++, mbbIndex++) {
|
||||||
int biome = mbb.get(mbbIndex) & 0xFF;
|
int biome = byteBuffer.get(mbbIndex) & 0xFF;
|
||||||
task.run(index, biome);
|
task.run(index, biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,9 +171,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
public BlockArrayClipboard toClipboard() {
|
public BlockArrayClipboard toClipboard() {
|
||||||
try {
|
try {
|
||||||
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(width - 1, height - 1, length - 1));
|
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(width - 1, height - 1, length - 1));
|
||||||
int ox = mbb.getShort(8);
|
int ox = byteBuffer.getShort(8);
|
||||||
int oy = mbb.getShort(10);
|
int oy = byteBuffer.getShort(10);
|
||||||
int oz = mbb.getShort(12);
|
int oz = byteBuffer.getShort(12);
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, this);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, this);
|
||||||
clipboard.setOrigin(BlockVector3.at(ox, oy, oz));
|
clipboard.setOrigin(BlockVector3.at(ox, oy, oz));
|
||||||
return clipboard;
|
return clipboard;
|
||||||
@ -213,9 +211,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
if (width * height * length != 0) {
|
if (width * height * length != 0) {
|
||||||
init();
|
init();
|
||||||
// write length etc
|
// write length etc
|
||||||
mbb.putChar(2, (char) width);
|
byteBuffer.putChar(2, (char) width);
|
||||||
mbb.putChar(4, (char) height);
|
byteBuffer.putChar(4, (char) height);
|
||||||
mbb.putChar(6, (char) length);
|
byteBuffer.putChar(6, (char) length);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -225,9 +223,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void setOrigin(BlockVector3 offset) {
|
public void setOrigin(BlockVector3 offset) {
|
||||||
try {
|
try {
|
||||||
mbb.putShort(8, (short) offset.getBlockX());
|
byteBuffer.putShort(8, (short) offset.getBlockX());
|
||||||
mbb.putShort(10, (short) offset.getBlockY());
|
byteBuffer.putShort(10, (short) offset.getBlockY());
|
||||||
mbb.putShort(12, (short) offset.getBlockZ());
|
byteBuffer.putShort(12, (short) offset.getBlockZ());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -248,9 +246,9 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
braf.setLength(size);
|
braf.setLength(size);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
mbb.putChar(2, (char) width);
|
byteBuffer.putChar(2, (char) width);
|
||||||
mbb.putChar(4, (char) height);
|
byteBuffer.putChar(4, (char) height);
|
||||||
mbb.putChar(6, (char) length);
|
byteBuffer.putChar(6, (char) length);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -258,7 +256,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flush() {
|
public void flush() {
|
||||||
mbb.force();
|
byteBuffer.force();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiskOptimizedClipboard(int width, int height, int length) {
|
public DiskOptimizedClipboard(int width, int height, int length) {
|
||||||
@ -267,7 +265,6 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
|
|
||||||
private void closeDirectBuffer(ByteBuffer cb) {
|
private void closeDirectBuffer(ByteBuffer cb) {
|
||||||
if (cb == null || !cb.isDirect()) return;
|
if (cb == null || !cb.isDirect()) return;
|
||||||
|
|
||||||
// we could use this type cast and call functions without reflection code,
|
// we could use this type cast and call functions without reflection code,
|
||||||
// but static import from sun.* package is risky for non-SUN virtual machine.
|
// but static import from sun.* package is risky for non-SUN virtual machine.
|
||||||
//try { ((sun.nio.ch.DirectBuffer)cb).cleaner().clean(); } catch (Exception ex) { }
|
//try { ((sun.nio.ch.DirectBuffer)cb).cleaner().clean(); } catch (Exception ex) { }
|
||||||
@ -299,14 +296,15 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
try {
|
try {
|
||||||
if (mbb != null) {
|
if (byteBuffer != null) {
|
||||||
mbb.force();
|
byteBuffer.force();
|
||||||
fc.close();
|
fileChannel.close();
|
||||||
braf.close();
|
braf.close();
|
||||||
|
//noinspection ResultOfMethodCallIgnored
|
||||||
file.setWritable(true);
|
file.setWritable(true);
|
||||||
closeDirectBuffer(mbb);
|
closeDirectBuffer(byteBuffer);
|
||||||
mbb = null;
|
byteBuffer = null;
|
||||||
fc = null;
|
fileChannel = null;
|
||||||
braf = null;
|
braf = null;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -337,13 +335,13 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void streamCombinedIds(NBTStreamer.ByteReader task) {
|
public void streamCombinedIds(NBTStreamer.ByteReader task) {
|
||||||
try {
|
try {
|
||||||
mbb.force();
|
byteBuffer.force();
|
||||||
int pos = HEADER_SIZE;
|
int pos = HEADER_SIZE;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, pos += 4) {
|
for (int x = 0; x < width; x++, pos += 4) {
|
||||||
int combinedId = mbb.getInt(pos);
|
int combinedId = byteBuffer.getInt(pos);
|
||||||
task.run(index++, combinedId);
|
task.run(index++, combinedId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,7 +358,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(final BlockReader task, boolean air) {
|
public void forEach(final BlockReader task, boolean air) {
|
||||||
mbb.force();
|
byteBuffer.force();
|
||||||
int pos = HEADER_SIZE;
|
int pos = HEADER_SIZE;
|
||||||
IntegerTrio trio = new IntegerTrio();
|
IntegerTrio trio = new IntegerTrio();
|
||||||
final boolean hasTile = !nbtMap.isEmpty();
|
final boolean hasTile = !nbtMap.isEmpty();
|
||||||
@ -369,7 +367,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, pos += 4) {
|
for (int x = 0; x < width; x++, pos += 4) {
|
||||||
int combinedId = mbb.getInt(pos);
|
int combinedId = byteBuffer.getInt(pos);
|
||||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||||
BlockState state = type.withStateId(combinedId);
|
BlockState state = type.withStateId(combinedId);
|
||||||
if (type.getMaterial().hasContainer()) {
|
if (type.getMaterial().hasContainer()) {
|
||||||
@ -388,7 +386,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, pos += 4) {
|
for (int x = 0; x < width; x++, pos += 4) {
|
||||||
int combinedId = mbb.getInt(pos);
|
int combinedId = byteBuffer.getInt(pos);
|
||||||
BlockState state = BlockState.getFromInternalId(combinedId);
|
BlockState state = BlockState.getFromInternalId(combinedId);
|
||||||
task.run(x, y, z, state);
|
task.run(x, y, z, state);
|
||||||
}
|
}
|
||||||
@ -399,7 +397,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, pos += 4) {
|
for (int x = 0; x < width; x++, pos += 4) {
|
||||||
int combinedId = mbb.getInt(pos);
|
int combinedId = byteBuffer.getInt(pos);
|
||||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||||
if (!type.getMaterial().isAir()) {
|
if (!type.getMaterial().isAir()) {
|
||||||
BlockState state = type.withStateId(combinedId);
|
BlockState state = type.withStateId(combinedId);
|
||||||
@ -427,7 +425,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
public BaseBlock getBlock(int x, int y, int z) {
|
public BaseBlock getBlock(int x, int y, int z) {
|
||||||
try {
|
try {
|
||||||
int index = HEADER_SIZE + (getIndex(x, y, z) << 2);
|
int index = HEADER_SIZE + (getIndex(x, y, z) << 2);
|
||||||
int combinedId = mbb.getInt(index);
|
int combinedId = byteBuffer.getInt(index);
|
||||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||||
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
|
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
|
||||||
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
|
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
|
||||||
@ -440,7 +438,6 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
} catch (IndexOutOfBoundsException ignore) {
|
} catch (IndexOutOfBoundsException ignore) {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||||
}
|
}
|
||||||
@ -449,7 +446,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
public BaseBlock getBlock(int i) {
|
public BaseBlock getBlock(int i) {
|
||||||
try {
|
try {
|
||||||
int diskIndex = (HEADER_SIZE) + (i << 2);
|
int diskIndex = (HEADER_SIZE) + (i << 2);
|
||||||
int combinedId = mbb.getInt(diskIndex);
|
int combinedId = byteBuffer.getInt(diskIndex);
|
||||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||||
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
|
BaseBlock base = type.withStateId(combinedId).toBaseBlock();
|
||||||
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
|
if (type.getMaterial().hasContainer() && !nbtMap.isEmpty()) {
|
||||||
@ -499,7 +496,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
try {
|
try {
|
||||||
int index = (HEADER_SIZE) + ((getIndex(x, y, z) << 2));
|
int index = (HEADER_SIZE) + ((getIndex(x, y, z) << 2));
|
||||||
int combined = block.getInternalId();
|
int combined = block.getInternalId();
|
||||||
mbb.putInt(index, combined);
|
byteBuffer.putInt(index, combined);
|
||||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
if (hasNbt) {
|
if (hasNbt) {
|
||||||
setTile(x, y, z, block.getNbtData());
|
setTile(x, y, z, block.getNbtData());
|
||||||
@ -516,7 +513,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
try {
|
try {
|
||||||
int combined = block.getInternalId();
|
int combined = block.getInternalId();
|
||||||
int index = (HEADER_SIZE) + (i << 2);
|
int index = (HEADER_SIZE) + (i << 2);
|
||||||
mbb.putInt(index, combined);
|
byteBuffer.putInt(index, combined);
|
||||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
if (hasNbt) {
|
if (hasNbt) {
|
||||||
int y = i / area;
|
int y = i / area;
|
||||||
|
@ -5,6 +5,7 @@ import com.boydti.fawe.jnbt.NBTStreamer;
|
|||||||
import com.boydti.fawe.object.IntegerTrio;
|
import com.boydti.fawe.object.IntegerTrio;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.IntTag;
|
import com.sk89q.jnbt.IntTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
@ -28,9 +29,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class MemoryOptimizedClipboard extends FaweClipboard {
|
public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||||
|
|
||||||
public static final int BLOCK_SIZE = 1048576 * 4;
|
private static final int BLOCK_SIZE = 1048576 * 4;
|
||||||
public static final int BLOCK_MASK = 1048575;
|
private static final int BLOCK_MASK = 1048575;
|
||||||
public static final int BLOCK_SHIFT = 20;
|
private static final int BLOCK_SHIFT = 20;
|
||||||
|
|
||||||
private int length;
|
private int length;
|
||||||
private int height;
|
private int height;
|
||||||
@ -338,9 +339,9 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
|||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int index, B block) {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int index, B block) {
|
||||||
int combinedId = block.getInternalId();
|
int combinedId = block.getInternalId();
|
||||||
setCombinedId(index, combinedId);
|
setCombinedId(index, combinedId);
|
||||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
if (hasNbt) {
|
if (hasNbt) {
|
||||||
setTile(index, ((BaseBlock)block).getNbtData());
|
setTile(index, block.getNbtData());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -32,19 +32,14 @@ public class AverageColorPattern extends AbstractExtentPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
BlockType blockType = extent.getBlock(getPosition).getBlockType();
|
BlockType blockType = get.getBlock(extent).getBlockType();
|
||||||
TextureUtil util = holder.getTextureUtil();
|
TextureUtil util = holder.getTextureUtil();
|
||||||
int currentColor = util.getColor(blockType);
|
int currentColor = util.getColor(blockType);
|
||||||
if (currentColor == 0) return false;
|
if (currentColor == 0) return false;
|
||||||
int newColor = util.averageColor(currentColor, color);
|
int newColor = util.averageColor(currentColor, color);
|
||||||
BlockType newBlock = util.getNearestBlock(newColor);
|
BlockType newBlock = util.getNearestBlock(newColor);
|
||||||
if (newBlock == blockType) return false;
|
if (newBlock == blockType) return false;
|
||||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
return set.setBlock(extent, newBlock.getDefaultState());
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import java.io.IOException;
|
|||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
|
|
||||||
public class DesaturatePattern extends AbstractPattern {
|
public class DesaturatePattern extends AbstractPattern {
|
||||||
private transient TextureHolder holder;
|
private final TextureHolder holder;
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
private final double value;
|
private final double value;
|
||||||
|
|
||||||
@ -27,7 +27,11 @@ public class DesaturatePattern extends AbstractPattern {
|
|||||||
public BaseBlock apply(BlockVector3 position) {
|
public BaseBlock apply(BlockVector3 position) {
|
||||||
BlockType block = extent.getBlock(position).getBlockType();
|
BlockType block = extent.getBlock(position).getBlockType();
|
||||||
TextureUtil util = holder.getTextureUtil();
|
TextureUtil util = holder.getTextureUtil();
|
||||||
int color = util.getColor(block);
|
int color = getColor(util.getColor(block));
|
||||||
|
return util.getNearestBlock(color).getDefaultState().toBaseBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColor(int color) {
|
||||||
int r = (color >> 16) & 0xFF;
|
int r = (color >> 16) & 0xFF;
|
||||||
int g = (color >> 8) & 0xFF;
|
int g = (color >> 8) & 0xFF;
|
||||||
int b = (color >> 0) & 0xFF;
|
int b = (color >> 0) & 0xFF;
|
||||||
@ -37,35 +41,22 @@ public class DesaturatePattern extends AbstractPattern {
|
|||||||
int green = (int) (g + value * (l - g));
|
int green = (int) (g + value * (l - g));
|
||||||
int blue = (int) (b + value * (l - b));
|
int blue = (int) (b + value * (l - b));
|
||||||
int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
|
int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
|
||||||
return util.getNearestBlock(newColor).getDefaultState().toBaseBlock();
|
return newColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
BlockType block = extent.getBlock(getPosition).getBlockType();
|
BlockType type = get.getBlock(extent).getBlockType();
|
||||||
TextureUtil util = holder.getTextureUtil();
|
TextureUtil util = holder.getTextureUtil();
|
||||||
int color = util.getColor(block);
|
int color = util.getColor(type);
|
||||||
int r = (color >> 16) & 0xFF;
|
int newColor = getColor(color);
|
||||||
int g = (color >> 8) & 0xFF;
|
|
||||||
int b = (color >> 0) & 0xFF;
|
|
||||||
int alpha = (color >> 24) & 0xFF;
|
|
||||||
double l = 0.3f * r + 0.6f * g + 0.1f * b;
|
|
||||||
int red = (int) (r + value * (l - r));
|
|
||||||
int green = (int) (g + value * (l - g));
|
|
||||||
int blue = (int) (b + value * (l - b));
|
|
||||||
int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
|
|
||||||
if (newColor == color) {
|
if (newColor == color) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BlockType newBlock = util.getNextNearestBlock(newColor);
|
BlockType newType = util.getNextNearestBlock(newColor);
|
||||||
if (block.equals(newBlock)) {
|
if (type.equals(newType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
return set.setBlock(extent, newType.getDefaultState());
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.boydti.fawe.util.TextureHolder;
|
import com.boydti.fawe.util.TextureHolder;
|
||||||
import com.boydti.fawe.util.TextureUtil;
|
import com.boydti.fawe.util.TextureUtil;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -14,7 +15,7 @@ import java.io.IOException;
|
|||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
|
|
||||||
public class SaturatePattern extends AbstractPattern {
|
public class SaturatePattern extends AbstractPattern {
|
||||||
private transient TextureHolder holder;
|
private final TextureHolder holder;
|
||||||
private final int color;
|
private final int color;
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
|
|
||||||
@ -35,19 +36,14 @@ public class SaturatePattern extends AbstractPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
BlockType block = extent.getBlock(getPosition).getBlockType();
|
BlockType block = get.getBlock(extent).getBlockType();
|
||||||
TextureUtil util = holder.getTextureUtil();
|
TextureUtil util = holder.getTextureUtil();
|
||||||
int currentColor = util.getColor(block);
|
int currentColor = util.getColor(block);
|
||||||
if (currentColor == 0) return false;
|
if (currentColor == 0) return false;
|
||||||
int newColor = util.multiplyColor(currentColor, color);
|
int newColor = util.multiplyColor(currentColor, color);
|
||||||
BlockType newBlock = util.getNearestBlock(newColor);
|
BlockType newBlock = util.getNearestBlock(newColor);
|
||||||
if (newBlock.equals(block)) return false;
|
if (newBlock.equals(block)) return false;
|
||||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
return set.setBlock(extent, newBlock.getDefaultState());
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,16 @@ package com.boydti.fawe.object.pattern;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.util.TextureUtil;
|
import com.boydti.fawe.util.TextureUtil;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class ShadePattern extends AbstractPattern {
|
public class ShadePattern extends AbstractPattern {
|
||||||
private transient TextureUtil util;
|
private final TextureUtil util;
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
private final boolean darken;
|
private final boolean darken;
|
||||||
|
|
||||||
@ -29,8 +28,13 @@ public class ShadePattern extends AbstractPattern {
|
|||||||
return (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block)).getDefaultState().toBaseBlock();
|
return (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block)).getDefaultState().toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
@Override
|
||||||
stream.defaultReadObject();
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
util = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
BlockType type = get.getBlock(extent).getBlockType();
|
||||||
|
BlockType newType = (darken ? util.getDarkerBlock(type) : util.getLighterBlock(type));
|
||||||
|
if (type != newType) {
|
||||||
|
return set.setBlock(extent, newType.getDefaultState());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,24 @@ package com.boydti.fawe.util;
|
|||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
||||||
import com.boydti.fawe.object.FaweLimit;
|
import com.boydti.fawe.object.FaweLimit;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.HistoryExtent;
|
||||||
import com.boydti.fawe.object.NullChangeSet;
|
import com.boydti.fawe.object.NullChangeSet;
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||||
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
|
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
|
||||||
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import com.boydti.fawe.object.extent.NullExtent;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||||
@ -26,10 +29,12 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class EditSessionBuilder {
|
public class EditSessionBuilder {
|
||||||
private World world;
|
private World world;
|
||||||
private String worldName;
|
private String worldName;
|
||||||
private FaweQueue queue;
|
private Extent extent;
|
||||||
private FawePlayer player;
|
private FawePlayer player;
|
||||||
private FaweLimit limit;
|
private FaweLimit limit;
|
||||||
private FaweChangeSet changeSet;
|
private FaweChangeSet changeSet;
|
||||||
@ -60,9 +65,17 @@ public class EditSessionBuilder {
|
|||||||
public EditSessionBuilder(@Nonnull World world) {
|
public EditSessionBuilder(@Nonnull World world) {
|
||||||
checkNotNull(world);
|
checkNotNull(world);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
this.extent = world;
|
||||||
this.worldName = Fawe.imp().getWorldName(world);
|
this.worldName = Fawe.imp().getWorldName(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EditSessionBuilder(World world, String worldName) {
|
||||||
|
if (world == null && worldName == null) throw new NullPointerException("Both world and worldname cannot be null");
|
||||||
|
this.world = world;
|
||||||
|
this.extent = world;
|
||||||
|
this.worldName = worldName;
|
||||||
|
}
|
||||||
|
|
||||||
public EditSessionBuilder(@Nonnull String worldName) {
|
public EditSessionBuilder(@Nonnull String worldName) {
|
||||||
checkNotNull(worldName);
|
checkNotNull(worldName);
|
||||||
this.worldName = worldName;
|
this.worldName = worldName;
|
||||||
@ -176,8 +189,8 @@ public class EditSessionBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditSessionBuilder queue(@Nullable FaweQueue queue) {
|
public EditSessionBuilder extent(@Nullable Extent extent) {
|
||||||
this.queue = queue;
|
this.extent = extent;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,10 +204,261 @@ public class EditSessionBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean wrapped;
|
||||||
|
|
||||||
|
private AbstractDelegateExtent wrapExtent(final AbstractDelegateExtent extent, final EventBus eventBus, EditSessionEvent event, final EditSession.Stage stage) {
|
||||||
|
event = event.clone(stage);
|
||||||
|
event.setExtent(extent);
|
||||||
|
eventBus.post(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return new NullExtent(extent, FaweException.MANUAL);
|
||||||
|
}
|
||||||
|
final Extent toReturn = event.getExtent();
|
||||||
|
if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) {
|
||||||
|
return new NullExtent(toReturn, FaweException.MANUAL);
|
||||||
|
}
|
||||||
|
if (!(toReturn instanceof AbstractDelegateExtent)) {
|
||||||
|
Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
|
||||||
|
return extent;
|
||||||
|
}
|
||||||
|
if (toReturn != extent) {
|
||||||
|
String className = toReturn.getClass().getName().toLowerCase();
|
||||||
|
for (String allowed : Settings.IMP.EXTENT.ALLOWED_PLUGINS) {
|
||||||
|
if (className.contains(allowed.toLowerCase())) {
|
||||||
|
this.wrapped = true;
|
||||||
|
return (AbstractDelegateExtent) toReturn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Settings.IMP.EXTENT.DEBUG) {
|
||||||
|
Fawe.debug("&cPotentially unsafe extent blocked: " + toReturn.getClass().getName());
|
||||||
|
Fawe.debug("&8 - &7For area restrictions, it is recommended to use the FaweAPI");
|
||||||
|
Fawe.debug("&8 - &7For block logging, it is recommended to use use BlocksHub");
|
||||||
|
Fawe.debug("&8 - &7To allow this plugin add it to the FAWE `allowed-plugins` list");
|
||||||
|
Fawe.debug("&8 - &7To hide this message set `debug` to false in the FAWE config.yml");
|
||||||
|
if (toReturn.getClass().getName().contains("CoreProtect")) {
|
||||||
|
Fawe.debug("Note on CoreProtect: ");
|
||||||
|
Fawe.debug(" - If you disable CP's WE logger (CP config) and this still shows, please update CP");
|
||||||
|
Fawe.debug(" - Use BlocksHub and set `debug` false in the FAWE config");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return extent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FaweChangeSet changeTask;
|
||||||
|
private int maxY;
|
||||||
|
private HistoryExtent history;
|
||||||
|
private AbstractDelegateExtent bypassHistory;
|
||||||
|
private AbstractDelegateExtent bypassAll;
|
||||||
|
|
||||||
|
public EditSessionBuilder compile() {
|
||||||
|
if (extent != null) return this;
|
||||||
|
|
||||||
|
wrapped = false;
|
||||||
|
if (world == null && !this.worldName.isEmpty()) {
|
||||||
|
world = FaweAPI.getWorld(this.worldName);
|
||||||
|
}
|
||||||
|
if (eventBus == null) {
|
||||||
|
eventBus = WorldEdit.getInstance().getEventBus();
|
||||||
|
}
|
||||||
|
if (event == null) {
|
||||||
|
event = new EditSessionEvent(world, player == null ? null : (player.getPlayer()), -1, null);
|
||||||
|
}
|
||||||
|
if (player == null && event.getActor() != null) {
|
||||||
|
player = FawePlayer.wrap(event.getActor());
|
||||||
|
}
|
||||||
|
if (limit == null) {
|
||||||
|
if (player == null) {
|
||||||
|
limit = FaweLimit.MAX;
|
||||||
|
} else {
|
||||||
|
limit = player.getLimit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (autoQueue == null) {
|
||||||
|
autoQueue = true;
|
||||||
|
}
|
||||||
|
if (fastmode == null) {
|
||||||
|
if (player == null) {
|
||||||
|
fastmode = !Settings.IMP.HISTORY.ENABLE_FOR_CONSOLE;
|
||||||
|
} else {
|
||||||
|
fastmode = player.getSession().hasFastMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (checkMemory == null) {
|
||||||
|
checkMemory = player != null && !this.fastmode;
|
||||||
|
}
|
||||||
|
if (checkMemory) {
|
||||||
|
if (MemUtil.isMemoryLimitedSlow()) {
|
||||||
|
if (Perm.hasPermission(player, "worldedit.fast")) {
|
||||||
|
BBC.WORLDEDIT_OOM_ADMIN.send(player);
|
||||||
|
}
|
||||||
|
throw FaweException.LOW_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// this.originalLimit = limit;
|
||||||
|
this.blockBag = limit.INVENTORY_MODE != 0 ? blockBag : null;
|
||||||
|
// this.limit = limit.copy();
|
||||||
|
|
||||||
|
// if (queue == null) {
|
||||||
|
// boolean placeChunks = this.fastmode || this.limit.FAST_PLACEMENT;
|
||||||
|
// World unwrapped = WorldWrapper.unwrap(world);
|
||||||
|
// if (unwrapped instanceof FaweQueue) {
|
||||||
|
// queue = (FaweQueue) unwrapped;
|
||||||
|
// } else if (unwrapped instanceof MCAWorld) {
|
||||||
|
// queue = ((MCAWorld) unwrapped).getQueue();
|
||||||
|
// } else if (player != null && world.equals(player.getWorld())) {
|
||||||
|
// queue = player.getFaweQueue(placeChunks, autoQueue);
|
||||||
|
// } else {
|
||||||
|
// queue = SetQueue.IMP.getNewQueue(world, placeChunks, autoQueue);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (combineStages == null) {
|
||||||
|
// combineStages =
|
||||||
|
// // If it's enabled in the settings
|
||||||
|
// Settings.IMP.HISTORY.COMBINE_STAGES
|
||||||
|
// // If fast placement is disabled, it's slower to perform a copy on each chunk
|
||||||
|
// && this.limit.FAST_PLACEMENT
|
||||||
|
// // If the specific queue doesn't support it
|
||||||
|
// && queue.supports(FaweQueue.Capability.CHANGE_TASKS)
|
||||||
|
// // If the edit uses items from the inventory we can't use a delayed task
|
||||||
|
// && this.blockBag == null;
|
||||||
|
// }
|
||||||
|
// if (!Settings.IMP.QUEUE.PROGRESS.DISPLAY.equalsIgnoreCase("false") && player != null) {
|
||||||
|
// switch (Settings.IMP.QUEUE.PROGRESS.DISPLAY.toLowerCase()) {
|
||||||
|
// case "chat":
|
||||||
|
// this.queue.setProgressTask(new ChatProgressTracker(player));
|
||||||
|
// break;
|
||||||
|
// case "title":
|
||||||
|
// case "true":
|
||||||
|
// default:
|
||||||
|
// this.queue.setProgressTask(new DefaultProgressTracker(player));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// this.bypassAll = wrapExtent(new FastWorldEditExtent(world, queue), eventBus, event, EditSession.Stage.BEFORE_CHANGE);
|
||||||
|
// this.bypassHistory = (this.extent = wrapExtent(bypassAll, eventBus, event, EditSession.Stage.BEFORE_REORDER));
|
||||||
|
// if (!this.fastmode || changeSet != null) {
|
||||||
|
// if (changeSet == null) {
|
||||||
|
// if (Settings.IMP.HISTORY.USE_DISK) {
|
||||||
|
// UUID uuid = player == null ? EditSession.CONSOLE : player.getUUID();
|
||||||
|
// if (Settings.IMP.HISTORY.USE_DATABASE) {
|
||||||
|
// changeSet = new RollbackOptimizedHistory(world, uuid);
|
||||||
|
// } else {
|
||||||
|
// changeSet = new DiskStorageHistory(world, uuid);
|
||||||
|
// }
|
||||||
|
// } else if (combineStages && Settings.IMP.HISTORY.COMPRESSION_LEVEL == 0 && !(queue instanceof MCAQueue)) {
|
||||||
|
// changeSet = new CPUOptimizedChangeSet(world);
|
||||||
|
// } else {
|
||||||
|
// changeSet = new MemoryOptimizedHistory(world);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (this.limit.SPEED_REDUCTION > 0) {
|
||||||
|
// this.bypassHistory = new SlowExtent(this.bypassHistory, this.limit.SPEED_REDUCTION);
|
||||||
|
// }
|
||||||
|
// if (changeSet instanceof NullChangeSet && Fawe.imp().getBlocksHubApi() != null && player != null) {
|
||||||
|
// changeSet = LoggingChangeSet.wrap(player, changeSet);
|
||||||
|
// }
|
||||||
|
// if (!(changeSet instanceof NullChangeSet)) {
|
||||||
|
// if (!(changeSet instanceof LoggingChangeSet) && player != null && Fawe.imp().getBlocksHubApi() != null) {
|
||||||
|
// changeSet = LoggingChangeSet.wrap(player, changeSet);
|
||||||
|
// }
|
||||||
|
// if (this.blockBag != null) {
|
||||||
|
// changeSet = new BlockBagChangeSet(changeSet, blockBag, limit.INVENTORY_MODE == 1);
|
||||||
|
// }
|
||||||
|
// if (combineStages) {
|
||||||
|
// changeTask = changeSet;
|
||||||
|
// changeSet.addChangeTask(queue);
|
||||||
|
// } else {
|
||||||
|
// this.extent = (history = new HistoryExtent(bypassHistory, changeSet, queue));
|
||||||
|
//// if (this.blockBag != null) {
|
||||||
|
//// this.extent = new BlockBagExtent(this.extent, blockBag, limit.INVENTORY_MODE == 1);
|
||||||
|
//// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (allowedRegions == null) {
|
||||||
|
// if (player != null && !player.hasPermission("fawe.bypass") && !player.hasPermission("fawe.bypass.regions") && !(queue instanceof VirtualWorld)) {
|
||||||
|
// allowedRegions = player.getCurrentRegions();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// this.maxY = world == null ? 255 : world.getMaxY();
|
||||||
|
// if (allowedRegions != null) {
|
||||||
|
// if (allowedRegions.length == 0) {
|
||||||
|
// this.extent = new NullExtent(this.extent, FaweException.NO_REGION);
|
||||||
|
// } else {
|
||||||
|
// this.extent = new ProcessedWEExtent(this.extent, this.limit);
|
||||||
|
// if (allowedRegions.length == 1) {
|
||||||
|
// this.extent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
|
||||||
|
// } else {
|
||||||
|
// this.extent = new MultiRegionExtent(this.extent, this.limit, allowedRegions);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// this.extent = new HeightBoundExtent(this.extent, this.limit, 0, maxY);
|
||||||
|
// }
|
||||||
|
// if (this.limit.STRIP_NBT != null && !this.limit.STRIP_NBT.isEmpty()) {
|
||||||
|
// this.extent = new StripNBTExtent(this.extent, this.limit.STRIP_NBT);
|
||||||
|
// }
|
||||||
|
// this.extent = wrapExtent(this.extent, eventBus, event, EditSession.Stage.BEFORE_HISTORY);
|
||||||
|
// return this;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public EditSession build() {
|
public EditSession build() {
|
||||||
if (eventBus == null) {
|
if (eventBus == null) {
|
||||||
eventBus = WorldEdit.getInstance().getEventBus();
|
eventBus = WorldEdit.getInstance().getEventBus();
|
||||||
}
|
}
|
||||||
return new EditSession(worldName, world, queue, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, eventBus, event);
|
return new EditSession(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Extent getExtent() {
|
||||||
|
return extent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWorldName() {
|
||||||
|
return worldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWrapped() {
|
||||||
|
return wrapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasFastMode() {
|
||||||
|
return fastmode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HistoryExtent getHistory() {
|
||||||
|
return history;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractDelegateExtent getBypassHistory() {
|
||||||
|
return bypassHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractDelegateExtent getBypassAll() {
|
||||||
|
return bypassAll;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FaweLimit getLimit() {
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FawePlayer getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FaweChangeSet getChangeTask() {
|
||||||
|
return changeTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockBag getBlockBag() {
|
||||||
|
return blockBag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxY() {
|
||||||
|
return maxY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,8 @@ public final class NBTInputStream implements Closeable {
|
|||||||
* from the specified input stream.
|
* from the specified input stream.
|
||||||
*
|
*
|
||||||
* @param is the input stream
|
* @param is the input stream
|
||||||
* @throws IOException if an I/O error occurs
|
|
||||||
*/
|
*/
|
||||||
public NBTInputStream(InputStream is) throws IOException {
|
public NBTInputStream(InputStream is) {
|
||||||
this.is = new DataInputStream(is);
|
this.is = new DataInputStream(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,7 +363,7 @@ public final class NBTInputStream implements Closeable {
|
|||||||
int toRead = Math.min(length << 2, buf.length);
|
int toRead = Math.min(length << 2, buf.length);
|
||||||
is.readFully(buf, 0, toRead);
|
is.readFully(buf, 0, toRead);
|
||||||
for (int i = 0; i < toRead; i += 4, index++) {
|
for (int i = 0; i < toRead; i += 4, index++) {
|
||||||
data[index] = ((buf[i + 0] & 0xFF) << 24) + ((buf[i + 1] & 0xFF) << 16) + ((buf[i + 2] & 0xFF) << 8) + (buf[i + 3] & 0xFF);
|
data[index] = ((buf[i] & 0xFF) << 24) + ((buf[i + 1] & 0xFF) << 16) + ((buf[i + 2] & 0xFF) << 8) + (buf[i + 3] & 0xFF);
|
||||||
}
|
}
|
||||||
length -= toRead;
|
length -= toRead;
|
||||||
}
|
}
|
||||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -38,6 +38,7 @@ import com.boydti.fawe.util.MaskTraverser;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -91,6 +92,7 @@ import java.util.Set;
|
|||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clipboard commands.
|
* Clipboard commands.
|
||||||
*/
|
*/
|
||||||
@ -123,20 +125,24 @@ public class ClipboardCommands {
|
|||||||
Mask mask, CommandContext context) throws WorldEditException {
|
Mask mask, CommandContext context) throws WorldEditException {
|
||||||
BlockVector3 min = region.getMinimumPoint();
|
BlockVector3 min = region.getMinimumPoint();
|
||||||
BlockVector3 max = region.getMaximumPoint();
|
BlockVector3 max = region.getMaximumPoint();
|
||||||
|
|
||||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||||
if (volume >= limit.MAX_CHECKS) {
|
if (volume >= limit.MAX_CHECKS) {
|
||||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
throw FaweException.MAX_CHECKS;
|
||||||
}
|
}
|
||||||
fp.checkConfirmationRegion(() -> {
|
fp.checkConfirmationRegion(() -> {
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||||
|
|
||||||
session.setClipboard(new ClipboardHolder(clipboard));
|
session.setClipboard(new ClipboardHolder(clipboard));
|
||||||
|
|
||||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||||
copy.setCopyingEntities(!skipEntities);
|
copy.setCopyingEntities(!skipEntities);
|
||||||
copy.setCopyingBiomes(copyBiomes);
|
copy.setCopyingBiomes(copyBiomes);
|
||||||
|
|
||||||
Mask sourceMask = editSession.getSourceMask();
|
Mask sourceMask = editSession.getSourceMask();
|
||||||
if (sourceMask != null) {
|
if (sourceMask != null) {
|
||||||
new MaskTraverser(sourceMask).reset(editSession);
|
new MaskTraverser(sourceMask).reset(editSession);
|
||||||
@ -204,12 +210,13 @@ public class ClipboardCommands {
|
|||||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||||
if (volume >= limit.MAX_CHECKS) {
|
if (volume >= limit.MAX_CHECKS) {
|
||||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
throw FaweException.MAX_CHECKS;
|
||||||
}
|
}
|
||||||
if (volume >= limit.MAX_CHANGES) {
|
if (volume >= limit.MAX_CHANGES) {
|
||||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
throw FaweException.MAX_CHANGES;
|
||||||
}
|
}
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
|
|
||||||
ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
|
ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes);
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard);
|
||||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||||
@ -221,6 +228,7 @@ public class ClipboardCommands {
|
|||||||
name = "/cut",
|
name = "/cut",
|
||||||
desc = "Cut the selection to the clipboard",
|
desc = "Cut the selection to the clipboard",
|
||||||
descFooter = "WARNING: Cutting and pasting entities cannot be undone!"
|
descFooter = "WARNING: Cutting and pasting entities cannot be undone!"
|
||||||
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.cut")
|
@CommandPermissions("worldedit.clipboard.cut")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@ -237,21 +245,24 @@ public class ClipboardCommands {
|
|||||||
CommandContext context) throws WorldEditException {
|
CommandContext context) throws WorldEditException {
|
||||||
BlockVector3 min = region.getMinimumPoint();
|
BlockVector3 min = region.getMinimumPoint();
|
||||||
BlockVector3 max = region.getMaximumPoint();
|
BlockVector3 max = region.getMaximumPoint();
|
||||||
|
|
||||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||||
if (volume >= limit.MAX_CHECKS) {
|
if (volume >= limit.MAX_CHECKS) {
|
||||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
throw FaweException.MAX_CHECKS;
|
||||||
}
|
}
|
||||||
if (volume >= limit.MAX_CHANGES) {
|
if (volume >= limit.MAX_CHANGES) {
|
||||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES);
|
throw FaweException.MAX_CHANGES;
|
||||||
}
|
}
|
||||||
fp.checkConfirmationRegion(() -> {
|
fp.checkConfirmationRegion(() -> {
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
|
|
||||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
|
||||||
clipboard.setOrigin(session.getPlacementPosition(player));
|
clipboard.setOrigin(session.getPlacementPosition(player));
|
||||||
|
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
|
||||||
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
|
||||||
copy.setCopyingEntities(!skipEntities);
|
copy.setCopyingEntities(copyEntities);
|
||||||
copy.setRemovingEntities(true);
|
copy.setRemovingEntities(true);
|
||||||
copy.setCopyingBiomes(copyBiomes);
|
copy.setCopyingBiomes(copyBiomes);
|
||||||
Mask sourceMask = editSession.getSourceMask();
|
Mask sourceMask = editSession.getSourceMask();
|
||||||
@ -413,6 +424,7 @@ public class ClipboardCommands {
|
|||||||
@Command(
|
@Command(
|
||||||
name = "/paste",
|
name = "/paste",
|
||||||
desc = "Paste the clipboard's contents"
|
desc = "Paste the clipboard's contents"
|
||||||
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.paste")
|
@CommandPermissions("worldedit.clipboard.paste")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
@ -481,6 +493,7 @@ public class ClipboardCommands {
|
|||||||
name = "/place",
|
name = "/place",
|
||||||
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)"
|
desc = "Place the clipboard's contents without applying transformations (e.g. rotate)"
|
||||||
)
|
)
|
||||||
|
|
||||||
@CommandPermissions("worldedit.clipboard.place")
|
@CommandPermissions("worldedit.clipboard.place")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void place(Player player, LocalSession session, final EditSession editSession,
|
public void place(Player player, LocalSession session, final EditSession editSession,
|
||||||
@ -551,6 +564,7 @@ public class ClipboardCommands {
|
|||||||
public void flip(Player player, LocalSession session,
|
public void flip(Player player, LocalSession session,
|
||||||
@Arg(desc = "The direction to flip, defaults to look direction.", def = Direction.AIM)
|
@Arg(desc = "The direction to flip, defaults to look direction.", def = Direction.AIM)
|
||||||
@Direction BlockVector3 direction) throws WorldEditException {
|
@Direction BlockVector3 direction) throws WorldEditException {
|
||||||
|
|
||||||
ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
AffineTransform transform = new AffineTransform();
|
AffineTransform transform = new AffineTransform();
|
||||||
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
|
transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3());
|
||||||
@ -563,7 +577,7 @@ public class ClipboardCommands {
|
|||||||
desc = "Clear your clipboard"
|
desc = "Clear your clipboard"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.clear")
|
@CommandPermissions("worldedit.clipboard.clear")
|
||||||
public void clearClipboard(Player player, LocalSession session) throws WorldEditException {
|
public void clearClipboard(Player player, LocalSession session, EditSession editSession) throws WorldEditException {
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
BBC.CLIPBOARD_CLEARED.send(player);
|
BBC.CLIPBOARD_CLEARED.send(player);
|
||||||
}
|
}
|
||||||
|
@ -205,6 +205,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
" - Use to replace slabs or where the data values needs to be shifted instead of set"
|
" - Use to replace slabs or where the data values needs to be shifted instead of set"
|
||||||
)
|
)
|
||||||
public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
|
public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
|
||||||
|
|
||||||
return new IdDataMaskPattern(extent, pattern, bitmask);
|
return new IdDataMaskPattern(extent, pattern, bitmask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,6 +214,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Only change the block id"
|
desc = "Only change the block id"
|
||||||
)
|
)
|
||||||
public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||||
|
|
||||||
return new IdPattern(extent, pattern);
|
return new IdPattern(extent, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,6 +223,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Only change the block data"
|
desc = "Only change the block data"
|
||||||
)
|
)
|
||||||
public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||||
|
|
||||||
return new DataPattern(extent, pattern);
|
return new DataPattern(extent, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,6 +233,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Set the biome"
|
desc = "Set the biome"
|
||||||
)
|
)
|
||||||
public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
|
public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
|
||||||
|
|
||||||
return new BiomePattern(extent, biome);
|
return new BiomePattern(extent, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,6 +243,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Offset the pattern to where you click"
|
desc = "Offset the pattern to where you click"
|
||||||
)
|
)
|
||||||
public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||||
|
|
||||||
return new RelativePattern(pattern);
|
return new RelativePattern(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,6 +255,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
"Example: #!x[#!z[#~[#l3d[pattern]]]]"
|
"Example: #!x[#!z[#~[#l3d[pattern]]]]"
|
||||||
)
|
)
|
||||||
public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||||
|
|
||||||
return new NoXPattern(pattern);
|
return new NoXPattern(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,6 +265,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "The pattern will not be provided the y axis info"
|
desc = "The pattern will not be provided the y axis info"
|
||||||
)
|
)
|
||||||
public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||||
|
|
||||||
return new NoYPattern(pattern);
|
return new NoYPattern(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,6 +275,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "The pattern will not be provided the z axis info"
|
desc = "The pattern will not be provided the z axis info"
|
||||||
)
|
)
|
||||||
public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
||||||
|
|
||||||
return new NoZPattern(pattern);
|
return new NoZPattern(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,6 +293,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Offset a pattern"
|
desc = "Offset a pattern"
|
||||||
)
|
)
|
||||||
public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
||||||
|
|
||||||
return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
|
return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,6 +302,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given ranomized offset `[0, <distance>)`. e.g. Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard"
|
desc = "Applies to only blocks on a surface. Selects a block from provided pattern with a given ranomized offset `[0, <distance>)`. e.g. Use `#existing` to randomly offset blocks in the world, or `#copy` to offset blocks in your clipboard"
|
||||||
)
|
)
|
||||||
public Pattern surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) {
|
public Pattern surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) {
|
||||||
|
|
||||||
return new SurfaceRandomOffsetPattern(pattern, (int) distance);
|
return new SurfaceRandomOffsetPattern(pattern, (int) distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,6 +311,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Randomly spread solid blocks"
|
desc = "Randomly spread solid blocks"
|
||||||
)
|
)
|
||||||
public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
||||||
|
|
||||||
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,6 +321,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Randomly spread blocks"
|
desc = "Randomly spread blocks"
|
||||||
)
|
)
|
||||||
public Pattern spread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
public Pattern spread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
||||||
|
|
||||||
return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,6 +331,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Sequentially set blocks from a list of patterns"
|
desc = "Sequentially set blocks from a list of patterns"
|
||||||
)
|
)
|
||||||
public Pattern linear(Actor actor, LocalSession session, Pattern other) {
|
public Pattern linear(Actor actor, LocalSession session, Pattern other) {
|
||||||
|
|
||||||
if (other instanceof RandomPattern) {
|
if (other instanceof RandomPattern) {
|
||||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||||
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||||
@ -332,6 +345,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Use the x,y,z coordinate to pick a block from the list"
|
desc = "Use the x,y,z coordinate to pick a block from the list"
|
||||||
)
|
)
|
||||||
public Pattern linear3d(Actor actor, LocalSession session, Pattern other) {
|
public Pattern linear3d(Actor actor, LocalSession session, Pattern other) {
|
||||||
|
|
||||||
if (other instanceof RandomPattern) {
|
if (other instanceof RandomPattern) {
|
||||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||||
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||||
@ -345,6 +359,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Use the x,z coordinate to pick a block from the list"
|
desc = "Use the x,z coordinate to pick a block from the list"
|
||||||
)
|
)
|
||||||
public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
|
public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
|
||||||
|
|
||||||
if (other instanceof RandomPattern) {
|
if (other instanceof RandomPattern) {
|
||||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||||
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||||
@ -358,6 +373,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax"
|
desc = "Expression pattern: http://wiki.sk89q.com/wiki/WorldEdit/Expression_syntax"
|
||||||
)
|
)
|
||||||
public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException {
|
public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException {
|
||||||
|
|
||||||
Expression exp = Expression.compile(input, "x", "y", "z");
|
Expression exp = Expression.compile(input, "x", "y", "z");
|
||||||
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||||
exp.setEnvironment(env);
|
exp.setEnvironment(env);
|
||||||
|
@ -29,7 +29,11 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
|||||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||||
|
|
||||||
|
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
|
import com.boydti.fawe.beta.filters.SetFilter;
|
||||||
|
import com.boydti.fawe.beta.implementation.QueueHandler;
|
||||||
|
import com.boydti.fawe.beta.filters.DistrFilter;
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||||
import com.boydti.fawe.object.FaweLimit;
|
import com.boydti.fawe.object.FaweLimit;
|
||||||
@ -54,6 +58,7 @@ import com.sk89q.worldedit.function.generator.FloraGenerator;
|
|||||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
||||||
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||||
@ -76,9 +81,11 @@ import com.sk89q.worldedit.util.Location;
|
|||||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||||
import com.sk89q.worldedit.util.command.binding.Range;
|
import com.sk89q.worldedit.util.command.binding.Range;
|
||||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import com.sk89q.worldedit.world.biome.Biomes;
|
import com.sk89q.worldedit.world.biome.Biomes;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -109,6 +116,43 @@ public class RegionCommands {
|
|||||||
this.worldEdit = worldEdit;
|
this.worldEdit = worldEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = {"debugtest"},
|
||||||
|
usage = "",
|
||||||
|
desc = "debugtest",
|
||||||
|
help = "debugtest"
|
||||||
|
)
|
||||||
|
@CommandPermissions("fawe.admin.debug")
|
||||||
|
public void debugtest(Player player, @Selection Region region) throws WorldEditException {
|
||||||
|
QueueHandler queueHandler = Fawe.get().getQueueHandler();
|
||||||
|
World world = player.getWorld();
|
||||||
|
DistrFilter filter = new DistrFilter();
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
queueHandler.apply(world, region, filter);
|
||||||
|
long diff = System.currentTimeMillis() - start;
|
||||||
|
System.out.println(diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = {"db2"},
|
||||||
|
usage = "",
|
||||||
|
desc = "db2",
|
||||||
|
help = "db2"
|
||||||
|
)
|
||||||
|
@CommandPermissions("fawe.admin.debug")
|
||||||
|
public void db2(Player player, @Selection Region region, String blockStr) throws WorldEditException {
|
||||||
|
QueueHandler queueHandler = Fawe.get().getQueueHandler();
|
||||||
|
World world = player.getWorld();
|
||||||
|
BlockState block = BlockState.get(blockStr);
|
||||||
|
SetFilter filter = new SetFilter(block);
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
queueHandler.apply(world, region, filter);
|
||||||
|
long diff = System.currentTimeMillis() - start;
|
||||||
|
System.out.println(diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/fixlighting",
|
name = "/fixlighting",
|
||||||
desc = "Get the light at a position"
|
desc = "Get the light at a position"
|
||||||
@ -417,7 +461,7 @@ public class RegionCommands {
|
|||||||
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
|
||||||
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
FaweLimit limit = FawePlayer.wrap(player).getLimit();
|
||||||
if (volume >= limit.MAX_CHECKS) {
|
if (volume >= limit.MAX_CHECKS) {
|
||||||
throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
throw FaweException.MAX_CHECKS;
|
||||||
}
|
}
|
||||||
player.checkConfirmationRegion(() -> {
|
player.checkConfirmationRegion(() -> {
|
||||||
try {
|
try {
|
||||||
@ -673,6 +717,7 @@ public class RegionCommands {
|
|||||||
descFooter = "Hollows out the object contained in this selection.\n" +
|
descFooter = "Hollows out the object contained in this selection.\n" +
|
||||||
"Optionally fills the hollowed out part with the given block.\n" +
|
"Optionally fills the hollowed out part with the given block.\n" +
|
||||||
"Thickness is measured in manhattan distance."
|
"Thickness is measured in manhattan distance."
|
||||||
|
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.hollow")
|
@CommandPermissions("worldedit.region.hollow")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@ -682,9 +727,11 @@ public class RegionCommands {
|
|||||||
int thickness,
|
int thickness,
|
||||||
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
||||||
Pattern pattern,
|
Pattern pattern,
|
||||||
|
|
||||||
CommandContext context) throws WorldEditException {
|
CommandContext context) throws WorldEditException {
|
||||||
|
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
|
||||||
player.checkConfirmationRegion(() -> {
|
player.checkConfirmationRegion(() -> {
|
||||||
int affected = editSession.hollowOutRegion(region, thickness, pattern);
|
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
}, getArguments(context), region, context);
|
}, getArguments(context), region, context);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
|||||||
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
||||||
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
||||||
import com.boydti.fawe.object.schematic.StructureFormat;
|
import com.boydti.fawe.object.schematic.StructureFormat;
|
||||||
|
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.chat.Message;
|
import com.boydti.fawe.util.chat.Message;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
@ -80,6 +81,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.enginehub.piston.annotation.Command;
|
import org.enginehub.piston.annotation.Command;
|
||||||
import org.enginehub.piston.annotation.CommandContainer;
|
import org.enginehub.piston.annotation.CommandContainer;
|
||||||
@ -403,8 +405,8 @@ public class SchematicCommands {
|
|||||||
}
|
}
|
||||||
if (new PlayerSaveClipboardEvent(player, clipboard, uri, f.toURI()).call()) {
|
if (new PlayerSaveClipboardEvent(player, clipboard, uri, f.toURI()).call()) {
|
||||||
try (ClipboardWriter writer = format.getWriter(fos)) {
|
try (ClipboardWriter writer = format.getWriter(fos)) {
|
||||||
if (writer instanceof StructureFormat) {
|
if (writer instanceof MinecraftStructure) {
|
||||||
((StructureFormat) writer).write(target, player.getName());
|
((MinecraftStructure) writer).write(target, player.getName());
|
||||||
} else {
|
} else {
|
||||||
writer.write(target);
|
writer.write(target);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
|||||||
import com.boydti.fawe.object.mask.IdMask;
|
import com.boydti.fawe.object.mask.IdMask;
|
||||||
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
|
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
|
||||||
import com.boydti.fawe.object.regions.selector.PolyhedralRegionSelector;
|
import com.boydti.fawe.object.regions.selector.PolyhedralRegionSelector;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -490,7 +491,7 @@ public class SelectionCommands {
|
|||||||
// TODO multi clipboard distribution
|
// TODO multi clipboard distribution
|
||||||
Clipboard clipboard = session.getClipboard().getClipboard(); // throws if missing
|
Clipboard clipboard = session.getClipboard().getClipboard(); // throws if missing
|
||||||
region = clipboard.getRegion();
|
region = clipboard.getRegion();
|
||||||
editSession.setExtent(new AbstractDelegateExtent(clipboard));
|
new ExtentTraverser<AbstractDelegateExtent>(editSession).setNext(new AbstractDelegateExtent(clipboard));
|
||||||
} else {
|
} else {
|
||||||
region = session.getSelection(player.getWorld());
|
region = session.getSelection(player.getWorld());
|
||||||
}
|
}
|
||||||
@ -499,6 +500,7 @@ public class SelectionCommands {
|
|||||||
else
|
else
|
||||||
distribution = (List) editSession.getBlockDistribution(region);
|
distribution = (List) editSession.getBlockDistribution(region);
|
||||||
|
|
||||||
|
|
||||||
if (distribution.isEmpty()) { // *Should* always be false
|
if (distribution.isEmpty()) { // *Should* always be false
|
||||||
player.printError("No blocks counted.");
|
player.printError("No blocks counted.");
|
||||||
return;
|
return;
|
||||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
|
|||||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.DelegateConsumer;
|
import com.boydti.fawe.object.DelegateConsumer;
|
||||||
@ -60,6 +61,7 @@ import com.sk89q.worldedit.function.mask.Mask;
|
|||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
@ -75,6 +75,7 @@ public class WorldEditCommands {
|
|||||||
FaweVersion fVer = Fawe.get().getVersion();
|
FaweVersion fVer = Fawe.get().getVersion();
|
||||||
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
String fVerStr = fVer == null ? "unknown" : "-" + fVer.build;
|
||||||
actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92");
|
actor.print("FastAsyncWorldEdit" + fVerStr + " created by Empire92");
|
||||||
|
|
||||||
if (fVer != null) {
|
if (fVer != null) {
|
||||||
actor.printDebug("----------- Platforms -----------");
|
actor.printDebug("----------- Platforms -----------");
|
||||||
FaweVersion version = Fawe.get().getVersion();
|
FaweVersion version = Fawe.get().getVersion();
|
||||||
|
@ -48,6 +48,7 @@ import com.sk89q.minecraft.util.commands.CommandException;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.MaxBrushRadiusException;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -643,15 +644,16 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
Brush brush = current.getBrush();
|
Brush brush = current.getBrush();
|
||||||
if (brush == null) return;
|
if (brush == null) return;
|
||||||
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
||||||
EditSession editSession = new EditSessionBuilder(player.getWorld())
|
EditSessionBuilder builder = new EditSessionBuilder(player.getWorld())
|
||||||
.player(fp)
|
.player(fp)
|
||||||
.allowedRegionsEverywhere()
|
.allowedRegionsEverywhere()
|
||||||
.autoQueue(false)
|
.autoQueue(false)
|
||||||
.blockBag(null)
|
.blockBag(null)
|
||||||
.changeSetNull()
|
.changeSetNull()
|
||||||
.combineStages(false)
|
.combineStages(false);
|
||||||
.build();
|
EditSession editSession = builder.build();
|
||||||
VisualExtent newVisualExtent = new VisualExtent(editSession.getExtent(), editSession.getQueue());
|
|
||||||
|
VisualExtent newVisualExtent = new VisualExtent(builder.getExtent(), builder.getQueue());
|
||||||
BlockVector3 position = getPosition(editSession, player);
|
BlockVector3 position = getPosition(editSession, player);
|
||||||
if (position != null) {
|
if (position != null) {
|
||||||
editSession.setExtent(newVisualExtent);
|
editSession.setExtent(newVisualExtent);
|
||||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
|||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class GravityBrush implements Brush {
|
public class GravityBrush implements Brush {
|
||||||
@ -43,8 +44,8 @@ public class GravityBrush implements Brush {
|
|||||||
for (int x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
|
for (int x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
|
||||||
for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
|
for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
|
||||||
int freeSpot = startCheckY;
|
int freeSpot = startCheckY;
|
||||||
for (int y = startCheckY; y <= endY; ++y) {
|
for (int y = startCheckY; y <= endY; y++) {
|
||||||
final BlockState block = editSession.getLazyBlock(x, y, z);
|
BlockStateHolder block = editSession.getBlock(x, y, z);
|
||||||
if (!block.getBlockType().getMaterial().isAir()) {
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
if (y != freeSpot) {
|
if (y != freeSpot) {
|
||||||
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
|
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
|
||||||
|
@ -47,10 +47,8 @@ import javax.annotation.Nullable;
|
|||||||
/**
|
/**
|
||||||
* A base class for {@link Extent}s that merely passes extents onto another.
|
* A base class for {@link Extent}s that merely passes extents onto another.
|
||||||
*/
|
*/
|
||||||
public class AbstractDelegateExtent implements LightingExtent {
|
public class AbstractDelegateExtent implements Extent, LightingExtent {
|
||||||
|
private final Extent extent;
|
||||||
private transient final Extent extent;
|
|
||||||
protected MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
@ -62,126 +60,18 @@ public class AbstractDelegateExtent implements LightingExtent {
|
|||||||
this.extent = extent;
|
this.extent = extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSkyLight(int x, int y, int z) {
|
|
||||||
if (extent instanceof LightingExtent) {
|
|
||||||
return ((LightingExtent) extent).getSkyLight(x, y, z);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxY() {
|
|
||||||
return extent.getMaxY();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBlockLight(int x, int y, int z) {
|
|
||||||
if (extent instanceof LightingExtent) {
|
|
||||||
return ((LightingExtent) extent).getBlockLight(x, y, z);
|
|
||||||
}
|
|
||||||
return getBrightness(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getOpacity(int x, int y, int z) {
|
|
||||||
if (extent instanceof LightingExtent) {
|
|
||||||
return ((LightingExtent) extent).getOpacity(x, y, z);
|
|
||||||
}
|
|
||||||
return getLazyBlock(x, y, z).getBlockType().getMaterial().getLightOpacity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLight(int x, int y, int z) {
|
|
||||||
if (extent instanceof LightingExtent) {
|
|
||||||
return ((LightingExtent) extent).getLight(x, y, z);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBrightness(int x, int y, int z) {
|
|
||||||
if (extent instanceof LightingExtent) {
|
|
||||||
return ((LightingExtent) extent).getBrightness(x, y, z);
|
|
||||||
}
|
|
||||||
return getLazyBlock(x, y, z).getBlockType().getMaterial().getLightValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the extent.
|
* Get the extent.
|
||||||
*
|
*
|
||||||
* @return the extent
|
* @return the extent
|
||||||
*/
|
*/
|
||||||
public Extent getExtent() {
|
public final Extent getExtent() {
|
||||||
return extent;
|
return extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/*
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
Bounds
|
||||||
return extent.getLazyBlock(mutable.setComponents(x, y, z));
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return extent.getLazyBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
|
||||||
return setBlock(mutable.setComponents(x, y, z), block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
|
||||||
return extent.getBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
|
||||||
return extent.getFullBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
|
||||||
return extent.setBlock(location, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public Entity createEntity(Location location, BaseEntity entity) {
|
|
||||||
return extent.createEntity(location, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends Entity> getEntities() {
|
|
||||||
return extent.getEntities();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends Entity> getEntities(Region region) {
|
|
||||||
return extent.getEntities(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BiomeType getBiome(BlockVector2 position) {
|
|
||||||
return extent.getBiome(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
|
||||||
return extent.setBiome(position, biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
|
||||||
return extent.setBiome(x, y, z, biome);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
|
||||||
return extent.getHighestTerrainBlock(x, z, minY, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
return extent.getMinimumPoint();
|
return extent.getMinimumPoint();
|
||||||
@ -192,78 +82,90 @@ public class AbstractDelegateExtent implements LightingExtent {
|
|||||||
return extent.getMaximumPoint();
|
return extent.getMaximumPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Operation commitBefore() {
|
@Override
|
||||||
return null;
|
public int getMaxY() {
|
||||||
|
return extent.getMaxY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Input + Output
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
|
return extent.getBlock(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||||
|
return extent.getFullBlock(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeType getBiomeType(int x, int z) {
|
||||||
|
return extent.getBiomeType(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
return extent.setBiome(x, y, z, biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
|
return extent.setBlock(x, y, z, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Light
|
||||||
|
*/
|
||||||
|
public int getSkyLight(int x, int y, int z) {
|
||||||
|
if (extent instanceof LightingExtent) {
|
||||||
|
return ((LightingExtent) extent).getSkyLight(x, y, z);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBlockLight(int x, int y, int z) {
|
||||||
|
if (extent instanceof LightingExtent) {
|
||||||
|
return ((LightingExtent) extent).getBlockLight(x, y, z);
|
||||||
|
}
|
||||||
|
return getBrightness(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOpacity(int x, int y, int z) {
|
||||||
|
if (extent instanceof LightingExtent) {
|
||||||
|
return ((LightingExtent) extent).getOpacity(x, y, z);
|
||||||
|
}
|
||||||
|
return getBlock(x, y, z).getBlockType().getMaterial().getLightOpacity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLight(int x, int y, int z) {
|
||||||
|
if (extent instanceof LightingExtent) {
|
||||||
|
return ((LightingExtent) extent).getLight(x, y, z);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBrightness(int x, int y, int z) {
|
||||||
|
if (extent instanceof LightingExtent) {
|
||||||
|
return ((LightingExtent) extent).getBrightness(x, y, z);
|
||||||
|
}
|
||||||
|
return getBlock(x, y, z).getBlockType().getMaterial().getLightValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Generic
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + ":" + extent.toString();
|
return super.toString() + ":" + extent.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected Operation commitBefore() {
|
||||||
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
return null;
|
||||||
return extent.getNearestSurfaceLayer(x, z, y, minY, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
|
||||||
return extent.getHighestTerrainBlock(x, z, minY, maxY, filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
|
|
||||||
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
|
||||||
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
|
||||||
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) {
|
|
||||||
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
|
|
||||||
return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCaves(Region region) throws WorldEditException {
|
|
||||||
extent.addCaves(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generate(Region region, GenBase gen) throws WorldEditException {
|
|
||||||
extent.generate(region, gen);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
|
||||||
extent.spawnResource(region, gen, rarity, frequency);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(BlockVector3 pt) {
|
|
||||||
return extent.contains(pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
|
||||||
extent.addOre(region, mask, material, size, frequency, rarity, minY, maxY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addOres(Region region, Mask mask) throws WorldEditException {
|
|
||||||
extent.addOres(region, mask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -281,6 +183,4 @@ public class AbstractDelegateExtent implements LightingExtent {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ package com.sk89q.worldedit.extent;
|
|||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -45,30 +47,13 @@ public interface InputExtent {
|
|||||||
* @param position position of the block
|
* @param position position of the block
|
||||||
* @return the block
|
* @return the block
|
||||||
*/
|
*/
|
||||||
BlockState getBlock(BlockVector3 position);
|
default BlockState getBlock(BlockVector3 position) {
|
||||||
|
return getBlock(position.getX(), position.getY(), position.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
default BlockState getBlock(int x, int y, int z) {
|
||||||
* Get a lazy, immutable snapshot of the block at the given location that only
|
return getBlock(MutableBlockVector3.get(x, y, z));
|
||||||
* immediately contains information about the block's type (and metadata).
|
}
|
||||||
*
|
|
||||||
* <p>Further information (such as NBT data) will be available <strong>by the
|
|
||||||
* time of access</strong>. Therefore, it is not recommended that
|
|
||||||
* this method is used if the world is being simulated at the time of
|
|
||||||
* call. If the block needs to be stored for future use, then this method should
|
|
||||||
* definitely not be used. Moreover, the block that is returned is immutable (or
|
|
||||||
* should be), and therefore modifications should not be attempted on it. If a
|
|
||||||
* modifiable copy is required, then the block should be cloned.</p>
|
|
||||||
*
|
|
||||||
* <p>This method exists because it is sometimes important to inspect the block
|
|
||||||
* at a given location, but {@link #getBlock(BlockVector3)} may be too expensive in
|
|
||||||
* the underlying implementation. It is also not possible to implement
|
|
||||||
* caching if the returned object is mutable, so this methods allows caching
|
|
||||||
* implementations to be used.</p>
|
|
||||||
*
|
|
||||||
* @param position position of the block
|
|
||||||
* @return the block
|
|
||||||
*/
|
|
||||||
BlockState getLazyBlock(BlockVector3 position);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a immutable snapshot of the block at the given location.
|
* Get a immutable snapshot of the block at the given location.
|
||||||
@ -76,7 +61,13 @@ public interface InputExtent {
|
|||||||
* @param position position of the block
|
* @param position position of the block
|
||||||
* @return the block
|
* @return the block
|
||||||
*/
|
*/
|
||||||
BaseBlock getFullBlock(BlockVector3 position);
|
default BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
|
return getFullBlock(position.getX(), position.getY(), position.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
default BaseBlock getFullBlock(int x, int y, int z) {
|
||||||
|
return getFullBlock(MutableBlockVector3.get(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the biome at the given location.
|
* Get the biome at the given location.
|
||||||
@ -87,6 +78,11 @@ public interface InputExtent {
|
|||||||
* @param position the (x, z) location to check the biome at
|
* @param position the (x, z) location to check the biome at
|
||||||
* @return the biome at the location
|
* @return the biome at the location
|
||||||
*/
|
*/
|
||||||
BiomeType getBiome(BlockVector2 position);
|
default BiomeType getBiome(BlockVector2 position) {
|
||||||
|
return getBiomeType(position.getX(), position.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
default BiomeType getBiomeType(int x, int z) {
|
||||||
|
return getBiome(MutableBlockVector2.get(x, z));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,16 +73,10 @@ public class NullExtent implements Extent {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return BlockTypes.AIR.getDefaultState();
|
return BlockTypes.AIR.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return BlockTypes.AIR.getDefaultState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return getBlock(position).toBaseBlock();
|
return getBlock(position).toBaseBlock();
|
||||||
|
@ -199,9 +199,20 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
setupClipboard(0, uuid);
|
setupClipboard(0, uuid);
|
||||||
}
|
}
|
||||||
int[] pos = value.getIntArray("Pos");
|
int[] pos = value.getIntArray("Pos");
|
||||||
int x = pos[0];
|
int x,y,z;
|
||||||
int y = pos[1];
|
if (pos.length != 3) {
|
||||||
int z = pos[2];
|
System.out.println("Invalid tile " + value);
|
||||||
|
if (!value.containsKey("x") || !value.containsKey("y") || !value.containsKey("z")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
x = value.getInt("x");
|
||||||
|
y = value.getInt("y");
|
||||||
|
z = value.getInt("z");
|
||||||
|
} else {
|
||||||
|
x = pos[0];
|
||||||
|
y = pos[1];
|
||||||
|
z = pos[2];
|
||||||
|
}
|
||||||
Map<String, Tag> values = value.getValue();
|
Map<String, Tag> values = value.getValue();
|
||||||
Tag id = values.get("Id");
|
Tag id = values.get("Id");
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
|
@ -51,6 +51,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,19 +95,11 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long[] adapt(Direction... dirs) {
|
private static long[] adapt(Direction... dirs) {
|
||||||
long[] arr = new long[dirs.length];
|
return Arrays.stream(dirs).mapToLong(dir -> 1L << dir.ordinal()).toArray();
|
||||||
for (int i = 0; i < arr.length; i++) {
|
|
||||||
arr[i] = 1L << dirs[i].ordinal();
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] adapt(Long... dirs) {
|
private static long[] adapt(Long... dirs) {
|
||||||
long[] arr = new long[dirs.length];
|
return Arrays.stream(dirs).mapToLong(dir -> dir).toArray();
|
||||||
for (int i = 0; i < arr.length; i++) {
|
|
||||||
arr[i] = dirs[i];
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long[] getDirections(AbstractProperty property) {
|
private static long[] getDirections(AbstractProperty property) {
|
||||||
@ -138,7 +131,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
case FACING: {
|
case FACING: {
|
||||||
List<Direction> directions = new ArrayList<>();
|
List<Direction> directions = new ArrayList<>();
|
||||||
for (Object value : values) {
|
for (Object value : values) {
|
||||||
directions.add(Direction.valueOf(value.toString().toUpperCase()));
|
directions.add(Direction.valueOf(value.toString().toUpperCase(Locale.ROOT)));
|
||||||
}
|
}
|
||||||
return adapt(directions.toArray(new Direction[0]));
|
return adapt(directions.toArray(new Direction[0]));
|
||||||
}
|
}
|
||||||
@ -220,9 +213,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long notIndex(long mask, int... indexes) {
|
private static long notIndex(long mask, int... indexes) {
|
||||||
for (int index : indexes) {
|
mask |= Arrays.stream(indexes).mapToLong(index -> (1L << (index + values().length))).reduce(0, (a, b) -> a | b);
|
||||||
mask = mask | (1L << (index + values().length));
|
|
||||||
}
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,10 +335,10 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
Object southState = tmp.getState(PropertyKey.SOUTH);
|
Object southState = tmp.getState(PropertyKey.SOUTH);
|
||||||
Object westState = tmp.getState(PropertyKey.WEST);
|
Object westState = tmp.getState(PropertyKey.WEST);
|
||||||
|
|
||||||
tmp = tmp.with(PropertyKey.valueOf(newNorth.name().toUpperCase()), northState);
|
tmp = tmp.with(PropertyKey.valueOf(newNorth.name().toUpperCase(Locale.ROOT)), northState);
|
||||||
tmp = tmp.with(PropertyKey.valueOf(newEast.name().toUpperCase()), eastState);
|
tmp = tmp.with(PropertyKey.valueOf(newEast.name().toUpperCase(Locale.ROOT)), eastState);
|
||||||
tmp = tmp.with(PropertyKey.valueOf(newSouth.name().toUpperCase()), southState);
|
tmp = tmp.with(PropertyKey.valueOf(newSouth.name().toUpperCase(Locale.ROOT)), southState);
|
||||||
tmp = tmp.with(PropertyKey.valueOf(newWest.name().toUpperCase()), westState);
|
tmp = tmp.with(PropertyKey.valueOf(newWest.name().toUpperCase(Locale.ROOT)), westState);
|
||||||
|
|
||||||
newMaskedId = tmp.getInternalId();
|
newMaskedId = tmp.getInternalId();
|
||||||
}
|
}
|
||||||
@ -476,7 +467,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return BlockState.getFromInternalId(newMaskedId);
|
return BlockState.getFromInternalId(newMaskedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BaseBlock transform(BlockStateHolder block) {
|
public final BaseBlock transform(BlockStateHolder<BaseBlock> block) {
|
||||||
BlockState transformed = transform(block.toImmutableState());
|
BlockState transformed = transform(block.toImmutableState());
|
||||||
if (block.hasNbtData()) {
|
if (block.hasNbtData()) {
|
||||||
return transformBaseBlockNBT(transformed, block.getNbtData(), transform);
|
return transformBaseBlockNBT(transformed, block.getNbtData(), transform);
|
||||||
@ -501,13 +492,8 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
return transform(super.getLazyBlock(x, y, z));
|
return transform(super.getBlock(x, y, z));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return transform(super.getLazyBlock(position));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,256 +19,215 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.boydti.fawe.object.collection.FastBitSet;
|
|
||||||
import com.boydti.fawe.util.StringMan;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.NullExtent;
|
import com.sk89q.worldedit.extent.NullExtent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.function.Predicate;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
public class BlockMask extends ABlockMask {
|
||||||
* A mask that checks whether blocks at the given positions are matched by
|
private final boolean[] ordinals;
|
||||||
* a block in a list.
|
|
||||||
*
|
|
||||||
* <p>This mask checks for both an exact block type and state value match,
|
|
||||||
* respecting fuzzy status of the BlockState.</p>
|
|
||||||
* @deprecated use BlockMaskBuilder
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class BlockMask extends AbstractExtentMask {
|
|
||||||
|
|
||||||
private final long[][] bitSets;
|
|
||||||
protected final static long[] ALL = new long[0];
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new block mask.
|
|
||||||
*
|
|
||||||
* @param extent the extent
|
|
||||||
* @param blocks a list of blocks to match
|
|
||||||
*/
|
|
||||||
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
|
||||||
super(extent);
|
|
||||||
checkNotNull(blocks);
|
|
||||||
this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new block mask.
|
|
||||||
*
|
|
||||||
* @param extent the extent
|
|
||||||
* @param block an array of blocks to match
|
|
||||||
*/
|
|
||||||
public BlockMask(Extent extent, BaseBlock... block) {
|
|
||||||
super(extent);
|
|
||||||
checkNotNull(block);
|
|
||||||
this.bitSets = new BlockMaskBuilder().addBlocks(block).optimize().getBits();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockMask() {
|
public BlockMask() {
|
||||||
super(NullExtent.INSTANCE);
|
this(new NullExtent());
|
||||||
this.bitSets = new long[BlockTypes.size()][];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BlockMask(Extent extent, long[][] bitSets) {
|
public BlockMask(Extent extent) {
|
||||||
super(extent);
|
this(extent, new boolean[BlockTypes.states.length]);
|
||||||
this.bitSets = bitSets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockMaskBuilder toBuilder() {
|
public BlockMask(Extent extent, boolean[] ordinals) {
|
||||||
return new BlockMaskBuilder(this.bitSets);
|
super(extent == null ? new NullExtent() : extent);
|
||||||
|
this.ordinals = ordinals;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated NBT not supported by this mask
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
||||||
|
this(extent);
|
||||||
|
add(blocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask add(Predicate<BlockState> predicate) {
|
||||||
|
for (int i = 0; i < ordinals.length; i++) {
|
||||||
|
if (!ordinals[i]) {
|
||||||
|
BlockState state = BlockTypes.states[i];
|
||||||
|
if (state != null) ordinals[i] = predicate.test(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask add(BlockState... states) {
|
||||||
|
addStates(Arrays.asList(states));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask remove(BlockState... states) {
|
||||||
|
for (BlockState state : states) ordinals[state.getOrdinal()] = false;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask clear() {
|
||||||
|
Arrays.fill(ordinals, false);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
for (boolean value : ordinals) {
|
||||||
|
if (value) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask addStates(Collection<BlockState> states) {
|
||||||
|
for (BlockState state : states) ordinals[state.getOrdinal()] = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask add(BlockType... types) {
|
||||||
|
addTypes(Arrays.asList(types));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask addTypes(Collection<BlockType> types) {
|
||||||
|
for (BlockType type : types) {
|
||||||
|
for (BlockState state : type.getAllStates()) {
|
||||||
|
ordinals[state.getOrdinal()] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated NBT not supported by this mask
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void add(Collection<BaseBlock> blocks) {
|
||||||
|
for (BaseBlock block : blocks) {
|
||||||
|
add(block.toBlockState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public boolean test(BlockState state) {
|
||||||
List<String> strings = new ArrayList<>();
|
return ordinals[state.getOrdinal()];
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
}
|
||||||
if (bitSets[i] != null) {
|
|
||||||
long[] set = bitSets[i];
|
@Override
|
||||||
BlockType type = BlockTypes.get(i);
|
public boolean test(BlockVector3 vector) {
|
||||||
if (set == ALL) {
|
return ordinals[vector.getOrdinal(getExtent())];
|
||||||
strings.add(type.getId());
|
}
|
||||||
} else {
|
|
||||||
for (BlockState state : type.getAllStates()) {
|
@Override
|
||||||
if (test(state)) {
|
public Mask and(Mask mask) {
|
||||||
strings.add(state.getAsString());
|
if (mask instanceof ABlockMask) {
|
||||||
|
ABlockMask other = (ABlockMask) mask;
|
||||||
|
for (int i = 0; i < ordinals.length; i++) {
|
||||||
|
if (ordinals[i]) {
|
||||||
|
ordinals[i] = other.test(BlockState.getFromOrdinal(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mask or(Mask mask) {
|
||||||
|
if (mask instanceof ABlockMask) {
|
||||||
|
ABlockMask other = (ABlockMask) mask;
|
||||||
|
for (int i = 0; i < ordinals.length; i++) {
|
||||||
|
if (!ordinals[i]) {
|
||||||
|
ordinals[i] = other.test(BlockState.getFromOrdinal(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
return StringMan.join(strings, ",");
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask optimize() {
|
public Mask optimize() {
|
||||||
Map<Object, Integer> states = new HashMap<>();
|
int setStates = 0;
|
||||||
int indexFound = -1;
|
BlockState setState = null;
|
||||||
{
|
BlockState unsetState = null;
|
||||||
int indexNull = -1;
|
int totalStates = 0;
|
||||||
int indexAll = -1;
|
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
int setTypes = 0;
|
||||||
long[] bs = bitSets[i];
|
BlockType setType = null;
|
||||||
if (bs == null) {
|
BlockType unsetType = null;
|
||||||
indexNull = i;
|
int totalTypes = 0;
|
||||||
states.put(null, states.getOrDefault(null, 0) + 1);
|
|
||||||
} else if (bs.length == 0) {
|
for (BlockType type : BlockTypes.values) {
|
||||||
indexAll = i;
|
if (type != null) {
|
||||||
states.put(ALL, states.getOrDefault(ALL, 0) + 1);
|
totalTypes++;
|
||||||
} else if (indexFound == -1) {
|
boolean hasAll = true;
|
||||||
indexFound = i;
|
boolean hasAny = false;
|
||||||
|
List<BlockState> all = type.getAllStates();
|
||||||
|
for (BlockState state : all) {
|
||||||
|
totalStates++;
|
||||||
|
hasAll &= test(state);
|
||||||
|
hasAny = true;
|
||||||
|
}
|
||||||
|
if (hasAll) {
|
||||||
|
setTypes++;
|
||||||
|
setType = type;
|
||||||
|
setStates += all.size();
|
||||||
|
setState = type.getDefaultState();
|
||||||
|
} else if (hasAny) {
|
||||||
|
for (BlockState state : all) {
|
||||||
|
if (test(state)) {
|
||||||
|
setStates++;
|
||||||
|
setState = state;
|
||||||
} else {
|
} else {
|
||||||
return this;
|
unsetState = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Only types, no states
|
} else {
|
||||||
if (indexFound == -1) {
|
unsetType = type;
|
||||||
if (states.size() == 1) {
|
|
||||||
return states.keySet().iterator().next() == null ? Masks.alwaysFalse() : Masks.alwaysTrue();
|
|
||||||
}
|
|
||||||
if (states.get(ALL) == 1) return new SingleBlockTypeMask(getExtent(), BlockTypes.get(indexAll));
|
|
||||||
if (states.get(null) == 1)
|
|
||||||
return new SingleBlockTypeMask(getExtent(), BlockTypes.get(indexNull)).inverse();
|
|
||||||
|
|
||||||
boolean[] types = new boolean[BlockTypes.size()];
|
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
|
||||||
if (bitSets[i].length == 0) types[i] = true;
|
|
||||||
}
|
|
||||||
return new BlockTypeMask(getExtent(), types);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlockType type = BlockTypes.get(indexFound);
|
|
||||||
Mask mask = getOptimizedMask(type, bitSets[indexFound]);
|
|
||||||
if (mask == null) { // Try with inverse
|
|
||||||
long[] newBitSet = bitSets[indexFound];
|
|
||||||
for (int i = 0; i < newBitSet.length; i++) newBitSet[i] = ~newBitSet[i];
|
|
||||||
mask = getOptimizedMask(type, bitSets[indexFound]);
|
|
||||||
if (mask != null) mask = mask.inverse();
|
|
||||||
}
|
}
|
||||||
return mask;
|
if (setStates == 0) {
|
||||||
|
return Masks.alwaysFalse();
|
||||||
|
}
|
||||||
|
if (setStates == totalStates) {
|
||||||
|
return Masks.alwaysTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mask getOptimizedMask(BlockType type, long[] bitSet) {
|
if (setStates == 1) {
|
||||||
boolean single = true;
|
return new SingleBlockStateMask(getExtent(), setState);
|
||||||
int and = type.getInternalId();
|
|
||||||
List<? extends Property> properties = type.getProperties();
|
|
||||||
for (AbstractProperty prop : (List<AbstractProperty<?>>) type.getProperties()) {
|
|
||||||
List values = prop.getValues();
|
|
||||||
int numSet = 0;
|
|
||||||
for (int i = 0; i < values.size(); i++) {
|
|
||||||
int localI = i << prop.getBitOffset();
|
|
||||||
if (FastBitSet.get(bitSet, localI)) {
|
|
||||||
numSet++;
|
|
||||||
and |= prop.modify(and, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Cannot optimize multiple property values - use current mask (null)
|
|
||||||
if (numSet != values.size() && numSet != 1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
single = single && numSet == 1;
|
|
||||||
}
|
|
||||||
if (single)
|
|
||||||
return new SingleBlockStateMask(getExtent(), BlockState.getFromInternalId(and));
|
|
||||||
return new SingleBlockStateBitMask(getExtent(), and);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if (setStates == totalStates - 1) {
|
||||||
public Mask and(Mask other) {
|
return new InverseSingleBlockStateMask(getExtent(), unsetState);
|
||||||
if (other instanceof BlockMask) {
|
|
||||||
long[][] otherBitSets = ((BlockMask) other).bitSets;
|
|
||||||
for (int i = 0; i < otherBitSets.length; i++) {
|
|
||||||
long[] otherBitSet = otherBitSets[i];
|
|
||||||
long[] bitSet = bitSets[i];
|
|
||||||
if (otherBitSet == null) bitSets[i] = null;
|
|
||||||
else if (otherBitSet.length == 0) continue;
|
|
||||||
else if (bitSet == null) continue;
|
|
||||||
else if (bitSet.length == 0) bitSets[i] = otherBitSet;
|
|
||||||
else for (int j = 0; j < otherBitSet.length; j++) bitSet[j] &= otherBitSet[j];
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
if (other instanceof SingleBlockStateMask) {
|
|
||||||
return new BlockMaskBuilder(bitSets).filter(((SingleBlockStateMask) other).getBlockState()).build(getExtent());
|
|
||||||
}
|
|
||||||
if (other instanceof SingleBlockTypeMask) {
|
|
||||||
return new BlockMaskBuilder(bitSets).filter(((SingleBlockTypeMask) other).getBlockType()).build(getExtent());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if (setTypes == 1) {
|
||||||
public Mask or(Mask other) {
|
return new SingleBlockTypeMask(getExtent(), setType);
|
||||||
if (other instanceof BlockMask) {
|
|
||||||
long[][] otherBitSets = ((BlockMask) other).bitSets;
|
|
||||||
for (int i = 0; i < otherBitSets.length; i++) {
|
|
||||||
long[] otherBitSet = otherBitSets[i];
|
|
||||||
long[] bitSet = bitSets[i];
|
|
||||||
if (otherBitSet == null) continue;
|
|
||||||
else if (otherBitSet.length == 0) bitSets[i] = ALL;
|
|
||||||
else if (bitSet == null) bitSets[i] = otherBitSet;
|
|
||||||
else if (bitSet.length == 0) continue;
|
|
||||||
else for (int j = 0; j < otherBitSet.length; j++) bitSet[j] |= otherBitSet[j];
|
|
||||||
}
|
}
|
||||||
return this;
|
|
||||||
}
|
if (setTypes == totalTypes - 1) {
|
||||||
if (other instanceof SingleBlockStateMask) {
|
return new InverseSingleBlockTypeMask(getExtent(), unsetType);
|
||||||
return new BlockMaskBuilder(bitSets).add(((SingleBlockStateMask) other).getBlockState()).build(getExtent());
|
|
||||||
}
|
|
||||||
if (other instanceof SingleBlockTypeMask) {
|
|
||||||
return new BlockMaskBuilder(bitSets).add(((SingleBlockTypeMask) other).getBlockType()).build(getExtent());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask inverse() {
|
public Mask inverse() {
|
||||||
long[][] cloned = bitSets.clone();
|
boolean[] cloned = ordinals.clone();
|
||||||
for (int i = 0; i < cloned.length; i++) {
|
for (int i = 0; i < cloned.length; i++) cloned[i] = !cloned[i];
|
||||||
if (cloned[i] == null) cloned[i] = ALL;
|
|
||||||
else if (cloned[i] == ALL) cloned[i] = null;
|
|
||||||
else {
|
|
||||||
for (int j = 0; j < cloned[i].length; j++)
|
|
||||||
cloned[i][j] = ~cloned[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new BlockMask(getExtent(), cloned);
|
return new BlockMask(getExtent(), cloned);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean test(BlockState block) {
|
|
||||||
long[] bitSet = bitSets[block.getInternalBlockTypeId()];
|
|
||||||
if (bitSet == null) return false;
|
|
||||||
if (bitSet.length == 0) return true;
|
|
||||||
return FastBitSet.get(bitSet, block.getInternalPropertiesId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(BlockVector3 vector) {
|
|
||||||
BlockStateHolder block = getExtent().getBlock(vector);
|
|
||||||
long[] bitSet = bitSets[block.getInternalBlockTypeId()];
|
|
||||||
if (bitSet == null) return false;
|
|
||||||
if (bitSet.length == 0) return true;
|
|
||||||
return FastBitSet.get(bitSet, block.getInternalPropertiesId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import com.sk89q.worldedit.extent.Extent;
|
|||||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -28,6 +29,8 @@ public class BlockMaskBuilder {
|
|||||||
private static final Operator LESS_EQUAL = (a, b) -> a <= b;
|
private static final Operator LESS_EQUAL = (a, b) -> a <= b;
|
||||||
private static final Operator NOT = (a, b) -> a != b;
|
private static final Operator NOT = (a, b) -> a != b;
|
||||||
|
|
||||||
|
private final static long[] ALL = new long[0];
|
||||||
|
|
||||||
private interface Operator {
|
private interface Operator {
|
||||||
boolean test(int left, int right);
|
boolean test(int left, int right);
|
||||||
}
|
}
|
||||||
@ -223,7 +226,7 @@ public class BlockMaskBuilder {
|
|||||||
if (states == null) return false;
|
if (states == null) return false;
|
||||||
List values = prop.getValues();
|
List values = prop.getValues();
|
||||||
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
||||||
return (states == BlockMask.ALL || FastBitSet.get(states, localI));
|
return (states == ALL || FastBitSet.get(states, localI));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void suggest(String input, String property, Collection<BlockType> finalTypes) throws InputParseException {
|
private void suggest(String input, String property, Collection<BlockType> finalTypes) throws InputParseException {
|
||||||
@ -240,6 +243,7 @@ public class BlockMaskBuilder {
|
|||||||
///// end internal /////
|
///// end internal /////
|
||||||
|
|
||||||
private long[][] bitSets;
|
private long[][] bitSets;
|
||||||
|
private boolean[] ordinals;
|
||||||
|
|
||||||
private boolean optimizedStates = true;
|
private boolean optimizedStates = true;
|
||||||
|
|
||||||
@ -256,14 +260,23 @@ public class BlockMaskBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BlockMaskBuilder addAll() {
|
public BlockMaskBuilder addAll() {
|
||||||
Arrays.fill(bitSets, BlockMask.ALL);
|
for (int i = 0; i < bitSets.length; i++) {
|
||||||
optimizedStates = true;
|
bitSets[i] = ALL;
|
||||||
|
}
|
||||||
|
reset(true);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reset(boolean optimized) {
|
||||||
|
this.ordinals = null;
|
||||||
|
this.optimizedStates = optimized;
|
||||||
|
}
|
||||||
|
|
||||||
public BlockMaskBuilder clear() {
|
public BlockMaskBuilder clear() {
|
||||||
Arrays.fill(bitSets, null);
|
for (int i = 0; i < bitSets.length; i++) {
|
||||||
optimizedStates = true;
|
bitSets[i] = null;
|
||||||
|
}
|
||||||
|
reset(true);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,13 +290,13 @@ public class BlockMaskBuilder {
|
|||||||
int i = type.getInternalId();
|
int i = type.getInternalId();
|
||||||
long[] states = bitSets[i];
|
long[] states = bitSets[i];
|
||||||
if (states != null) {
|
if (states != null) {
|
||||||
if (states == BlockMask.ALL) {
|
if (states == ALL) {
|
||||||
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
Arrays.fill(states, -1);
|
Arrays.fill(states, -1);
|
||||||
}
|
}
|
||||||
int stateId = state.getInternalPropertiesId();
|
int stateId = state.getInternalPropertiesId();
|
||||||
FastBitSet.clear(states, stateId);
|
FastBitSet.clear(states, stateId);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -305,7 +318,7 @@ public class BlockMaskBuilder {
|
|||||||
if (states != null) {
|
if (states != null) {
|
||||||
int stateId = state.getInternalPropertiesId();
|
int stateId = state.getInternalPropertiesId();
|
||||||
boolean set = true;
|
boolean set = true;
|
||||||
if (states == BlockMask.ALL) {
|
if (states == ALL) {
|
||||||
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
} else {
|
} else {
|
||||||
set = FastBitSet.get(states, stateId);
|
set = FastBitSet.get(states, stateId);
|
||||||
@ -315,7 +328,7 @@ public class BlockMaskBuilder {
|
|||||||
FastBitSet.set(states, stateId);
|
FastBitSet.set(states, stateId);
|
||||||
else
|
else
|
||||||
bitSets[i] = null;
|
bitSets[i] = null;
|
||||||
optimizedStates = true;
|
reset(true);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -344,14 +357,14 @@ public class BlockMaskBuilder {
|
|||||||
List values = prop.getValues();
|
List values = prop.getValues();
|
||||||
for (int j = 0; j < values.size(); j++) {
|
for (int j = 0; j < values.size(); j++) {
|
||||||
int localI = j << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
int localI = j << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
||||||
if (states == BlockMask.ALL || FastBitSet.get(states, localI)) {
|
if (states == ALL || FastBitSet.get(states, localI)) {
|
||||||
if (!allowed.test(type, new AbstractMap.SimpleEntry(prop, values.get(j)))) {
|
if (!allowed.test(type, new AbstractMap.SimpleEntry(prop, values.get(j)))) {
|
||||||
if (states == BlockMask.ALL) {
|
if (states == ALL) {
|
||||||
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
FastBitSet.setAll(states);
|
FastBitSet.setAll(states);
|
||||||
}
|
}
|
||||||
FastBitSet.clear(states, localI);
|
FastBitSet.clear(states, localI);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,7 +374,7 @@ public class BlockMaskBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BlockMaskBuilder add(BlockType type) {
|
public BlockMaskBuilder add(BlockType type) {
|
||||||
bitSets[type.getInternalId()] = BlockMask.ALL;
|
bitSets[type.getInternalId()] = ALL;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,13 +382,13 @@ public class BlockMaskBuilder {
|
|||||||
BlockType type = state.getBlockType();
|
BlockType type = state.getBlockType();
|
||||||
int i = type.getInternalId();
|
int i = type.getInternalId();
|
||||||
long[] states = bitSets[i];
|
long[] states = bitSets[i];
|
||||||
if (states != BlockMask.ALL) {
|
if (states != ALL) {
|
||||||
if (states == null) {
|
if (states == null) {
|
||||||
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
}
|
}
|
||||||
int stateId = state.getInternalPropertiesId();
|
int stateId = state.getInternalPropertiesId();
|
||||||
FastBitSet.set(states, stateId);
|
FastBitSet.set(states, stateId);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -404,7 +417,7 @@ public class BlockMaskBuilder {
|
|||||||
for (int i = 0; i < bitSets.length; i++) {
|
for (int i = 0; i < bitSets.length; i++) {
|
||||||
BlockType type = BlockTypes.get(i);
|
BlockType type = BlockTypes.get(i);
|
||||||
if (allow.test(type)) {
|
if (allow.test(type)) {
|
||||||
bitSets[i] = BlockMask.ALL;
|
bitSets[i] = ALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@ -413,7 +426,7 @@ public class BlockMaskBuilder {
|
|||||||
public BlockMaskBuilder addAll(Predicate<BlockType> typePredicate, BiPredicate<BlockType, Map.Entry<Property<?>, ?>> propPredicate) {
|
public BlockMaskBuilder addAll(Predicate<BlockType> typePredicate, BiPredicate<BlockType, Map.Entry<Property<?>, ?>> propPredicate) {
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
for (int i = 0; i < bitSets.length; i++) {
|
||||||
long[] states = bitSets[i];
|
long[] states = bitSets[i];
|
||||||
if (states == BlockMask.ALL) continue;
|
if (states == ALL) continue;
|
||||||
BlockType type = BlockTypes.get(i);
|
BlockType type = BlockTypes.get(i);
|
||||||
if (!typePredicate.test(type)) {
|
if (!typePredicate.test(type)) {
|
||||||
continue;
|
continue;
|
||||||
@ -428,7 +441,7 @@ public class BlockMaskBuilder {
|
|||||||
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
}
|
}
|
||||||
FastBitSet.set(states, localI);
|
FastBitSet.set(states, localI);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -440,7 +453,7 @@ public class BlockMaskBuilder {
|
|||||||
public BlockMaskBuilder add(BlockType type, Property property, int index) {
|
public BlockMaskBuilder add(BlockType type, Property property, int index) {
|
||||||
AbstractProperty prop = (AbstractProperty) property;
|
AbstractProperty prop = (AbstractProperty) property;
|
||||||
long[] states = bitSets[type.getInternalId()];
|
long[] states = bitSets[type.getInternalId()];
|
||||||
if (states == BlockMask.ALL) return this;
|
if (states == ALL) return this;
|
||||||
|
|
||||||
List values = property.getValues();
|
List values = property.getValues();
|
||||||
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
||||||
@ -449,7 +462,7 @@ public class BlockMaskBuilder {
|
|||||||
bitSets[type.getInternalId()] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[type.getInternalId()] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
}
|
}
|
||||||
set(type, states, property, index);
|
set(type, states, property, index);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -460,13 +473,13 @@ public class BlockMaskBuilder {
|
|||||||
if (states == null) return this;
|
if (states == null) return this;
|
||||||
List values = property.getValues();
|
List values = property.getValues();
|
||||||
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
||||||
if (states == BlockMask.ALL || FastBitSet.get(states, localI)) {
|
if (states == ALL || FastBitSet.get(states, localI)) {
|
||||||
if (states == BlockMask.ALL) {
|
if (states == ALL) {
|
||||||
bitSets[type.getInternalId()] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[type.getInternalId()] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
FastBitSet.setAll(states);
|
FastBitSet.setAll(states);
|
||||||
}
|
}
|
||||||
clear(type, states, property, index);
|
clear(type, states, property, index);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -512,7 +525,7 @@ public class BlockMaskBuilder {
|
|||||||
if (!optimizedStates) {
|
if (!optimizedStates) {
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
for (int i = 0; i < bitSets.length; i++) {
|
||||||
long[] bitSet = bitSets[i];
|
long[] bitSet = bitSets[i];
|
||||||
if (bitSet == null || bitSet == BlockMask.ALL) continue;
|
if (bitSet == null || bitSet == ALL) continue;
|
||||||
BlockType type = BlockTypes.get(i);
|
BlockType type = BlockTypes.get(i);
|
||||||
int maxStateId = type.getMaxStateId();
|
int maxStateId = type.getMaxStateId();
|
||||||
if (maxStateId == 0) {
|
if (maxStateId == 0) {
|
||||||
@ -520,7 +533,7 @@ public class BlockMaskBuilder {
|
|||||||
bitSets[i] = null;
|
bitSets[i] = null;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
bitSets[i] = BlockMask.ALL;
|
bitSets[i] = ALL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -535,19 +548,38 @@ public class BlockMaskBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (set == 0) bitSets[i] = null;
|
if (set == 0) bitSets[i] = null;
|
||||||
else if (clear == 0) bitSets[i] = BlockMask.ALL;
|
else if (clear == 0) bitSets[i] = ALL;
|
||||||
}
|
}
|
||||||
optimizedStates = true;
|
reset(true);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long[][] getBits() {
|
private boolean[] getOrdinals() {
|
||||||
return this.bitSets;
|
if (ordinals == null) {
|
||||||
|
ordinals = new boolean[BlockTypes.states.length];
|
||||||
|
for (int i = 0; i < BlockTypes.values.length; i++) {
|
||||||
|
long[] bitSet = bitSets[i];
|
||||||
|
if (bitSet == null) continue;
|
||||||
|
BlockType type = BlockTypes.values[i];
|
||||||
|
if (bitSet == ALL) {
|
||||||
|
for (BlockState state : type.getAllStates()) {
|
||||||
|
ordinals[state.getOrdinal()] = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (BlockState state : type.getAllStates()) {
|
||||||
|
if (FastBitSet.get(bitSet, state.getInternalPropertiesId())) {
|
||||||
|
ordinals[state.getOrdinal()] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ordinals;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockMask build(Extent extent) {
|
public BlockMask build(Extent extent) {
|
||||||
optimize();
|
return new BlockMask(extent, getOrdinals());
|
||||||
return new BlockMask(extent, bitSets);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
@ -37,8 +36,12 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* <p>This mask checks for ONLY the block type. If state should also be checked,
|
* <p>This mask checks for ONLY the block type. If state should also be checked,
|
||||||
* use {@link BlockMask}.</p>
|
* use {@link BlockMask}.</p>
|
||||||
|
* @deprecated use BlockMaskBuilder
|
||||||
*/
|
*/
|
||||||
public class BlockTypeMask extends AbstractExtentMask {
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public final class BlockTypeMask extends AbstractExtentMask {
|
||||||
|
|
||||||
private final boolean[] types;
|
private final boolean[] types;
|
||||||
|
|
||||||
@ -110,12 +113,11 @@ public class BlockTypeMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return types[getExtent().getBlock(vector).getBlockType().getInternalId()];
|
return test(vector.getBlock(getExtent()).getBlockType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public boolean test(BlockType block) {
|
||||||
@Override
|
return types[block.getInternalId()];
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,11 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class SingleBlockTypeMask extends AbstractExtentMask {
|
public class SingleBlockTypeMask extends ABlockMask {
|
||||||
private final int internalId;
|
private final int internalId;
|
||||||
|
|
||||||
public SingleBlockTypeMask(Extent extent, BlockType type) {
|
public SingleBlockTypeMask(Extent extent, BlockType type) {
|
||||||
@ -15,12 +16,17 @@ public class SingleBlockTypeMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return getExtent().getBlock(vector).getBlockType().getInternalId() == internalId;
|
return test(vector.getBlock(getExtent()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean test(BlockState state) {
|
||||||
|
return state.getBlockType().getInternalId() == internalId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask inverse() {
|
public Mask inverse() {
|
||||||
return new BlockMaskBuilder().add(BlockTypes.get(internalId)).build(getExtent()).inverse();
|
return new InverseSingleBlockTypeMask(getExtent(), BlockTypes.values[internalId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockType getBlockType() {
|
public BlockType getBlockType() {
|
||||||
|
@ -27,10 +27,10 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class SolidBlockMask extends BlockTypeMask {
|
public class SolidBlockMask extends BlockMask {
|
||||||
|
|
||||||
public SolidBlockMask(Extent extent) {
|
public SolidBlockMask(Extent extent) {
|
||||||
super(extent, getTypes());
|
super(extent);
|
||||||
|
add(state -> state.getMaterial().isSolid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,11 +22,7 @@ package com.sk89q.worldedit.function.visitor;
|
|||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.config.Settings;
|
|
||||||
import com.boydti.fawe.example.MappedFaweQueue;
|
import com.boydti.fawe.example.MappedFaweQueue;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
|
||||||
import com.boydti.fawe.object.HasFaweQueue;
|
|
||||||
import com.boydti.fawe.object.IntegerTrio;
|
|
||||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
@ -38,8 +34,11 @@ import com.sk89q.worldedit.util.Direction;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a breadth-first search starting from points added with
|
* Performs a breadth-first search starting from points added with
|
||||||
* {@link #visit(BlockVector3)}. The search continues
|
* {@link #visit(BlockVector3)}. The search continues
|
||||||
@ -81,13 +80,12 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final RegionFunction function;
|
private final RegionFunction function;
|
||||||
private BlockVectorSet queue;
|
private BlockVector3[] directions;
|
||||||
private BlockVectorSet visited;
|
private BlockVectorSet visited;
|
||||||
|
private BlockVectorSet queue;
|
||||||
private int affected = 0;
|
private int affected = 0;
|
||||||
private int currentDepth = 0;
|
private int currentDepth = 0;
|
||||||
private final int maxDepth;
|
private final int maxDepth;
|
||||||
private List<BlockVector3> directions = new ArrayList<>();
|
|
||||||
private final MappedFaweQueue mFaweQueue;
|
|
||||||
private int maxBranch = Integer.MAX_VALUE;
|
private int maxBranch = Integer.MAX_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,33 +99,20 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BreadthFirstSearch(RegionFunction function, int maxDepth) {
|
public BreadthFirstSearch(RegionFunction function, int maxDepth) {
|
||||||
this(function, maxDepth, null);
|
|
||||||
checkNotNull(function);
|
checkNotNull(function);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public BreadthFirstSearch(RegionFunction function, int maxDepth, HasFaweQueue faweQueue) {
|
|
||||||
checkNotNull(function);
|
|
||||||
FaweQueue fq = faweQueue != null ? faweQueue.getQueue() : null;
|
|
||||||
this.mFaweQueue = fq instanceof MappedFaweQueue ? (MappedFaweQueue) fq : null;
|
|
||||||
this.queue = new BlockVectorSet();
|
this.queue = new BlockVectorSet();
|
||||||
this.visited = new BlockVectorSet();
|
this.visited = new BlockVectorSet();
|
||||||
this.function = function;
|
this.function = function;
|
||||||
this.directions.addAll(Arrays.asList(DEFAULT_DIRECTIONS));
|
this.directions = DEFAULT_DIRECTIONS;
|
||||||
this.maxDepth = maxDepth;
|
this.maxDepth = maxDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDirections(List<BlockVector3> directions) {
|
public void setDirections(BlockVector3... directions) {
|
||||||
this.directions = directions;
|
this.directions = directions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntegerTrio[] getIntDirections() {
|
public void setDirections(Collection<BlockVector3> directions) {
|
||||||
IntegerTrio[] array = new IntegerTrio[directions.size()];
|
setDirections(directions.toArray(new BlockVector3[0]));
|
||||||
for (int i = 0; i < array.length; i++) {
|
|
||||||
BlockVector3 dir = directions.get(i);
|
|
||||||
array[i] = new IntegerTrio(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ());
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,34 +123,36 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
* unit vectors. An example of a valid direction is
|
* unit vectors. An example of a valid direction is
|
||||||
* {@code BlockVector3.at(1, 0, 1)}.</p>
|
* {@code BlockVector3.at(1, 0, 1)}.</p>
|
||||||
*
|
*
|
||||||
* <p>The list of directions can be cleared.</p>
|
|
||||||
*
|
|
||||||
* @return the list of directions
|
* @return the list of directions
|
||||||
*/
|
*/
|
||||||
protected Collection<BlockVector3> getDirections() {
|
public Collection<BlockVector3> getDirections() {
|
||||||
return directions;
|
return Arrays.asList(directions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the directions along the axes as directions to visit.
|
* Add the directions along the axes as directions to visit.
|
||||||
*/
|
*/
|
||||||
protected void addAxes() {
|
public void addAxes() {
|
||||||
directions.add(BlockVector3.UNIT_MINUS_Y);
|
HashSet<BlockVector3> set = new HashSet<>(Arrays.asList(directions));
|
||||||
directions.add(BlockVector3.UNIT_Y);
|
set.add(BlockVector3.UNIT_MINUS_Y);
|
||||||
directions.add(BlockVector3.UNIT_MINUS_X);
|
set.add(BlockVector3.UNIT_Y);
|
||||||
directions.add(BlockVector3.UNIT_X);
|
set.add(BlockVector3.UNIT_MINUS_X);
|
||||||
directions.add(BlockVector3.UNIT_MINUS_Z);
|
set.add(BlockVector3.UNIT_X);
|
||||||
directions.add(BlockVector3.UNIT_Z);
|
set.add(BlockVector3.UNIT_MINUS_Z);
|
||||||
|
set.add(BlockVector3.UNIT_Z);
|
||||||
|
setDirections(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the diagonal directions as directions to visit.
|
* Add the diagonal directions as directions to visit.
|
||||||
*/
|
*/
|
||||||
protected void addDiagonal() {
|
public void addDiagonal() {
|
||||||
directions.add(Direction.NORTHEAST.toBlockVector());
|
HashSet<BlockVector3> set = new HashSet<>(Arrays.asList(directions));
|
||||||
directions.add(Direction.SOUTHEAST.toBlockVector());
|
set.add(Direction.NORTHEAST.toBlockVector());
|
||||||
directions.add(Direction.SOUTHWEST.toBlockVector());
|
set.add(Direction.SOUTHEAST.toBlockVector());
|
||||||
directions.add(Direction.NORTHWEST.toBlockVector());
|
set.add(Direction.SOUTHWEST.toBlockVector());
|
||||||
|
set.add(Direction.NORTHWEST.toBlockVector());
|
||||||
|
setDirections(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,21 +193,6 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
public void setMaxBranch(int maxBranch) {
|
public void setMaxBranch(int maxBranch) {
|
||||||
this.maxBranch = maxBranch;
|
this.maxBranch = maxBranch;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Try to visit the given 'to' location.
|
|
||||||
*
|
|
||||||
* @param from the origin block
|
|
||||||
* @param to the block under question
|
|
||||||
*/
|
|
||||||
private void visit(BlockVector3 from, BlockVector3 to) {
|
|
||||||
BlockVector3 blockVector = to;
|
|
||||||
if (!visited.contains(blockVector)) {
|
|
||||||
visited.add(blockVector);
|
|
||||||
if (isVisitable(from, to)) {
|
|
||||||
queue.add(blockVector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the given 'to' block should be visited, starting from the
|
* Return whether the given 'to' block should be visited, starting from the
|
||||||
@ -244,42 +216,22 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
@Override
|
@Override
|
||||||
public Operation resume(RunContext run) throws WorldEditException {
|
public Operation resume(RunContext run) throws WorldEditException {
|
||||||
MutableBlockVector3 mutable = new MutableBlockVector3();
|
MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
IntegerTrio[] dirs = getIntDirections();
|
// MutableBlockVector3 mutable2 = new MutableBlockVector3();
|
||||||
|
boolean shouldTrim = false;
|
||||||
|
BlockVector3[] dirs = directions;
|
||||||
BlockVectorSet tempQueue = new BlockVectorSet();
|
BlockVectorSet tempQueue = new BlockVectorSet();
|
||||||
BlockVectorSet chunkLoadSet = new BlockVectorSet();
|
BlockVectorSet chunkLoadSet = new BlockVectorSet();
|
||||||
for (currentDepth = 0; !queue.isEmpty() && currentDepth <= maxDepth; currentDepth++) {
|
for (currentDepth = 0; !queue.isEmpty() && currentDepth <= maxDepth; currentDepth++) {
|
||||||
if (mFaweQueue != null && Settings.IMP.QUEUE.PRELOAD_CHUNKS > 1) {
|
|
||||||
int cx = Integer.MIN_VALUE;
|
|
||||||
int cz = Integer.MIN_VALUE;
|
|
||||||
for (BlockVector3 from : queue) {
|
|
||||||
for (IntegerTrio direction : dirs) {
|
|
||||||
int x = from.getBlockX() + direction.x;
|
|
||||||
int z = from.getBlockZ() + direction.z;
|
|
||||||
if (cx != (cx = x >> 4) || cz != (cz = z >> 4)) {
|
|
||||||
int y = from.getBlockY() + direction.y;
|
|
||||||
if (y < 0 || y >= 256) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!visited.contains(x, y, z)) {
|
|
||||||
chunkLoadSet.add(cx, 0, cz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (BlockVector3 chunk : chunkLoadSet) {
|
|
||||||
mFaweQueue.queueChunkLoad(chunk.getBlockX(), chunk.getBlockZ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (BlockVector3 from : queue) {
|
for (BlockVector3 from : queue) {
|
||||||
if (function.apply(from)) affected++;
|
if (function.apply(from)) affected++;
|
||||||
for (int i = 0, j = 0; i < dirs.length && j < maxBranch; i++) {
|
for (int i = 0, j = 0; i < dirs.length && j < maxBranch; i++) {
|
||||||
IntegerTrio direction = dirs[i];
|
BlockVector3 direction = dirs[i];
|
||||||
int y = from.getBlockY() + direction.y;
|
int y = from.getBlockY() + direction.getY();
|
||||||
if (y < 0 || y >= 256) {
|
if (y < 0 || y >= 256) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int x = from.getBlockX() + direction.x;
|
int x = from.getBlockX() + direction.getX();
|
||||||
int z = from.getBlockZ() + direction.z;
|
int z = from.getBlockZ() + direction.getZ();
|
||||||
if (!visited.contains(x, y, z)) {
|
if (!visited.contains(x, y, z)) {
|
||||||
if (isVisitable(from, mutable.setComponents(x, y, z))) {
|
if (isVisitable(from, mutable.setComponents(x, y, z))) {
|
||||||
j++;
|
j++;
|
||||||
|
@ -21,30 +21,36 @@ package com.sk89q.worldedit.math;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
|
import com.google.common.collect.ComparisonChain;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An immutable 3-dimensional vector.
|
* An immutable 3-dimensional vector.
|
||||||
*/
|
*/
|
||||||
public class BlockVector3 {
|
public abstract class BlockVector3 {
|
||||||
|
|
||||||
public static final BlockVector3 ZERO = new BlockVector3(0, 0, 0);
|
public static final BlockVector3 ZERO = BlockVector3.at(0, 0, 0);
|
||||||
public static final BlockVector3 UNIT_X = new BlockVector3(1, 0, 0);
|
public static final BlockVector3 UNIT_X = BlockVector3.at(1, 0, 0);
|
||||||
public static final BlockVector3 UNIT_Y = new BlockVector3(0, 1, 0);
|
public static final BlockVector3 UNIT_Y = BlockVector3.at(0, 1, 0);
|
||||||
public static final BlockVector3 UNIT_Z = new BlockVector3(0, 0, 1);
|
public static final BlockVector3 UNIT_Z = BlockVector3.at(0, 0, 1);
|
||||||
public static final BlockVector3 UNIT_MINUS_X = new BlockVector3(-1, 0, 0);
|
public static final BlockVector3 UNIT_MINUS_X = BlockVector3.at(-1, 0, 0);
|
||||||
public static final BlockVector3 UNIT_MINUS_Y = new BlockVector3(0, -1, 0);
|
public static final BlockVector3 UNIT_MINUS_Y = BlockVector3.at(0, -1, 0);
|
||||||
public static final BlockVector3 UNIT_MINUS_Z = new BlockVector3(0, 0, -1);
|
public static final BlockVector3 UNIT_MINUS_Z = BlockVector3.at(0, 0, -1);
|
||||||
public static final BlockVector3 ONE = new BlockVector3(1, 1, 1);
|
public static final BlockVector3 ONE = BlockVector3.at(1, 1, 1);
|
||||||
|
|
||||||
public static BlockVector3 at(double x, double y, double z) {
|
public static BlockVector3 at(double x, double y, double z) {
|
||||||
return at((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z));
|
return at((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockVector3 at(int x, int y, int z) {
|
public static BlockVector3 at(int x, int y, int z) {
|
||||||
return new BlockVector3(x, y, z);
|
return new BlockVector3Imp(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// thread-safe initialization idiom
|
// thread-safe initialization idiom
|
||||||
@ -65,23 +71,6 @@ public class BlockVector3 {
|
|||||||
return YzxOrderComparator.YZX_ORDER;
|
return YzxOrderComparator.YZX_ORDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int x, y, z;
|
|
||||||
|
|
||||||
protected BlockVector3(){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an instance.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param y the Y coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
*/
|
|
||||||
protected BlockVector3(int x, int y, int z) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MutableBlockVector3 setComponents(double x, double y, double z) {
|
public MutableBlockVector3 setComponents(double x, double y, double z) {
|
||||||
return new MutableBlockVector3((int) x, (int) y, (int) z);
|
return new MutableBlockVector3((int) x, (int) y, (int) z);
|
||||||
}
|
}
|
||||||
@ -91,37 +80,71 @@ public class BlockVector3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MutableBlockVector3 mutX(double x) {
|
public MutableBlockVector3 mutX(double x) {
|
||||||
return new MutableBlockVector3((int) x, y, z);
|
return new MutableBlockVector3((int) x, getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableBlockVector3 mutY(double y) {
|
public MutableBlockVector3 mutY(double y) {
|
||||||
return new MutableBlockVector3(x, (int) y, z);
|
return new MutableBlockVector3(getX(), (int) y, getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableBlockVector3 mutZ(double z) {
|
public MutableBlockVector3 mutZ(double z) {
|
||||||
return new MutableBlockVector3(x, y, (int) z);
|
return new MutableBlockVector3(getX(), getY(), (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableBlockVector3 mutX(int x) {
|
public MutableBlockVector3 mutX(int x) {
|
||||||
return new MutableBlockVector3(x, y, z);
|
return new MutableBlockVector3(x, getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableBlockVector3 mutY(int y) {
|
public MutableBlockVector3 mutY(int y) {
|
||||||
return new MutableBlockVector3(x, y, z);
|
return new MutableBlockVector3(getX(), y, getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableBlockVector3 mutZ(int z) {
|
public MutableBlockVector3 mutZ(int z) {
|
||||||
return new MutableBlockVector3(x, y, z);
|
return new MutableBlockVector3(getX(), getY(), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockVector3 toImmutable() {
|
||||||
|
return BlockVector3.at(getX(), getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Get the BlockVector3 to the north<br>
|
||||||
|
// * Normal use you would use north(this),
|
||||||
|
// * To avoid constructing a new Vector, pass e.g. north(some MutableBlockVector3)
|
||||||
|
// * There is no gaurantee it will use this provided vector
|
||||||
|
// * @param orDefault the vector to use as the result<br>
|
||||||
|
// * @return BlockVector3
|
||||||
|
// */
|
||||||
|
// public BlockVector3 north(BlockVector3 orDefault) {
|
||||||
|
// return orDefault.setComponents(getX(), getY(), getZ() - 1);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public BlockVector3 east(BlockVector3 orDefault) {
|
||||||
|
// return orDefault.setComponents(getX() + 1, getY(), getZ());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public BlockVector3 south(BlockVector3 orDefault) {
|
||||||
|
// return orDefault.setComponents(getX(), getY(), getZ() + 1);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public BlockVector3 west(BlockVector3 orDefault) {
|
||||||
|
// return orDefault.setComponents(getX() - 1, getY(), getZ());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public BlockVector3 up(BlockVector3 orDefault) {
|
||||||
|
// return orDefault.setComponents(getX(), getY() + 1, getZ());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public BlockVector3 down(BlockVector3 orDefault) {
|
||||||
|
// return orDefault.setComponents(getX(), getY() - 1, getZ());
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the X coordinate.
|
* Get the X coordinate.
|
||||||
*
|
*
|
||||||
* @return the x coordinate
|
* @return the x coordinate
|
||||||
*/
|
*/
|
||||||
public int getX() {
|
public abstract int getX();
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the X coordinate.
|
* Get the X coordinate.
|
||||||
@ -129,7 +152,7 @@ public class BlockVector3 {
|
|||||||
* @return the x coordinate
|
* @return the x coordinate
|
||||||
*/
|
*/
|
||||||
public int getBlockX() {
|
public int getBlockX() {
|
||||||
return x;
|
return getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,7 +162,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 withX(int x) {
|
public BlockVector3 withX(int x) {
|
||||||
return BlockVector3.at(x, y, z);
|
return BlockVector3.at(x, getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,9 +170,7 @@ public class BlockVector3 {
|
|||||||
*
|
*
|
||||||
* @return the y coordinate
|
* @return the y coordinate
|
||||||
*/
|
*/
|
||||||
public int getY() {
|
public abstract int getY();
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Y coordinate.
|
* Get the Y coordinate.
|
||||||
@ -157,7 +178,7 @@ public class BlockVector3 {
|
|||||||
* @return the y coordinate
|
* @return the y coordinate
|
||||||
*/
|
*/
|
||||||
public int getBlockY() {
|
public int getBlockY() {
|
||||||
return y;
|
return getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,7 +188,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 withY(int y) {
|
public BlockVector3 withY(int y) {
|
||||||
return BlockVector3.at(x, y, z);
|
return BlockVector3.at(getX(), y, getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,9 +196,7 @@ public class BlockVector3 {
|
|||||||
*
|
*
|
||||||
* @return the z coordinate
|
* @return the z coordinate
|
||||||
*/
|
*/
|
||||||
public int getZ() {
|
public abstract int getZ();
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Z coordinate.
|
* Get the Z coordinate.
|
||||||
@ -185,7 +204,7 @@ public class BlockVector3 {
|
|||||||
* @return the z coordinate
|
* @return the z coordinate
|
||||||
*/
|
*/
|
||||||
public int getBlockZ() {
|
public int getBlockZ() {
|
||||||
return z;
|
return getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -195,7 +214,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 withZ(int z) {
|
public BlockVector3 withZ(int z) {
|
||||||
return BlockVector3.at(x, y, z);
|
return BlockVector3.at(getX(), getY(), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,7 +224,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 add(BlockVector3 other) {
|
public BlockVector3 add(BlockVector3 other) {
|
||||||
return add(other.x, other.y, other.z);
|
return add(other.getX(), other.getY(), other.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,7 +236,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 add(int x, int y, int z) {
|
public BlockVector3 add(int x, int y, int z) {
|
||||||
return BlockVector3.at(this.x + x, this.y + y, this.z + z);
|
return BlockVector3.at(this.getX() + x, this.getY() + y, this.getZ() + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -228,12 +247,12 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 add(BlockVector3... others) {
|
public BlockVector3 add(BlockVector3... others) {
|
||||||
int newX = x, newY = y, newZ = z;
|
int newX = getX(), newY = getY(), newZ = getZ();
|
||||||
|
|
||||||
for (BlockVector3 other : others) {
|
for (BlockVector3 other : others) {
|
||||||
newX += other.x;
|
newX += other.getX();
|
||||||
newY += other.y;
|
newY += other.getY();
|
||||||
newZ += other.z;
|
newZ += other.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return BlockVector3.at(newX, newY, newZ);
|
return BlockVector3.at(newX, newY, newZ);
|
||||||
@ -247,7 +266,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 subtract(BlockVector3 other) {
|
public BlockVector3 subtract(BlockVector3 other) {
|
||||||
return subtract(other.x, other.y, other.z);
|
return subtract(other.getX(), other.getY(), other.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -260,7 +279,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 subtract(int x, int y, int z) {
|
public BlockVector3 subtract(int x, int y, int z) {
|
||||||
return BlockVector3.at(this.x - x, this.y - y, this.z - z);
|
return BlockVector3.at(this.getX() - x, this.getY() - y, this.getZ() - z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -271,12 +290,12 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 subtract(BlockVector3... others) {
|
public BlockVector3 subtract(BlockVector3... others) {
|
||||||
int newX = x, newY = y, newZ = z;
|
int newX = getX(), newY = getY(), newZ = getZ();
|
||||||
|
|
||||||
for (BlockVector3 other : others) {
|
for (BlockVector3 other : others) {
|
||||||
newX -= other.x;
|
newX -= other.getX();
|
||||||
newY -= other.y;
|
newY -= other.getY();
|
||||||
newZ -= other.z;
|
newZ -= other.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return BlockVector3.at(newX, newY, newZ);
|
return BlockVector3.at(newX, newY, newZ);
|
||||||
@ -289,7 +308,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 multiply(BlockVector3 other) {
|
public BlockVector3 multiply(BlockVector3 other) {
|
||||||
return multiply(other.x, other.y, other.z);
|
return multiply(other.getX(), other.getY(), other.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,7 +320,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 multiply(int x, int y, int z) {
|
public BlockVector3 multiply(int x, int y, int z) {
|
||||||
return BlockVector3.at(this.x * x, this.y * y, this.z * z);
|
return BlockVector3.at(this.getX() * x, this.getY() * y, this.getZ() * z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -311,12 +330,12 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 multiply(BlockVector3... others) {
|
public BlockVector3 multiply(BlockVector3... others) {
|
||||||
int newX = x, newY = y, newZ = z;
|
int newX = getX(), newY = getY(), newZ = getZ();
|
||||||
|
|
||||||
for (BlockVector3 other : others) {
|
for (BlockVector3 other : others) {
|
||||||
newX *= other.x;
|
newX *= other.getX();
|
||||||
newY *= other.y;
|
newY *= other.getY();
|
||||||
newZ *= other.z;
|
newZ *= other.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return BlockVector3.at(newX, newY, newZ);
|
return BlockVector3.at(newX, newY, newZ);
|
||||||
@ -339,7 +358,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 divide(BlockVector3 other) {
|
public BlockVector3 divide(BlockVector3 other) {
|
||||||
return divide(other.x, other.y, other.z);
|
return divide(other.getX(), other.getY(), other.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -351,7 +370,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 divide(int x, int y, int z) {
|
public BlockVector3 divide(int x, int y, int z) {
|
||||||
return BlockVector3.at(this.x / x, this.y / y, this.z / z);
|
return BlockVector3.at(this.getX() / x, this.getY() / y, this.getZ() / z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -423,7 +442,7 @@ public class BlockVector3 {
|
|||||||
* @return length, squared
|
* @return length, squared
|
||||||
*/
|
*/
|
||||||
public int lengthSq() {
|
public int lengthSq() {
|
||||||
return x * x + y * y + z * z;
|
return getX() * getX() + getY() * getY() + getZ() * getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -443,9 +462,9 @@ public class BlockVector3 {
|
|||||||
* @return distance
|
* @return distance
|
||||||
*/
|
*/
|
||||||
public int distanceSq(BlockVector3 other) {
|
public int distanceSq(BlockVector3 other) {
|
||||||
int dx = other.x - x;
|
int dx = other.getX() - getX();
|
||||||
int dy = other.y - y;
|
int dy = other.getY() - getY();
|
||||||
int dz = other.z - z;
|
int dz = other.getZ() - getZ();
|
||||||
return dx * dx + dy * dy + dz * dz;
|
return dx * dx + dy * dy + dz * dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,9 +476,9 @@ public class BlockVector3 {
|
|||||||
*/
|
*/
|
||||||
public BlockVector3 normalize() {
|
public BlockVector3 normalize() {
|
||||||
double len = length();
|
double len = length();
|
||||||
double x = this.x / len;
|
double x = this.getX() / len;
|
||||||
double y = this.y / len;
|
double y = this.getY() / len;
|
||||||
double z = this.z / len;
|
double z = this.getZ() / len;
|
||||||
return BlockVector3.at(x, y, z);
|
return BlockVector3.at(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,7 +489,7 @@ public class BlockVector3 {
|
|||||||
* @return the dot product of this and the other vector
|
* @return the dot product of this and the other vector
|
||||||
*/
|
*/
|
||||||
public double dot(BlockVector3 other) {
|
public double dot(BlockVector3 other) {
|
||||||
return x * other.x + y * other.y + z * other.z;
|
return getX() * other.getX() + getY() * other.getY() + getZ() * other.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -480,10 +499,10 @@ public class BlockVector3 {
|
|||||||
* @return the cross product of this and the other vector
|
* @return the cross product of this and the other vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 cross(BlockVector3 other) {
|
public BlockVector3 cross(BlockVector3 other) {
|
||||||
return new BlockVector3(
|
return new BlockVector3Imp(
|
||||||
y * other.z - z * other.y,
|
getY() * other.getZ() - getZ() * other.getY(),
|
||||||
z * other.x - x * other.z,
|
getZ() * other.getX() - getX() * other.getZ(),
|
||||||
x * other.y - y * other.x
|
getX() * other.getY() - getY() * other.getX()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +514,7 @@ public class BlockVector3 {
|
|||||||
* @return true if the vector is contained
|
* @return true if the vector is contained
|
||||||
*/
|
*/
|
||||||
public boolean containedWithin(BlockVector3 min, BlockVector3 max) {
|
public boolean containedWithin(BlockVector3 min, BlockVector3 max) {
|
||||||
return x >= min.x && x <= max.x && y >= min.y && y <= max.y && z >= min.z && z <= max.z;
|
return getX() >= min.getX() && getX() <= max.getX() && getY() >= min.getY() && getY() <= max.getY() && getZ() >= min.getZ() && getZ() <= max.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -507,11 +526,11 @@ public class BlockVector3 {
|
|||||||
*/
|
*/
|
||||||
public BlockVector3 clampY(int min, int max) {
|
public BlockVector3 clampY(int min, int max) {
|
||||||
checkArgument(min <= max, "minimum cannot be greater than maximum");
|
checkArgument(min <= max, "minimum cannot be greater than maximum");
|
||||||
if (y < min) {
|
if (getY() < min) {
|
||||||
return BlockVector3.at(x, min, z);
|
return BlockVector3.at(getX(), min, getZ());
|
||||||
}
|
}
|
||||||
if (y > max) {
|
if (getY() > max) {
|
||||||
return BlockVector3.at(x, max, z);
|
return BlockVector3.at(getX(), max, getZ());
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -555,7 +574,7 @@ public class BlockVector3 {
|
|||||||
* @return a new vector
|
* @return a new vector
|
||||||
*/
|
*/
|
||||||
public BlockVector3 abs() {
|
public BlockVector3 abs() {
|
||||||
return BlockVector3.at(Math.abs(x), Math.abs(y), Math.abs(z));
|
return BlockVector3.at(Math.abs(getX()), Math.abs(getY()), Math.abs(getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -571,8 +590,8 @@ public class BlockVector3 {
|
|||||||
*/
|
*/
|
||||||
public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
||||||
angle = Math.toRadians(angle);
|
angle = Math.toRadians(angle);
|
||||||
double x = this.x - aboutX;
|
double x = this.getX() - aboutX;
|
||||||
double z = this.z - aboutZ;
|
double z = this.getZ() - aboutZ;
|
||||||
double cos = Math.cos(angle);
|
double cos = Math.cos(angle);
|
||||||
double sin = Math.sin(angle);
|
double sin = Math.sin(angle);
|
||||||
double x2 = x * cos - z * sin;
|
double x2 = x * cos - z * sin;
|
||||||
@ -580,7 +599,7 @@ public class BlockVector3 {
|
|||||||
|
|
||||||
return BlockVector3.at(
|
return BlockVector3.at(
|
||||||
x2 + aboutX + translateX,
|
x2 + aboutX + translateX,
|
||||||
y,
|
getY(),
|
||||||
z2 + aboutZ + translateZ
|
z2 + aboutZ + translateZ
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -626,10 +645,10 @@ public class BlockVector3 {
|
|||||||
* @return minimum
|
* @return minimum
|
||||||
*/
|
*/
|
||||||
public BlockVector3 getMinimum(BlockVector3 v2) {
|
public BlockVector3 getMinimum(BlockVector3 v2) {
|
||||||
return new BlockVector3(
|
return new BlockVector3Imp(
|
||||||
Math.min(x, v2.x),
|
Math.min(getX(), v2.getX()),
|
||||||
Math.min(y, v2.y),
|
Math.min(getY(), v2.getY()),
|
||||||
Math.min(z, v2.z)
|
Math.min(getZ(), v2.getZ())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,44 +659,110 @@ public class BlockVector3 {
|
|||||||
* @return maximum
|
* @return maximum
|
||||||
*/
|
*/
|
||||||
public BlockVector3 getMaximum(BlockVector3 v2) {
|
public BlockVector3 getMaximum(BlockVector3 v2) {
|
||||||
return new BlockVector3(
|
return new BlockVector3Imp(
|
||||||
Math.max(x, v2.x),
|
Math.max(getX(), v2.getX()),
|
||||||
Math.max(y, v2.y),
|
Math.max(getY(), v2.getY()),
|
||||||
Math.max(z, v2.z)
|
Math.max(getZ(), v2.getZ())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Methods for getting/setting blocks
|
||||||
|
|
||||||
|
Why are these methods here?
|
||||||
|
- Getting a block at a position requires various operations
|
||||||
|
(bounds checks, cache checks, ensuring loaded chunk, get ChunkSection, etc.)
|
||||||
|
- When iterating over a region, it will provide custom BlockVector3 positions
|
||||||
|
- These override the below set/get and avoid lookups (as the iterator shifts it to the chunk level)
|
||||||
|
*/
|
||||||
|
|
||||||
|
public boolean setOrdinal(Extent orDefault, int ordinal) {
|
||||||
|
return orDefault.setBlock(this, BlockState.getFromOrdinal(ordinal));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setBlock(Extent orDefault, BlockState state) {
|
||||||
|
return orDefault.setBlock(this, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setFullBlock(Extent orDefault, BaseBlock block) {
|
||||||
|
return orDefault.setBlock(this, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setBiome(Extent orDefault, BiomeType biome) {
|
||||||
|
return orDefault.setBiome(getX(), getY(), getZ(), biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrdinal(Extent orDefault) {
|
||||||
|
return getBlock(orDefault).getOrdinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getOrdinalChar(Extent orDefault) {
|
||||||
|
return (char) getOrdinal(orDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getBlock(Extent orDefault) {
|
||||||
|
return orDefault.getBlock(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseBlock getFullBlock(Extent orDefault) {
|
||||||
|
return orDefault.getFullBlock(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag getNbtData(Extent orDefault) {
|
||||||
|
return orDefault.getFullBlock(getX(), getY(), getZ()).getNbtData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getOrdinalBelow(Extent orDefault) {
|
||||||
|
return orDefault.getBlock(getX(), getY() - 1, getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getStateAbove(Extent orDefault) {
|
||||||
|
return orDefault.getBlock(getX(), getY() + 1, getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getStateRelativeY(Extent orDefault, final int y) {
|
||||||
|
return orDefault.getBlock(getX(), getY() + y, getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Adapt
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a 2D vector by dropping the Y component from this vector.
|
* Creates a 2D vector by dropping the Y component from this vector.
|
||||||
*
|
*
|
||||||
* @return a new {@link BlockVector2}
|
* @return a new {@link BlockVector2}
|
||||||
*/
|
*/
|
||||||
public BlockVector2 toBlockVector2() {
|
public BlockVector2 toBlockVector2() {
|
||||||
return BlockVector2.at(x, z);
|
return BlockVector2.at(getX(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 toVector3() {
|
public Vector3 toVector3() {
|
||||||
return Vector3.at(x, y, z);
|
return Vector3.at(getX(), getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public final boolean equals(Object obj) {
|
||||||
if (!(obj instanceof BlockVector3)) {
|
if (!(obj instanceof BlockVector3)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockVector3 other = (BlockVector3) obj;
|
return equals((BlockVector3) obj);
|
||||||
return other.x == this.x && other.y == this.y && other.z == this.z;
|
}
|
||||||
|
|
||||||
|
public final boolean equals(BlockVector3 other) {
|
||||||
|
return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return (x ^ (z << 12)) ^ (y << 24);
|
return (getX() ^ (getZ() << 12)) ^ (getY() << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "(" + x + ", " + y + ", " + z + ")";
|
return "(" + getX() + ", " + getY() + ", " + getZ() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
package com.sk89q.worldedit.math;
|
package com.sk89q.worldedit.math;
|
||||||
|
|
||||||
|
import com.boydti.fawe.FaweCache;
|
||||||
|
|
||||||
public class MutableVector3 extends Vector3 {
|
public class MutableVector3 extends Vector3 {
|
||||||
|
|
||||||
public MutableVector3() {
|
public MutableVector3() {
|
||||||
}
|
}
|
||||||
|
public static MutableVector3 get(int x, int y, int z) {
|
||||||
|
return FaweCache.MUTABLE_VECTOR3.get().setComponents(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MutableVector3 get(double x, double y, double z) {
|
||||||
|
return FaweCache.MUTABLE_VECTOR3.get().setComponents(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
public MutableVector3(double x, double y, double z) {
|
public MutableVector3(double x, double y, double z) {
|
||||||
super(x, y, z);
|
super(x, y, z);
|
||||||
@ -77,7 +86,4 @@ public class MutableVector3 extends Vector3 {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,11 @@ package com.sk89q.worldedit.regions;
|
|||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.ChunkFilterBlock;
|
||||||
|
import com.boydti.fawe.beta.Filter;
|
||||||
|
import com.boydti.fawe.beta.IChunk;
|
||||||
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
@ -387,7 +392,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(int x, int y, int z) {
|
public boolean contains(int x, int y, int z) {
|
||||||
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ && y >= this.minY && y <= this.maxY;
|
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ && y >= this.minY && y <= this.maxY;
|
||||||
@ -398,14 +402,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ;
|
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(BlockVector3 position) {
|
|
||||||
BlockVector3 min = getMinimumPoint();
|
|
||||||
BlockVector3 max = getMaximumPoint();
|
|
||||||
|
|
||||||
return position.containedWithin(min, max);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<BlockVector3> iterator() {
|
public Iterator<BlockVector3> iterator() {
|
||||||
if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9 || useOldIterator) {
|
if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9 || useOldIterator) {
|
||||||
@ -610,4 +606,51 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
BlockVector3 size = BlockVector3.ONE.multiply(apothem);
|
BlockVector3 size = BlockVector3.ONE.multiply(apothem);
|
||||||
return new CuboidRegion(origin.subtract(size), origin.add(size));
|
return new CuboidRegion(origin.subtract(size), origin.add(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinY() {
|
||||||
|
return minY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxY() {
|
||||||
|
return maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filter(final IChunk chunk, final Filter filter, ChunkFilterBlock block, final IChunkGet get, final IChunkSet set) {
|
||||||
|
int X = chunk.getX();
|
||||||
|
int Z = chunk.getZ();
|
||||||
|
block = block.init(X, Z, get);
|
||||||
|
|
||||||
|
if ((minX + 15) >> 4 <= X && (maxX - 15) >> 4 >= X && (minZ + 15) >> 4 <= Z && (maxZ - 15) >> 4 >= Z) {
|
||||||
|
filter(chunk, filter, block, get, set, minY, maxY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int localMinX = Math.max(minX, X << 4) & 15;
|
||||||
|
int localMaxX = Math.min(maxX, 15 + X << 4) & 15;
|
||||||
|
int localMinZ = Math.max(minZ, Z << 4) & 15;
|
||||||
|
int localMaxZ = Math.min(maxZ, 15 + Z << 4) & 15;
|
||||||
|
|
||||||
|
int yStart = (minY & 15);
|
||||||
|
int yEnd = (maxY & 15);
|
||||||
|
|
||||||
|
int minSection = minY >> 4;
|
||||||
|
int maxSection = maxY >> 4;
|
||||||
|
if (minSection == maxSection) {
|
||||||
|
filter(chunk, filter, block, get, set, minSection, localMinX, yStart, localMinZ, localMaxX, yEnd, localMaxZ);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (yStart != 0) {
|
||||||
|
filter(chunk, filter, block, get, set, minSection, localMinX, yStart, localMinZ, localMaxX, 15, localMaxZ);
|
||||||
|
minSection++;
|
||||||
|
}
|
||||||
|
if (yEnd != 15) {
|
||||||
|
filter(chunk, filter, block, get, set, minSection, localMinX, 0, localMinZ, localMaxX, 15, localMaxZ);
|
||||||
|
maxSection--;
|
||||||
|
}
|
||||||
|
for (int layer = minSection; layer < maxSection; layer++) {
|
||||||
|
filter(chunk, filter, block, get, set, layer, localMinX, yStart, localMinZ, localMaxX, yEnd, localMaxZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,11 @@ package com.sk89q.worldedit.regions;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.ChunkFilterBlock;
|
||||||
|
import com.boydti.fawe.beta.Filter;
|
||||||
|
import com.boydti.fawe.beta.IChunk;
|
||||||
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
@ -288,26 +293,22 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
minY += changeY;
|
minY += changeY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if a point is inside this region.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(BlockVector3 position) {
|
public boolean contains(int x, int y, int z) {
|
||||||
final int blockY = position.getBlockY();
|
if (y < minY || y > maxY) {
|
||||||
if (blockY < minY || blockY > maxY) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//todo the following lines can possibly be removed and replaced with upstream
|
return contains(x, z);
|
||||||
int px = position.getBlockX();
|
}
|
||||||
int pz = position.getBlockZ();
|
|
||||||
|
|
||||||
double dx = Math.abs(px - center.getBlockX()) * radiusInverse.getX();
|
@Override
|
||||||
double dz = Math.abs(pz - center.getBlockZ()) * radiusInverse.getZ();
|
public boolean contains(int x, int z) {
|
||||||
|
double dx = Math.abs(x - center.getBlockX()) * radiusInverse.getX();
|
||||||
|
double dz = Math.abs(z - center.getBlockZ()) * radiusInverse.getZ();
|
||||||
|
|
||||||
return dx * dx + dz * dz <= 1;
|
return dx * dx + dz * dz <= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the height of the cylinder to fit the specified Y.
|
* Sets the height of the cylinder to fit the specified Y.
|
||||||
*
|
*
|
||||||
@ -362,6 +363,16 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
return Polygons.polygonizeCylinder(center, radius, maxPoints);
|
return Polygons.polygonizeCylinder(center, radius, maxPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinY() {
|
||||||
|
return minY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxY() {
|
||||||
|
return maxY;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a new instance with the given center and radius in the X and Z
|
* Return a new instance with the given center and radius in the X and Z
|
||||||
* axes with a Y that extends from the bottom of the extent to the top
|
* axes with a Y that extends from the bottom of the extent to the top
|
||||||
@ -381,4 +392,16 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
|||||||
return new CylinderRegion(center, radiusVec, minY, maxY);
|
return new CylinderRegion(center, radiusVec, minY, maxY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filter(final IChunk chunk, final Filter filter, final ChunkFilterBlock block, final IChunkGet get, final IChunkSet set) {
|
||||||
|
int bcx = chunk.getX() >> 4;
|
||||||
|
int bcz = chunk.getZ() >> 4;
|
||||||
|
int tcx = bcx + 15;
|
||||||
|
int tcz = bcz + 15;
|
||||||
|
if (contains(bcx, bcz) && contains(tcx, tcz)) {
|
||||||
|
filter(chunk, filter, block, get, set, minY, maxY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.filter(chunk, filter, block, get, set);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,13 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.regions;
|
package com.sk89q.worldedit.regions;
|
||||||
|
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.ChunkFilterBlock;
|
||||||
|
import com.boydti.fawe.beta.Filter;
|
||||||
|
import com.boydti.fawe.beta.IChunk;
|
||||||
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
@ -44,6 +51,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
private Vector3 radius;
|
private Vector3 radius;
|
||||||
|
|
||||||
private Vector3 radiusSqr;
|
private Vector3 radiusSqr;
|
||||||
|
private Vector3 inverseRadius;
|
||||||
private int radiusLengthSqr;
|
private int radiusLengthSqr;
|
||||||
private boolean sphere;
|
private boolean sphere;
|
||||||
|
|
||||||
@ -180,6 +188,12 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
radiusSqr = radius.multiply(radius);
|
radiusSqr = radius.multiply(radius);
|
||||||
radiusLengthSqr = (int) radiusSqr.getX();
|
radiusLengthSqr = (int) radiusSqr.getX();
|
||||||
this.sphere = radius.getY() == radius.getX() && radius.getX() == radius.getZ();
|
this.sphere = radius.getY() == radius.getX() && radius.getX() == radius.getZ();
|
||||||
|
if (radius.getY() == radius.getX() && radius.getX() == radius.getZ()) {
|
||||||
|
this.sphere = true;
|
||||||
|
} else {
|
||||||
|
this.sphere = false;
|
||||||
|
}
|
||||||
|
inverseRadius = Vector3.ONE.divide(radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -207,18 +221,18 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(BlockVector3 position) {
|
public boolean contains(int x, int y, int z) {
|
||||||
int cx = position.getBlockX() - center.getBlockX();
|
int cx = x - center.getBlockX();
|
||||||
int cx2 = cx * cx;
|
int cx2 = cx * cx;
|
||||||
if (cx2 > radiusSqr.getBlockX()) {
|
if (cx2 > radiusSqr.getBlockX()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int cz = position.getBlockZ() - center.getBlockZ();
|
int cz = z - center.getBlockZ();
|
||||||
int cz2 = cz * cz;
|
int cz2 = cz * cz;
|
||||||
if (cz2 > radiusSqr.getBlockZ()) {
|
if (cz2 > radiusSqr.getBlockZ()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int cy = position.getBlockY() - center.getBlockY();
|
int cy = y - center.getBlockY();
|
||||||
int cy2 = cy * cy;
|
int cy2 = cy * cy;
|
||||||
if (radiusSqr.getBlockY() < 255 && cy2 > radiusSqr.getBlockY()) {
|
if (radiusSqr.getBlockY() < 255 && cy2 > radiusSqr.getBlockY()) {
|
||||||
return false;
|
return false;
|
||||||
@ -226,10 +240,30 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
if (sphere) {
|
if (sphere) {
|
||||||
return cx2 + cy2 + cz2 <= radiusLengthSqr;
|
return cx2 + cy2 + cz2 <= radiusLengthSqr;
|
||||||
}
|
}
|
||||||
double cxd = (double) cx / radius.getBlockX();
|
double cxd = cx2 * inverseRadius.getX();
|
||||||
double cyd = (double) cy / radius.getBlockY();
|
double cyd = cy2 * inverseRadius.getY();
|
||||||
double czd = (double) cz / radius.getBlockZ();
|
double czd = cz2 * inverseRadius.getZ();
|
||||||
return cxd * cxd + cyd * cyd + czd * czd <= 1;
|
return cxd + cyd + czd <= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(int x, int z) {
|
||||||
|
int cx = x - center.getBlockX();
|
||||||
|
int cx2 = cx * cx;
|
||||||
|
if (cx2 > radiusSqr.getBlockX()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int cz = z - center.getBlockZ();
|
||||||
|
int cz2 = cz * cz;
|
||||||
|
if (cz2 > radiusSqr.getBlockZ()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (sphere) {
|
||||||
|
return cx2 + cz2 <= radiusLengthSqr;
|
||||||
|
}
|
||||||
|
double cxd = cx2 * inverseRadius.getX();
|
||||||
|
double czd = cz2 * inverseRadius.getZ();
|
||||||
|
return cxd + czd <= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,4 +286,113 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
return (EllipsoidRegion) super.clone();
|
return (EllipsoidRegion) super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void filterSpherePartial(int y1, int y2, int bx, int bz, Filter filter, ChunkFilterBlock block, IChunkGet get, IChunkSet set) {
|
||||||
|
int sectionStart = y1 >> 4;
|
||||||
|
int sectionEnd = y2 >> 4;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void filterSpherePartial(int layer, int y1, int y2, int bx, int bz, Filter filter, ChunkFilterBlock block, IChunkGet get, IChunkSet set) {
|
||||||
|
int cx = center.getBlockX();
|
||||||
|
int cy = center.getBlockY();
|
||||||
|
int cz = center.getBlockZ();
|
||||||
|
|
||||||
|
block.init(get, set, layer);
|
||||||
|
|
||||||
|
int by = layer << 4;
|
||||||
|
int diffY;
|
||||||
|
for (int y = y1, yy = by + y1; y <= y2; y++, yy++) {
|
||||||
|
diffY = cy - yy;
|
||||||
|
int remainderY = radiusLengthSqr - (diffY * diffY);
|
||||||
|
if (remainderY >= 0) {
|
||||||
|
for (int z = 0; z < 16; z++) {
|
||||||
|
int zz = z + bz;
|
||||||
|
int diffZ = cz - zz;
|
||||||
|
int remainderZ = remainderY - (diffZ * diffZ);
|
||||||
|
if (remainderZ >= 0) {
|
||||||
|
int diffX = MathMan.usqrt(remainderZ);
|
||||||
|
int minX = Math.max(0, cx - diffX - bx);
|
||||||
|
int maxX = Math.min(15, cx + diffX - bx);
|
||||||
|
if (minX != maxX) {
|
||||||
|
block.filter(filter, minX, y, z, maxX, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filter(IChunk chunk, Filter filter, ChunkFilterBlock block, IChunkGet get, IChunkSet set) {
|
||||||
|
// Check bounds
|
||||||
|
// This needs to be able to perform 50M blocks/sec otherwise it becomes a bottleneck
|
||||||
|
int cx = center.getBlockX();
|
||||||
|
int cz = center.getBlockZ();
|
||||||
|
int bx = chunk.getX() << 4;
|
||||||
|
int bz = chunk.getZ() << 4;
|
||||||
|
int tx = bx + 15;
|
||||||
|
int tz = bz + 15;
|
||||||
|
int cx1 = bx - cx;
|
||||||
|
int cx2 = tx - cx;
|
||||||
|
int cxMax, cxMin;
|
||||||
|
if (cx1 < cx2) {
|
||||||
|
cxMin = cx1;
|
||||||
|
cxMax = cx2;
|
||||||
|
} else {
|
||||||
|
cxMin = cx2;
|
||||||
|
cxMax = cx1;
|
||||||
|
}
|
||||||
|
int cxMin2 = cxMin * cxMin;
|
||||||
|
int cxMax2 = cxMax * cxMax;
|
||||||
|
int cz1 = bz - cz;
|
||||||
|
int cz2 = tz - cz;
|
||||||
|
int czMax, czMin;
|
||||||
|
if (cz1 < cz2) {
|
||||||
|
czMin = cz1;
|
||||||
|
czMax = cz2;
|
||||||
|
} else {
|
||||||
|
czMin = cz2;
|
||||||
|
czMax = cz1;
|
||||||
|
}
|
||||||
|
int czMin2 = czMin * czMin;
|
||||||
|
int czMax2 = czMax * czMax;
|
||||||
|
|
||||||
|
|
||||||
|
if (sphere) {
|
||||||
|
// Does not contain chunk
|
||||||
|
if (cxMin2 + czMin2 >= radiusLengthSqr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int diffY2 = radiusLengthSqr - cxMax2 - czMax2;
|
||||||
|
// (shortcut) Contains all of certain layers
|
||||||
|
if (diffY2 >= 0) {
|
||||||
|
// Get the solid layers
|
||||||
|
int cy = center.getBlockY();
|
||||||
|
int diffYFull = MathMan.usqrt(diffY2);
|
||||||
|
int yBotFull = Math.max(0, cy - diffYFull);
|
||||||
|
int yTopFull = Math.min(255, cy + diffYFull);
|
||||||
|
// Set those layers
|
||||||
|
filter(chunk, filter, block, get, set, yBotFull, yTopFull);
|
||||||
|
|
||||||
|
// Fill the remaining layers
|
||||||
|
if (yBotFull != 0 || yTopFull != 255) {
|
||||||
|
int diffYPartial = MathMan.usqrt(radiusLengthSqr - cxMin * cxMin - czMin * czMin);
|
||||||
|
|
||||||
|
if (yBotFull != 0) {
|
||||||
|
int yBotPartial = Math.max(0, cy - diffYPartial);
|
||||||
|
filterSpherePartial(yBotPartial, yBotFull - 1, bx, bz, filter, block, get, set);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yTopFull != 255) {
|
||||||
|
int yTopPartial = Math.min(255, cy + diffYPartial);
|
||||||
|
filterSpherePartial(yTopFull + 1, yTopPartial - 1, bx, bz, filter, block, get, set);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
super.filter(chunk, filter, block, get, set); // TODO optimize non spheres
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,16 @@
|
|||||||
package com.sk89q.worldedit.world;
|
package com.sk89q.worldedit.world;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -69,7 +68,7 @@ public abstract class AbstractWorld implements World {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask createLiquidMask() {
|
public Mask createLiquidMask() {
|
||||||
return new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
|
return new BlockMask(this).add(BlockTypes.LAVA, BlockTypes.WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -96,11 +95,6 @@ public abstract class AbstractWorld implements World {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return getBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) {
|
public boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority) {
|
||||||
if (taskId == -1) {
|
if (taskId == -1) {
|
||||||
|
@ -26,9 +26,8 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
@ -41,6 +40,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
|||||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract implementation of {@link World}.
|
* An abstract implementation of {@link World}.
|
||||||
@ -59,12 +59,16 @@ public interface SimpleWorld extends World {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default BaseBlock getFullBlock(BlockVector3 position) {
|
default BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return getLazyBlock(position).toBaseBlock();
|
return getBlock(position).toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
<B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 pt, B block) throws WorldEditException;
|
<B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 pt, B block) throws WorldEditException;
|
||||||
|
|
||||||
|
@Nullable @Override default Path getStoragePath() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default int getMaxY() {
|
default int getMaxY() {
|
||||||
return getMaximumPoint().getBlockY();
|
return getMaximumPoint().getBlockY();
|
||||||
@ -72,7 +76,7 @@ public interface SimpleWorld extends World {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
default Mask createLiquidMask() {
|
default Mask createLiquidMask() {
|
||||||
return new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
|
return new BlockMask(this).add(BlockTypes.LAVA, BlockTypes.WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -115,11 +119,6 @@ public interface SimpleWorld extends World {
|
|||||||
return BlockVector3.at(30000000, 255, 30000000);
|
return BlockVector3.at(30000000, 255, 30000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
default @Nullable Operation commit() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
default boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
||||||
|
@ -26,6 +26,7 @@ import com.sk89q.jnbt.Tag;
|
|||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.function.mask.ABlockMask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||||
@ -47,8 +48,8 @@ import java.util.Objects;
|
|||||||
*/
|
*/
|
||||||
public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||||
|
|
||||||
private BlockState blockState;
|
private final BlockState blockState;
|
||||||
@Nullable protected CompoundTag nbtData;
|
private final CompoundTag nbtData;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BaseBlock() {
|
public BaseBlock() {
|
||||||
@ -71,6 +72,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
|||||||
*/
|
*/
|
||||||
public BaseBlock(BlockState blockState) {
|
public BaseBlock(BlockState blockState) {
|
||||||
this.blockState = blockState;
|
this.blockState = blockState;
|
||||||
|
nbtData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -181,7 +183,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNbtData(@Nullable CompoundTag nbtData) {
|
public void setNbtData(@Nullable CompoundTag nbtData) {
|
||||||
this.nbtData = nbtData;
|
throw new UnsupportedOperationException("Immutable");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -233,13 +235,19 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock toBaseBlock() {
|
public final char getOrdinalChar() {
|
||||||
|
return blockState.getOrdinalChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final BaseBlock toBaseBlock() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
return extent.setBlock(set, this);
|
set.setFullBlock(extent, this);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -280,7 +288,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return blockState.hashCode(); // stop changing this
|
return getOrdinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -291,5 +299,4 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
|||||||
return blockState.getAsString();
|
return blockState.getAsString();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,11 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.block;
|
package com.sk89q.worldedit.world.block;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
|
||||||
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
||||||
import com.sk89q.worldedit.function.pattern.FawePattern;
|
import com.sk89q.worldedit.function.pattern.FawePattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
@ -38,13 +35,16 @@ import com.sk89q.worldedit.world.item.ItemType;
|
|||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
public class BlockType implements FawePattern, Keyed {
|
public class BlockType implements FawePattern, Keyed {
|
||||||
private final String id;
|
private final String id;
|
||||||
@ -173,10 +173,15 @@ public class BlockType implements FawePattern, Keyed {
|
|||||||
*
|
*
|
||||||
* @return The default state
|
* @return The default state
|
||||||
*/
|
*/
|
||||||
public BlockState getDefaultState() {
|
public final BlockState getDefaultState() {
|
||||||
return this.settings.defaultState;
|
return this.settings.defaultState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Deprecated use a Mask instead
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public FuzzyBlockState getFuzzyMatcher() {
|
public FuzzyBlockState getFuzzyMatcher() {
|
||||||
return new FuzzyBlockState(this);
|
return new FuzzyBlockState(this);
|
||||||
}
|
}
|
||||||
@ -288,7 +293,7 @@ public class BlockType implements FawePattern, Keyed {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
return extent.setBlock(set, this.getDefaultState());
|
return set.setBlock(extent, getDefaultState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -296,7 +301,11 @@ public class BlockType implements FawePattern, Keyed {
|
|||||||
return this.getDefaultState().toBaseBlock();
|
return this.getDefaultState().toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mask toMask(Extent extent) {
|
public SingleBlockTypeMask toMask() {
|
||||||
|
return toMask(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleBlockTypeMask toMask(Extent extent) {
|
||||||
return new SingleBlockTypeMask(extent, this);
|
return new SingleBlockTypeMask(extent, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.world.registry.LegacyMapper;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public final class ItemTypes {
|
public final class ItemTypes {
|
||||||
|
|
||||||
@ -914,7 +915,7 @@ public final class ItemTypes {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ItemType parse(String input) {
|
public static ItemType parse(String input) {
|
||||||
input = input.toLowerCase();
|
input = input.toLowerCase(Locale.ROOT);
|
||||||
if (!Character.isAlphabetic(input.charAt(0))) {
|
if (!Character.isAlphabetic(input.charAt(0))) {
|
||||||
try {
|
try {
|
||||||
ItemType legacy = LegacyMapper.getInstance().getItemFromLegacy(input);
|
ItemType legacy = LegacyMapper.getInstance().getItemFromLegacy(input);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren