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 | ||
|
|
cb9de2d290 | ||
|
|
ec2b6a9007 | ||
|
|
d9ceee01b5 |
No files matched your search
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
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)
|
@Mixin(AnvilChunkLoader.class)
|
||||||
public abstract class MixinAnvilChunkLoader {
|
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,
|
private void onCheckedReadChunkFromNBT__Async(World world, int x, int z, NBTTagCompound compound,
|
||||||
CallbackInfoReturnable<Object[]> cir) {
|
CallbackInfoReturnable<Object[]> cir) {
|
||||||
ChunkFixerUtility.processChunkNBT(compound, world);
|
ChunkFixerUtility.processChunkNBT(compound, world);
|
||||||
|
|||||||
@@ -60,6 +60,15 @@ public class ChunkFixerUtility {
|
|||||||
// Blocks16 and Data16 exist only because of NEID.
|
// Blocks16 and Data16 exist only because of NEID.
|
||||||
byte[] blockArray = section.getByteArray("Blocks16");
|
byte[] blockArray = section.getByteArray("Blocks16");
|
||||||
byte[] metadataArray = section.getByteArray("Data16");
|
byte[] metadataArray = section.getByteArray("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 sectionY = section.getByte("Y");
|
byte sectionY = section.getByte("Y");
|
||||||
|
|
||||||
@@ -84,6 +93,11 @@ public class ChunkFixerUtility {
|
|||||||
blockConversionInfo.blockName = blockName;
|
blockConversionInfo.blockName = blockName;
|
||||||
blockConversionInfo.blockID = blockId;
|
blockConversionInfo.blockID = blockId;
|
||||||
blockConversionInfo.metadata = (byte) metadata; // Updated
|
blockConversionInfo.metadata = (byte) metadata; // Updated
|
||||||
|
// If we wrote a nonzero metadata, keep track of this because it means the
|
||||||
|
// new array needs to be written back to NBT
|
||||||
|
if (metadata != 0) {
|
||||||
|
hasWrittenNonZero = true;
|
||||||
|
}
|
||||||
blockConversionInfo.world = world;
|
blockConversionInfo.world = world;
|
||||||
|
|
||||||
int x = index % 16;
|
int x = index % 16;
|
||||||
@@ -107,6 +121,12 @@ public class ChunkFixerUtility {
|
|||||||
metadataArray[index * 2 + 1] = (byte) (newMetadata & 0xFF);
|
metadataArray[index * 2 + 1] = (byte) (newMetadata & 0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +156,17 @@ public class ChunkFixerUtility {
|
|||||||
int chunkZPos) {
|
int chunkZPos) {
|
||||||
byte[] blockArray = section.getByteArray("Blocks16");
|
byte[] blockArray = section.getByteArray("Blocks16");
|
||||||
byte[] metadataArray = section.getByteArray("Data16"); // Updated to use Data16
|
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");
|
byte y = section.getByte("Y");
|
||||||
|
|
||||||
List<ConversionInfo> filteredList = filterConversionInfosByY(conversionInfoList, y);
|
List<ConversionInfo> filteredList = filterConversionInfosByY(conversionInfoList, y);
|
||||||
@@ -145,6 +176,13 @@ public class ChunkFixerUtility {
|
|||||||
int index = computeBlockIndex(localCoords);
|
int index = computeBlockIndex(localCoords);
|
||||||
setBlockInfo(info.blockInfo.block, index, blockArray);
|
setBlockInfo(info.blockInfo.block, index, blockArray);
|
||||||
setMetadata(info.blockInfo.metadata, index, metadataArray); // This uses the updated setMetadata
|
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