mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Attempt to fix concurrency issues
This commit is contained in:
parent
3e60ad21bf
commit
7d56164882
@ -27,13 +27,8 @@ import com.volmit.iris.engine.framework.IrisAccess;
|
|||||||
import com.volmit.iris.engine.parallel.BurstExecutor;
|
import com.volmit.iris.engine.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
|
||||||
import com.volmit.iris.util.format.Form;
|
|
||||||
import com.volmit.iris.util.math.Position2;
|
|
||||||
import com.volmit.iris.util.math.Spiraler;
|
|
||||||
import com.volmit.iris.util.plugin.MortarCommand;
|
import com.volmit.iris.util.plugin.MortarCommand;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -26,6 +26,7 @@ import com.volmit.iris.engine.data.nbt.tag.ListTag;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
|
|
||||||
import static com.volmit.iris.engine.data.mca.LoadFlags.*;
|
import static com.volmit.iris.engine.data.mca.LoadFlags.*;
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ public class Chunk {
|
|||||||
private int[] biomes;
|
private int[] biomes;
|
||||||
private CompoundTag heightMaps;
|
private CompoundTag heightMaps;
|
||||||
private CompoundTag carvingMasks;
|
private CompoundTag carvingMasks;
|
||||||
private final Section[] sections = new Section[16];
|
private final AtomicReferenceArray<Section> sections = new AtomicReferenceArray<>(16);
|
||||||
private ListTag<CompoundTag> entities;
|
private ListTag<CompoundTag> entities;
|
||||||
private ListTag<CompoundTag> tileEntities;
|
private ListTag<CompoundTag> tileEntities;
|
||||||
private ListTag<CompoundTag> tileTicks;
|
private ListTag<CompoundTag> tileTicks;
|
||||||
@ -129,7 +130,7 @@ public class Chunk {
|
|||||||
if (newSection.isEmpty()) {
|
if (newSection.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sections[sectionIndex] = newSection;
|
sections.set(sectionIndex, newSection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +300,7 @@ public class Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) {
|
public CompoundTag getBlockStateAt(int blockX, int blockY, int blockZ) {
|
||||||
Section section = sections[MCAUtil.blockToChunk(blockY)];
|
Section section = sections.get(MCAUtil.blockToChunk(blockY));
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -320,9 +321,10 @@ public class Chunk {
|
|||||||
*/
|
*/
|
||||||
public void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) {
|
public void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) {
|
||||||
int sectionIndex = MCAUtil.blockToChunk(blockY);
|
int sectionIndex = MCAUtil.blockToChunk(blockY);
|
||||||
Section section = sections[sectionIndex];
|
Section section = sections.get(sectionIndex);
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
section = sections[sectionIndex] = Section.newSection();
|
section = Section.newSection();
|
||||||
|
sections.set(sectionIndex, section);
|
||||||
}
|
}
|
||||||
section.setBlockStateAt(blockX, blockY, blockZ, state, cleanup);
|
section.setBlockStateAt(blockX, blockY, blockZ, state, cleanup);
|
||||||
}
|
}
|
||||||
@ -383,7 +385,7 @@ public class Chunk {
|
|||||||
* @return The Section.
|
* @return The Section.
|
||||||
*/
|
*/
|
||||||
public Section getSection(int sectionY) {
|
public Section getSection(int sectionY) {
|
||||||
return sections[sectionY];
|
return sections.get(sectionY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -393,7 +395,7 @@ public class Chunk {
|
|||||||
* @param section The section to be set.
|
* @param section The section to be set.
|
||||||
*/
|
*/
|
||||||
public void setSection(int sectionY, Section section) {
|
public void setSection(int sectionY, Section section) {
|
||||||
sections[sectionY] = section;
|
sections.set(sectionY, section);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -632,7 +634,9 @@ public class Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void cleanupPalettesAndBlockStates() {
|
public void cleanupPalettesAndBlockStates() {
|
||||||
for (Section section : sections) {
|
for (int i = 0; i < sections.length(); i++)
|
||||||
|
{
|
||||||
|
Section section = sections.get(i);
|
||||||
if (section != null) {
|
if (section != null) {
|
||||||
section.cleanupPaletteAndBlockStates();
|
section.cleanupPaletteAndBlockStates();
|
||||||
}
|
}
|
||||||
@ -673,9 +677,9 @@ public class Chunk {
|
|||||||
level.putString("Status", status);
|
level.putString("Status", status);
|
||||||
if (structures != null) level.put("Structures", structures);
|
if (structures != null) level.put("Structures", structures);
|
||||||
ListTag<CompoundTag> sections = new ListTag<>(CompoundTag.class);
|
ListTag<CompoundTag> sections = new ListTag<>(CompoundTag.class);
|
||||||
for (int i = 0; i < this.sections.length; i++) {
|
for (int i = 0; i < this.sections.length(); i++) {
|
||||||
if (this.sections[i] != null) {
|
if (this.sections.get(i) != null) {
|
||||||
sections.add(this.sections[i].updateHandle(i));
|
sections.add(this.sections.get(i).updateHandle(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
level.put("Sections", sections);
|
level.put("Sections", sections);
|
||||||
@ -683,6 +687,6 @@ public class Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int sectionCount() {
|
public int sectionCount() {
|
||||||
return sections.length;
|
return sections.length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,7 @@ public final class MCAUtil {
|
|||||||
if (chunks > 0 && to != file) {
|
if (chunks > 0 && to != file) {
|
||||||
Files.move(to.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.move(to.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user