Plex-FAWE/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.8 KiB
Java
Raw Normal View History

package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
2018-12-23 16:19:33 +00:00
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
2019-03-31 16:09:20 +00:00
import com.sk89q.worldedit.math.MutableBlockVector2;
2019-04-03 05:53:58 +00:00
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public class OffsetExtent extends ResettableExtent {
private final int dx;
private final int dy;
private final int dz;
2019-03-31 16:09:20 +00:00
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
public OffsetExtent(Extent parent, int dx, int dy, int dz) {
super(parent);
this.dx = dx;
this.dy = dy;
this.dz = dz;
}
@Override
2019-04-03 05:53:58 +00:00
public boolean setBiome(BlockVector2 position, BiomeType biome) {
return getExtent()
.setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz),
biome);
}
@Override
2019-04-03 05:53:58 +00:00
public boolean setBiome(int x, int y, int z, BiomeType biome) {
return getExtent().setBiome(x + dx, y + dy, z + dz, biome);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block)
throws WorldEditException {
return getExtent().setBlock(location.getBlockX() + dx, location.getBlockY() + dy,
location.getBlockZ() + dz, block);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
throws WorldEditException {
return getExtent().setBlock(x + dx, y + dy, z + dz, block);
}
@Override
public ResettableExtent setExtent(Extent extent) {
2019-03-31 16:09:20 +00:00
mutable = new MutableBlockVector2();
return super.setExtent(extent);
}
}