mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 08:08:34 +00:00
Use more MutableBlockVector3s
This commit is contained in:
@ -24,12 +24,20 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
|
||||
<<<<<<< Updated upstream
|
||||
return getExtent().setBlock(location.getX(), location.getY(), location.getZ(), block);
|
||||
=======
|
||||
return getExtent().setBlock(location.getX() + dx, location.getY() + dy, location.getZ() + dz, block);
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
<<<<<<< Updated upstream
|
||||
return getExtent().setBlock(x, y, z, block);
|
||||
=======
|
||||
return getExtent().setBlock(x + dx, y + dy, z + dz, block);
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.fastasyncworldedit.core.extent;
|
||||
|
||||
import com.fastasyncworldedit.core.history.changeset.AbstractChangeSet;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
@ -25,6 +26,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class HistoryExtent extends AbstractDelegateExtent {
|
||||
|
||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private AbstractChangeSet changeSet;
|
||||
|
||||
/**
|
||||
@ -97,7 +99,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public boolean setBiome(BlockVector3 position, BiomeType newBiome) {
|
||||
BiomeType oldBiome = this.getBiome(position);
|
||||
if (oldBiome.getId() != newBiome.getId()) {
|
||||
if (!oldBiome.getId().equals(newBiome.getId())) {
|
||||
this.changeSet.addBiomeChange(position.getBlockX(), position.getBlockY(), position.getBlockZ(), oldBiome, newBiome);
|
||||
return getExtent().setBiome(position, newBiome);
|
||||
} else {
|
||||
@ -107,8 +109,8 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType newBiome) {
|
||||
BiomeType oldBiome = this.getBiome(BlockVector3.at(x, y, z));
|
||||
if (oldBiome.getId() != newBiome.getId()) {
|
||||
BiomeType oldBiome = this.getBiome(mutable.setComponents(x, y, z));
|
||||
if (!oldBiome.getId().equals(newBiome.getId())) {
|
||||
this.changeSet.addBiomeChange(x, y, z, oldBiome, newBiome);
|
||||
return getExtent().setBiome(x, y, z, newBiome);
|
||||
} else {
|
||||
|
@ -45,9 +45,20 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
return min.add(tmp.roundHalfUp().toBlockPoint());
|
||||
}
|
||||
|
||||
private BlockVector3 getPos(int x, int y, int z) {
|
||||
if (min == null) {
|
||||
min = BlockVector3.at(x, y, z);
|
||||
}
|
||||
mutable.mutX(x - min.getX());
|
||||
mutable.mutY(y - min.getY());
|
||||
mutable.mutZ(z - min.getZ());
|
||||
MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3()));
|
||||
return min.add(tmp.roundHalfUp().toBlockPoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return super.getBlock(getPos(BlockVector3.at(x, y, z)));
|
||||
return super.getBlock(getPos(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,12 +76,12 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
mutable.mutX(position.getBlockX());
|
||||
mutable.mutZ(position.getBlockZ());
|
||||
mutable.mutY(position.getBlockY());
|
||||
return super.getBiome(getPos(mutable));
|
||||
return super.getBiome(getPos(mutable.getX(), mutable.getY(), mutable.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||
return this.setBlock(getPos(BlockVector3.at(x, y, z)), block);
|
||||
return this.setBlock(getPos(x, y, z), block);
|
||||
}
|
||||
|
||||
|
||||
@ -84,7 +95,7 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
mutable.mutX(position.getBlockX());
|
||||
mutable.mutZ(position.getBlockZ());
|
||||
mutable.mutY(position.getBlockY());
|
||||
return super.setBiome(getPos(mutable), biome);
|
||||
return super.setBiome(getPos(mutable.getX(), mutable.getY(), mutable.getZ()), biome);
|
||||
}
|
||||
|
||||
public void setTransform(Transform transform) {
|
||||
|
@ -4,6 +4,7 @@ import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.function.visitor.Order;
|
||||
import com.fastasyncworldedit.core.internal.io.FaweOutputStream;
|
||||
import com.fastasyncworldedit.core.jnbt.streamer.IntValueReader;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.fastasyncworldedit.core.util.IOUtil;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.IntArrayTag;
|
||||
@ -278,12 +279,12 @@ public class FastSchematicWriter implements ClipboardWriter {
|
||||
BlockVector3 min = clipboard.getMinimumPoint();
|
||||
int width = clipboard.getRegion().getWidth();
|
||||
int length = clipboard.getRegion().getLength();
|
||||
MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
for (int z = 0, i = 0; z < length; z++) {
|
||||
int z0 = min.getBlockZ() + z;
|
||||
for (int x = 0; x < width; x++, i++) {
|
||||
int x0 = min.getBlockX() + x;
|
||||
BlockVector3 pt = BlockVector3.at(x0, min.getBlockY(), z0);
|
||||
BiomeType biome = clipboard.getBiome(pt);
|
||||
BiomeType biome = clipboard.getBiome(mutable.setComponents(x0, min.getY(), z0));
|
||||
task.applyInt(i, biome.getInternalId());
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.fastasyncworldedit.core.extent.transform;
|
||||
|
||||
import com.fastasyncworldedit.core.extent.ResettableExtent;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
@ -10,6 +11,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
public class PatternTransform extends ResettableExtent {
|
||||
|
||||
private final Pattern pattern;
|
||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
public PatternTransform(Extent parent, Pattern pattern) {
|
||||
super(parent);
|
||||
@ -22,4 +24,14 @@ public class PatternTransform extends ResettableExtent {
|
||||
return pattern.apply(getExtent(), location, location);
|
||||
}
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block)
|
||||
throws WorldEditException {
|
||||
mutable.setComponents(x, y, z);
|
||||
return pattern.apply(extent, mutable, mutable);
|
||||
}
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
Reference in New Issue
Block a user