mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
chore: replace some hardcoded ordinals
This commit is contained in:
parent
46e8a37cf0
commit
e5d27c27bb
@ -11,6 +11,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.BlockTypesCache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
@ -191,8 +192,8 @@ public class CPUOptimizedClipboard extends LinearClipboard {
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int index, B block) {
|
||||
char ordinal = block.getOrdinalChar();
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||
ordinal = BlockTypesCache.ReservedIDs.AIR;
|
||||
}
|
||||
states[index] = ordinal;
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
|
@ -26,6 +26,7 @@ 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 com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -696,8 +697,8 @@ public class DiskOptimizedClipboard extends LinearClipboard {
|
||||
try {
|
||||
int index = headerSize + (getIndex(x, y, z) << 1);
|
||||
char ordinal = block.getOrdinalChar();
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||
ordinal = BlockTypesCache.ReservedIDs.AIR;
|
||||
}
|
||||
byteBuffer.putChar(index, ordinal);
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
|
@ -16,6 +16,7 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
@ -269,8 +270,8 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(int index, B block) {
|
||||
int ordinal = block.getOrdinal();
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||
ordinal = BlockTypesCache.ReservedIDs.AIR;
|
||||
}
|
||||
setOrdinal(index, ordinal);
|
||||
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
|
||||
|
@ -172,8 +172,8 @@ public class FastSchematicWriter implements ClipboardWriter {
|
||||
}
|
||||
|
||||
int ordinal = block.getOrdinal();
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||
ordinal = BlockTypesCache.ReservedIDs.AIR;
|
||||
}
|
||||
char value = palette[ordinal];
|
||||
if (value == Character.MAX_VALUE) {
|
||||
|
@ -41,8 +41,8 @@ public class DistrFilter extends ForkedFilter<DistrFilter> {
|
||||
@Override
|
||||
public final void applyBlock(FilterBlock block) {
|
||||
int ordinal = block.getOrdinal();
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||
ordinal = BlockTypesCache.ReservedIDs.AIR;
|
||||
}
|
||||
counter[ordinal]++;
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ public class HeightmapProcessor implements IBatchProcessor {
|
||||
for (int y = 15; y >= 0; y--) {
|
||||
// We don't need to actually iterate over x and z as we're both reading and writing an index
|
||||
for (int j = 0; j < BLOCKS_PER_Y; j++) {
|
||||
char ordinal = 0;
|
||||
char ordinal = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
if (hasSectionSet) {
|
||||
ordinal = setSection[index(y, j)];
|
||||
}
|
||||
if (ordinal == 0) {
|
||||
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||
if (!hasSectionGet) {
|
||||
if (!hasSectionSet) {
|
||||
continue layer;
|
||||
|
@ -5,6 +5,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
|
||||
public class MutableBiomeChange implements Change {
|
||||
|
||||
@ -13,8 +14,8 @@ public class MutableBiomeChange implements Change {
|
||||
private int to;
|
||||
|
||||
public MutableBiomeChange() {
|
||||
this.from = 0;
|
||||
this.to = 0;
|
||||
this.from = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
this.to = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
|
||||
public void setBiome(int x, int y, int z, int from, int to) {
|
||||
|
@ -6,6 +6,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
|
||||
public class MutableFullBlockChange implements Change {
|
||||
|
||||
@ -39,14 +40,14 @@ public class MutableFullBlockChange implements Change {
|
||||
if (blockBag != null) {
|
||||
BlockState toState = BlockState.getFromOrdinal(to);
|
||||
if (fromState != toState) {
|
||||
if (allowFetch && from != 0) {
|
||||
if (allowFetch && from != BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||
try {
|
||||
blockBag.fetchPlacedBlock(fromState);
|
||||
} catch (BlockBagException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (allowStore && to != 0) {
|
||||
if (allowStore && to != BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||
try {
|
||||
blockBag.storeDroppedBlock(toState);
|
||||
} catch (BlockBagException ignored) {
|
||||
|
@ -186,7 +186,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
}
|
||||
final int combinedFrom = from;
|
||||
final int combinedTo = blocksSet[index];
|
||||
if (combinedTo != 0) {
|
||||
if (combinedTo != BlockTypesCache.ReservedIDs.__RESERVED__) {
|
||||
add(xx, yy, zz, combinedFrom, combinedTo);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
@ -71,7 +72,7 @@ public interface IBatchProcessor {
|
||||
if (arr != null) {
|
||||
int index = (minY & 15) << 8;
|
||||
for (int i = 0; i < index; i++) {
|
||||
arr[i] = 0;
|
||||
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
} else {
|
||||
arr = new char[4096];
|
||||
@ -89,7 +90,7 @@ public interface IBatchProcessor {
|
||||
if (arr != null) {
|
||||
int index = ((maxY + 1) & 15) << 8;
|
||||
for (int i = index; i < arr.length; i++) {
|
||||
arr[i] = 0;
|
||||
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
} else {
|
||||
arr = new char[4096];
|
||||
@ -130,7 +131,7 @@ public interface IBatchProcessor {
|
||||
if (arr != null) {
|
||||
int index = (minY & 15) << 8;
|
||||
for (int i = index; i < 4096; i++) {
|
||||
arr[i] = 0;
|
||||
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
}
|
||||
set.setBlocks(layer, arr);
|
||||
@ -139,7 +140,7 @@ public interface IBatchProcessor {
|
||||
if (arr != null) {
|
||||
int index = ((maxY + 1) & 15) << 8;
|
||||
for (int i = 0; i < index; i++) {
|
||||
arr[i] = 0;
|
||||
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
}
|
||||
set.setBlocks(layer, arr);
|
||||
|
@ -31,6 +31,7 @@ import com.fastasyncworldedit.core.queue.IChunkSet;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -839,14 +840,14 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
for (int z = 0; z < lowerZ; z++) {
|
||||
// null the z values
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
arr[index] = 0;
|
||||
arr[index] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
}
|
||||
index = indexY + upperZi;
|
||||
for (int z = upperZ + 1; z < 16; z++) {
|
||||
// null the z values
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
arr[index] = 0;
|
||||
arr[index] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -855,11 +856,11 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
for (int z = lowerZ; z <= upperZ; z++, index += 16) {
|
||||
for (int x = 0; x < lowerX; x++) {
|
||||
// null the x values
|
||||
arr[index + x] = 0;
|
||||
arr[index + x] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
for (int x = upperX + 1; x < 16; x++) {
|
||||
// null the x values
|
||||
arr[index + x] = 0;
|
||||
arr[index + x] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -925,7 +926,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
for (int z = lowerZ; z <= upperZ; z++) {
|
||||
// null the z values
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
arr[index] = 0;
|
||||
arr[index] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -934,7 +935,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
for (int z = lowerZ; z <= upperZ; z++, index += 16) {
|
||||
for (int x = lowerX; x <= upperX; x++) {
|
||||
// null the x values
|
||||
arr[index + x] = 0;
|
||||
arr[index + x] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
@ -408,8 +409,8 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
||||
for (int y = 0, index = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
if (arr[index] != 0 && !contains(x, y, z)) {
|
||||
arr[index] = 0;
|
||||
if (arr[index] != BlockTypesCache.ReservedIDs.__RESERVED__ && !contains(x, y, z)) {
|
||||
arr[index] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -458,8 +459,8 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
||||
for (int y = 0, index = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
if (arr[index] != 0 && contains(x, y, z)) {
|
||||
arr[index] = 0;
|
||||
if (arr[index] != BlockTypesCache.ReservedIDs.__RESERVED__ && contains(x, y, z)) {
|
||||
arr[index] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||
processExtra = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user