3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-07 12:00:07 +01:00

Remove nullblock from EditSession

Dieser Commit ist enthalten in:
MattBDev 2019-06-23 14:05:14 -04:00
Ursprung 753b34ef99
Commit 57f992a524
14 geänderte Dateien mit 37 neuen und 47 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.bukkit.listener;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.command.CFICommands;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FawePlayer;
@ -15,30 +14,25 @@ import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.injector.netty.WirePacket;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.WrappedBlockData;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.event.platform.BlockInteractEvent;
import com.sk89q.worldedit.event.platform.Interaction;
import com.sk89q.worldedit.extension.platform.PlatformManager;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -70,7 +64,7 @@ public class CFIPacketListener implements Listener {
Player plr = event.getPlayer();
BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint());
if (!sendBlockChange(plr, gen, pt, Interaction.HIT)) {
gen.setBlock(pt, EditSession.nullBlock);
gen.setBlock(pt, BlockTypes.AIR.getDefaultState());
}
} catch (WorldEditException e) {
e.printStackTrace();

Datei anzeigen

@ -24,6 +24,7 @@ import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.concurrent.ThreadLocalRandom;
@ -69,7 +70,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
if (super.test(vector) && vector.getBlockY() >= minY) {
BaseBlock block = editSession.getFullBlock(vector);
if (!block.getBlockType().getMaterial().isAir()) {
builder.add(vector, EditSession.nullBlock.toBaseBlock(), block);
builder.add(vector, BlockTypes.AIR.getDefaultState().toBaseBlock(), block);
return true;
}
}

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.jnbt.NBTStreamer;
import com.boydti.fawe.object.IntegerTrio;
@ -10,7 +9,6 @@ import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -24,7 +22,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import sun.misc.Unsafe;
import java.io.Closeable;
import java.io.File;
@ -446,7 +443,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
e.printStackTrace();
MainUtil.handleError(e);
}
return EditSession.nullBlock.toBaseBlock();
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}
@Override
@ -485,7 +482,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
} catch (Exception e) {
MainUtil.handleError(e);
}
return EditSession.nullBlock.toBaseBlock();
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}
@Override

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.clipboard;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
@ -15,6 +14,7 @@ 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;
import javax.annotation.Nullable;
import java.util.Collections;
@ -74,12 +74,12 @@ public class EmptyClipboard implements Clipboard {
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
return EditSession.nullBlock.toBaseBlock();
return BlockTypes.AIR.getDefaultState().toBaseBlock();
}
@Override
public BlockState getLazyBlock(BlockVector3 position) {
return EditSession.nullBlock;
return BlockTypes.AIR.getDefaultState();
}
@Override

Datei anzeigen

@ -17,6 +17,7 @@ import com.sk89q.worldedit.math.MutableBlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.ArrayList;
import java.util.List;
@ -149,7 +150,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
}
task.run(xx, yy, zz, block);
} else if (air) {
task.run(xx, yy, zz, EditSession.nullBlock);
task.run(xx, yy, zz, BlockTypes.AIR.getDefaultState());
}
}
}

Datei anzeigen

@ -3,8 +3,8 @@ package com.boydti.fawe.object.clipboard;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BlockTypes;
public class WorldCutClipboard extends WorldCopyClipboard {
public WorldCutClipboard(EditSession editSession, Region region, boolean copyEntities, boolean copyBiome) {
@ -21,13 +21,13 @@ public class WorldCutClipboard extends WorldCopyClipboard {
int yy = my + y;
int zz = mz + z;
BaseBlock block = extent.getFullBlock(BlockVector3.at(xx, yy, zz));
extent.setBlock(xx, yy, zz, EditSession.nullBlock);
extent.setBlock(xx, yy, zz, BlockTypes.AIR.getDefaultState());
return block;
}
public BaseBlock getBlockAbs(int x, int y, int z) {
BaseBlock block = extent.getFullBlock(BlockVector3.at(x, y, z));
extent.setBlock(x, y, z, EditSession.nullBlock);
extent.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
return block;
}
@ -40,4 +40,4 @@ public class WorldCutClipboard extends WorldCopyClipboard {
extent.commit();
}
}
}
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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) {

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.function.pattern.AbstractPattern;
@ -9,7 +8,7 @@ import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.IOException;
@ -59,7 +58,7 @@ public class ExpressionPattern extends AbstractPattern {
return BlockState.getFromInternalId((int) combined).toBaseBlock();
} catch (EvaluationException e) {
e.printStackTrace();
return EditSession.nullBlock.toBaseBlock();
return BlockTypes.AIR.getDefaultState().toBaseBlock();
} catch (Throwable e) {
e.printStackTrace();
throw e;
@ -74,4 +73,4 @@ public class ExpressionPattern extends AbstractPattern {
e.printStackTrace();
}
}
}
}

Datei anzeigen

@ -235,7 +235,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
private final int maxY;
public static final UUID CONSOLE = UUID.fromString("1-1-3-3-7");
public static final BlockState nullBlock = BlockTypes.AIR.getDefaultState();
@Deprecated
public EditSession(@Nonnull World world, @Nullable FaweQueue queue, @Nullable FawePlayer player, @Nullable FaweLimit limit, @Nullable FaweChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) {
@ -2121,7 +2120,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
if (replacement == null) replacement = nullBlock;
if (replacement == null) replacement = BlockTypes.AIR.getDefaultState();
final BlockReplace remove = replacement instanceof ExistingPattern ? null : new BlockReplace(this, replacement);
copy.setCopyBiomes(copyBiomes);

Datei anzeigen

@ -54,7 +54,7 @@ public class RecursivePickaxe implements BlockTool {
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
final int radius = (int) range;
final BlockReplace replace = new BlockReplace(editSession, (editSession.nullBlock));
final BlockReplace replace = new BlockReplace(editSession, (BlockTypes.AIR.getDefaultState()));
editSession.setMask((Mask) null);
RecursiveVisitor visitor = new RecursiveVisitor(new IdMask(editSession), replace, radius, editSession);
visitor.visit(pos);
@ -64,4 +64,4 @@ public class RecursivePickaxe implements BlockTool {
session.remember(editSession);
return true;
}
}
}

Datei anzeigen

@ -26,6 +26,7 @@ import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
public class GravityBrush implements Brush {
@ -52,7 +53,7 @@ public class GravityBrush implements Brush {
BlockStateHolder block = editSession.getLazyBlock(x, y, z);
if (!block.getBlockType().getMaterial().isAir()) {
if (y != freeSpot) {
editSession.setBlock(x, y, z, EditSession.nullBlock);
editSession.setBlock(x, y, z, BlockTypes.AIR.getDefaultState());
editSession.setBlock(x, freeSpot, z, block);
}
freeSpot = y + 1;

Datei anzeigen

@ -201,7 +201,7 @@ public class HeightMap {
// Grow -- start from 1 below top replacing airblocks
for (int setY = newBlock - 1, getY = curBlock; setY >= curBlock; --setY, getY--) {
BlockStateHolder get = session.getBlock(xr, getY, zr);
if (get != EditSession.nullBlock) tmpBlock = get;
if (get != BlockTypes.AIR.getDefaultState()) tmpBlock = get;
session.setBlock(xr, setY, zr, tmpBlock);
++blocksChanged;
}