mirror of
https://github.com/GTNewHorizons/Postea.git
synced 2026-11-24 05:54:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
361c851706 | ||
|
|
ebb2517488 | ||
|
|
ff97e8841c | ||
|
|
b60e19b434 |
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.26'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.27'
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,12 @@ import com.gtnewhorizons.postea.utility.ChunkFixerUtility;
|
||||
@Mixin(AnvilChunkLoader.class)
|
||||
public abstract class MixinAnvilChunkLoader {
|
||||
|
||||
@Inject(method = "checkedReadChunkFromNBT__Async", at = @At("HEAD"), remap = false)
|
||||
@Inject(
|
||||
method = "checkedReadChunkFromNBT__Async",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/chunk/storage/AnvilChunkLoader;readChunkFromNBT(Lnet/minecraft/world/World;Lnet/minecraft/nbt/NBTTagCompound;)Lnet/minecraft/world/chunk/Chunk;"),
|
||||
remap = false)
|
||||
private void onCheckedReadChunkFromNBT__Async(World world, int x, int z, NBTTagCompound compound,
|
||||
CallbackInfoReturnable<Object[]> cir) {
|
||||
ChunkFixerUtility.processChunkNBT(compound, world);
|
||||
|
||||
@@ -156,6 +156,17 @@ public class ChunkFixerUtility {
|
||||
int chunkZPos) {
|
||||
byte[] blockArray = section.getByteArray("Blocks16");
|
||||
byte[] metadataArray = section.getByteArray("Data16"); // Updated to use Data16
|
||||
|
||||
// If metadata array is empty, it was all zeroes. We create a new array to write our new values to,
|
||||
// and only save this when a nonzero value was written
|
||||
boolean wasAllZero = false;
|
||||
if (metadataArray.length == 0) {
|
||||
wasAllZero = true;
|
||||
metadataArray = new byte[8192];
|
||||
}
|
||||
// Keep track of if we write a nonzero element to the metadata array
|
||||
boolean hasWrittenNonZero = false;
|
||||
|
||||
byte y = section.getByte("Y");
|
||||
|
||||
List<ConversionInfo> filteredList = filterConversionInfosByY(conversionInfoList, y);
|
||||
@@ -165,6 +176,13 @@ public class ChunkFixerUtility {
|
||||
int index = computeBlockIndex(localCoords);
|
||||
setBlockInfo(info.blockInfo.block, index, blockArray);
|
||||
setMetadata(info.blockInfo.metadata, index, metadataArray); // This uses the updated setMetadata
|
||||
if (info.blockInfo.metadata != 0) hasWrittenNonZero = true;
|
||||
}
|
||||
|
||||
// After processing all replacements, if we made a new metadata array and wrote a nonzero value to it,
|
||||
// write it back to world NBT to save
|
||||
if (wasAllZero && hasWrittenNonZero) {
|
||||
section.setByteArray("Data16", metadataArray);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user