2021-07-23 15:48:51 +00:00
|
|
|
package com.fastasyncworldedit.core.extent;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
|
|
|
import com.sk89q.worldedit.extent.Extent;
|
2018-12-23 16:19:33 +00:00
|
|
|
import com.sk89q.worldedit.math.BlockVector3;
|
2019-04-03 05:53:58 +00:00
|
|
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
2020-03-21 01:39:40 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
|
|
import com.sk89q.worldedit.world.block.BlockState;
|
2018-08-12 14:03:07 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
2019-06-23 18:05:14 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2019-08-06 20:38:25 +00:00
|
|
|
public class TemporalExtent extends PassthroughExtent {
|
2021-07-24 15:34:05 +00:00
|
|
|
|
2020-10-05 17:41:41 +00:00
|
|
|
private int x;
|
|
|
|
private int y;
|
|
|
|
private int z = Integer.MAX_VALUE;
|
2019-06-23 18:05:14 +00:00
|
|
|
private BlockStateHolder<?> block = BlockTypes.AIR.getDefaultState();
|
2018-08-12 14:03:07 +00:00
|
|
|
|
2020-10-05 17:41:41 +00:00
|
|
|
private int bx;
|
|
|
|
private int bz = Integer.MAX_VALUE;
|
2019-04-03 05:53:58 +00:00
|
|
|
private BiomeType biome = null;
|
2018-08-12 14:03:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance.
|
|
|
|
*
|
|
|
|
* @param extent the extent
|
|
|
|
*/
|
|
|
|
public TemporalExtent(Extent extent) {
|
|
|
|
super(extent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-25 17:31:12 +00:00
|
|
|
public <B extends BlockStateHolder<B>> void set(int x, int y, int z, B block) {
|
2018-08-12 14:03:07 +00:00
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.z = z;
|
2019-03-25 17:31:12 +00:00
|
|
|
this.block = block;
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
|
2019-04-03 05:53:58 +00:00
|
|
|
public void set(int x, int z, BiomeType biome) {
|
2018-08-12 14:03:07 +00:00
|
|
|
this.bx = x;
|
|
|
|
this.bz = z;
|
|
|
|
this.biome = biome;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-12-23 16:19:33 +00:00
|
|
|
public BlockState getBlock(BlockVector3 position) {
|
2018-08-12 14:03:07 +00:00
|
|
|
if (position.getX() == x && position.getY() == y && position.getZ() == z) {
|
2019-03-25 17:31:12 +00:00
|
|
|
return block.toImmutableState();
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
|
|
|
return super.getBlock(position);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-28 20:31:22 +00:00
|
|
|
public BlockState getBlock(int x, int y, int z) {
|
2018-08-12 14:03:07 +00:00
|
|
|
if (this.x == x && this.y == y && this.z == z) {
|
2019-03-25 17:31:12 +00:00
|
|
|
return block.toImmutableState();
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2019-05-28 20:31:22 +00:00
|
|
|
return super.getBlock(x, y, z);
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|
2019-06-23 18:05:14 +00:00
|
|
|
|
2019-03-25 17:31:12 +00:00
|
|
|
@Override
|
|
|
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
|
|
|
if (position.getX() == x && position.getY() == y && position.getZ() == z) {
|
2020-10-05 17:41:41 +00:00
|
|
|
if (block instanceof BaseBlock) {
|
|
|
|
return (BaseBlock) block;
|
2020-04-30 20:26:52 +00:00
|
|
|
} else {
|
2019-07-22 20:42:40 +00:00
|
|
|
return block.toBaseBlock();
|
2019-03-25 17:31:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.getFullBlock(position);
|
|
|
|
}
|
2018-08-12 14:03:07 +00:00
|
|
|
|
|
|
|
@Override
|
2020-09-12 13:31:42 +00:00
|
|
|
public BiomeType getBiome(BlockVector3 position) {
|
2018-08-12 14:03:07 +00:00
|
|
|
if (position.getX() == bx && position.getZ() == bz) {
|
|
|
|
return biome;
|
|
|
|
}
|
|
|
|
return super.getBiome(position);
|
|
|
|
}
|
2021-07-24 15:34:05 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
}
|