Remove nullblock from EditSession

This commit is contained in:
MattBDev
2019-06-23 14:05:14 -04:00
parent 753b34ef99
commit 57f992a524
14 changed files with 37 additions and 47 deletions

View File

@ -3,7 +3,6 @@ package com.boydti.fawe.object.extent;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.util.WEManager;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -16,6 +15,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Collection;
import javax.annotation.Nullable;
@ -110,14 +110,14 @@ public abstract class FaweRegionExtent extends ResettableExtent {
}
return super.getBiome(position);
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
if (!contains(position)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION);
}
return EditSession.nullBlock.toBaseBlock();
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}
return super.getFullBlock(position);
}
@ -128,7 +128,7 @@ public abstract class FaweRegionExtent extends ResettableExtent {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION);
}
return EditSession.nullBlock;
return BlockTypes.AIR.getDefaultState();
}
return super.getBlock(position);
}
@ -139,7 +139,7 @@ public abstract class FaweRegionExtent extends ResettableExtent {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION);
}
return EditSession.nullBlock;
return BlockTypes.AIR.getDefaultState();
}
return super.getLazyBlock(position);
}
@ -150,7 +150,7 @@ public abstract class FaweRegionExtent extends ResettableExtent {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION);
}
return EditSession.nullBlock;
return BlockTypes.AIR.getDefaultState();
}
return super.getLazyBlock(x, y, z);
}

View File

@ -3,8 +3,6 @@ package com.boydti.fawe.object.extent;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.util.WEManager;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -18,6 +16,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.List;
@ -66,17 +65,17 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
public BlockState getLazyBlock(int x, int y, int z) {
if (!limit.MAX_CHECKS()) {
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
return EditSession.nullBlock;
return BlockTypes.AIR.getDefaultState();
} else {
return extent.getLazyBlock(x, y, z);
}
}
@Override
public BaseBlock getFullBlock(BlockVector3 pos) {
if (!limit.MAX_CHECKS()) {
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
return EditSession.nullBlock.toBaseBlock();
return BlockTypes.AIR.getDefaultState().toBaseBlock();
} else {
return extent.getFullBlock(pos);
}

View File

@ -1,6 +1,5 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
@ -9,11 +8,11 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.registry.BundledBlockData;
import com.sk89q.worldedit.world.block.BlockTypes;
public class TemporalExtent extends AbstractDelegateExtent {
private int x, y, z = Integer.MAX_VALUE;
private BlockStateHolder<?> block = EditSession.nullBlock;
private BlockStateHolder<?> block = BlockTypes.AIR.getDefaultState();
private int bx, bz = Integer.MAX_VALUE;
private BiomeType biome = null;
@ -72,7 +71,7 @@ public class TemporalExtent extends AbstractDelegateExtent {
}
return super.getLazyBlock(x, y, z);
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
if (position.getX() == x && position.getY() == y && position.getZ() == z) {