chore: remove deprecated Chunk#getPosition(Vector3i) (#4888)

Co-authored-by: jdrueckert <jd.rueckert@googlemail.com>
Co-authored-by: Kevin Turner <83819+keturn@users.noreply.github.com>
develop
Michael Pollind 2022-01-07 09:42:49 -08:00 committed by GitHub
parent ef3f47b7ae
commit b27c8e274d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 103 additions and 111 deletions

View File

@ -61,7 +61,7 @@ class ChunkProcessingPipelineTest extends TerasologyTestingEnvironment {
Future<Chunk> chunkFuture = pipeline.invokeGeneratorTask(new Vector3i(0, 0, 0), () -> chunk);
Chunk chunkAfterProcessing = chunkFuture.get(1, TimeUnit.SECONDS);
Assertions.assertEquals(chunkAfterProcessing.getPosition(new Vector3i()), chunk.getPosition(new Vector3i()),
Assertions.assertEquals(chunkAfterProcessing.getPosition(), chunk.getPosition(),
"Chunk after processing must have equals position, probably pipeline lost you chunk");
}
@ -102,7 +102,7 @@ class ChunkProcessingPipelineTest extends TerasologyTestingEnvironment {
.filter((p) -> !p.equals(positionToGenerate)) //remove central chunk.
.map(this::createChunkAt)
.collect(Collectors.toMap(
(chunk) -> chunk.getPosition(new Vector3i()),
ChunkImpl::getPosition,
Function.identity()
));
@ -119,7 +119,7 @@ class ChunkProcessingPipelineTest extends TerasologyTestingEnvironment {
Future<Chunk> chunkFuture = pipeline.invokeGeneratorTask(new Vector3i(0, 0, 0), () -> chunk);
Chunk chunkAfterProcessing = chunkFuture.get(1, TimeUnit.SECONDS);
Assertions.assertEquals(chunkAfterProcessing.getPosition(new Vector3i()), chunk.getPosition(new Vector3i()),
Assertions.assertEquals(chunkAfterProcessing.getPosition(), chunk.getPosition(),
"Chunk after processing must have equals position, probably pipeline lost you chunk");
}
@ -130,13 +130,13 @@ class ChunkProcessingPipelineTest extends TerasologyTestingEnvironment {
void multiRequirementsChunksWillGeneratedSuccess() throws ExecutionException, InterruptedException,
TimeoutException {
Vector3i positionToGenerate = new Vector3i(0, 0, 0);
Map<Vector3i, Chunk> chunkToGenerate =
Map<Vector3ic, Chunk> chunkToGenerate =
getNearChunkPositions(positionToGenerate)
.stream()
.filter((p) -> !p.equals(positionToGenerate)) //remove central chunk.
.map(this::createChunkAt)
.collect(Collectors.toMap(
(chunk) -> chunk.getPosition(new Vector3i()),
ChunkImpl::getPosition,
Function.identity()
));
@ -160,7 +160,7 @@ class ChunkProcessingPipelineTest extends TerasologyTestingEnvironment {
Chunk chunkAfterProcessing = chunkFuture.get(1, TimeUnit.SECONDS);
Assertions.assertEquals(chunkAfterProcessing.getPosition(new Vector3i()), chunk.getPosition(new Vector3i()),
Assertions.assertEquals(chunkAfterProcessing.getPosition(), chunk.getPosition(),
"Chunk after processing must have equals position, probably pipeline lost you chunk");
}
@ -181,16 +181,16 @@ class ChunkProcessingPipelineTest extends TerasologyTestingEnvironment {
"flat merging task",
(chunks) -> chunks.stream()
.sorted((o1, o2) -> {
Function<Chunk, Vector3i> pos = (c) -> c.getPosition(new Vector3i());
return Comparator.comparing(pos.andThen(Vector3i::x))
.thenComparing(pos.andThen(Vector3i::y))
.thenComparing(pos.andThen(Vector3i::z))
Function<Chunk, Vector3ic> pos = Chunk::getPosition;
return Comparator.comparing(pos.andThen(Vector3ic::x))
.thenComparing(pos.andThen(Vector3ic::y))
.thenComparing(pos.andThen(Vector3ic::z))
.compare(o1, o2);
}).toArray(Chunk[]::new)[5],
this::getNearChunkPositions));
pipeline.addStage(ChunkTaskProvider.create("finish chunk", (c) -> {
c.markReady();
chunkCache.put(c.getPosition(new Vector3i()), c);
chunkCache.put(c.getPosition(), c);
}));

View File

@ -190,12 +190,12 @@ public class BetweenChunkPropagationTest extends TerasologyTestingEnvironment {
SelectChunkProvider(Chunk... chunks) {
for (Chunk chunk : chunks) {
this.chunks.put(chunk.getPosition(new Vector3i()), chunk);
this.chunks.put(chunk.getPosition(), chunk);
}
}
public void addChunk(Chunk chunk) {
chunks.put(chunk.getPosition(new Vector3i()), chunk);
chunks.put(chunk.getPosition(), chunk);
}
@Override

View File

@ -3,7 +3,7 @@
package org.terasology.fixtures;
import org.joml.Vector3i;
import org.joml.Vector3ic;
import org.terasology.engine.persistence.ChunkStore;
import org.terasology.engine.world.chunks.Chunk;
@ -18,8 +18,8 @@ public class TestChunkStore implements ChunkStore {
}
@Override
public Vector3i getChunkPosition() {
return chunk.getPosition(new Vector3i());
public Vector3ic getChunkPosition() {
return chunk.getPosition();
}
@Override

View File

@ -3,7 +3,6 @@
package org.terasology.fixtures;
import org.joml.Vector3i;
import org.joml.Vector3ic;
import org.terasology.engine.network.Client;
import org.terasology.engine.persistence.ChunkStore;
@ -33,7 +32,7 @@ public class TestStorageManager implements StorageManager {
}
public void add(Chunk chunk) {
chunkStores.put(chunk.getPosition(new Vector3i()), new TestChunkStore(chunk));
chunkStores.put(chunk.getPosition(), new TestChunkStore(chunk));
}
@Override

View File

@ -198,7 +198,7 @@ public class HeadlessWorldRenderer implements WorldRenderer {
chunksInProximity.clear();
for (Vector3ic chunkPosition : viewRegion) {
Chunk c = chunkProvider.getChunk(chunkPosition);
if (c != null && worldProvider.getLocalView(c.getPosition(new Vector3i())) != null) {
if (c != null && worldProvider.getLocalView(c.getPosition()) != null) {
chunksInProximity.add(c);
} else {
chunksCurrentlyPending = true;
@ -222,7 +222,7 @@ public class HeadlessWorldRenderer implements WorldRenderer {
// add
for (Vector3ic chunkPosition : viewRegion) {
Chunk c = chunkProvider.getChunk(chunkPosition);
if (c != null && worldProvider.getLocalView(c.getPosition(new Vector3i())) != null) {
if (c != null && worldProvider.getLocalView(c.getPosition()) != null) {
chunksInProximity.add(c);
} else {
chunksCurrentlyPending = true;

View File

@ -46,7 +46,7 @@ public final class SectorUtil {
*/
public static void addChunksToRegionComponent(SectorRegionComponent regionComponent, Collection<Chunk> chunks) {
regionComponent.chunks.addAll(chunks.stream()
.map(k -> k.getPosition(new Vector3i()))
.map(k -> new Vector3i(k.getPosition()))
.collect(Collectors.toSet()));
}

View File

@ -5,7 +5,7 @@ package org.terasology.engine.monitoring.chunk;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.common.eventbus.EventBus;
import org.joml.Vector3i;
import org.joml.Vector3ic;
import org.terasology.engine.rendering.primitives.ChunkMesh;
import org.terasology.engine.world.chunks.Chunk;
import org.terasology.engine.world.chunks.ChunkProvider;
@ -16,7 +16,7 @@ import java.util.Map;
public final class ChunkMonitor {
private static final EventBus EVENT_BUS = new EventBus("ChunkMonitor");
private static final Map<Vector3i, ChunkMonitorEntry> CHUNKS = Maps.newConcurrentMap();
private static final Map<Vector3ic, ChunkMonitorEntry> CHUNKS = Maps.newConcurrentMap();
private ChunkMonitor() {
}
@ -27,7 +27,7 @@ public final class ChunkMonitor {
private static synchronized ChunkMonitorEntry registerChunk(Chunk chunk) {
Preconditions.checkNotNull(chunk, "The parameter 'chunk' must not be null");
final Vector3i pos = chunk.getPosition(new Vector3i());
final Vector3ic pos = chunk.getPosition();
ChunkMonitorEntry entry = CHUNKS.get(pos);
if (entry == null) {
entry = new ChunkMonitorEntry(pos);
@ -54,29 +54,27 @@ public final class ChunkMonitor {
public static void fireChunkCreated(Chunk chunk) {
Preconditions.checkNotNull(chunk, "The parameter 'chunk' must not be null");
final ChunkMonitorEntry entry = registerChunk(chunk);
if (entry != null) {
post(new ChunkMonitorEvent.Created(entry));
}
post(new ChunkMonitorEvent.Created(entry));
}
public static void fireChunkDisposed(Chunk chunk) {
Preconditions.checkNotNull(chunk, "The parameter 'chunk' must not be null");
post(new ChunkMonitorEvent.Disposed(chunk.getPosition(new Vector3i())));
post(new ChunkMonitorEvent.Disposed(chunk.getPosition()));
}
public static void fireChunkRevived(Chunk chunk) {
Preconditions.checkNotNull(chunk, "The parameter 'chunk' must not be null");
post(new ChunkMonitorEvent.Revived(chunk.getPosition(new Vector3i())));
post(new ChunkMonitorEvent.Revived(chunk.getPosition()));
}
public static void fireChunkDeflated(Chunk chunk, int oldSize, int newSize) {
Preconditions.checkNotNull(chunk, "The parameter 'chunk' must not be null");
post(new ChunkMonitorEvent.Deflated(chunk.getPosition(new Vector3i()), oldSize, newSize));
post(new ChunkMonitorEvent.Deflated(chunk.getPosition(), oldSize, newSize));
}
public static void fireChunkTessellated(Vector3i chunkPos, ChunkMesh mesh) {
Preconditions.checkNotNull(chunkPos, "The parameter 'chunkPos' must not be null");
post(new ChunkMonitorEvent.Tessellated(chunkPos, mesh));
public static void fireChunkTessellated(Chunk chunk, ChunkMesh mesh) {
Preconditions.checkNotNull(chunk, "The parameter 'chunkPos' must not be null");
post(new ChunkMonitorEvent.Tessellated(chunk.getPosition(), mesh));
}
public static synchronized void getChunks(List<ChunkMonitorEntry> output) {

View File

@ -4,19 +4,19 @@ package org.terasology.engine.monitoring.chunk;
import com.google.common.base.Preconditions;
import org.joml.Vector3i;
import org.joml.Vector3ic;
import org.terasology.engine.world.chunks.Chunk;
import java.lang.ref.WeakReference;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
public class ChunkMonitorEntry {
private final Vector3i pos;
private final Vector3ic pos;
private Deque<WeakReference<Chunk>> chunks = new LinkedList<>();
public ChunkMonitorEntry(Vector3i pos) {
public ChunkMonitorEntry(Vector3ic pos) {
this.pos = Preconditions.checkNotNull(pos, "The parameter 'pos' must not be null");
}
@ -24,17 +24,11 @@ public class ChunkMonitorEntry {
if (chunks.size() == 0) {
return;
}
final Iterator<WeakReference<Chunk>> it = chunks.iterator();
while (it.hasNext()) {
final WeakReference<Chunk> w = it.next();
if (w.get() == null) {
it.remove();
}
}
chunks.removeIf(w -> w.get() == null);
}
public Vector3i getPosition() {
return new Vector3i(pos);
public Vector3ic getPosition() {
return pos;
}
public Chunk getLatestChunk() {
@ -47,7 +41,7 @@ public class ChunkMonitorEntry {
public void addChunk(Chunk value) {
Preconditions.checkNotNull(value, "The parameter 'value' must not be null");
Preconditions.checkArgument(pos.equals(value.getPosition(new Vector3i())),
Preconditions.checkArgument(pos.equals(value.getPosition()),
"Expected chunk for position {} but got position {} instead", pos, value.getPosition(new Vector3i()));
purge();
chunks.add(new WeakReference<>(value));

View File

@ -3,7 +3,7 @@
package org.terasology.engine.monitoring.chunk;
import com.google.common.base.Preconditions;
import org.joml.Vector3i;
import org.joml.Vector3ic;
import org.terasology.engine.rendering.primitives.ChunkMesh;
import org.terasology.engine.world.chunks.ChunkProvider;
@ -31,14 +31,14 @@ public abstract class ChunkMonitorEvent {
public static class BasicChunkEvent extends ChunkMonitorEvent {
protected final Vector3i position;
protected final Vector3ic position;
public BasicChunkEvent(Vector3i position) {
public BasicChunkEvent(Vector3ic position) {
Preconditions.checkNotNull(position, "The parameter 'chunk' must not be null");
this.position = position;
}
public final Vector3i getPosition() {
public final Vector3ic getPosition() {
return position;
}
}
@ -58,13 +58,13 @@ public abstract class ChunkMonitorEvent {
}
public static class Revived extends BasicChunkEvent {
public Revived(Vector3i position) {
public Revived(Vector3ic position) {
super(position);
}
}
public static class Disposed extends BasicChunkEvent {
public Disposed(Vector3i position) {
public Disposed(Vector3ic position) {
super(position);
}
}
@ -74,7 +74,7 @@ public abstract class ChunkMonitorEvent {
public final int oldSize;
public final int newSize;
public Deflated(Vector3i position, int oldSize, int newSize) {
public Deflated(Vector3ic position, int oldSize, int newSize) {
super(position);
this.oldSize = oldSize;
this.newSize = newSize;
@ -85,7 +85,7 @@ public abstract class ChunkMonitorEvent {
public final ChunkMeshInfo meshInfo;
public Tessellated(Vector3i position, ChunkMesh mesh) {
public Tessellated(Vector3ic position, ChunkMesh mesh) {
super(position);
this.meshInfo = new ChunkMeshInfo(mesh);
}

View File

@ -9,6 +9,7 @@ import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import org.joml.Vector3f;
import org.joml.Vector3i;
import org.joml.Vector3ic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.engine.logic.players.LocalPlayer;
@ -60,7 +61,7 @@ public class ChunkMonitorDisplay extends JPanel {
private final EventBus eventbus = new EventBus("ChunkMonitorDisplay");
private final List<ChunkMonitorEntry> chunks = Lists.newArrayList();
private final Map<Vector3i, ChunkMonitorEntry> map = Maps.newHashMap();
private final Map<Vector3ic, ChunkMonitorEntry> map = Maps.newHashMap();
private final ImageBuffer image = new ImageBuffer();
private int refreshInterval;
@ -128,12 +129,12 @@ public class ChunkMonitorDisplay extends JPanel {
int max = 0;
int y = renderY;
for (ChunkMonitorEntry chunk : chunks) {
final Vector3i pos = chunk.getPosition();
if (pos.y < min) {
min = pos.y;
final Vector3ic pos = chunk.getPosition();
if (pos.y() < min) {
min = pos.y();
}
if (pos.y > max) {
max = pos.y;
if (pos.y() > max) {
max = pos.y();
}
}
if (y < min) {
@ -456,16 +457,16 @@ public class ChunkMonitorDisplay extends JPanel {
recomputeRenderY();
} else if (event instanceof ChunkMonitorEvent.BasicChunkEvent) {
final ChunkMonitorEvent.BasicChunkEvent bEvent = (ChunkMonitorEvent.BasicChunkEvent) event;
final Vector3i pos = bEvent.getPosition();
final Vector3ic pos = bEvent.getPosition();
final ChunkMonitorEntry entry;
if (event instanceof ChunkMonitorEvent.Created) {
final ChunkMonitorEvent.Created cEvent = (ChunkMonitorEvent.Created) event;
entry = cEvent.getEntry();
if (pos.y < minRenderY) {
minRenderY = pos.y;
if (pos.y() < minRenderY) {
minRenderY = pos.y();
}
if (pos.y > maxRenderY) {
maxRenderY = pos.y;
if (pos.y() > maxRenderY) {
maxRenderY = pos.y();
}
chunks.add(entry);
map.put(pos, entry);
@ -581,21 +582,21 @@ public class ChunkMonitorDisplay extends JPanel {
int ymin = Integer.MAX_VALUE;
int ymax = Integer.MIN_VALUE;
for (ChunkMonitorEntry entry : chunkEntries) {
final Vector3i pos = entry.getPosition();
if (pos.y != renderY) {
final Vector3ic pos = entry.getPosition();
if (pos.y() != renderY) {
continue;
}
if (pos.x < xmin) {
xmin = pos.x;
if (pos.x() < xmin) {
xmin = pos.x();
}
if (pos.x > xmax) {
xmax = pos.x;
if (pos.x() > xmax) {
xmax = pos.x();
}
if (pos.z < ymin) {
ymin = pos.z;
if (pos.z() < ymin) {
ymin = pos.z();
}
if (pos.z > ymax) {
ymax = pos.z;
if (pos.z() > ymax) {
ymax = pos.z();
}
}
return new Rectangle(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1);
@ -638,13 +639,13 @@ public class ChunkMonitorDisplay extends JPanel {
}
private void renderChunks(Graphics2D g, int offsetx, int offsety, List<ChunkMonitorEntry> chunkEntries) {
chunkEntries.stream().filter(entry -> entry.getPosition().y == renderY).forEach(entry ->
chunkEntries.stream().filter(entry -> entry.getPosition().y() == renderY).forEach(entry ->
renderChunk(g, offsetx, offsety, entry.getPosition(), entry));
}
private void renderChunk(Graphics2D g, int offsetx, int offsety, Vector3i pos, ChunkMonitorEntry entry) {
private void renderChunk(Graphics2D g, int offsetx, int offsety, Vector3ic pos, ChunkMonitorEntry entry) {
g.setColor(calcChunkColor(entry));
g.fillRect(pos.x * chunkSize + offsetx + 1, pos.z * chunkSize + offsety + 1, chunkSize - 2, chunkSize - 2);
g.fillRect(pos.x() * chunkSize + offsetx + 1, pos.z() * chunkSize + offsety + 1, chunkSize - 2, chunkSize - 2);
}
private void render(Graphics2D g, int offsetx, int offsety, int width, int height, List<ChunkMonitorEntry> chunkEntries) {

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.persistence;
import org.joml.Vector3i;
import org.joml.Vector3ic;
import org.terasology.engine.world.chunks.Chunk;
/**
@ -14,7 +14,7 @@ public interface ChunkStore {
/**
* @return The position of the chunk in its world
*/
Vector3i getChunkPosition();
Vector3ic getChunkPosition();
/**
* @return The chunk itself

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.persistence.internal;
import org.joml.Vector3ic;
import org.terasology.engine.entitySystem.entity.internal.EngineEntityManager;
import org.joml.Vector3i;
import org.terasology.engine.persistence.ChunkStore;
@ -13,11 +14,11 @@ import org.terasology.engine.world.chunks.internal.ChunkSerializer;
final class ChunkStoreInternal implements ChunkStore {
private Vector3i chunkPosition;
private Chunk chunk;
private final Vector3i chunkPosition;
private final Chunk chunk;
private EngineEntityManager entityManager;
private EntityData.EntityStore entityStore;
private final EngineEntityManager entityManager;
private final EntityData.EntityStore entityStore;
ChunkStoreInternal(EntityData.ChunkStore chunkData, EngineEntityManager entityManager,
BlockManager blockManager, ExtraBlockDataManager extraDataManager) {
@ -29,8 +30,8 @@ final class ChunkStoreInternal implements ChunkStore {
}
@Override
public Vector3i getChunkPosition() {
return new Vector3i(chunkPosition);
public Vector3ic getChunkPosition() {
return chunkPosition;
}
@Override

View File

@ -5,7 +5,6 @@ package org.terasology.engine.persistence.internal;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.joml.Vector3f;
import org.joml.Vector3i;
import org.joml.Vector3ic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -224,7 +223,7 @@ public final class ReadWriteStorageManager extends AbstractStorageManager
chunkProvider.getAllChunks().stream().filter(Chunk::isReady).forEach(chunk -> {
// If there is a newer undisposed version of the chunk,we don't need to save the disposed version:
unloadedAndSavingChunkMap.remove(chunk.getPosition(new Vector3i()));
unloadedAndSavingChunkMap.remove(chunk.getPosition());
ChunkImpl chunkImpl = (ChunkImpl) chunk; // this storage manager can only work with ChunkImpls
saveTransactionBuilder.addLoadedChunk(chunk.getPosition(), chunkImpl);
});
@ -321,7 +320,7 @@ public final class ReadWriteStorageManager extends AbstractStorageManager
public void deactivateChunk(Chunk chunk) {
Collection<EntityRef> entitiesOfChunk = getEntitiesOfChunk(chunk);
ChunkImpl chunkImpl = (ChunkImpl) chunk; // storage manager only works with ChunkImpl
unloadedAndUnsavedChunkMap.put(chunk.getPosition(new Vector3i()), new CompressedChunkBuilder(getEntityManager(), chunkImpl,
unloadedAndUnsavedChunkMap.put(chunk.getPosition(), new CompressedChunkBuilder(getEntityManager(), chunkImpl,
entitiesOfChunk, true));
entitiesOfChunk.forEach(this::deactivateOrDestroyEntityRecursive);

View File

@ -145,7 +145,7 @@ public final class ChunkMeshUpdateManager {
@Override
public void run() {
ChunkMesh newMesh;
ChunkView chunkView = worldProvider.getLocalView(c.getPosition(new Vector3i()));
ChunkView chunkView = worldProvider.getLocalView(c.getPosition());
if (chunkView != null) {
/*
* Important set dirty flag first, so that a concurrent modification of the chunk in the mean time we
@ -156,7 +156,7 @@ public final class ChunkMeshUpdateManager {
newMesh = tessellator.generateMesh(chunkView);
c.setPendingMesh(newMesh);
ChunkMonitor.fireChunkTessellated(c.getPosition(new Vector3i()), newMesh);
ChunkMonitor.fireChunkTessellated(c, newMesh);
}
}

View File

@ -97,7 +97,7 @@ public class LodChunkProvider {
InternalLightProcessor.generateInternalLighting(chunk, 1 << scale);
//tintChunk(chunk);
ChunkView view = new ChunkViewCoreImpl(new Chunk[]{chunk},
new BlockRegion(chunk.getPosition(new Vector3i())), new Vector3i(), unloaded);
new BlockRegion(chunk.getPosition()), new Vector3i(), unloaded);
ChunkMesh mesh = tessellator.generateMesh(view, 1 << scale, 1);
readyChunks.add(new LodChunk(pos, mesh, scale));
}

View File

@ -43,7 +43,7 @@ public class ChunkImpl implements Chunk {
private static final DecimalFormat PERCENT_FORMAT = new DecimalFormat("0.##");
private static final DecimalFormat SIZE_FORMAT = new DecimalFormat("#,###");
protected final Vector3i chunkPos = new Vector3i();
protected final Vector3ic chunkPos;
protected BlockRegion region;
private BlockManager blockManager;
@ -80,7 +80,7 @@ public class ChunkImpl implements Chunk {
}
public ChunkImpl(Vector3ic chunkPos, TeraArray blocks, TeraArray[] extra, BlockManager blockManager) {
this.chunkPos.set(Preconditions.checkNotNull(chunkPos));
this.chunkPos = new Vector3i(Preconditions.checkNotNull(chunkPos));
this.blockData = Preconditions.checkNotNull(blocks);
this.extraData = Preconditions.checkNotNull(extra);
sunlightData = new TeraSparseArray8Bit(getChunkSizeX(), getChunkSizeY(), getChunkSizeZ());
@ -103,7 +103,7 @@ public class ChunkImpl implements Chunk {
@Override
public Vector3i getPosition(Vector3i dest) {
return dest.set(chunkPos.x, chunkPos.y, chunkPos.z);
return dest.set(chunkPos.x(), chunkPos.y(), chunkPos.z());
}
@Override
@ -252,17 +252,17 @@ public class ChunkImpl implements Chunk {
@Override
public int getChunkWorldOffsetX() {
return chunkPos.x * getChunkSizeX();
return chunkPos.x() * getChunkSizeX();
}
@Override
public int getChunkWorldOffsetY() {
return chunkPos.y * getChunkSizeY();
return chunkPos.y() * getChunkSizeY();
}
@Override
public int getChunkWorldOffsetZ() {
return chunkPos.z * getChunkSizeZ();
return chunkPos.z() * getChunkSizeZ();
}
@Override

View File

@ -128,7 +128,7 @@ public class ChunkRelevanceRegion {
private void sendChunkRelevant(Chunk chunk) {
if (listener != null) {
listener.onChunkRelevant(chunk.getPosition(new Vector3i()), chunk);
listener.onChunkRelevant(chunk.getPosition(), chunk);
}
}
@ -166,8 +166,8 @@ public class ChunkRelevanceRegion {
* chunks as relevant even when no light calculation has been performed yet.
*/
public void checkIfChunkIsRelevant(Chunk chunk) {
if (currentRegion.contains(chunk.getPosition(new Vector3i())) && !relevantChunks.contains(chunk.getPosition(new Vector3i()))) {
relevantChunks.add(chunk.getPosition(new Vector3i()));
if (currentRegion.contains(chunk.getPosition()) && !relevantChunks.contains(chunk.getPosition())) {
relevantChunks.add(chunk.getPosition());
sendChunkRelevant(chunk);
}
}

View File

@ -22,16 +22,16 @@ public class PreLodChunk extends ChunkImpl {
@Override
public int getChunkWorldOffsetX() {
return chunkPos.x * (Chunks.SIZE_X - 2) - 1;
return chunkPos.x() * (Chunks.SIZE_X - 2) - 1;
}
@Override
public int getChunkWorldOffsetY() {
return chunkPos.y * (Chunks.SIZE_Y - 4) - 2;
return chunkPos.y() * (Chunks.SIZE_Y - 4) - 2;
}
@Override
public int getChunkWorldOffsetZ() {
return chunkPos.z * (Chunks.SIZE_Z - 2) - 1;
return chunkPos.z() * (Chunks.SIZE_Z - 2) - 1;
}
}

View File

@ -126,7 +126,7 @@ public class LocalChunkProvider implements ChunkProvider {
if (chunkStore == null) {
chunk = new ChunkImpl(pos, blockManager, extraDataManager);
generator.createChunk(chunk, buffer);
generateQueuedEntities.put(chunk.getPosition(new Vector3i()), buffer.getAll());
generateQueuedEntities.put(chunk.getPosition(), buffer.getAll());
} else {
chunk = chunkStore.getChunk();
}
@ -390,7 +390,7 @@ public class LocalChunkProvider implements ChunkProvider {
loadingPipeline.shutdown();
unloadRequestTaskMaster.shutdown(new ChunkUnloadRequest(), true);
getAllChunks().stream().filter(Chunk::isReady).forEach(chunk -> {
worldEntity.send(new BeforeChunkUnload(chunk.getPosition(new Vector3i())));
worldEntity.send(new BeforeChunkUnload(chunk.getPosition()));
storageManager.deactivateChunk(chunk);
chunk.dispose();
});

View File

@ -99,15 +99,15 @@ public class RemoteChunkProvider implements ChunkProvider {
}
Chunk chunk;
while ((chunk = readyChunks.poll()) != null) {
Chunk oldChunk = chunkCache.put(chunk.getPosition(new Vector3i()), chunk);
Chunk oldChunk = chunkCache.put(chunk.getPosition(), chunk);
if (oldChunk != null) {
oldChunk.dispose();
}
chunk.markReady();
if (listener != null) {
listener.onChunkReady(chunk.getPosition(new Vector3i()));
listener.onChunkReady(chunk.getPosition());
}
worldEntity.send(new OnChunkLoaded(chunk.getPosition(new Vector3i())));
worldEntity.send(new OnChunkLoaded(chunk.getPosition()));
}
}

View File

@ -16,12 +16,12 @@ public class LocalChunkView implements PropagatorWorldView {
private PropagationRules rules;
private Chunk[] chunks;
private final Vector3i topLeft;
private final Vector3i topLeft = new Vector3i();
public LocalChunkView(Chunk[] chunks, PropagationRules rules) {
this.chunks = chunks;
this.rules = rules;
topLeft = chunks[0].getPosition(new Vector3i());
topLeft.set(chunks[0].getPosition());
}
/**