From d60d178513d4698d45ffd6a205f4c741caa2ed45 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 12 Sep 2021 11:33:44 +0100 Subject: [PATCH] Rename section index to position as it's a more suitable name (cherry picked from commit 74f1d21f6e3db8970763a080529e3fc1f03fdb81) --- .../implementation/blocks/CharBlocks.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharBlocks.java index 53950b614..952a2fb3a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/CharBlocks.java @@ -8,6 +8,8 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypesCache; import org.apache.logging.log4j.Logger; +import javax.annotation.Nullable; + public abstract class CharBlocks implements IBlocks { private static final Logger LOGGER = LogManagerCompat.getLogger(); @@ -65,17 +67,17 @@ public abstract class CharBlocks implements IBlocks { }; public char[][] blocks; public Section[] sections; - protected int minSectionIndex; - protected int maxSectionIndex; + protected int minSectionPosition; + protected int maxSectionPosition; protected int sectionCount; /** * New instance given initial min/max section indices. Can be negative. */ - public CharBlocks(int minSectionIndex, int maxSectionIndex) { - this.minSectionIndex = minSectionIndex; - this.maxSectionIndex = maxSectionIndex; - this.sectionCount = maxSectionIndex - minSectionIndex + 1; + public CharBlocks(int minSectionPosition, int maxSectionPosition) { + this.minSectionPosition = minSectionPosition; + this.maxSectionPosition = maxSectionPosition; + this.sectionCount = maxSectionPosition - minSectionPosition + 1; blocks = new char[sectionCount][]; sections = new Section[sectionCount]; for (int i = 0; i < sectionCount; i++) { @@ -116,7 +118,7 @@ public abstract class CharBlocks implements IBlocks { } public synchronized void reset(int layer) { - layer -= minSectionIndex; + layer -= minSectionPosition; sections[layer] = empty; } @@ -133,13 +135,13 @@ public abstract class CharBlocks implements IBlocks { // Not synchronized as any subsequent methods called from this class will be, or the section shouldn't appear as loaded anyway. @Override public boolean hasSection(int layer) { - layer -= minSectionIndex; + layer -= minSectionPosition; return layer >= 0 && layer < sections.length && sections[layer].isFull(); } @Override public char[] load(int layer) { - layer -= minSectionIndex; + layer -= minSectionPosition; synchronized (sections[layer]) { return sections[layer].get(this, layer); } @@ -153,7 +155,7 @@ public abstract class CharBlocks implements IBlocks { public char get(int x, int y, int z) { int layer = y >> 4; final int index = (y & 15) << 8 | z << 4 | x; - if (layer > maxSectionIndex || layer < minSectionIndex) { + if (layer > maxSectionPosition || layer < minSectionPosition) { return 0; } return get(layer, index); @@ -177,13 +179,13 @@ public abstract class CharBlocks implements IBlocks { */ public final char get(int layer, int index) { - layer -= minSectionIndex; + layer -= minSectionPosition; return sections[layer].get(this, layer, index); } public synchronized final void set(int layer, int index, char value) throws ArrayIndexOutOfBoundsException { - layer -= minSectionIndex; + layer -= minSectionPosition; sections[layer].set(this, layer, index, value); }