mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Lazy tags + get / set tiles
Lazy tags means tiles/ents are not translated into the nms NBTBase until it is needed. Should be faster in cases where getFullBlock is called, but nbt is not always needed. Commands like Copy and Paste, where the input/output are both nms worlds, can entirely bypass WorldEdit translating to and from the WorldEdit JNBT classes.
This commit is contained in:
parent
60759934a3
commit
144ea2ef34
@ -9,9 +9,11 @@ import com.boydti.fawe.beta.IChunkSet;
|
|||||||
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
|
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
|
||||||
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
||||||
import com.boydti.fawe.bukkit.adapter.DelegateLock;
|
import com.boydti.fawe.bukkit.adapter.DelegateLock;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_14.nbt.LazyCompoundTag_1_14;
|
||||||
import com.boydti.fawe.object.collection.AdaptedMap;
|
import com.boydti.fawe.object.collection.AdaptedMap;
|
||||||
import com.boydti.fawe.object.collection.BitArray4096;
|
import com.boydti.fawe.object.collection.BitArray4096;
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
import com.boydti.fawe.util.ReflectionUtils;
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.ListTag;
|
import com.sk89q.jnbt.ListTag;
|
||||||
@ -21,6 +23,7 @@ import com.sk89q.jnbt.Tag;
|
|||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
|
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_14_R4;
|
||||||
import com.sk89q.worldedit.internal.Constants;
|
import com.sk89q.worldedit.internal.Constants;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
@ -101,9 +104,8 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTag(int x, int y, int z) {
|
public CompoundTag getTag(int x, int y, int z) {
|
||||||
TileEntity tile = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
TileEntity tileEntity = getChunk().getTileEntity(new BlockPosition((x & 15) + (X << 4), y, (z & 15) + (Z << 4)));
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
return new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||||
return (CompoundTag) adapter.toNative(tile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Function<BlockPosition, BlockVector3> posNms2We = new Function<BlockPosition, BlockVector3>() {
|
private static final Function<BlockPosition, BlockVector3> posNms2We = new Function<BlockPosition, BlockVector3>() {
|
||||||
@ -116,8 +118,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
private final static Function<TileEntity, CompoundTag> nmsTile2We = new Function<TileEntity, CompoundTag>() {
|
private final static Function<TileEntity, CompoundTag> nmsTile2We = new Function<TileEntity, CompoundTag>() {
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag apply(TileEntity tileEntity) {
|
public CompoundTag apply(TileEntity tileEntity) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
return new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||||
return (CompoundTag) adapter.toNative(tileEntity.b());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -419,10 +420,11 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
|
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
|
||||||
final CompoundTag nativeTag = entry.getValue();
|
final CompoundTag nativeTag = entry.getValue();
|
||||||
final BlockVector3 blockHash = entry.getKey();
|
final BlockVector3 blockHash = entry.getKey();
|
||||||
final int x = blockHash.getX()+ bx;
|
final int x = blockHash.getX() + bx;
|
||||||
final int y = blockHash.getY();
|
final int y = blockHash.getY();
|
||||||
final int z = blockHash.getZ() + bz;
|
final int z = blockHash.getZ() + bz;
|
||||||
final BlockPosition pos = new BlockPosition(x, y, z);
|
final BlockPosition pos = new BlockPosition(x, y, z);
|
||||||
|
|
||||||
synchronized (nmsWorld) {
|
synchronized (nmsWorld) {
|
||||||
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
|
||||||
if (tileEntity == null || tileEntity.isRemoved()) {
|
if (tileEntity == null || tileEntity.isRemoved()) {
|
||||||
@ -473,18 +475,23 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
|||||||
Callable<Future> chain = new Callable<Future>() {
|
Callable<Future> chain = new Callable<Future>() {
|
||||||
@Override
|
@Override
|
||||||
public Future call() {
|
public Future call() {
|
||||||
// Run the sync tasks
|
try {
|
||||||
for (int i = 1; i < finalSyncTasks.length; i++) {
|
// Run the sync tasks
|
||||||
Runnable task = finalSyncTasks[i];
|
for (int i = 0; i < finalSyncTasks.length; i++) {
|
||||||
if (task != null) {
|
Runnable task = finalSyncTasks[i];
|
||||||
task.run();
|
if (task != null) {
|
||||||
|
task.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (callback == null) {
|
||||||
if (callback == null) {
|
if (finalizer != null) finalizer.run();
|
||||||
if (finalizer != null) finalizer.run();
|
return null;
|
||||||
return null;
|
} else {
|
||||||
} else {
|
return queueHandler.async(callback, null);
|
||||||
return queueHandler.async(callback, null);
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.bukkit.adapter.mc1_14.nbt;
|
package com.boydti.fawe.bukkit.adapter.mc1_14.nbt;
|
||||||
|
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.ListTag;
|
import com.sk89q.jnbt.ListTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
@ -14,43 +15,52 @@ import java.util.ArrayList;
|
|||||||
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.function.Supplier;
|
||||||
|
|
||||||
public class LazyCompoundTag_1_14 extends CompoundTag {
|
public class LazyCompoundTag_1_14 extends CompoundTag {
|
||||||
private final NBTTagCompound nmsTag;
|
private final Supplier<NBTTagCompound> nmsTag;
|
||||||
|
|
||||||
public LazyCompoundTag_1_14(NBTTagCompound tag) {
|
public LazyCompoundTag_1_14(Supplier<NBTTagCompound> tag) {
|
||||||
super(null);
|
super(null);
|
||||||
this.nmsTag = tag;
|
this.nmsTag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LazyCompoundTag_1_14(NBTTagCompound tag) {
|
||||||
|
this(() -> tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NBTTagCompound get() {
|
||||||
|
return nmsTag.get();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Tag> getValue() {
|
public Map<String, Tag> getValue() {
|
||||||
Map<String, Tag> value = super.getValue();
|
Map<String, Tag> value = super.getValue();
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
Tag tag = WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(nmsTag);
|
Tag tag = WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(nmsTag.get());
|
||||||
setValue(((CompoundTag) tag).getValue());
|
setValue(((CompoundTag) tag).getValue());
|
||||||
}
|
}
|
||||||
return super.getValue();
|
return super.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsKey(String key) {
|
public boolean containsKey(String key) {
|
||||||
return nmsTag.hasKey(key);
|
return nmsTag.get().hasKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getByteArray(String key) {
|
public byte[] getByteArray(String key) {
|
||||||
return nmsTag.getByteArray(key);
|
return nmsTag.get().getByteArray(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getByte(String key) {
|
public byte getByte(String key) {
|
||||||
return nmsTag.getByte(key);
|
return nmsTag.get().getByte(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDouble(String key) {
|
public double getDouble(String key) {
|
||||||
return nmsTag.getDouble(key);
|
return nmsTag.get().getDouble(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double asDouble(String key) {
|
public double asDouble(String key) {
|
||||||
NBTBase value = nmsTag.get(key);
|
NBTBase value = nmsTag.get().get(key);
|
||||||
if (value instanceof NBTNumber) {
|
if (value instanceof NBTNumber) {
|
||||||
return ((NBTNumber) value).asDouble();
|
return ((NBTNumber) value).asDouble();
|
||||||
}
|
}
|
||||||
@ -58,19 +68,19 @@ public class LazyCompoundTag_1_14 extends CompoundTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getFloat(String key) {
|
public float getFloat(String key) {
|
||||||
return nmsTag.getFloat(key);
|
return nmsTag.get().getFloat(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getIntArray(String key) {
|
public int[] getIntArray(String key) {
|
||||||
return nmsTag.getIntArray(key);
|
return nmsTag.get().getIntArray(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInt(String key) {
|
public int getInt(String key) {
|
||||||
return nmsTag.getInt(key);
|
return nmsTag.get().getInt(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int asInt(String key) {
|
public int asInt(String key) {
|
||||||
NBTBase value = nmsTag.get(key);
|
NBTBase value = nmsTag.get().get(key);
|
||||||
if (value instanceof NBTNumber) {
|
if (value instanceof NBTNumber) {
|
||||||
return ((NBTNumber) value).asInt();
|
return ((NBTNumber) value).asInt();
|
||||||
}
|
}
|
||||||
@ -78,7 +88,7 @@ public class LazyCompoundTag_1_14 extends CompoundTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Tag> getList(String key) {
|
public List<Tag> getList(String key) {
|
||||||
NBTBase tag = nmsTag.get(key);
|
NBTBase tag = nmsTag.get().get(key);
|
||||||
if (tag instanceof NBTTagList) {
|
if (tag instanceof NBTTagList) {
|
||||||
ArrayList<Tag> list = new ArrayList<>();
|
ArrayList<Tag> list = new ArrayList<>();
|
||||||
NBTTagList nbtList = (NBTTagList) tag;
|
NBTTagList nbtList = (NBTTagList) tag;
|
||||||
@ -95,7 +105,7 @@ public class LazyCompoundTag_1_14 extends CompoundTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ListTag getListTag(String key) {
|
public ListTag getListTag(String key) {
|
||||||
NBTBase tag = nmsTag.get(key);
|
NBTBase tag = nmsTag.get().get(key);
|
||||||
if (tag instanceof NBTTagList) {
|
if (tag instanceof NBTTagList) {
|
||||||
return (ListTag) WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(tag);
|
return (ListTag) WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(tag);
|
||||||
}
|
}
|
||||||
@ -113,15 +123,15 @@ public class LazyCompoundTag_1_14 extends CompoundTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long[] getLongArray(String key) {
|
public long[] getLongArray(String key) {
|
||||||
return nmsTag.getLongArray(key);
|
return nmsTag.get().getLongArray(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLong(String key) {
|
public long getLong(String key) {
|
||||||
return nmsTag.getLong(key);
|
return nmsTag.get().getLong(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long asLong(String key) {
|
public long asLong(String key) {
|
||||||
NBTBase value = nmsTag.get(key);
|
NBTBase value = nmsTag.get().get(key);
|
||||||
if (value instanceof NBTNumber) {
|
if (value instanceof NBTNumber) {
|
||||||
return ((NBTNumber) value).asLong();
|
return ((NBTNumber) value).asLong();
|
||||||
}
|
}
|
||||||
@ -129,10 +139,15 @@ public class LazyCompoundTag_1_14 extends CompoundTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public short getShort(String key) {
|
public short getShort(String key) {
|
||||||
return nmsTag.getShort(key);
|
return nmsTag.get().getShort(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(String key) {
|
public String getString(String key) {
|
||||||
return nmsTag.getString(key);
|
return nmsTag.get().getString(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return nmsTag.get().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAM
|
|||||||
|
|
||||||
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.mc1_14.FAWE_Spigot_v1_14_R4;
|
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_14_R4;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.sk89q.util.yaml.YAMLProcessor;
|
import com.sk89q.util.yaml.YAMLProcessor;
|
||||||
|
@ -155,7 +155,6 @@ public class BukkitImplLoader {
|
|||||||
*/
|
*/
|
||||||
public BukkitImplAdapter loadAdapter() throws AdapterLoadException {
|
public BukkitImplAdapter loadAdapter() throws AdapterLoadException {
|
||||||
for (String className : adapterCandidates) {
|
for (String className : adapterCandidates) {
|
||||||
System.out.println("Try load " + className);
|
|
||||||
try {
|
try {
|
||||||
Class<?> cls = Class.forName(className);
|
Class<?> cls = Class.forName(className);
|
||||||
if (cls.isSynthetic()) continue;
|
if (cls.isSynthetic()) continue;
|
||||||
|
@ -17,11 +17,17 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.boydti.fawe.bukkit.adapter.mc1_14;
|
package com.sk89q.worldedit.bukkit.adapter.impl;
|
||||||
|
|
||||||
|
import com.bekvon.bukkit.residence.commands.material;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_14.BlockMaterial_1_14;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_14.BukkitAdapter_1_14;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_14.MapChunkUtil_1_14;
|
||||||
|
import com.boydti.fawe.bukkit.adapter.mc1_14.nbt.LazyCompoundTag_1_14;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
@ -74,6 +80,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -82,7 +89,7 @@ import java.util.stream.Stream;
|
|||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<NBTBase> {
|
public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<NBTBase> {
|
||||||
private final BukkitImplAdapter<NBTBase> parent;
|
private final Spigot_v1_14_R4 parent;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// Code that may break between versions of Minecraft
|
// Code that may break between versions of Minecraft
|
||||||
@ -242,9 +249,6 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
|
|||||||
@Override
|
@Override
|
||||||
public OptionalInt getInternalBlockStateId(BlockState state) {
|
public OptionalInt getInternalBlockStateId(BlockState state) {
|
||||||
BlockMaterial_1_14 material = (BlockMaterial_1_14) state.getMaterial();
|
BlockMaterial_1_14 material = (BlockMaterial_1_14) state.getMaterial();
|
||||||
if (material.isAir()) {
|
|
||||||
return OptionalInt.empty();
|
|
||||||
}
|
|
||||||
IBlockData mcState = material.getCraftBlockData().getState();
|
IBlockData mcState = material.getCraftBlockData().getState();
|
||||||
return OptionalInt.of(Block.REGISTRY_ID.getId(mcState));
|
return OptionalInt.of(Block.REGISTRY_ID.getId(mcState));
|
||||||
}
|
}
|
||||||
@ -324,9 +328,7 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||||
Map<String, ? extends Property<?>> result = getParent().getProperties(blockType);
|
return getParent().getProperties(blockType);
|
||||||
System.out.println("Result " + result);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -343,4 +345,17 @@ public final class FAWE_Spigot_v1_14_R4 extends CachedBukkitAdapter implements I
|
|||||||
weStack.setNbtData(((CompoundTag) toNative(nmsStack.getTag())));
|
weStack.setNbtData(((CompoundTag) toNative(nmsStack.getTag())));
|
||||||
return weStack;
|
return weStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tag toNative(NBTBase foreign) {
|
||||||
|
return parent.toNative(foreign);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTBase fromNative(Tag foreign) {
|
||||||
|
if (foreign instanceof LazyCompoundTag_1_14) {
|
||||||
|
return ((LazyCompoundTag_1_14) foreign).get();
|
||||||
|
}
|
||||||
|
return parent.fromNative(foreign);
|
||||||
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ import java.util.concurrent.Future;
|
|||||||
/**
|
/**
|
||||||
* An interface for getting blocks.
|
* An interface for getting blocks.
|
||||||
*/
|
*/
|
||||||
public interface IChunkGet extends IBlocks, Trimable, InputExtent {
|
public interface IChunkGet extends IBlocks, Trimable, InputExtent, ITileInput {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
BaseBlock getFullBlock(int x, int y, int z);
|
BaseBlock getFullBlock(int x, int y, int z);
|
||||||
@ -26,6 +26,7 @@ public interface IChunkGet extends IBlocks, Trimable, InputExtent {
|
|||||||
@Override
|
@Override
|
||||||
BlockState getBlock(int x, int y, int z);
|
BlockState getBlock(int x, int y, int z);
|
||||||
|
|
||||||
|
@Override
|
||||||
CompoundTag getTag(int x, int y, int z);
|
CompoundTag getTag(int x, int y, int z);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.boydti.fawe.beta;
|
||||||
|
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
|
||||||
|
public interface ITileInput {
|
||||||
|
CompoundTag getTag(int x, int y, int z);
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.boydti.fawe.beta.implementation.blocks;
|
|||||||
|
|
||||||
import com.boydti.fawe.beta.IChunkGet;
|
import com.boydti.fawe.beta.IChunkGet;
|
||||||
import com.boydti.fawe.beta.IChunkSet;
|
import com.boydti.fawe.beta.IChunkSet;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
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.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -11,7 +12,8 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||||
return BlockTypesCache.states[get(x, y, z)].toBaseBlock();
|
BlockState state = BlockTypesCache.states[get(x, y, z)];
|
||||||
|
return state.toBaseBlock(this, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,7 +101,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tile) {
|
public boolean setTile(int x, int y, int z, CompoundTag tile) {
|
||||||
if (tiles == null) {
|
if (tiles == null) {
|
||||||
tiles = new BlockVector3ChunkMap<CompoundTag>();
|
tiles = new BlockVector3ChunkMap<>();
|
||||||
}
|
}
|
||||||
tiles.put(x, y, z, tile);
|
tiles.put(x, y, z, tile);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1213,8 +1213,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
char combined = block.getDefaultState().getOrdinalChar();
|
char combined = block.getDefaultState().getOrdinalChar();
|
||||||
mainArr[index] = combined;
|
mainArr[index] = combined;
|
||||||
floorArr[index] = combined;
|
floorArr[index] = combined;
|
||||||
} else {
|
|
||||||
System.out.println("Block is null " + color + " | " + textureUtil.getClass());
|
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,12 @@ public class MutablePair<K, V> implements Map.Entry<K, V> {
|
|||||||
private V value;
|
private V value;
|
||||||
@Override
|
@Override
|
||||||
public K getKey() {
|
public K getKey() {
|
||||||
return null;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public V getValue() {
|
public V getValue() {
|
||||||
return null;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,7 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
public class SimpleBlockCopy implements RegionFunction {
|
public class SimpleBlockCopy implements RegionFunction {
|
||||||
|
|
||||||
|
@ -25,6 +25,15 @@ import java.util.Locale;
|
|||||||
* The {@code TAG_Byte_Array} tag.
|
* The {@code TAG_Byte_Array} tag.
|
||||||
*/
|
*/
|
||||||
public final class ByteArrayTag extends Tag {
|
public final class ByteArrayTag extends Tag {
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_Byte_Array";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_BYTE_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
private final byte[] value;
|
private final byte[] value;
|
||||||
|
|
||||||
|
@ -23,6 +23,14 @@ package com.sk89q.jnbt;
|
|||||||
* The {@code TAG_Byte} tag.
|
* The {@code TAG_Byte} tag.
|
||||||
*/
|
*/
|
||||||
public final class ByteTag extends NumberTag {
|
public final class ByteTag extends NumberTag {
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_BYTE;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_Byte";
|
||||||
|
}
|
||||||
|
|
||||||
private final byte value;
|
private final byte value;
|
||||||
|
|
||||||
|
@ -32,6 +32,15 @@ import java.util.UUID;
|
|||||||
* The {@code TAG_Compound} tag.
|
* The {@code TAG_Compound} tag.
|
||||||
*/
|
*/
|
||||||
public class CompoundTag extends Tag {
|
public class CompoundTag extends Tag {
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_Compound";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_COMPOUND;
|
||||||
|
}
|
||||||
|
|
||||||
private Map<String, Tag> value;
|
private Map<String, Tag> value;
|
||||||
|
|
||||||
|
@ -24,6 +24,14 @@ package com.sk89q.jnbt;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class DoubleTag extends NumberTag {
|
public final class DoubleTag extends NumberTag {
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_DOUBLE;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_Double";
|
||||||
|
}
|
||||||
|
|
||||||
private final double value;
|
private final double value;
|
||||||
|
|
||||||
|
@ -23,6 +23,15 @@ package com.sk89q.jnbt;
|
|||||||
* The {@code TAG_End} tag.
|
* The {@code TAG_End} tag.
|
||||||
*/
|
*/
|
||||||
public final class EndTag extends Tag {
|
public final class EndTag extends Tag {
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_End";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_END;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
|
@ -23,6 +23,14 @@ package com.sk89q.jnbt;
|
|||||||
* The {@code TAG_Float} tag.
|
* The {@code TAG_Float} tag.
|
||||||
*/
|
*/
|
||||||
public final class FloatTag extends NumberTag {
|
public final class FloatTag extends NumberTag {
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_FLOAT;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_Float";
|
||||||
|
}
|
||||||
|
|
||||||
private final float value;
|
private final float value;
|
||||||
|
|
||||||
|
@ -29,6 +29,15 @@ import java.util.Locale;
|
|||||||
* The {@code TAG_Int_Array} tag.
|
* The {@code TAG_Int_Array} tag.
|
||||||
*/
|
*/
|
||||||
public final class IntArrayTag extends Tag {
|
public final class IntArrayTag extends Tag {
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_Int_Array";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_INT_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
private final int[] value;
|
private final int[] value;
|
||||||
|
|
||||||
|
@ -23,6 +23,14 @@ package com.sk89q.jnbt;
|
|||||||
* The {@code TAG_Int} tag.
|
* The {@code TAG_Int} tag.
|
||||||
*/
|
*/
|
||||||
public final class IntTag extends NumberTag {
|
public final class IntTag extends NumberTag {
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_INT;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_Int";
|
||||||
|
}
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
|
@ -31,6 +31,15 @@ import javax.annotation.Nullable;
|
|||||||
* The {@code TAG_List} tag.
|
* The {@code TAG_List} tag.
|
||||||
*/
|
*/
|
||||||
public class ListTag extends Tag {
|
public class ListTag extends Tag {
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_List";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
private final Class<? extends Tag> type;
|
private final Class<? extends Tag> type;
|
||||||
private final List<Tag> value;
|
private final List<Tag> value;
|
||||||
@ -432,7 +441,7 @@ public class ListTag extends Tag {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder bldr = new StringBuilder();
|
StringBuilder bldr = new StringBuilder();
|
||||||
bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
|
bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(type.getTypeName()).append("\r\n{\r\n");
|
||||||
for (Tag t : value) {
|
for (Tag t : value) {
|
||||||
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,15 @@ import java.util.Locale;
|
|||||||
* The {@code TAG_Long_Array} tag.
|
* The {@code TAG_Long_Array} tag.
|
||||||
*/
|
*/
|
||||||
public class LongArrayTag extends Tag {
|
public class LongArrayTag extends Tag {
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_Long_Array";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_LONG_ARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
private final long[] value;
|
private final long[] value;
|
||||||
|
|
||||||
|
@ -24,6 +24,14 @@ package com.sk89q.jnbt;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class LongTag extends NumberTag {
|
public final class LongTag extends NumberTag {
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_LONG;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_Long";
|
||||||
|
}
|
||||||
|
|
||||||
private final long value;
|
private final long value;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
checkNotNull(name);
|
checkNotNull(name);
|
||||||
checkNotNull(tag);
|
checkNotNull(tag);
|
||||||
|
|
||||||
int type = NBTUtils.getTypeCode(tag.getClass());
|
int type = tag.getTypeCode();
|
||||||
writeNamedTagName(name, type);
|
writeNamedTagName(name, type);
|
||||||
|
|
||||||
if (type == NBTConstants.TYPE_END) {
|
if (type == NBTConstants.TYPE_END) {
|
||||||
@ -189,7 +189,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeTag(Tag tag) throws IOException {
|
public void writeTag(Tag tag) throws IOException {
|
||||||
int type = NBTUtils.getTypeCode(tag.getClass());
|
int type = tag.getTypeCode();
|
||||||
os.writeByte(type);
|
os.writeByte(type);
|
||||||
writeTagPayload(tag);
|
writeTagPayload(tag);
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
* if an I/O error occurs.
|
* if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public void writeTagPayload(Tag tag) throws IOException {
|
public void writeTagPayload(Tag tag) throws IOException {
|
||||||
int type = NBTUtils.getTypeCode(tag.getClass());
|
int type = tag.getTypeCode();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NBTConstants.TYPE_END:
|
case NBTConstants.TYPE_END:
|
||||||
writeEndTagPayload((EndTag) tag);
|
writeEndTagPayload((EndTag) tag);
|
||||||
@ -311,7 +311,7 @@ public final class NBTOutputStream extends OutputStream implements Closeable, Da
|
|||||||
int size = tags.size();
|
int size = tags.size();
|
||||||
if (!tags.isEmpty()) {
|
if (!tags.isEmpty()) {
|
||||||
Tag tag0 = tags.get(0);
|
Tag tag0 = tags.get(0);
|
||||||
os.writeByte(NBTUtils.getTypeCode(tag0.getClass()));
|
os.writeByte(tag0.getTypeCode());
|
||||||
} else {
|
} else {
|
||||||
os.writeByte(NBTUtils.getTypeCode(clazz));
|
os.writeByte(NBTUtils.getTypeCode(clazz));
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public final class NBTUtils {
|
|||||||
return "TAG_Byte_Array";
|
return "TAG_Byte_Array";
|
||||||
} else if (clazz.equals(ByteTag.class)) {
|
} else if (clazz.equals(ByteTag.class)) {
|
||||||
return "TAG_Byte";
|
return "TAG_Byte";
|
||||||
} else if (clazz.equals(CompoundTag.class)) {
|
} else if (CompoundTag.class.isAssignableFrom(clazz)) {
|
||||||
return "TAG_Compound";
|
return "TAG_Compound";
|
||||||
} else if (clazz.equals(DoubleTag.class)) {
|
} else if (clazz.equals(DoubleTag.class)) {
|
||||||
return "TAG_Double";
|
return "TAG_Double";
|
||||||
@ -89,7 +89,7 @@ public final class NBTUtils {
|
|||||||
return NBTConstants.TYPE_BYTE_ARRAY;
|
return NBTConstants.TYPE_BYTE_ARRAY;
|
||||||
} else if (clazz.equals(ByteTag.class)) {
|
} else if (clazz.equals(ByteTag.class)) {
|
||||||
return NBTConstants.TYPE_BYTE;
|
return NBTConstants.TYPE_BYTE;
|
||||||
} else if (clazz.equals(CompoundTag.class)) {
|
} else if (CompoundTag.class.isAssignableFrom(clazz)) {
|
||||||
return NBTConstants.TYPE_COMPOUND;
|
return NBTConstants.TYPE_COMPOUND;
|
||||||
} else if (clazz.equals(DoubleTag.class)) {
|
} else if (clazz.equals(DoubleTag.class)) {
|
||||||
return NBTConstants.TYPE_DOUBLE;
|
return NBTConstants.TYPE_DOUBLE;
|
||||||
|
@ -23,6 +23,14 @@ package com.sk89q.jnbt;
|
|||||||
* The {@code TAG_Short} tag.
|
* The {@code TAG_Short} tag.
|
||||||
*/
|
*/
|
||||||
public final class ShortTag extends NumberTag {
|
public final class ShortTag extends NumberTag {
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_SHORT;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_Short";
|
||||||
|
}
|
||||||
|
|
||||||
private final short value;
|
private final short value;
|
||||||
|
|
||||||
|
@ -25,6 +25,15 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* The {@code TAG_String} tag.
|
* The {@code TAG_String} tag.
|
||||||
*/
|
*/
|
||||||
public final class StringTag extends Tag {
|
public final class StringTag extends Tag {
|
||||||
|
@Override
|
||||||
|
public String getTypeName() {
|
||||||
|
return "TAG_String";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTypeCode() {
|
||||||
|
return NBTConstants.TYPE_STRING;
|
||||||
|
}
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
|
@ -35,4 +35,8 @@ public abstract class Tag {
|
|||||||
return getValue();
|
return getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract int getTypeCode();
|
||||||
|
|
||||||
|
public abstract String getTypeName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -154,15 +154,6 @@ public class BrushCommands {
|
|||||||
this.worldEdit = worldEdit;
|
this.worldEdit = worldEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "none",
|
|
||||||
aliases = "unbind",
|
|
||||||
desc = "Unbind a bound brush from your current item"
|
|
||||||
)
|
|
||||||
void none(Player player, LocalSession session) throws WorldEditException {
|
|
||||||
ToolCommands.setToolNone(player, session, "Brush");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "blendball",
|
name = "blendball",
|
||||||
aliases = {"bb", "blend"},
|
aliases = {"bb", "blend"},
|
||||||
@ -959,52 +950,6 @@ public class BrushCommands {
|
|||||||
return process(player, arguments, bs);
|
return process(player, arguments, bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "forest",
|
|
||||||
desc = "Forest brush, creates a forest in the area"
|
|
||||||
)
|
|
||||||
@CommandPermissions("worldedit.brush.forest")
|
|
||||||
public void forest(Player player, LocalSession localSession,
|
|
||||||
@Arg(desc = "The shape of the region")
|
|
||||||
RegionFactory shape,
|
|
||||||
@Arg(desc = "The size of the brush", def = "5")
|
|
||||||
Expression radius,
|
|
||||||
@Arg(desc = "The density of the brush", def = "20")
|
|
||||||
double density,
|
|
||||||
@Arg(desc = "The type of tree to use")
|
|
||||||
TreeGenerator.TreeType type) throws WorldEditException, EvaluationException {
|
|
||||||
setOperationBasedBrush(player, localSession, radius,
|
|
||||||
new Paint(new TreeGeneratorFactory(type), density / 100), shape, "worldedit.brush.forest");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "raise",
|
|
||||||
desc = "Raise brush, raise all blocks by one"
|
|
||||||
)
|
|
||||||
@CommandPermissions("worldedit.brush.raise")
|
|
||||||
public void raise(Player player, LocalSession localSession,
|
|
||||||
@Arg(desc = "The shape of the region")
|
|
||||||
RegionFactory shape,
|
|
||||||
@Arg(desc = "The size of the brush", def = "5")
|
|
||||||
Expression radius) throws WorldEditException, EvaluationException {
|
|
||||||
setOperationBasedBrush(player, localSession, radius,
|
|
||||||
new Deform("y-=1"), shape, "worldedit.brush.raise");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "lower",
|
|
||||||
desc = "Lower brush, lower all blocks by one"
|
|
||||||
)
|
|
||||||
@CommandPermissions("worldedit.brush.lower")
|
|
||||||
public void lower(Player player, LocalSession localSession,
|
|
||||||
@Arg(desc = "The shape of the region")
|
|
||||||
RegionFactory shape,
|
|
||||||
@Arg(desc = "The size of the brush", def = "5")
|
|
||||||
Expression radius) throws WorldEditException, EvaluationException {
|
|
||||||
setOperationBasedBrush(player, localSession, radius,
|
|
||||||
new Deform("y+=1"), shape, "worldedit.brush.lower");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "savebrush",
|
name = "savebrush",
|
||||||
aliases = {"save"},
|
aliases = {"save"},
|
||||||
@ -1139,7 +1084,7 @@ public class BrushCommands {
|
|||||||
@Arg(desc = "The shape of the region")
|
@Arg(desc = "The shape of the region")
|
||||||
RegionFactory shape,
|
RegionFactory shape,
|
||||||
@Arg(desc = "The size of the brush", def = "5")
|
@Arg(desc = "The size of the brush", def = "5")
|
||||||
double radius,
|
Expression radius,
|
||||||
@Arg(desc = "The pattern of blocks to set")
|
@Arg(desc = "The pattern of blocks to set")
|
||||||
Pattern pattern) throws WorldEditException {
|
Pattern pattern) throws WorldEditException {
|
||||||
setOperationBasedBrush(player, localSession, radius,
|
setOperationBasedBrush(player, localSession, radius,
|
||||||
@ -1155,7 +1100,7 @@ public class BrushCommands {
|
|||||||
@Arg(desc = "The shape of the region")
|
@Arg(desc = "The shape of the region")
|
||||||
RegionFactory shape,
|
RegionFactory shape,
|
||||||
@Arg(desc = "The size of the brush", def = "5")
|
@Arg(desc = "The size of the brush", def = "5")
|
||||||
double radius,
|
Expression radius,
|
||||||
@Arg(desc = "The density of the brush", def = "20")
|
@Arg(desc = "The density of the brush", def = "20")
|
||||||
double density,
|
double density,
|
||||||
@Arg(desc = "The type of tree to use")
|
@Arg(desc = "The type of tree to use")
|
||||||
@ -1173,7 +1118,7 @@ public class BrushCommands {
|
|||||||
@Arg(desc = "The shape of the region")
|
@Arg(desc = "The shape of the region")
|
||||||
RegionFactory shape,
|
RegionFactory shape,
|
||||||
@Arg(desc = "The size of the brush", def = "5")
|
@Arg(desc = "The size of the brush", def = "5")
|
||||||
double radius) throws WorldEditException {
|
Expression radius) throws WorldEditException {
|
||||||
setOperationBasedBrush(player, localSession, radius,
|
setOperationBasedBrush(player, localSession, radius,
|
||||||
new Deform("y-=1"), shape, "worldedit.brush.raise");
|
new Deform("y-=1"), shape, "worldedit.brush.raise");
|
||||||
}
|
}
|
||||||
@ -1187,7 +1132,7 @@ public class BrushCommands {
|
|||||||
@Arg(desc = "The shape of the region")
|
@Arg(desc = "The shape of the region")
|
||||||
RegionFactory shape,
|
RegionFactory shape,
|
||||||
@Arg(desc = "The size of the brush", def = "5")
|
@Arg(desc = "The size of the brush", def = "5")
|
||||||
double radius) throws WorldEditException {
|
Expression radius) throws WorldEditException {
|
||||||
setOperationBasedBrush(player, localSession, radius,
|
setOperationBasedBrush(player, localSession, radius,
|
||||||
new Deform("y+=1"), shape, "worldedit.brush.lower");
|
new Deform("y+=1"), shape, "worldedit.brush.lower");
|
||||||
}
|
}
|
||||||
|
@ -110,28 +110,26 @@ public class RegionCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/set",
|
name = "/set",
|
||||||
desc = "Sets all the blocks in the region"
|
aliases = {"/"},
|
||||||
|
desc = "Sets all the blocks in the region"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.set")
|
@CommandPermissions("worldedit.region.set")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public int set(Actor actor, EditSession editSession,
|
public int set(Actor actor, EditSession editSession,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@Arg(desc = "The pattern of blocks to set")
|
@Arg(desc = "The pattern of blocks to set")
|
||||||
Pattern pattern) {
|
Pattern pattern,
|
||||||
RegionFunction set = new BlockReplace(editSession, pattern);
|
InjectedValueAccess context) {
|
||||||
RegionVisitor visitor = new RegionVisitor(region, set);
|
actor.checkConfirmationRegion(() -> {
|
||||||
|
int affected = editSession.setBlocks(region, pattern);
|
||||||
Operations.completeBlindly(visitor);
|
if (affected != 0) {
|
||||||
List<String> messages = Lists.newArrayList();
|
BBC.OPERATION.send(actor, affected);
|
||||||
visitor.addStatusMessages(messages);
|
if (!actor.hasPermission("fawe.tips"))
|
||||||
if (messages.isEmpty()) {
|
BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(actor);
|
||||||
actor.print("Operation completed.");
|
}
|
||||||
} else {
|
}, getArguments(context), region, context);
|
||||||
actor.print("Operation completed (" + Joiner.on(", ").join(messages) + ").");
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
return visitor.getAffected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -147,27 +145,6 @@ public class RegionCommands {
|
|||||||
set(actor, editSession, region, BlockTypes.AIR, context);
|
set(actor, editSession, region, BlockTypes.AIR, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
|
||||||
name = "/set",
|
|
||||||
aliases = {"/"},
|
|
||||||
desc = "Sets all the blocks in the region"
|
|
||||||
)
|
|
||||||
@CommandPermissions("worldedit.region.set")
|
|
||||||
@Logging(REGION)
|
|
||||||
public void set(Actor actor, EditSession editSession,
|
|
||||||
@Selection Region region,
|
|
||||||
@Arg(desc = "The pattern of blocks to set")
|
|
||||||
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
|
|
||||||
actor.checkConfirmationRegion(() -> {
|
|
||||||
int affected = editSession.setBlocks(region, pattern);
|
|
||||||
if (affected != 0) {
|
|
||||||
BBC.OPERATION.send(actor, affected);
|
|
||||||
if (!actor.hasPermission("fawe.tips"))
|
|
||||||
BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(actor);
|
|
||||||
}
|
|
||||||
}, getArguments(context), region, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/test",
|
name = "/test",
|
||||||
desc = "test region"
|
desc = "test region"
|
||||||
@ -175,13 +152,11 @@ public class RegionCommands {
|
|||||||
@CommandPermissions("worldedit.region.test")
|
@CommandPermissions("worldedit.region.test")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void test(Player player, EditSession editSession, @Selection Region region, @Arg(desc = "hello there") BiomeType biome) throws WorldEditException {
|
public void test(Player player, EditSession editSession, @Selection Region region, @Arg(desc = "hello there") BiomeType biome) throws WorldEditException {
|
||||||
System.out.println("Test start");
|
|
||||||
editSession.addProcessor(new ChunkSendProcessor(editSession.getWorld(), () -> Collections.singleton(player)));
|
editSession.addProcessor(new ChunkSendProcessor(editSession.getWorld(), () -> Collections.singleton(player)));
|
||||||
editSession.addProcessor(NullProcessor.INSTANCE);
|
editSession.addProcessor(NullProcessor.INSTANCE);
|
||||||
FlatRegionFunction replace = new BiomeReplace(editSession, biome);
|
FlatRegionFunction replace = new BiomeReplace(editSession, biome);
|
||||||
FlatRegionVisitor visitor = new FlatRegionVisitor(Regions.asFlatRegion(region), replace);
|
FlatRegionVisitor visitor = new FlatRegionVisitor(Regions.asFlatRegion(region), replace);
|
||||||
Operations.completeLegacy(visitor);
|
Operations.completeLegacy(visitor);
|
||||||
System.out.println("Test end");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -179,9 +179,9 @@ public class ToolUtilCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/",
|
name = "/superpickaxe",
|
||||||
aliases = { "," },
|
aliases = {",", "/sp", "/pickaxe"},
|
||||||
desc = "Toggle the super pickaxe function"
|
desc = "Toggle the super pickaxe function"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.superpickaxe")
|
@CommandPermissions("worldedit.superpickaxe")
|
||||||
public void togglePickaxe(Player player, LocalSession session,
|
public void togglePickaxe(Player player, LocalSession session,
|
||||||
|
@ -56,7 +56,7 @@ import org.enginehub.piston.annotation.param.Arg;
|
|||||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||||
import org.enginehub.piston.annotation.param.Switch;
|
import org.enginehub.piston.annotation.param.Switch;
|
||||||
|
|
||||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class})
|
||||||
public class WorldEditCommands {
|
public class WorldEditCommands {
|
||||||
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
|
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ public enum Capability {
|
|||||||
* The capability of a platform to perform modifications to a world.
|
* The capability of a platform to perform modifications to a world.
|
||||||
*/
|
*/
|
||||||
WORLD_EDITING {
|
WORLD_EDITING {
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
void initialize(PlatformManager platformManager, Platform platform) {
|
void initialize(PlatformManager platformManager, Platform platform) {
|
||||||
BlockRegistry blockRegistry = platform.getRegistries().getBlockRegistry();
|
BlockRegistry blockRegistry = platform.getRegistries().getBlockRegistry();
|
||||||
@ -93,6 +94,7 @@ public enum Capability {
|
|||||||
void unload(PlatformManager platformManager, Platform platform) {
|
void unload(PlatformManager platformManager, Platform platform) {
|
||||||
BlockStateIdAccess.clear();
|
BlockStateIdAccess.clear();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
void initialize(PlatformManager platformManager, Platform platform) {
|
void initialize(PlatformManager platformManager, Platform platform) {
|
||||||
|
@ -31,7 +31,7 @@ import java.util.OptionalInt;
|
|||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
public final class BlockStateIdAccess {
|
public final class BlockStateIdAccess {
|
||||||
|
/*
|
||||||
private static final BiMap<BlockState, Integer> ASSIGNED_IDS = HashBiMap.create(2 << 13);
|
private static final BiMap<BlockState, Integer> ASSIGNED_IDS = HashBiMap.create(2 << 13);
|
||||||
|
|
||||||
public static OptionalInt getBlockStateId(BlockState holder) {
|
public static OptionalInt getBlockStateId(BlockState holder) {
|
||||||
@ -49,7 +49,7 @@ public final class BlockStateIdAccess {
|
|||||||
* {@link OptionalInt#empty()}. In those cases, we will use our own ID system,
|
* {@link OptionalInt#empty()}. In those cases, we will use our own ID system,
|
||||||
* since it's useful for other entries as well.
|
* since it's useful for other entries as well.
|
||||||
* @return an unused ID in WorldEdit's ID tracker
|
* @return an unused ID in WorldEdit's ID tracker
|
||||||
*/
|
/
|
||||||
private static int provideUnusedWorldEditId() {
|
private static int provideUnusedWorldEditId() {
|
||||||
return usedIds.nextClearBit(0);
|
return usedIds.nextClearBit(0);
|
||||||
}
|
}
|
||||||
@ -73,5 +73,12 @@ public final class BlockStateIdAccess {
|
|||||||
|
|
||||||
private BlockStateIdAccess() {
|
private BlockStateIdAccess() {
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
public static OptionalInt getBlockStateId(BlockState holder) {
|
||||||
|
return OptionalInt.of(holder.getOrdinal());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable BlockState getBlockStateById(int id) {
|
||||||
|
return BlockState.getFromOrdinal(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.world.block;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.ITileInput;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
@ -162,11 +163,6 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
|||||||
return this.nbtData;
|
return this.nbtData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setNbtData(@Nullable CompoundTag nbtData) {
|
|
||||||
throw new UnsupportedOperationException("This class is immutable.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the type ID and data value are equal.
|
* Checks whether the type ID and data value are equal.
|
||||||
*/
|
*/
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.block;
|
package com.sk89q.worldedit.world.block;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.ITileInput;
|
||||||
import com.boydti.fawe.command.SuggestInputParseException;
|
import com.boydti.fawe.command.SuggestInputParseException;
|
||||||
import com.boydti.fawe.object.string.MutableCharSequence;
|
import com.boydti.fawe.object.string.MutableCharSequence;
|
||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
@ -53,7 +54,8 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
|||||||
private final char ordinalChar;
|
private final char ordinalChar;
|
||||||
private final BlockType blockType;
|
private final BlockType blockType;
|
||||||
private BlockMaterial material;
|
private BlockMaterial material;
|
||||||
private BaseBlock emptyBaseBlock;
|
private final BaseBlock emptyBaseBlock;
|
||||||
|
private CompoundInput compoundInput = CompoundInput.NULL;
|
||||||
|
|
||||||
protected BlockState(BlockType blockType, int internalId, int ordinal) {
|
protected BlockState(BlockType blockType, int internalId, int ordinal) {
|
||||||
this.blockType = blockType;
|
this.blockType = blockType;
|
||||||
@ -196,7 +198,6 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
|||||||
case '=': {
|
case '=': {
|
||||||
charSequence.setSubstring(last, i);
|
charSequence.setSubstring(last, i);
|
||||||
property = (AbstractProperty) type.getPropertyMap().get(charSequence);
|
property = (AbstractProperty) type.getPropertyMap().get(charSequence);
|
||||||
if (property == null) System.out.println("No prop " + charSequence + " | " + type.getPropertyMap());
|
|
||||||
last = i + 1;
|
last = i + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -356,6 +357,9 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
|||||||
return this.material = blockType.getMaterial();
|
return this.material = blockType.getMaterial();
|
||||||
}
|
}
|
||||||
this.material = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this);
|
this.material = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this);
|
||||||
|
if (this.material.hasContainer()) {
|
||||||
|
this.compoundInput = CompoundInput.CONTAINER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
@ -388,4 +392,17 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getOrdinal();
|
return getOrdinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAir() {
|
||||||
|
try {
|
||||||
|
return material.isAir();
|
||||||
|
} catch (NullPointerException ignore) {
|
||||||
|
return getMaterial().isAir();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock toBaseBlock(ITileInput input, int x, int y, int z) {
|
||||||
|
return compoundInput.get(this, input, x, y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.world.block;
|
package com.sk89q.worldedit.world.block;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.ITileInput;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||||
import com.sk89q.worldedit.extent.OutputExtent;
|
import com.sk89q.worldedit.extent.OutputExtent;
|
||||||
@ -203,6 +205,10 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends FawePat
|
|||||||
throw new UnsupportedOperationException("State is immutable");
|
throw new UnsupportedOperationException("State is immutable");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default BaseBlock toBaseBlock(ITileInput input, int x, int y, int z) {
|
||||||
|
throw new UnsupportedOperationException("State is immutable");
|
||||||
|
}
|
||||||
|
|
||||||
default String getAsString() {
|
default String getAsString() {
|
||||||
if (getStates().isEmpty()) {
|
if (getStates().isEmpty()) {
|
||||||
return this.getBlockType().getId();
|
return this.getBlockType().getId();
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.sk89q.worldedit.world.block;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.ITileInput;
|
||||||
|
|
||||||
|
public enum CompoundInput {
|
||||||
|
NULL,
|
||||||
|
CONTAINER() {
|
||||||
|
@Override
|
||||||
|
public BaseBlock get(BlockState state, ITileInput input, int x, int y, int z) {
|
||||||
|
return state.toBaseBlock(input.getTag(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
public BaseBlock get(BlockState state, ITileInput input, int x, int y, int z) {
|
||||||
|
return state.toBaseBlock();
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.sk89q.worldedit.world.block;
|
package com.sk89q.worldedit.world.block;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.ITileInput;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
@ -934,7 +934,6 @@ public final class ItemTypes {
|
|||||||
}
|
}
|
||||||
String name = fieldsTmp[initIndex++].getName().toLowerCase(Locale.ROOT);
|
String name = fieldsTmp[initIndex++].getName().toLowerCase(Locale.ROOT);
|
||||||
CharSequence fullName = joined.init(ItemType.REGISTRY.getDefaultNamespace(), ':', name);
|
CharSequence fullName = joined.init(ItemType.REGISTRY.getDefaultNamespace(), ':', name);
|
||||||
System.out.println("Name " + fullName + " | " + ItemType.REGISTRY.getMap().get(fullName));
|
|
||||||
return ItemType.REGISTRY.getMap().get(fullName);
|
return ItemType.REGISTRY.getMap().get(fullName);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user