fix: add palette tag during schematic serialization

This commit is contained in:
LordMZTE 2024-07-20 15:17:06 +02:00
parent 7c61acbf01
commit f28ad3c1ec
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
3 changed files with 13 additions and 3 deletions

6
.gitignore vendored
View file

@ -5,4 +5,8 @@ build/
*.ipr
*.iws
forge-*-changelog.txt
out/
out/
bin/
.classpath
.project
.settings

View file

@ -27,8 +27,8 @@ minecraft {
runDir = "eclipse"
}
targetCompatibility = '1.6'
sourceCompatibility = '1.6'
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
processResources
{

View file

@ -5,6 +5,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@ -331,6 +332,11 @@ public class Schematic {
short[] blockIds = new short[blocks.length];
reduceToPalette(blocks, blockPalette, blockIds);
NBTTagList paletteNBT = new NBTTagList();
blockPalette.stream().map(NBTTagString::new).forEach(paletteNBT::appendTag);
schematicTag.setTag("Palette", paletteNBT);
byte[] lowBits = new byte[blocks.length];
byte[] highBits = new byte[(blocks.length >> 1) + (blocks.length & 1)];
boolean hasExtendedIDs = encodeBlockIDs(blockIds, lowBits, highBits);