mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Fixed a bunch of extends and removed slottableblockbag
This commit is contained in:
parent
8b96cdc9a5
commit
24a147465d
@ -19,19 +19,17 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
||||||
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
|
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
|
||||||
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
|
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
|
||||||
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
|
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag {
|
public class BukkitPlayerBlockBag extends BlockBag {
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private ItemStack[] items;
|
private ItemStack[] items;
|
||||||
@ -63,19 +61,6 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseItem getItem(int slot) {
|
|
||||||
loadInventory();
|
|
||||||
return BukkitAdapter.adapt(items[slot]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setItem(int slot, BaseItem block) {
|
|
||||||
loadInventory();
|
|
||||||
BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(block.getType(), block.getNbtData(), 1);
|
|
||||||
items[slot] = BukkitAdapter.adapt(stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetchBlock(BlockState blockState) throws BlockBagException {
|
public void fetchBlock(BlockState blockState) throws BlockBagException {
|
||||||
if (blockState.getBlockType().getMaterial().isAir()) {
|
if (blockState.getBlockType().getMaterial().isAir()) {
|
||||||
|
@ -19,6 +19,8 @@ import com.boydti.fawe.util.StringMan;
|
|||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.boydti.fawe.util.TextureUtil;
|
import com.boydti.fawe.util.TextureUtil;
|
||||||
import com.boydti.fawe.util.image.ImageUtil;
|
import com.boydti.fawe.util.image.ImageUtil;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
import com.sk89q.worldedit.EmptyClipboardException;
|
import com.sk89q.worldedit.EmptyClipboardException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -925,7 +927,12 @@ public class CFICommands {
|
|||||||
ImageIO.write(image, "jpg", baos);
|
ImageIO.write(image, "jpg", baos);
|
||||||
byte[] data = baos.toByteArray();
|
byte[] data = baos.toByteArray();
|
||||||
player.print("Please wait...");
|
player.print("Please wait...");
|
||||||
URL url = ImgurUtility.uploadImage(data);
|
String json = ImgurUtility.getImgurContent(ImgurUtility.CLIENT_ID, data);
|
||||||
|
Gson gson = new Gson();
|
||||||
|
JsonObject obj = gson.fromJson(json, JsonObject.class);
|
||||||
|
JsonObject data1 = obj.get("data").getAsJsonObject();
|
||||||
|
String link = data1.get("link").getAsString();
|
||||||
|
URL url = new URL(link);
|
||||||
BBC.DOWNLOAD_LINK.send(player, url);
|
BBC.DOWNLOAD_LINK.send(player, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class DataAnglePattern extends AbstractPattern {
|
|||||||
this.factor = (1D / distance) * (1D / 255);
|
this.factor = (1D / distance) * (1D / 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSlope(BlockStateHolder block, BlockVector3 vector, Extent extent) {
|
public <T extends BlockStateHolder<T>> int getSlope(T block, BlockVector3 vector, Extent extent) {
|
||||||
int x = vector.getBlockX();
|
int x = vector.getBlockX();
|
||||||
int y = vector.getBlockY();
|
int y = vector.getBlockY();
|
||||||
int z = vector.getBlockZ();
|
int z = vector.getBlockZ();
|
||||||
|
@ -3,9 +3,9 @@ package com.boydti.fawe.object;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public abstract class DelegateConsumer<T> implements Consumer<T> {
|
public abstract class DelegateConsumer<T> implements Consumer<T> {
|
||||||
private final Consumer parent;
|
private final Consumer<T> parent;
|
||||||
|
|
||||||
public DelegateConsumer(Consumer parent) {
|
public DelegateConsumer(Consumer<T> parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package com.boydti.fawe.object;
|
|||||||
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
|
||||||
public abstract class FaweCommand<T> {
|
public abstract class FaweCommand<T> {
|
||||||
@ -13,7 +12,7 @@ public abstract class FaweCommand<T> {
|
|||||||
this(perm, true);
|
this(perm, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FaweCommand(final String perm, final boolean safe) {
|
public FaweCommand(String perm, boolean safe) {
|
||||||
this.perm = perm;
|
this.perm = perm;
|
||||||
this.safe = safe;
|
this.safe = safe;
|
||||||
}
|
}
|
||||||
@ -22,7 +21,7 @@ public abstract class FaweCommand<T> {
|
|||||||
return this.perm;
|
return this.perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean executeSafe(final Actor player, final String... args) {
|
public boolean executeSafe(Actor player, String... args) {
|
||||||
try {
|
try {
|
||||||
if (!safe) {
|
if (!safe) {
|
||||||
execute(player, args);
|
execute(player, args);
|
||||||
@ -42,5 +41,5 @@ public abstract class FaweCommand<T> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean execute(final Actor actor, final String... args);
|
public abstract boolean execute(Actor actor, String... args);
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,7 @@ public class FaweInputStream extends DataInputStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int readMedium() throws IOException {
|
public int readMedium() throws IOException {
|
||||||
return (int) (
|
return (read() << 16) + (read() << 8) + read();
|
||||||
(read() << 16) +
|
|
||||||
(read() << 8) +
|
|
||||||
read());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private NBTInputStream nbtIn;
|
private NBTInputStream nbtIn;
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
package com.boydti.fawe.object;
|
package com.boydti.fawe.object;
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Jesse on 4/5/2016.
|
|
||||||
*/
|
|
||||||
public class FaweLimit {
|
public class FaweLimit {
|
||||||
public int MAX_ACTIONS = 0;
|
public int MAX_ACTIONS = 0;
|
||||||
public int MAX_CHANGES = 0;
|
public int MAX_CHANGES = 0;
|
||||||
|
@ -37,7 +37,7 @@ public class FaweOutputStream extends DataOutputStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeVarInt(int i) throws IOException {
|
public void writeVarInt(int i) throws IOException {
|
||||||
while((i & -128) != 0) {
|
while ((i & -128) != 0) {
|
||||||
this.writeByte(i & 127 | 128);
|
this.writeByte(i & 127 | 128);
|
||||||
i >>>= 7;
|
i >>>= 7;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
* @param extent the extent
|
* @param extent the extent
|
||||||
* @param changeSet the change set
|
* @param changeSet the change set
|
||||||
*/
|
*/
|
||||||
public HistoryExtent(final Extent extent, final FaweChangeSet changeSet) {
|
public HistoryExtent(Extent extent, FaweChangeSet changeSet) {
|
||||||
super(extent);
|
super(extent);
|
||||||
checkNotNull(changeSet);
|
checkNotNull(changeSet);
|
||||||
this.changeSet = changeSet;
|
this.changeSet = changeSet;
|
||||||
@ -43,6 +43,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
return changeSet;
|
return changeSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setChangeSet(FaweChangeSet fcs) {
|
public void setChangeSet(FaweChangeSet fcs) {
|
||||||
this.changeSet = fcs;
|
this.changeSet = fcs;
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||||
BaseBlock previous = getFullBlock(x, y, z);
|
BaseBlock previous = getFullBlock(x, y, z);
|
||||||
if (previous.getInternalId() == block.getInternalId()) {
|
if (previous.getInternalId() == block.getInternalId()) {
|
||||||
if (!previous.hasNbtData() && (block instanceof BaseBlock && !block.hasNbtData())) {
|
if (!previous.hasNbtData() && block instanceof BaseBlock && !block.hasNbtData()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,15 +62,15 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(final BlockVector3 location, final B block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||||
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location location, final BaseEntity state) {
|
public Entity createEntity(Location location, BaseEntity state) {
|
||||||
final Entity entity = super.createEntity(location, state);
|
final Entity entity = super.createEntity(location, state);
|
||||||
if ((state != null)) {
|
if (state != null) {
|
||||||
this.changeSet.addEntityCreate(state.getNbtData());
|
this.changeSet.addEntityCreate(state.getNbtData());
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
@ -81,13 +82,13 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(final Region region) {
|
public List<? extends Entity> getEntities(Region region) {
|
||||||
return this.wrapEntities(super.getEntities(region));
|
return this.wrapEntities(super.getEntities(region));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<? extends Entity> wrapEntities(final List<? extends Entity> entities) {
|
private List<? extends Entity> wrapEntities(List<? extends Entity> entities) {
|
||||||
final List<Entity> newList = new ArrayList<>(entities.size());
|
final List<Entity> newList = new ArrayList<>(entities.size());
|
||||||
for (final Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
newList.add(new TrackedEntity(entity));
|
newList.add(new TrackedEntity(entity));
|
||||||
}
|
}
|
||||||
return newList;
|
return newList;
|
||||||
@ -118,7 +119,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
public class TrackedEntity implements Entity {
|
public class TrackedEntity implements Entity {
|
||||||
private final Entity entity;
|
private final Entity entity;
|
||||||
|
|
||||||
private TrackedEntity(final Entity entity) {
|
private TrackedEntity(Entity entity) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +143,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
final Location location = this.entity.getLocation();
|
final Location location = this.entity.getLocation();
|
||||||
final BaseEntity state = this.entity.getState();
|
final BaseEntity state = this.entity.getState();
|
||||||
final boolean success = this.entity.remove();
|
final boolean success = this.entity.remove();
|
||||||
if ((state != null) && success) {
|
if (state != null && success) {
|
||||||
HistoryExtent.this.changeSet.addEntityRemove(state.getNbtData());
|
HistoryExtent.this.changeSet.addEntityRemove(state.getNbtData());
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
@ -150,7 +151,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public <T> T getFacet(final Class<? extends T> cls) {
|
public <T> T getFacet(Class<? extends T> cls) {
|
||||||
return this.entity.getFacet(cls);
|
return this.entity.getFacet(cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,11 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(final EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
Player fp = editSession.getPlayer();
|
Player player = editSession.getPlayer();
|
||||||
|
if (player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ClipboardHolder clipboard = session.getExistingClipboard();
|
ClipboardHolder clipboard = session.getExistingClipboard();
|
||||||
if (clipboard == null) {
|
if (clipboard == null) {
|
||||||
if (editSession.getExtent() instanceof VisualExtent) {
|
if (editSession.getExtent() instanceof VisualExtent) {
|
||||||
@ -84,8 +87,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
|||||||
ClipboardHolder holder = new ClipboardHolder(newClipboard);
|
ClipboardHolder holder = new ClipboardHolder(newClipboard);
|
||||||
session.setClipboard(holder);
|
session.setClipboard(holder);
|
||||||
int blocks = builder.size();
|
int blocks = builder.size();
|
||||||
BBC.COMMAND_COPY.send(fp, blocks);
|
BBC.COMMAND_COPY.send(player, blocks);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
AffineTransform transform = null;
|
AffineTransform transform = null;
|
||||||
if (randomRotate) {
|
if (randomRotate) {
|
||||||
@ -95,10 +97,10 @@ public class CopyPastaBrush implements Brush, ResettableTool {
|
|||||||
}
|
}
|
||||||
if (autoRotate) {
|
if (autoRotate) {
|
||||||
if (transform == null) transform = new AffineTransform();
|
if (transform == null) transform = new AffineTransform();
|
||||||
Location loc = fp.getLocation();
|
Location loc = player.getLocation();
|
||||||
float yaw = loc.getYaw();
|
float yaw = loc.getYaw();
|
||||||
float pitch = loc.getPitch();
|
float pitch = loc.getPitch();
|
||||||
transform = transform.rotateY((-yaw) % 360);
|
transform = transform.rotateY(-yaw % 360);
|
||||||
transform = transform.rotateX(pitch - 90);
|
transform = transform.rotateX(pitch - 90);
|
||||||
}
|
}
|
||||||
if (transform != null && !transform.isIdentity()) {
|
if (transform != null && !transform.isIdentity()) {
|
||||||
|
@ -78,14 +78,14 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
private CFIPrimitives oldPrimitives = new CFIPrimitives();
|
private CFIPrimitives oldPrimitives = new CFIPrimitives();
|
||||||
|
|
||||||
public final class CFIPrimitives implements Cloneable {
|
public final class CFIPrimitives implements Cloneable {
|
||||||
protected int waterHeight = 0;
|
int waterHeight;
|
||||||
protected int floorThickness = 0;
|
int floorThickness;
|
||||||
protected int worldThickness = 0;
|
int worldThickness;
|
||||||
protected boolean randomVariation = true;
|
boolean randomVariation = true;
|
||||||
protected int biomePriority = 0;
|
int biomePriority;
|
||||||
protected int waterId = BlockID.WATER;
|
int waterId = BlockID.WATER;
|
||||||
protected int bedrockId = BlockID.BEDROCK;
|
int bedrockId = BlockID.BEDROCK;
|
||||||
protected boolean modifiedMain = false;
|
boolean modifiedMain;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
@ -143,7 +143,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
return blocks.isModified() ||
|
return blocks.isModified() ||
|
||||||
heights.isModified() ||
|
heights.isModified() ||
|
||||||
biomes.isModified() ||
|
biomes.isModified() ||
|
||||||
(overlay != null && overlay.isModified()) ||
|
overlay != null && overlay.isModified() ||
|
||||||
!primitives.equals(oldPrimitives);
|
!primitives.equals(oldPrimitives);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,10 +220,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
super(width, length, regionFolder);
|
super(width, length, regionFolder);
|
||||||
|
|
||||||
blocks = new DifferentialBlockBuffer(width, length);
|
blocks = new DifferentialBlockBuffer(width, length);
|
||||||
heights = new DifferentialArray(new byte[getArea()]);
|
heights = new DifferentialArray<>(new byte[getArea()]);
|
||||||
biomes = new DifferentialArray(new byte[getArea()]);
|
biomes = new DifferentialArray<>(new byte[getArea()]);
|
||||||
floor = new DifferentialArray(new int[getArea()]);
|
floor = new DifferentialArray<>(new int[getArea()]);
|
||||||
main = new DifferentialArray(new int[getArea()]);
|
main = new DifferentialArray<>(new int[getArea()]);
|
||||||
|
|
||||||
int stone = BlockID.STONE;
|
int stone = BlockID.STONE;
|
||||||
int grass = BlockTypes.GRASS_BLOCK.getDefaultState().with(PropertyKey.SNOWY, false).getInternalId();
|
int grass = BlockTypes.GRASS_BLOCK.getDefaultState().with(PropertyKey.SNOWY, false).getInternalId();
|
||||||
@ -402,8 +402,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
int maxX = max.getBlockX();
|
int maxX = max.getBlockX();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
int tableWidth = (maxX - minX + 1);
|
int tableWidth = maxX - minX + 1;
|
||||||
int tableLength = (maxZ - minZ + 1);
|
int tableLength = maxZ - minZ + 1;
|
||||||
int smoothArea = tableWidth * tableLength;
|
int smoothArea = tableWidth * tableLength;
|
||||||
|
|
||||||
long[] copy = new long[smoothArea];
|
long[] copy = new long[smoothArea];
|
||||||
@ -411,10 +411,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
|
|
||||||
SummedAreaTable table = new SummedAreaTable(copy, layers, tableWidth, radius);
|
SummedAreaTable table = new SummedAreaTable(copy, layers, tableWidth, radius);
|
||||||
for (int j = 0; j < iterations; j++) {
|
for (int j = 0; j < iterations; j++) {
|
||||||
|
|
||||||
{ // Copy to table
|
{ // Copy to table
|
||||||
int localIndex = 0;
|
int localIndex = 0;
|
||||||
int zIndex = (minZ * getWidth());
|
int zIndex = minZ * getWidth();
|
||||||
for (int z = minZ; z <= maxZ; z++, zIndex += getWidth()) {
|
for (int z = minZ; z <= maxZ; z++, zIndex += getWidth()) {
|
||||||
int index = zIndex + minX;
|
int index = zIndex + minX;
|
||||||
for (int x = minX; x <= maxX; x++, index++, localIndex++) {
|
for (int x = minX; x <= maxX; x++, index++, localIndex++) {
|
||||||
@ -422,7 +421,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
if (BlockTypes.getFromStateId(combined) == BlockTypes.SNOW) {
|
if (BlockTypes.getFromStateId(combined) == BlockTypes.SNOW) {
|
||||||
layers[localIndex] = (char) (((heights[index] & 0xFF) << 3) + (floor[index] >> BlockTypes.BIT_OFFSET) - 7);
|
layers[localIndex] = (char) (((heights[index] & 0xFF) << 3) + (floor[index] >> BlockTypes.BIT_OFFSET) - 7);
|
||||||
} else {
|
} else {
|
||||||
layers[localIndex] = (char) (((heights[index] & 0xFF) << 3));
|
layers[localIndex] = (char) ((heights[index] & 0xFF) << 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,7 +430,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
table.processSummedAreaTable();
|
table.processSummedAreaTable();
|
||||||
// Copy from table
|
// Copy from table
|
||||||
int localIndex = 0;
|
int localIndex = 0;
|
||||||
int zIndex = (minZ * getWidth());
|
int zIndex = minZ * getWidth();
|
||||||
for (int z = minZ, localZ = 0; z <= maxZ; z++, localZ++, zIndex += getWidth()) {
|
for (int z = minZ, localZ = 0; z <= maxZ; z++, localZ++, zIndex += getWidth()) {
|
||||||
int index = zIndex + minX;
|
int index = zIndex + minX;
|
||||||
for (int x = minX, localX = 0; x <= maxX; x++, localX++, index++, localIndex++) {
|
for (int x = minX, localX = 0; x <= maxX; x++, localX++, index++, localIndex++) {
|
||||||
@ -444,8 +443,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final void setLayerHeight(int index, int height) {
|
private final void setLayerHeight(int index, int height) {
|
||||||
int blockHeight = (height) >> 3;
|
int blockHeight = height >> 3;
|
||||||
int layerHeight = (height) & 0x7;
|
int layerHeight = height & 0x7;
|
||||||
setLayerHeight(index, blockHeight, layerHeight);
|
setLayerHeight(index, blockHeight, layerHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,21 +456,21 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
case BlockID.SNOW_BLOCK:
|
case BlockID.SNOW_BLOCK:
|
||||||
if (layerHeight != 0) {
|
if (layerHeight != 0) {
|
||||||
this.heights.setByte(index, (byte) (blockHeight + 1));
|
this.heights.setByte(index, (byte) (blockHeight + 1));
|
||||||
this.floor.setInt(index, (BlockTypes.SNOW.getInternalId() + layerHeight));
|
this.floor.setInt(index, BlockTypes.SNOW.getInternalId() + layerHeight);
|
||||||
} else {
|
} else {
|
||||||
this.heights.setByte(index, (byte) (blockHeight));
|
this.heights.setByte(index, (byte) blockHeight);
|
||||||
this.floor.setInt(index, (BlockTypes.SNOW_BLOCK.getInternalId()));
|
this.floor.setInt(index, BlockTypes.SNOW_BLOCK.getInternalId());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.heights.setByte(index, (byte) (blockHeight));
|
this.heights.setByte(index, (byte) blockHeight);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void setLayerHeightRaw(int index, int height) {
|
private final void setLayerHeightRaw(int index, int height) {
|
||||||
int blockHeight = (height) >> 3;
|
int blockHeight = height >> 3;
|
||||||
int layerHeight = (height) & 0x7;
|
int layerHeight = height & 0x7;
|
||||||
setLayerHeightRaw(index, blockHeight, layerHeight);
|
setLayerHeightRaw(index, blockHeight, layerHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,14 +482,14 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
case BlockID.SNOW_BLOCK:
|
case BlockID.SNOW_BLOCK:
|
||||||
if (layerHeight != 0) {
|
if (layerHeight != 0) {
|
||||||
this.heights.getByteArray()[index] = (byte) (blockHeight + 1);
|
this.heights.getByteArray()[index] = (byte) (blockHeight + 1);
|
||||||
this.floor.getIntArray()[index] = (BlockTypes.SNOW.getInternalId() + layerHeight);
|
this.floor.getIntArray()[index] = BlockTypes.SNOW.getInternalId() + layerHeight;
|
||||||
} else {
|
} else {
|
||||||
this.heights.getByteArray()[index] = (byte) (blockHeight);
|
this.heights.getByteArray()[index] = (byte) blockHeight;
|
||||||
this.floor.getIntArray()[index] = (BlockTypes.SNOW_BLOCK.getInternalId());
|
this.floor.getIntArray()[index] = BlockTypes.SNOW_BLOCK.getInternalId();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.heights.getByteArray()[index] = (byte) (blockHeight);
|
this.heights.getByteArray()[index] = (byte) blockHeight;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -512,7 +511,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
if (BlockTypes.getFromStateId(combined) == BlockTypes.SNOW) {
|
if (BlockTypes.getFromStateId(combined) == BlockTypes.SNOW) {
|
||||||
layers[i] = (char) (((heights[i] & 0xFF) << 3) + (floor[i] >> BlockTypes.BIT_OFFSET) - 7);
|
layers[i] = (char) (((heights[i] & 0xFF) << 3) + (floor[i] >> BlockTypes.BIT_OFFSET) - 7);
|
||||||
} else {
|
} else {
|
||||||
layers[i] = (char) (((heights[i] & 0xFF) << 3));
|
layers[i] = (char) ((heights[i] & 0xFF) << 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -625,7 +624,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addSchems(Mask mask, List<ClipboardHolder> clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException {
|
public void addSchems(Mask mask, List<ClipboardHolder> clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException {
|
||||||
int scaledRarity = (256 * rarity) / 100;
|
int scaledRarity = 256 * rarity / 100;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
AffineTransform identity = new AffineTransform();
|
AffineTransform identity = new AffineTransform();
|
||||||
LocalBlockVector2DSet placed = new LocalBlockVector2DSet();
|
LocalBlockVector2DSet placed = new LocalBlockVector2DSet();
|
||||||
@ -851,8 +850,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
if (chunkOffset != null && player != null && update) {
|
if (chunkOffset != null && player != null && update) {
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
|
|
||||||
int lenCX = (getWidth() + 15) >> 4;
|
int lenCX = getWidth() + 15 >> 4;
|
||||||
int lenCZ = (getLength() + 15) >> 4;
|
int lenCZ = getLength() + 15 >> 4;
|
||||||
|
|
||||||
int OX = chunkOffset.getBlockX();
|
int OX = chunkOffset.getBlockX();
|
||||||
int OZ = chunkOffset.getBlockZ();
|
int OZ = chunkOffset.getBlockZ();
|
||||||
@ -1013,6 +1012,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BufferedImage draw() {
|
public BufferedImage draw() {
|
||||||
// TODO NOT IMPLEMENTED
|
// TODO NOT IMPLEMENTED
|
||||||
// return new HeightMapMCADrawer(this).draw();
|
// return new HeightMapMCADrawer(this).draw();
|
||||||
@ -1020,11 +1020,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBiomePriority(int value) {
|
public void setBiomePriority(int value) {
|
||||||
this.primitives.biomePriority = ((value * 65536) / 100) - 32768;
|
this.primitives.biomePriority = value * 65536 / 100 - 32768;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBiomePriority() {
|
public int getBiomePriority() {
|
||||||
return ((primitives.biomePriority + 32768) * 100) / 65536;
|
return (primitives.biomePriority + 32768) * 100 / 65536;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockAndBiomeColor(BufferedImage img, Mask mask, BufferedImage imgMask, boolean whiteOnly) {
|
public void setBlockAndBiomeColor(BufferedImage img, Mask mask, BufferedImage imgMask, boolean whiteOnly) {
|
||||||
@ -1107,9 +1107,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
|
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
|
||||||
TextureUtil textureUtil = getTextureUtil();
|
TextureUtil textureUtil = getTextureUtil();
|
||||||
|
|
||||||
biomes.record(new Runnable() {
|
biomes.record(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
byte[] biomesArr = biomes.get();
|
byte[] biomesArr = biomes.get();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int y = 0; y < img.getHeight(); y++) {
|
for (int y = 0; y < img.getHeight(); y++) {
|
||||||
@ -1122,7 +1120,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1598,7 +1595,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
chunk.hasSections[layer] = true;
|
chunk.hasSections[layer] = true;
|
||||||
}
|
}
|
||||||
if (primitives.waterHeight != 0) {
|
if (primitives.waterHeight != 0) {
|
||||||
int maxIndex = (primitives.waterHeight) << 8;
|
int maxIndex = primitives.waterHeight << 8;
|
||||||
Arrays.fill(chunk.blocks, 0, maxIndex, primitives.waterId);
|
Arrays.fill(chunk.blocks, 0, maxIndex, primitives.waterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1620,7 +1617,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
|
|
||||||
final boolean hasFloorThickness = primitives.floorThickness != 0 || primitives.worldThickness != 0;
|
final boolean hasFloorThickness = primitives.floorThickness != 0 || primitives.worldThickness != 0;
|
||||||
if (primitives.worldThickness != 0) {
|
if (primitives.worldThickness != 0) {
|
||||||
int endLayer = ((minY - primitives.worldThickness + 1) >> 4);
|
int endLayer = minY - primitives.worldThickness + 1 >> 4;
|
||||||
for (int layer = 0; layer < endLayer; layer++) {
|
for (int layer = 0; layer < endLayer; layer++) {
|
||||||
chunk.hasSections[layer] = false;
|
chunk.hasSections[layer] = false;
|
||||||
}
|
}
|
||||||
@ -1652,7 +1649,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
chunk.blocks[index + ((height) << 8)] = floorCombined;
|
chunk.blocks[index + (height << 8)] = floorCombined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (primitives.worldThickness != 0) {
|
if (primitives.worldThickness != 0) {
|
||||||
@ -1663,7 +1660,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
chunk.blocks[index + ((height) << 8)] = floorCombined;
|
chunk.blocks[index + (height << 8)] = floorCombined;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = minMainY; y < maxMainY; y++) {
|
for (int y = minMainY; y < maxMainY; y++) {
|
||||||
@ -1672,7 +1669,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
|
|
||||||
if (hasOverlay) {
|
if (hasOverlay) {
|
||||||
int overlayCombined = overlay[globalIndex];
|
int overlayCombined = overlay[globalIndex];
|
||||||
int overlayIndex = index + ((height + 1) << 8);
|
int overlayIndex = index + (height + 1 << 8);
|
||||||
chunk.blocks[overlayIndex] = overlayCombined;
|
chunk.blocks[overlayIndex] = overlayCombined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1929,6 +1926,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||||
|
return setBiome(position.getX(), 0, position.getBlockZ(), biome);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBlockLightLevel(BlockVector3 position) {
|
public int getBlockLightLevel(BlockVector3 position) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -12,7 +12,7 @@ import com.sk89q.worldedit.extent.PassthroughExtent;
|
|||||||
public class MemoryCheckingExtent extends PassthroughExtent {
|
public class MemoryCheckingExtent extends PassthroughExtent {
|
||||||
private final Player player;
|
private final Player player;
|
||||||
|
|
||||||
public MemoryCheckingExtent(final Player player, final Extent extent) {
|
public MemoryCheckingExtent(Player player, Extent extent) {
|
||||||
super(extent);
|
super(extent);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.boydti.fawe.object.extent;
|
package com.boydti.fawe.object.extent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
@ -10,7 +9,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -32,24 +31,21 @@ public class MultiTransform extends RandomTransform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
boolean result = false;
|
return Arrays.stream(extents).map(extent -> extent.setBlock(x, y, z, block))
|
||||||
for (AbstractDelegateExtent extent : extents) result |= extent.setBlock(x, y, z, block);
|
.reduce(false, (a, b) -> a || b);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||||
boolean result = false;
|
return Arrays.stream(extents).map(extent -> extent.setBlock(location, block))
|
||||||
for (AbstractDelegateExtent extent : extents) result |= extent.setBlock(location, block);
|
.reduce(false, (a, b) -> a || b);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||||
boolean result = false;
|
return Arrays.stream(extents).map(extent -> extent.setBiome(position, biome))
|
||||||
for (AbstractDelegateExtent extent : extents) result |= extent.setBiome(position, biome);
|
.reduce(false, (a, b) -> a || b);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -20,17 +20,15 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.util.Countable;
|
import com.sk89q.worldedit.util.Countable;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.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;
|
||||||
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 javax.annotation.Nullable;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class NullExtent extends FaweRegionExtent {
|
public class NullExtent extends FaweRegionExtent {
|
||||||
|
|
||||||
@ -60,7 +58,7 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeType getBiome(final BlockVector2 arg0) {
|
public BiomeType getBiome(BlockVector2 arg0) {
|
||||||
throw reason;
|
throw reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +68,7 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(final BlockVector3 arg0) {
|
public BlockState getBlock(BlockVector3 arg0) {
|
||||||
throw reason;
|
throw reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +91,7 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(final BlockVector2 arg0, final BiomeType arg1) {
|
public boolean setBiome(BlockVector2 arg0, BiomeType arg1) {
|
||||||
throw reason;
|
throw reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,18 +101,18 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(final BlockVector3 arg0, final BlockStateHolder arg1) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 arg0, B arg1) throws WorldEditException {
|
||||||
throw reason;
|
throw reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||||
throw reason;
|
throw reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
public Entity createEntity(Location arg0, BaseEntity arg1) {
|
||||||
throw reason;
|
throw reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +157,7 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(final Region arg0) {
|
public List<? extends Entity> getEntities(Region arg0) {
|
||||||
throw reason;
|
throw reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public class PatternTransform extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||||
return pattern.apply(getExtent(), location, location);
|
return pattern.apply(getExtent(), location, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
private final FaweLimit limit;
|
private final FaweLimit limit;
|
||||||
private final AbstractDelegateExtent extent;
|
private final AbstractDelegateExtent extent;
|
||||||
|
|
||||||
public ProcessedWEExtent(final Extent parent, FaweLimit limit) {
|
public ProcessedWEExtent(Extent parent, FaweLimit limit) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.limit = limit;
|
this.limit = limit;
|
||||||
this.extent = (AbstractDelegateExtent) parent;
|
this.extent = (AbstractDelegateExtent) parent;
|
||||||
@ -32,7 +32,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location location, final BaseEntity entity) {
|
public Entity createEntity(Location location, BaseEntity entity) {
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(final BlockVector3 location, final B block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||||
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||||
boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData();
|
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||||
if (hasNbt) {
|
if (hasNbt) {
|
||||||
if (!limit.MAX_BLOCKSTATES()) {
|
if (!limit.MAX_BLOCKSTATES()) {
|
||||||
WEManager.IMP.cancelEdit(this, FaweException.MAX_TILES);
|
WEManager.IMP.cancelEdit(this, FaweException.MAX_TILES);
|
||||||
@ -97,7 +97,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(final BlockVector2 position, final BiomeType biome) {
|
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||||
if (!limit.MAX_CHANGES()) {
|
if (!limit.MAX_CHANGES()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, FaweException.MAX_CHANGES);
|
WEManager.IMP.cancelEditSafe(this, FaweException.MAX_CHANGES);
|
||||||
return false;
|
return false;
|
||||||
|
@ -33,7 +33,7 @@ public class RandomOffsetTransform extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 pos, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pos, T block) throws WorldEditException {
|
||||||
int x = pos.getBlockX() + random.nextInt(1 + (dx << 1)) - dx;
|
int x = pos.getBlockX() + random.nextInt(1 + (dx << 1)) - dx;
|
||||||
int y = pos.getBlockY() + random.nextInt(1 + (dy << 1)) - dy;
|
int y = pos.getBlockY() + random.nextInt(1 + (dy << 1)) - dy;
|
||||||
int z = pos.getBlockZ() + random.nextInt(1 + (dz << 1)) - dz;
|
int z = pos.getBlockZ() + random.nextInt(1 + (dz << 1)) - dz;
|
||||||
@ -41,7 +41,7 @@ public class RandomOffsetTransform extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
x = x + random.nextInt(1 + (dx << 1)) - dx;
|
x = x + random.nextInt(1 + (dx << 1)) - dx;
|
||||||
y = y + random.nextInt(1 + (dy << 1)) - dy;
|
y = y + random.nextInt(1 + (dy << 1)) - dy;
|
||||||
z = z + random.nextInt(1 + (dz << 1)) - dz;
|
z = z + random.nextInt(1 + (dz << 1)) - dz;
|
||||||
|
@ -60,7 +60,7 @@ public class ScaleTransform extends ResettableExtent {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
MutableBlockVector3 pos = new MutableBlockVector3(getPos(location));
|
MutableBlockVector3 pos = new MutableBlockVector3(getPos(location));
|
||||||
double sx = pos.getX();
|
double sx = pos.getX();
|
||||||
@ -96,7 +96,7 @@ public class ScaleTransform extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x1, int y1, int z1, BlockStateHolder block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x1, int y1, int z1, B block) throws WorldEditException {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
MutableBlockVector3 pos = new MutableBlockVector3(getPos(x1, y1, z1));
|
MutableBlockVector3 pos = new MutableBlockVector3(getPos(x1, y1, z1));
|
||||||
double sx = pos.getX();
|
double sx = pos.getX();
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.boydti.fawe.object.extent;
|
package com.boydti.fawe.object.extent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
@ -13,7 +11,6 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public abstract class SelectTransform extends ResettableExtent {
|
public abstract class SelectTransform extends ResettableExtent {
|
||||||
@ -34,12 +31,12 @@ public abstract class SelectTransform extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
return getExtent(x, y, z).setBlock(x, y, z, block);
|
return getExtent(x, y, z).setBlock(x, y, z, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
||||||
return getExtent(position).setBlock(position, block);
|
return getExtent(position).setBlock(position, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package com.boydti.fawe.object.extent;
|
package com.boydti.fawe.object.extent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
public class SourceMaskExtent extends TemporalExtent {
|
public class SourceMaskExtent extends TemporalExtent {
|
||||||
private Mask mask;
|
private Mask mask;
|
||||||
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
@ -42,13 +40,13 @@ public class SourceMaskExtent extends TemporalExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||||
set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
||||||
return mask.test(location) && super.setBlock(location, block);
|
return mask.test(location) && super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
set(x, y, z, block);
|
set(x, y, z, block);
|
||||||
mutable.mutX(x);
|
mutable.mutX(x);
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
|
@ -26,7 +26,7 @@ public class BiomeCopy implements RegionFunction {
|
|||||||
if (x != mPos2d.getBlockX() || z != mPos2d.getBlockZ()) {
|
if (x != mPos2d.getBlockX() || z != mPos2d.getBlockZ()) {
|
||||||
mPos2d.setComponents(x, z);
|
mPos2d.setComponents(x, z);
|
||||||
BlockVector2 bv = mPos2d;
|
BlockVector2 bv = mPos2d;
|
||||||
return destination.setBiome( bv, source.getBiome(bv));
|
return destination.setBiome(bv, source.getBiome(bv));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,6 @@ public class CombinedBlockCopy implements RegionFunction {
|
|||||||
// BlockStateHolder block = source.getBlock(position);
|
// BlockStateHolder block = source.getBlock(position);
|
||||||
BaseBlock block = source.getFullBlock(position);
|
BaseBlock block = source.getFullBlock(position);
|
||||||
function.apply(position);
|
function.apply(position);
|
||||||
return destination.setBlock(position, block);
|
return destination.setBlock(position.getX(),position.getY(),position.getZ(), block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@ public class SimpleBlockCopy implements RegionFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
return destination.setBlock(position, source.getFullBlock(position));
|
return destination.setBlock(position.getX(),position.getY(),position.getZ(), source.getFullBlock(position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
package com.boydti.fawe.object.io.serialize;
|
|
||||||
|
|
||||||
import com.boydti.fawe.util.ReflectionUtils;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call serialize(stream) to serialize any field with @Serialize<br/>
|
|
||||||
* Call deserialize(stream) to deserialize any field with @Serialize<br/>
|
|
||||||
*/
|
|
||||||
public interface Serializer extends Serializable {
|
|
||||||
default void serialize(java.io.ObjectOutputStream stream) throws IOException {
|
|
||||||
try {
|
|
||||||
for (Field field : getClass().getDeclaredFields()) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
if (field.getDeclaredAnnotation(Serialize.class) != null) {
|
|
||||||
Class<?> type = field.getType();
|
|
||||||
boolean primitive = type.isPrimitive();
|
|
||||||
Object value = field.get(this);
|
|
||||||
if (primitive) {
|
|
||||||
stream.writeObject(value);
|
|
||||||
} else if (value == null){
|
|
||||||
stream.writeByte(0);
|
|
||||||
} else {
|
|
||||||
stream.writeByte(1);
|
|
||||||
stream.writeObject(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default void deserialize(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
for (Field field : getClass().getDeclaredFields()) {
|
|
||||||
if (field.getDeclaredAnnotation(Serialize.class) != null) {
|
|
||||||
Class<?> type = field.getType();
|
|
||||||
boolean primitive = type.isPrimitive();
|
|
||||||
|
|
||||||
if (primitive) {
|
|
||||||
ReflectionUtils.setField(field, this, stream.readObject());
|
|
||||||
} else if (stream.readByte() == 1) {
|
|
||||||
ReflectionUtils.setField(field, this, stream.readObject());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.boydti.fawe.object.io.zstd;
|
|
||||||
|
|
||||||
class FrameHeader
|
|
||||||
{
|
|
||||||
final long headerSize;
|
|
||||||
final int windowSize;
|
|
||||||
final long contentSize;
|
|
||||||
final long dictionaryId;
|
|
||||||
final boolean hasChecksum;
|
|
||||||
|
|
||||||
public FrameHeader(long headerSize, int windowSize, long contentSize, long dictionaryId, boolean hasChecksum)
|
|
||||||
{
|
|
||||||
this.headerSize = headerSize;
|
|
||||||
this.windowSize = windowSize;
|
|
||||||
this.contentSize = contentSize;
|
|
||||||
this.dictionaryId = dictionaryId;
|
|
||||||
this.hasChecksum = hasChecksum;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package com.boydti.fawe.object.io.zstd;
|
|
||||||
|
|
||||||
public class MalformedInputException extends RuntimeException {
|
|
||||||
|
|
||||||
private final long offset;
|
|
||||||
|
|
||||||
public MalformedInputException(long offset) {
|
|
||||||
this(offset, "Malformed input");
|
|
||||||
}
|
|
||||||
|
|
||||||
public MalformedInputException(long offset, String reason) {
|
|
||||||
super(reason + ": offset=" + offset);
|
|
||||||
this.offset = offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getOffset() {
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.boydti.fawe.object.io.zstd;
|
|
||||||
|
|
||||||
class Util
|
|
||||||
{
|
|
||||||
private Util()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int highestBit(int value)
|
|
||||||
{
|
|
||||||
return 31 - Integer.numberOfLeadingZeros(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPowerOf2(int value)
|
|
||||||
{
|
|
||||||
return (value & (value - 1)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int mask(int bits)
|
|
||||||
{
|
|
||||||
return (1 << bits) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void verify(boolean condition, long offset, String reason)
|
|
||||||
{
|
|
||||||
if (!condition) {
|
|
||||||
throw new MalformedInputException(offset, reason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MalformedInputException fail(long offset, String reason)
|
|
||||||
{
|
|
||||||
throw new MalformedInputException(offset, reason);
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,6 +6,7 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
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.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ public class AngleColorPattern extends DataAnglePattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlope(BlockStateHolder block, BlockVector3 vector, Extent extent) {
|
public <T extends BlockStateHolder<T>> int getSlope(T block, BlockVector3 vector, Extent extent) {
|
||||||
int slope = super.getSlope(block, vector, extent);
|
int slope = super.getSlope(block, vector, extent);
|
||||||
if (slope != -1) {
|
if (slope != -1) {
|
||||||
int x = vector.getBlockX();
|
int x = vector.getBlockX();
|
||||||
@ -46,7 +47,7 @@ public class AngleColorPattern extends DataAnglePattern {
|
|||||||
int z = vector.getBlockZ();
|
int z = vector.getBlockZ();
|
||||||
int height = extent.getNearestSurfaceTerrainBlock(x, z, y, 0, maxY);
|
int height = extent.getNearestSurfaceTerrainBlock(x, z, y, 0, maxY);
|
||||||
if (height > 0) {
|
if (height > 0) {
|
||||||
BlockStateHolder below = extent.getBlock(x, height - 1, z);
|
BlockState below = extent.getBlock(x, height - 1, z);
|
||||||
if (!below.getBlockType().getMaterial().isMovementBlocker()) {
|
if (!below.getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
@ -57,7 +58,7 @@ public class AngleColorPattern extends DataAnglePattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
BlockStateHolder block = get.getBlock(extent);
|
BlockState block = get.getBlock(extent);
|
||||||
int slope = getSlope(block, get, extent);
|
int slope = getSlope(block, get, extent);
|
||||||
if (slope == -1) return false;
|
if (slope == -1) return false;
|
||||||
int color = holder.getTextureUtil().getColor(block.getBlockType());
|
int color = holder.getTextureUtil().getColor(block.getBlockType());
|
||||||
|
@ -7,7 +7,6 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.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.SplittableRandom;
|
import java.util.SplittableRandom;
|
||||||
@ -58,7 +57,7 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
|
|||||||
mutable.mutX(set.getX() + r.nextInt(dx2) - dx);
|
mutable.mutX(set.getX() + r.nextInt(dx2) - dx);
|
||||||
mutable.mutY(set.getY() + r.nextInt(dy2) - dy);
|
mutable.mutY(set.getY() + r.nextInt(dy2) - dy);
|
||||||
mutable.mutZ(set.getZ() + r.nextInt(dz2) - dz);
|
mutable.mutZ(set.getZ() + r.nextInt(dz2) - dz);
|
||||||
BlockStateHolder block = pattern.apply(mutable);
|
BaseBlock block = pattern.apply(mutable);
|
||||||
if (block.getMaterial().isSolid()) {
|
if (block.getMaterial().isSolid()) {
|
||||||
return pattern.apply(extent, get, mutable);
|
return pattern.apply(extent, get, mutable);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
||||||
@ -57,7 +56,7 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
|||||||
|
|
||||||
private boolean allowed(BlockVector3 bv) {
|
private boolean allowed(BlockVector3 bv) {
|
||||||
MutableBlockVector3 v = new MutableBlockVector3(bv);
|
MutableBlockVector3 v = new MutableBlockVector3(bv);
|
||||||
BlockStateHolder block = pattern.apply(bv);
|
BaseBlock block = pattern.apply(bv);
|
||||||
if (!block.getBlockType().getMaterial().isMovementBlocker()) {
|
if (!block.getBlockType().getMaterial().isMovementBlocker()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -101,7 +100,7 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPassthrough(BlockVector3 v) {
|
private boolean canPassthrough(BlockVector3 v) {
|
||||||
BlockStateHolder block = pattern.apply(v);
|
BaseBlock block = pattern.apply(v);
|
||||||
return !block.getBlockType().getMaterial().isMovementBlocker();
|
return !block.getBlockType().getMaterial().isMovementBlocker();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import com.sk89q.worldedit.registry.state.Property;
|
|||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
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 com.sk89q.worldedit.world.entity.EntityTypes;
|
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||||
@ -170,7 +169,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
|||||||
// Palette
|
// Palette
|
||||||
ArrayList<HashMap<String, Object>> palette = new ArrayList<>();
|
ArrayList<HashMap<String, Object>> palette = new ArrayList<>();
|
||||||
for (BlockVector3 point : region) {
|
for (BlockVector3 point : region) {
|
||||||
BlockStateHolder block = clipboard.getBlock(point);
|
BlockState block = clipboard.getBlock(point);
|
||||||
int combined = block.getInternalId();
|
int combined = block.getInternalId();
|
||||||
BlockType type = block.getBlockType();
|
BlockType type = block.getBlockType();
|
||||||
|
|
||||||
|
@ -7,14 +7,14 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import java.awt.Color;
|
||||||
import javax.imageio.ImageIO;
|
import java.awt.Graphics2D;
|
||||||
import javax.imageio.stream.ImageOutputStream;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.imageio.stream.ImageOutputStream;
|
||||||
|
|
||||||
public class PNGWriter implements ClipboardWriter {
|
public class PNGWriter implements ClipboardWriter {
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ public class PNGWriter implements ClipboardWriter {
|
|||||||
double cpy2 = cpy1 + dpyj[zz];
|
double cpy2 = cpy1 + dpyj[zz];
|
||||||
for (int y = y0; y < y0 + height; y++) {
|
for (int y = y0; y < y0 + height; y++) {
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
BlockStateHolder block = clipboard.getBlock(mutable);
|
BlockState block = clipboard.getBlock(mutable);
|
||||||
if (block.getBlockType().getMaterial().isAir()) {
|
if (block.getBlockType().getMaterial().isAir()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -264,7 +265,7 @@ public class Schematic {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(BlockVector3 mutable) throws WorldEditException {
|
public boolean apply(BlockVector3 mutable) throws WorldEditException {
|
||||||
BlockStateHolder block = clipboard.getBlock(mutable);
|
BlockState block = clipboard.getBlock(mutable);
|
||||||
int xx = mutable.getBlockX() + relx;
|
int xx = mutable.getBlockX() + relx;
|
||||||
int zz = mutable.getBlockZ() + relz;
|
int zz = mutable.getBlockZ() + relz;
|
||||||
if (copyBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) {
|
if (copyBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) {
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package com.boydti.fawe.util;
|
package com.boydti.fawe.util;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
|
||||||
|
|
||||||
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 it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package com.boydti.fawe.util;
|
package com.boydti.fawe.util;
|
||||||
|
|
||||||
|
|
||||||
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 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;
|
||||||
@ -123,10 +120,6 @@ public class DelegateTextureUtil extends TextureUtil {
|
|||||||
return parent.colorDistance(red1, green1, blue1, c2);
|
return parent.colorDistance(red1, green1, blue1, c2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int hueDistance(int red1, int green1, int blue1, int red2, int green2, int blue2) {
|
|
||||||
return TextureUtil.hueDistance(red1, green1, blue1, red2, green2, blue2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getDistance(BufferedImage image, int c1) {
|
public long getDistance(BufferedImage image, int c1) {
|
||||||
return parent.getDistance(image, c1);
|
return parent.getDistance(image, c1);
|
||||||
|
@ -41,8 +41,7 @@ public class FaweTimer implements Runnable {
|
|||||||
if (tick < lastGetTPSTick + tickInterval) {
|
if (tick < lastGetTPSTick + tickInterval) {
|
||||||
return lastGetTPSValue;
|
return lastGetTPSValue;
|
||||||
}
|
}
|
||||||
double total = 0;
|
double total = Arrays.stream(history).sum();
|
||||||
for (double v : history) total += v;
|
|
||||||
lastGetTPSValue = total / history.length;
|
lastGetTPSValue = total / history.length;
|
||||||
lastGetTPSTick = tick;
|
lastGetTPSTick = tick;
|
||||||
return lastGetTPSValue;
|
return lastGetTPSValue;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package com.boydti.fawe.util;
|
package com.boydti.fawe.util;
|
||||||
|
|
||||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -13,30 +10,6 @@ import java.util.stream.Collectors;
|
|||||||
public class ImgurUtility {
|
public class ImgurUtility {
|
||||||
public static final String CLIENT_ID = "50e34b65351eb07";
|
public static final String CLIENT_ID = "50e34b65351eb07";
|
||||||
|
|
||||||
public static URL uploadImage(File file) throws IOException {
|
|
||||||
return uploadImage(new FileInputStream(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static URL uploadImage(InputStream inputStream) throws IOException {
|
|
||||||
inputStream = new BufferedInputStream(inputStream);
|
|
||||||
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(Short.MAX_VALUE);
|
|
||||||
int i;
|
|
||||||
while ((i = inputStream.read()) != -1) {
|
|
||||||
baos.write(i);
|
|
||||||
}
|
|
||||||
baos.flush();
|
|
||||||
return uploadImage(baos.toByteArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static URL uploadImage(byte[] image) throws IOException {
|
|
||||||
String json = getImgurContent(CLIENT_ID, image);
|
|
||||||
Gson gson = new Gson();
|
|
||||||
JsonObject obj = gson.fromJson(json, JsonObject.class);
|
|
||||||
JsonObject data = obj.get("data").getAsJsonObject();
|
|
||||||
String link = data.get("link").getAsString();
|
|
||||||
return new URL(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getImgurContent(String clientID, byte[] image) throws IOException {
|
public static String getImgurContent(String clientID, byte[] image) throws IOException {
|
||||||
String imageString = Base64.getEncoder().encodeToString(image);
|
String imageString = Base64.getEncoder().encodeToString(image);
|
||||||
URL url = new URL("https://api.imgur.com/3/image");
|
URL url = new URL("https://api.imgur.com/3/image");
|
||||||
|
@ -69,10 +69,10 @@ public class TextureUtil implements TextureHolder {
|
|||||||
private BiomeColor[] biomes = new BiomeColor[]{
|
private BiomeColor[] biomes = new BiomeColor[]{
|
||||||
// ID Name Temperature, rainfall, grass, foliage colors
|
// ID Name Temperature, rainfall, grass, foliage colors
|
||||||
// - note: the colors here are just placeholders, they are computed in the program
|
// - note: the colors here are just placeholders, they are computed in the program
|
||||||
new BiomeColor(0, "ocean", 0.5f, 0.5f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(0, "ocean", 0.5f, 0.5f, 0x92BD59, 7842607),
|
||||||
// default values of temp and rain
|
// default values of temp and rain
|
||||||
new BiomeColor(1, "plains", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(1, "plains", 0.8f, 0.4f, 0x92BD59, 7842607),
|
||||||
new BiomeColor(2, "desert", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(2, "desert", 2.0f, 0.0f, 0x92BD59, 7842607),
|
||||||
new BiomeColor(3, "mountains", 0.2f, 0.3f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(3, "mountains", 0.2f, 0.3f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(4, "forest", 0.7f, 0.8f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(4, "forest", 0.7f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(5, "taiga", 0.25f, 0.8f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(5, "taiga", 0.25f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||||
@ -97,7 +97,7 @@ public class TextureUtil implements TextureHolder {
|
|||||||
new BiomeColor(22, "jungle_hills", 0.95f, 0.9f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(22, "jungle_hills", 0.95f, 0.9f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(23, "jungle_edge", 0.95f, 0.8f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(23, "jungle_edge", 0.95f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(24, "deep_ocean", 0.5f, 0.5f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(24, "deep_ocean", 0.5f, 0.5f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(25, "stone_shore", 0.2f, 0.3f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(25, "stone_shore", 0.2f, 0.3f, 9616729, 0x77AB2F),
|
||||||
new BiomeColor(26, "snowy_beach", 0.05f, 0.3f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(26, "snowy_beach", 0.05f, 0.3f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(27, "birch_forest", 0.6f, 0.6f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(27, "birch_forest", 0.6f, 0.6f, 0x92BD59, 0x77AB2F),
|
||||||
new BiomeColor(28, "birch_forest_hills", 0.6f, 0.6f, 0x92BD59, 0x77AB2F),
|
new BiomeColor(28, "birch_forest_hills", 0.6f, 0.6f, 0x92BD59, 0x77AB2F),
|
||||||
|
@ -15,7 +15,6 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -44,26 +43,6 @@ public class WEManager {
|
|||||||
cancelEditSafe(parent, reason);
|
cancelEditSafe(parent, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean maskContains(HashSet<RegionWrapper> mask, int x, int z) {
|
|
||||||
for (RegionWrapper region : mask) {
|
|
||||||
if (x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean maskContains(RegionWrapper[] mask, int x, int z) {
|
|
||||||
switch (mask.length) {
|
|
||||||
case 0:
|
|
||||||
return false;
|
|
||||||
case 1:
|
|
||||||
return mask[0].isIn(x, z);
|
|
||||||
default:
|
|
||||||
return Arrays.stream(mask).anyMatch(region -> region.isIn(x, z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Region[] getMask(Player player) {
|
public Region[] getMask(Player player) {
|
||||||
return getMask(player, FaweMaskManager.MaskType.getDefaultMaskType());
|
return getMask(player, FaweMaskManager.MaskType.getDefaultMaskType());
|
||||||
|
@ -3,5 +3,5 @@ package com.boydti.fawe.util.image;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public interface Drawable {
|
public interface Drawable {
|
||||||
public BufferedImage draw();
|
BufferedImage draw();
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,5 @@ package com.boydti.fawe.util.image;
|
|||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
|
||||||
public interface ImageViewer extends Closeable{
|
public interface ImageViewer extends Closeable{
|
||||||
public void view(Drawable drawable);
|
void view(Drawable drawable);
|
||||||
}
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
package com.boydti.fawe.util.terrain;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.boydti.fawe.util.MathMan.pairInt;
|
|
||||||
|
|
||||||
public final class Erosion {
|
|
||||||
private final int area;
|
|
||||||
private float[][] terrainHeight;
|
|
||||||
private float[][] waterHeight;
|
|
||||||
|
|
||||||
private long[] queue_2;
|
|
||||||
private long[] queue;
|
|
||||||
private int queueIndex;
|
|
||||||
|
|
||||||
public Erosion(int width, int length) {
|
|
||||||
this.area = width * length;
|
|
||||||
queue = new long[area];
|
|
||||||
Arrays.fill(queue, -1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addWater(int x, int z, float amt) {
|
|
||||||
waterHeight[x][z] += amt;
|
|
||||||
queue[queueIndex++] = pairInt(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void propogateWater() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -87,10 +87,16 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
|
||||||
return parent.setBlock(position, block, notifyAndLight);
|
return parent.setBlock(position, block, notifyAndLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||||
|
throws WorldEditException {
|
||||||
|
return parent.setBlock(x, y, z, block);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
||||||
return parent.setTile(x, y, z, tile);
|
return parent.setTile(x, y, z, tile);
|
||||||
@ -112,7 +118,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulateBlockMine(final BlockVector3 pt) {
|
public void simulateBlockMine(BlockVector3 pt) {
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Object value) {
|
public void run(Object value) {
|
||||||
@ -214,7 +220,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean regenerate(final Region region, final EditSession session) {
|
public boolean regenerate(Region region, EditSession session) {
|
||||||
return session.regenerate(region);
|
return session.regenerate(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +240,7 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(final Region region) {
|
public List<? extends Entity> getEntities(Region region) {
|
||||||
return TaskManager.IMP.sync(new RunnableVal<List<? extends Entity>>() {
|
return TaskManager.IMP.sync(new RunnableVal<List<? extends Entity>>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(List<? extends Entity> value) {
|
public void run(List<? extends Entity> value) {
|
||||||
@ -279,6 +285,11 @@ public class WorldWrapper extends AbstractWorld {
|
|||||||
return parent.setBiome(position, biome);
|
return parent.setBiome(position, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
return parent.setBiome(x, y , z, biome);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
|
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
|
||||||
return parent.notifyAndLightBlock(position, previousType);
|
return parent.notifyAndLightBlock(position, previousType);
|
||||||
|
@ -64,6 +64,7 @@ import com.sk89q.worldedit.function.GroundFunction;
|
|||||||
import com.sk89q.worldedit.function.RegionFunction;
|
import com.sk89q.worldedit.function.RegionFunction;
|
||||||
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
||||||
import com.sk89q.worldedit.function.block.BlockReplace;
|
import com.sk89q.worldedit.function.block.BlockReplace;
|
||||||
|
import com.sk89q.worldedit.function.block.Counter;
|
||||||
import com.sk89q.worldedit.function.block.Naturalizer;
|
import com.sk89q.worldedit.function.block.Naturalizer;
|
||||||
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
||||||
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
|
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
|
||||||
@ -144,8 +145,8 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import javax.annotation.Nonnull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -216,7 +217,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
public static final UUID CONSOLE = UUID.fromString("1-1-3-3-7");
|
public static final UUID CONSOLE = UUID.fromString("1-1-3-3-7");
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public EditSession(@Nonnull World world, @Nullable Player player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
|
public EditSession(@NotNull World world, @Nullable Player player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
|
||||||
this(null, world, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event);
|
this(null, world, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1091,7 +1092,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fall(final Region region, boolean fullHeight, final BlockStateHolder replace) {
|
public <B extends BlockStateHolder<B>> int fall(final Region region, boolean fullHeight, final B replace) {
|
||||||
FlatRegion flat = asFlatRegion(region);
|
FlatRegion flat = asFlatRegion(region);
|
||||||
final int startPerformY = region.getMinimumPoint().getBlockY();
|
final int startPerformY = region.getMinimumPoint().getBlockY();
|
||||||
final int startCheckY = fullHeight ? 0 : startPerformY;
|
final int startCheckY = fullHeight ? 0 : startPerformY;
|
||||||
@ -1160,6 +1161,33 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
return this.changes = visitor.getAffected();
|
return this.changes = visitor.getAffected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count the number of blocks of a list of types in a region.
|
||||||
|
*
|
||||||
|
* @param region the region
|
||||||
|
* @param searchBlocks the list of blocks to search
|
||||||
|
* @return the number of blocks that matched the block
|
||||||
|
*/
|
||||||
|
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
||||||
|
BlockMask mask = new BlockMask(this, searchBlocks);
|
||||||
|
return countBlocks(region, mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count the number of blocks of a list of types in a region.
|
||||||
|
*
|
||||||
|
* @param region the region
|
||||||
|
* @param searchMask mask to match
|
||||||
|
* @return the number of blocks that matched the mask
|
||||||
|
*/
|
||||||
|
public int countBlocks(Region region, Mask searchMask) {
|
||||||
|
Counter count = new Counter();
|
||||||
|
RegionMaskingFilter filter = new RegionMaskingFilter(searchMask, count);
|
||||||
|
RegionVisitor visitor = new RegionVisitor(region, filter);
|
||||||
|
Operations.completeBlindly(visitor); // We can't throw exceptions, nor do we expect any
|
||||||
|
return count.getCount();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills an area recursively in the X/Z directions.
|
* Fills an area recursively in the X/Z directions.
|
||||||
*
|
*
|
||||||
@ -1259,8 +1287,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
getWorld(), // Causes clamping of Y range
|
getWorld(), // Causes clamping of Y range
|
||||||
position.add(-apothem + 1, 0, -apothem + 1),
|
position.add(-apothem + 1, 0, -apothem + 1),
|
||||||
position.add(apothem - 1, -height + 1, apothem - 1));
|
position.add(apothem - 1, -height + 1, apothem - 1));
|
||||||
Pattern pattern = BlockTypes.AIR.getDefaultState();
|
return setBlocks(region, BlockTypes.AIR.getDefaultState());
|
||||||
return setBlocks(region, pattern);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2515,7 +2542,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
for (int x = minX; x <= maxX; ++x) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; ++y) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
BlockStateHolder blk = getBlock(x, y, z);
|
BlockState blk = getBlock(x, y, z);
|
||||||
BlockType type = blk.getBlockType();
|
BlockType type = blk.getBlockType();
|
||||||
int[] stateCounter = counter[type.getInternalId()];
|
int[] stateCounter = counter[type.getInternalId()];
|
||||||
if (stateCounter == null) {
|
if (stateCounter == null) {
|
||||||
@ -2526,8 +2553,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (final BlockVector3 pt : region) {
|
for (BlockVector3 pt : region) {
|
||||||
BlockStateHolder blk = this.getBlock(pt);
|
BlockState blk = this.getBlock(pt);
|
||||||
BlockType type = blk.getBlockType();
|
BlockType type = blk.getBlockType();
|
||||||
int[] stateCounter = counter[type.getInternalId()];
|
int[] stateCounter = counter[type.getInternalId()];
|
||||||
if (stateCounter == null) {
|
if (stateCounter == null) {
|
||||||
@ -2638,8 +2665,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
return deformRegion(region, zero, unit, expressionString, WorldEdit.getInstance().getConfiguration().calculationTimeout);
|
return deformRegion(region, zero, unit, expressionString, WorldEdit.getInstance().getConfiguration().calculationTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deformRegion(final Region region, final Vector3 zero, final Vector3 unit, final String expressionString,
|
public int deformRegion(Region region, Vector3 zero, Vector3 unit, String expressionString,
|
||||||
final int timeout) throws ExpressionException, MaxChangedBlocksException {
|
int timeout) throws ExpressionException, MaxChangedBlocksException {
|
||||||
final Expression expression = Expression.compile(expressionString, "x", "y", "z");
|
final Expression expression = Expression.compile(expressionString, "x", "y", "z");
|
||||||
expression.optimize();
|
expression.optimize();
|
||||||
|
|
||||||
@ -2692,7 +2719,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
return hollowOutRegion(region, thickness, pattern, new SolidBlockMask(this));
|
return hollowOutRegion(region, thickness, pattern, new SolidBlockMask(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hollowOutRegion(final Region region, final int thickness, final Pattern pattern, Mask mask) {
|
public int hollowOutRegion(Region region, int thickness, Pattern pattern, Mask mask) {
|
||||||
try {
|
try {
|
||||||
final Set<BlockVector3> outside = new LocalBlockVectorSet();
|
final Set<BlockVector3> outside = new LocalBlockVectorSet();
|
||||||
|
|
||||||
@ -2760,7 +2787,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int drawLine(final Pattern pattern, final BlockVector3 pos1, final BlockVector3 pos2, final double radius, final boolean filled) throws MaxChangedBlocksException {
|
public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled) throws MaxChangedBlocksException {
|
||||||
return drawLine(pattern, pos1, pos2, radius, filled, false);
|
return drawLine(pattern, pos1, pos2, radius, filled, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2795,8 +2822,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
if (Math.max(Math.max(dx, dy), dz) == dx && notdrawn) {
|
if (Math.max(Math.max(dx, dy), dz) == dx && notdrawn) {
|
||||||
for (int domstep = 0; domstep <= dx; domstep++) {
|
for (int domstep = 0; domstep <= dx; domstep++) {
|
||||||
tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1);
|
tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1);
|
||||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1));
|
tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dx * (y2 - y1 > 0 ? 1 : -1));
|
||||||
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1));
|
tipz = (int) Math.round(z1 + domstep * (double) dz / (double) dx * (z2 - z1 > 0 ? 1 : -1));
|
||||||
|
|
||||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||||
}
|
}
|
||||||
@ -2806,8 +2833,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
if (Math.max(Math.max(dx, dy), dz) == dy && notdrawn) {
|
if (Math.max(Math.max(dx, dy), dz) == dy && notdrawn) {
|
||||||
for (int domstep = 0; domstep <= dy; domstep++) {
|
for (int domstep = 0; domstep <= dy; domstep++) {
|
||||||
tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1);
|
tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1);
|
||||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1));
|
tipx = (int) Math.round(x1 + domstep * (double) dx / (double) dy * (x2 - x1 > 0 ? 1 : -1));
|
||||||
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1));
|
tipz = (int) Math.round(z1 + domstep * (double) dz / (double) dy * (z2 - z1 > 0 ? 1 : -1));
|
||||||
|
|
||||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||||
}
|
}
|
||||||
@ -2817,8 +2844,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
if (Math.max(Math.max(dx, dy), dz) == dz && notdrawn) {
|
if (Math.max(Math.max(dx, dy), dz) == dz && notdrawn) {
|
||||||
for (int domstep = 0; domstep <= dz; domstep++) {
|
for (int domstep = 0; domstep <= dz; domstep++) {
|
||||||
tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1);
|
tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1);
|
||||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1));
|
tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dz * (y2-y1>0 ? 1 : -1));
|
||||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1));
|
tipx = (int) Math.round(x1 + domstep * (double) dx / (double) dz * (x2-x1>0 ? 1 : -1));
|
||||||
|
|
||||||
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
vset.add(BlockVector3.at(tipx, tipy, tipz));
|
||||||
}
|
}
|
||||||
@ -2921,7 +2948,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
final LocalBlockVectorSet returnset = new LocalBlockVectorSet();
|
final LocalBlockVectorSet returnset = new LocalBlockVectorSet();
|
||||||
final int ceilrad = (int) Math.ceil(radius);
|
final int ceilrad = (int) Math.ceil(radius);
|
||||||
for (final BlockVector3 v : vset) {
|
for (BlockVector3 v : vset) {
|
||||||
final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
||||||
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||||
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
||||||
@ -3055,11 +3082,11 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
Direction.DOWN.toBlockVector(),
|
Direction.DOWN.toBlockVector(),
|
||||||
};
|
};
|
||||||
|
|
||||||
public boolean regenerate(final Region region) {
|
public boolean regenerate(Region region) {
|
||||||
return regenerate(region, this);
|
return regenerate(region, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean regenerate(final Region region, final EditSession session) {
|
public boolean regenerate(Region region, EditSession session) {
|
||||||
return session.regenerate(region, null, null);
|
return session.regenerate(region, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3073,7 +3100,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean regenerate(final Region region, final BiomeType biome, final Long seed) {
|
public boolean regenerate(Region region, BiomeType biome, Long seed) {
|
||||||
//TODO Optimize - avoid Vector2D creation (make mutable)
|
//TODO Optimize - avoid Vector2D creation (make mutable)
|
||||||
final FaweChangeSet fcs = (FaweChangeSet) this.getChangeSet();
|
final FaweChangeSet fcs = (FaweChangeSet) this.getChangeSet();
|
||||||
this.setChangeSet(null);
|
this.setChangeSet(null);
|
||||||
@ -3096,11 +3123,13 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
final int bz = cz << 4;
|
final int bz = cz << 4;
|
||||||
final BlockVector3 cmin = BlockVector3.at(bx, 0, bz);
|
final BlockVector3 cmin = BlockVector3.at(bx, 0, bz);
|
||||||
final BlockVector3 cmax = cmin.add(15, maxY, 15);
|
final BlockVector3 cmax = cmin.add(15, maxY, 15);
|
||||||
final boolean containsBot1 = (fe == null || fe.contains(cmin.getBlockX(), cmin.getBlockY(), cmin.getBlockZ()));
|
final boolean containsBot1 =
|
||||||
|
fe == null || fe.contains(cmin.getBlockX(), cmin.getBlockY(), cmin.getBlockZ());
|
||||||
final boolean containsBot2 = region.contains(cmin);
|
final boolean containsBot2 = region.contains(cmin);
|
||||||
final boolean containsTop1 = (fe == null || fe.contains(cmax.getBlockX(), cmax.getBlockY(), cmax.getBlockZ()));
|
final boolean containsTop1 =
|
||||||
|
fe == null || fe.contains(cmax.getBlockX(), cmax.getBlockY(), cmax.getBlockZ());
|
||||||
final boolean containsTop2 = region.contains(cmax);
|
final boolean containsTop2 = region.contains(cmax);
|
||||||
if (((containsBot2 && containsTop2)) && !containsBot1 && !containsTop1) {
|
if (containsBot2 && containsTop2 && !containsBot1 && !containsTop1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean conNextX = chunks.contains(mutable2D.setComponents(cx + 1, cz));
|
boolean conNextX = chunks.contains(mutable2D.setComponents(cx + 1, cz));
|
||||||
@ -3146,7 +3175,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
fcs.add(mutable, block, BlockTypes.AIR.getDefaultState().toBaseBlock());
|
fcs.add(mutable, block, BlockTypes.AIR.getDefaultState().toBaseBlock());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BlockStateHolder block = getFullBlock(mutable);
|
BaseBlock block = getFullBlock(mutable);
|
||||||
try {
|
try {
|
||||||
setBlock(mutable, block);
|
setBlock(mutable, block);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
|
@ -38,6 +38,8 @@ import com.boydti.fawe.object.schematic.Schematic;
|
|||||||
import com.boydti.fawe.util.ImgurUtility;
|
import com.boydti.fawe.util.ImgurUtility;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.MaskTraverser;
|
import com.boydti.fawe.util.MaskTraverser;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
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;
|
||||||
@ -361,7 +363,13 @@ public class ClipboardCommands {
|
|||||||
ClipboardWriter writer = format.getWriter(baos);
|
ClipboardWriter writer = format.getWriter(baos);
|
||||||
writer.write(target);
|
writer.write(target);
|
||||||
baos.flush();
|
baos.flush();
|
||||||
url = ImgurUtility.uploadImage(baos.toByteArray());
|
String json = ImgurUtility
|
||||||
|
.getImgurContent(ImgurUtility.CLIENT_ID, baos.toByteArray());
|
||||||
|
Gson gson = new Gson();
|
||||||
|
JsonObject obj = gson.fromJson(json, JsonObject.class);
|
||||||
|
JsonObject data = obj.get("data").getAsJsonObject();
|
||||||
|
String link = data.get("link").getAsString();
|
||||||
|
url = new URL(link);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
url = null;
|
url = null;
|
||||||
|
@ -19,23 +19,17 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extension.factory.parser;
|
package com.sk89q.worldedit.extension.factory.parser;
|
||||||
|
|
||||||
import com.boydti.fawe.command.SuggestInputParseException;
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.jnbt.JSON2NBT;
|
import com.google.common.collect.Maps;
|
||||||
import com.boydti.fawe.jnbt.NBTException;
|
|
||||||
import com.boydti.fawe.util.MathMan;
|
|
||||||
import com.boydti.fawe.util.StringMan;
|
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.NotABlockException;
|
import com.sk89q.worldedit.NotABlockException;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
|
||||||
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
|
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
|
||||||
import com.sk89q.worldedit.blocks.SignBlock;
|
import com.sk89q.worldedit.blocks.SignBlock;
|
||||||
import com.sk89q.worldedit.blocks.SkullBlock;
|
import com.sk89q.worldedit.blocks.SkullBlock;
|
||||||
import com.sk89q.worldedit.blocks.metadata.MobType;
|
import com.sk89q.worldedit.command.util.SuggestionHelper;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
|
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
|
||||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
@ -43,8 +37,6 @@ import com.sk89q.worldedit.extension.input.NoMatchException;
|
|||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
|
||||||
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
|
|
||||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||||
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;
|
||||||
@ -57,13 +49,12 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
||||||
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
|
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,6 +157,71 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Map<Property<?>, Object> parseProperties(BlockType type, String[] stateProperties, ParserContext context) throws NoMatchException {
|
||||||
|
Map<Property<?>, Object> blockStates = new HashMap<>();
|
||||||
|
|
||||||
|
if (stateProperties.length > 0) { // Block data not yet detected
|
||||||
|
// Parse the block data (optional)
|
||||||
|
for (String parseableData : stateProperties) {
|
||||||
|
try {
|
||||||
|
String[] parts = parseableData.split("=");
|
||||||
|
if (parts.length != 2) {
|
||||||
|
throw new NoMatchException("Bad state format in " + parseableData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Property<Object> propertyKey = (Property<Object>) type.getPropertyMap().get(parts[0]);
|
||||||
|
if (propertyKey == null) {
|
||||||
|
if (context.getActor() != null) {
|
||||||
|
throw new NoMatchException("Unknown property " + parts[0] + " for block " + type.getId());
|
||||||
|
} else {
|
||||||
|
WorldEdit.logger.warn("Unknown property " + parts[0] + " for block " + type.getId());
|
||||||
|
}
|
||||||
|
return Maps.newHashMap();
|
||||||
|
}
|
||||||
|
if (blockStates.containsKey(propertyKey)) {
|
||||||
|
throw new NoMatchException("Duplicate property " + parts[0]);
|
||||||
|
}
|
||||||
|
Object value;
|
||||||
|
try {
|
||||||
|
value = propertyKey.getValueFor(parts[1]);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new NoMatchException("Unknown value " + parts[1] + " for state " + parts[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockStates.put(propertyKey, value);
|
||||||
|
} catch (NoMatchException e) {
|
||||||
|
throw e; // Pass-through
|
||||||
|
} catch (Exception e) {
|
||||||
|
WorldEdit.logger.warn("Unknown state '" + parseableData + "'", e);
|
||||||
|
throw new NoMatchException("Unknown state '" + parseableData + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return blockStates;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<String> getSuggestions(String input) {
|
||||||
|
final int idx = input.lastIndexOf('[');
|
||||||
|
if (idx < 0) {
|
||||||
|
return SuggestionHelper.getNamespacedRegistrySuggestions(BlockType.REGISTRY, input);
|
||||||
|
}
|
||||||
|
String blockType = input.substring(0, idx);
|
||||||
|
BlockType type = BlockTypes.get(blockType.toLowerCase(Locale.ROOT));
|
||||||
|
if (type == null) {
|
||||||
|
return Stream.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
String props = input.substring(idx + 1);
|
||||||
|
if (props.isEmpty()) {
|
||||||
|
return type.getProperties().stream().map(p -> input + p.getName() + "=");
|
||||||
|
}
|
||||||
|
|
||||||
|
return SuggestionHelper.getBlockPropertySuggestions(blockType, props);
|
||||||
|
}
|
||||||
|
|
||||||
private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException {
|
private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException {
|
||||||
BlockType blockType = null;
|
BlockType blockType = null;
|
||||||
Map<Property<?>, Object> blockStates = new HashMap<>();
|
Map<Property<?>, Object> blockStates = new HashMap<>();
|
||||||
@ -182,28 +238,16 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
throw new InputParseException("Invalid colon.");
|
throw new InputParseException("Invalid colon.");
|
||||||
} else if (split.length == 1) {
|
} else if (split.length == 1) {
|
||||||
state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]));
|
state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]));
|
||||||
} else if (MathMan.isInteger(split[0])) {
|
|
||||||
int id = Integer.parseInt(split[0]);
|
|
||||||
int data = Integer.parseInt(split[1]);
|
|
||||||
if (data < 0 || data >= 16) {
|
|
||||||
throw new InputParseException("Invalid data " + data);
|
|
||||||
}
|
|
||||||
state = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
|
|
||||||
} else {
|
} else {
|
||||||
BlockType type = BlockTypes.get(split[0].toLowerCase(Locale.ROOT));
|
state = LegacyMapper.getInstance().getBlockFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||||
if (type != null) {
|
|
||||||
int data = Integer.parseInt(split[1]);
|
|
||||||
if (data < 0 || data >= 16) {
|
|
||||||
throw new InputParseException("Invalid data " + data);
|
|
||||||
}
|
|
||||||
state = LegacyMapper.getInstance().getBlockFromLegacy(type.getLegacyCombinedId() >> 4, data);
|
|
||||||
}
|
}
|
||||||
|
if (state != null) {
|
||||||
|
blockType = state.getBlockType();
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag nbt = null;
|
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
String typeString;
|
String typeString;
|
||||||
String stateString = null;
|
String stateString = null;
|
||||||
@ -247,8 +291,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
|
|
||||||
blockType = blockInHand.getBlockType();
|
blockType = blockInHand.getBlockType();
|
||||||
blockStates.putAll(blockInHand.getStates());
|
blockStates.putAll(blockInHand.getStates());
|
||||||
} else if (typeString.matches("pos[0-9]+")) {
|
} else if ("pos1".equalsIgnoreCase(typeString)) {
|
||||||
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
|
|
||||||
// Get the block type from the "primary position"
|
// Get the block type from the "primary position"
|
||||||
final World world = context.requireWorld();
|
final World world = context.requireWorld();
|
||||||
final BlockVector3 primaryPosition;
|
final BlockVector3 primaryPosition;
|
||||||
@ -261,74 +304,53 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
|
|
||||||
blockType = blockInHand.getBlockType();
|
blockType = blockInHand.getBlockType();
|
||||||
blockStates.putAll(blockInHand.getStates());
|
blockStates.putAll(blockInHand.getStates());
|
||||||
} else if (typeString.matches("slot[0-9]+")) {
|
|
||||||
int slot = Integer.parseInt(typeString.substring(4)) - 1;
|
|
||||||
Actor actor = context.requireActor();
|
|
||||||
if (!(actor instanceof Player)) {
|
|
||||||
throw new InputParseException("The user is not a player!");
|
|
||||||
}
|
|
||||||
Player player = (Player) actor;
|
|
||||||
BlockBag bag = player.getInventoryBlockBag();
|
|
||||||
if (true) {
|
|
||||||
throw new InputParseException("Unsupported!");
|
|
||||||
}
|
|
||||||
SlottableBlockBag slottable = (SlottableBlockBag) bag;
|
|
||||||
BaseItem item = slottable.getItem(slot);
|
|
||||||
|
|
||||||
if (!item.getType().hasBlockType()) {
|
|
||||||
throw new InputParseException("You're not holding a block!");
|
|
||||||
}
|
|
||||||
state = item.getType().getBlockType().getDefaultState();
|
|
||||||
nbt = item.getNbtData();
|
|
||||||
} else {
|
} else {
|
||||||
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT));
|
// Attempt to lookup a block from ID or name.
|
||||||
|
blockType = BlockTypes.get(typeString.toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
|
||||||
if (type != null) {
|
if (blockType == null) {
|
||||||
state = type.getDefaultState();
|
throw new NoMatchException("Does not match a valid block type: '" + input + "'");
|
||||||
}
|
}
|
||||||
if (state == null) {
|
|
||||||
throw new NoMatchException(
|
|
||||||
"Does not match a valid block type: '" + input + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nbt == null) nbt = state.getNbtData();
|
|
||||||
|
|
||||||
if (stateString != null) {
|
blockStates.putAll(parseProperties(blockType, stateProperties, context));
|
||||||
state = BlockState.get(state.getBlockType(), "[" + stateString + "]", state);
|
|
||||||
if (context.isPreferringWildcard()) {
|
if (context.isPreferringWildcard()) {
|
||||||
if (stateString.isEmpty()) {
|
|
||||||
state = new FuzzyBlockState(state);
|
|
||||||
} else {
|
|
||||||
BlockType type = state.getBlockType();
|
|
||||||
FuzzyBlockState.Builder fuzzyBuilder = FuzzyBlockState.builder();
|
FuzzyBlockState.Builder fuzzyBuilder = FuzzyBlockState.builder();
|
||||||
fuzzyBuilder.type(type);
|
fuzzyBuilder.type(blockType);
|
||||||
String[] entries = stateString.split(",");
|
for (Map.Entry<Property<?>, Object> blockState : blockStates.entrySet()) {
|
||||||
for (String entry : entries) {
|
@SuppressWarnings("unchecked")
|
||||||
String[] split = entry.split("=");
|
Property<Object> objProp = (Property<Object>) blockState.getKey();
|
||||||
String key = split[0];
|
fuzzyBuilder.withProperty(objProp, blockState.getValue());
|
||||||
String val = split[1];
|
|
||||||
Property<Object> prop = type.getProperty(key);
|
|
||||||
fuzzyBuilder.withProperty(prop, prop.getValueFor(val));
|
|
||||||
}
|
}
|
||||||
state = fuzzyBuilder.build();
|
state = fuzzyBuilder.build();
|
||||||
|
} else {
|
||||||
|
// No wildcards allowed => eliminate them. (Start with default state)
|
||||||
|
state = blockType.getDefaultState();
|
||||||
|
for (Map.Entry<Property<?>, Object> blockState : blockStates.entrySet()) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Property<Object> objProp = (Property<Object>) blockState.getKey();
|
||||||
|
state = state.with(objProp, blockState.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// this should be impossible but IntelliJ isn't that smart
|
||||||
|
if (blockType == null) {
|
||||||
if (blockAndExtraData.length > 1 && blockAndExtraData[1].startsWith("{")) {
|
throw new NoMatchException("Does not match a valid block type: '" + input + "'");
|
||||||
String joined = StringMan.join(Arrays.copyOfRange(blockAndExtraData, 1, blockAndExtraData.length), "|");
|
|
||||||
try {
|
|
||||||
nbt = JSON2NBT.getTagFromJson(joined);
|
|
||||||
} catch (NBTException e) {
|
|
||||||
throw new NoMatchException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the item is allowed
|
// Check if the item is allowed
|
||||||
BlockType blockType = state.getBlockType();
|
if (context.isRestricted()) {
|
||||||
|
Actor actor = context.requireActor();
|
||||||
|
if (actor != null && !actor.hasPermission("worldedit.anyblock")
|
||||||
|
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.getId())) {
|
||||||
|
throw new DisallowedUsageException("You are not allowed to use '" + input + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (nbt != null) return validate(context, state.toBaseBlock(nbt));
|
if (!context.isTryingLegacy()) {
|
||||||
|
return state.toBaseBlock();
|
||||||
|
}
|
||||||
|
|
||||||
if (blockType == BlockTypes.SIGN || blockType == BlockTypes.WALL_SIGN
|
if (blockType == BlockTypes.SIGN || blockType == BlockTypes.WALL_SIGN
|
||||||
|| BlockCategories.SIGNS.contains(blockType)) {
|
|| BlockCategories.SIGNS.contains(blockType)) {
|
||||||
@ -343,22 +365,17 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
// Allow setting mob spawn type
|
// Allow setting mob spawn type
|
||||||
if (blockAndExtraData.length > 1) {
|
if (blockAndExtraData.length > 1) {
|
||||||
String mobName = blockAndExtraData[1];
|
String mobName = blockAndExtraData[1];
|
||||||
for (MobType mobType : MobType.values()) {
|
EntityType ent = EntityTypes.get(mobName.toLowerCase(Locale.ROOT));
|
||||||
if (mobType.getName().toLowerCase().equals(mobName.toLowerCase(Locale.ROOT))) {
|
if (ent == null) {
|
||||||
mobName = mobType.getName();
|
throw new NoMatchException("Unknown entity type '" + mobName + "'");
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
mobName = ent.getId();
|
||||||
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
|
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
|
||||||
String finalMobName = mobName.toLowerCase(Locale.ROOT);
|
throw new NoMatchException("Unknown mob type '" + mobName + "'");
|
||||||
throw new SuggestInputParseException("Unknown mob type '" + mobName + "'", mobName, () -> Stream.of(MobType.values())
|
|
||||||
.map(m -> m.getName().toLowerCase(Locale.ROOT))
|
|
||||||
.filter(s -> s.startsWith(finalMobName))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
}
|
}
|
||||||
return validate(context, new MobSpawnerBlock(state, mobName));
|
return validate(context, new MobSpawnerBlock(state, mobName));
|
||||||
} else {
|
} else {
|
||||||
return validate(context, new MobSpawnerBlock(state, MobType.PIG.getName()));
|
return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.getId()));
|
||||||
}
|
}
|
||||||
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
|
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
|
||||||
// allow setting type/player/rotation
|
// allow setting type/player/rotation
|
||||||
|
@ -165,7 +165,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
|
|
||||||
if (free == 2) {
|
if (free == 2) {
|
||||||
final BlockVector3 pos = mutablePos.setComponents(x, y - 2, z);
|
final BlockVector3 pos = mutablePos.setComponents(x, y - 2, z);
|
||||||
final BlockStateHolder state = world.getBlock(pos);
|
final BlockState state = world.getBlock(pos);
|
||||||
setPosition(new Location(world,
|
setPosition(new Location(world,
|
||||||
Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5)));
|
Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5)));
|
||||||
return;
|
return;
|
||||||
|
@ -28,7 +28,6 @@ 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.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.registry.BiomeRegistry;
|
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
@ -120,10 +119,6 @@ public class ProvideBindings extends Bindings {
|
|||||||
return blockState(actor, argument).getBlockType();
|
return blockState(actor, argument).getBlockType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockStateHolder blockStateHolder(Actor actor, String argument) {
|
|
||||||
return blockState(actor, argument);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockState blockState(Actor actor, String argument) {
|
public BlockState blockState(Actor actor, String argument) {
|
||||||
return baseBlock(actor, argument).toBlockState();
|
return baseBlock(actor, argument).toBlockState();
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer;
|
import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
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.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -124,7 +124,6 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bounds
|
Bounds
|
||||||
*/
|
*/
|
||||||
@ -157,6 +156,12 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
|
|||||||
return extent.setBiome(x, y, z, biome);
|
return extent.setBiome(x, y, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block)
|
||||||
|
throws WorldEditException {
|
||||||
|
return extent.setBlock(position.getX(), position.getY(), position.getZ(), block);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
@ -168,6 +173,11 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
|
|||||||
return setBlock(x, y, z, getBlock(x, y, z).toBaseBlock(tile));
|
return setBlock(x, y, z, getBlock(x, y, z).toBaseBlock(tile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||||
|
return extent.setBiome(position.getX(), 0, position.getZ(), biome);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Light
|
Light
|
||||||
*/
|
*/
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
|
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
|
||||||
import com.boydti.fawe.object.exception.FaweException;
|
import com.boydti.fawe.object.exception.FaweException;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
@ -59,16 +61,13 @@ 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.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A world, portion of a world, clipboard, or other object that can have blocks
|
* A world, portion of a world, clipboard, or other object that can have blocks
|
||||||
@ -295,7 +294,7 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
int clearanceAbove = maxY - y;
|
int clearanceAbove = maxY - y;
|
||||||
int clearanceBelow = y - minY;
|
int clearanceBelow = y - minY;
|
||||||
int clearance = Math.min(clearanceAbove, clearanceBelow);
|
int clearance = Math.min(clearanceAbove, clearanceBelow);
|
||||||
BlockStateHolder block = getBlock(x, y, z);
|
BlockState block = getBlock(x, y, z);
|
||||||
boolean state = !block.getBlockType().getMaterial().isMovementBlocker();
|
boolean state = !block.getBlockType().getMaterial().isMovementBlocker();
|
||||||
int offset = state ? 0 : 1;
|
int offset = state ? 0 : 1;
|
||||||
for (int d = 0; d <= clearance; d++) {
|
for (int d = 0; d <= clearance; d++) {
|
||||||
|
@ -92,6 +92,12 @@ public class NullExtent implements Extent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||||
|
throws WorldEditException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
|
||||||
return false;
|
return false;
|
||||||
@ -102,6 +108,11 @@ public class NullExtent implements Extent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Operation commit() {
|
public Operation commit() {
|
||||||
|
@ -186,6 +186,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
|
|||||||
return getExtent().cancel();
|
return getExtent().cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getMaxY() {
|
public int getMaxY() {
|
||||||
return getExtent().getMaxY();
|
return getExtent().getMaxY();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user