-
-
Notifications
You must be signed in to change notification settings - Fork 204
/
TemporalExtent.java
81 lines (68 loc) · 2.21 KB
/
TemporalExtent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.fastasyncworldedit.core.extent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
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.BlockTypes;
public abstract class TemporalExtent extends PassthroughExtent {
private int x;
private int y;
private int z = Integer.MAX_VALUE;
private BlockStateHolder<?> block = BlockTypes.AIR.getDefaultState();
private int bx;
private int bz = Integer.MAX_VALUE;
private BiomeType biome = null;
/**
* Create a new instance.
*
* @param extent the extent
*/
public TemporalExtent(Extent extent) {
super(extent);
}
public <B extends BlockStateHolder<B>> void set(int x, int y, int z, B block) {
this.x = x;
this.y = y;
this.z = z;
this.block = block;
}
public void set(int x, int z, BiomeType biome) {
this.bx = x;
this.bz = z;
this.biome = biome;
}
@Override
public BlockState getBlock(BlockVector3 position) {
if (position.getX() == x && position.getY() == y && position.getZ() == z) {
return block.toImmutableState();
}
return super.getBlock(position);
}
@Override
public BlockState getBlock(int x, int y, int z) {
if (this.x == x && this.y == y && this.z == z) {
return block.toImmutableState();
}
return super.getBlock(x, y, z);
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
if (position.getX() == x && position.getY() == y && position.getZ() == z) {
if (block instanceof BaseBlock) {
return (BaseBlock) block;
} else {
return block.toBaseBlock();
}
}
return super.getFullBlock(position);
}
@Override
public BiomeType getBiome(BlockVector3 position) {
if (position.getX() == bx && position.getZ() == bz) {
return biome;
}
return super.getBiome(position);
}
}