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

88 lines
2.6 KiB
Java
Raw Normal View History

package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.extent.PassthroughExtent;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
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-04-03 05:53:58 +00:00
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
2019-06-23 18:05:14 +00:00
import com.sk89q.worldedit.world.block.BlockTypes;
public class TemporalExtent extends PassthroughExtent {
private int x, y, z = Integer.MAX_VALUE;
2019-06-23 18:05:14 +00:00
private BlockStateHolder<?> block = BlockTypes.AIR.getDefaultState();
private int bx, bz = Integer.MAX_VALUE;
2019-04-03 05:53:58 +00:00
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;
}
2019-04-03 05:53:58 +00:00
public void set(int x, int z, BiomeType biome) {
this.bx = x;
this.bz = z;
this.biome = biome;
}
@Override
public int getBrightness(int x, int y, int z) {
if (this.x == x && this.y == y && this.z == z) {
return Math.min(15, block.getBlockType().getMaterial().getLightValue());
}
return super.getBrightness(x, y, z);
}
@Override
2018-12-23 16:19:33 +00:00
public BlockState getBlock(BlockVector3 position) {
if (position.getX() == x && position.getY() == y && position.getZ() == z) {
return block.toImmutableState();
}
return super.getBlock(position);
}
@Override
2019-05-28 20:31:22 +00:00
public BlockState getBlock(int x, int y, int z) {
if (this.x == x && this.y == y && this.z == z) {
return block.toImmutableState();
}
2019-05-28 20:31:22 +00:00
return super.getBlock(x, y, z);
}
2019-06-23 18:05:14 +00:00
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
if (position.getX() == x && position.getY() == y && position.getZ() == z) {
if(block instanceof BaseBlock) {
2019-07-22 20:42:40 +00:00
return (BaseBlock)block;
}else {
2019-07-22 20:42:40 +00:00
return block.toBaseBlock();
}
}
return super.getFullBlock(position);
}
@Override
2019-04-03 05:53:58 +00:00
public BiomeType getBiome(BlockVector2 position) {
if (position.getX() == bx && position.getZ() == bz) {
return biome;
}
return super.getBiome(position);
}
}