diff --git a/gradle.properties b/gradle.properties index 98df268b..290c99e7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ loader_version = 0.10.1+build.209 # Mod Properties - mod_version = 0.3.2-alpha + mod_version = 0.4.0-alpha maven_group = ru.betterend archives_base_name = better-end diff --git a/src/main/java/ru/betterend/world/structures/StructureWorld.java b/src/main/java/ru/betterend/world/structures/StructureWorld.java index 9cd507ae..73521d7c 100644 --- a/src/main/java/ru/betterend/world/structures/StructureWorld.java +++ b/src/main/java/ru/betterend/world/structures/StructureWorld.java @@ -4,7 +4,6 @@ import java.util.Map; import com.google.common.collect.Maps; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -112,10 +111,16 @@ public class StructureWorld { public Part(CompoundTag tag) { ListTag map = tag.getList("blocks", 10); + ListTag map2 = tag.getList("states", 10); + BlockState[] states = new BlockState[map2.size()]; + for (int i = 0; i < states.length; i++) { + states[i] = NbtHelper.toBlockState((CompoundTag) map2.get(i)); + } + map.forEach((element) -> { CompoundTag block = (CompoundTag) element; BlockPos pos = NbtHelper.toBlockPos(block.getCompound("pos")); - BlockState state = Block.getStateFromRawId(block.getInt("state")); + BlockState state = states[block.getInt("state")]; blocks.put(pos, state); }); } @@ -127,7 +132,6 @@ public class StructureWorld { void placeChunk(Chunk chunk) { blocks.forEach((pos, state) -> { - //if (pos.getY() > 10) chunk.setBlockState(pos, state, false); }); } @@ -138,12 +142,26 @@ public class StructureWorld { tag.putInt("z", z); ListTag map = new ListTag(); tag.put("blocks", map); + ListTag stateMap = new ListTag(); + tag.put("states", stateMap); + + int[] id = new int[1]; + Map states = Maps.newHashMap(); + blocks.forEach((pos, state) -> { + int stateID = states.getOrDefault(states, -1); + if (stateID < 0) { + stateID = id[0] ++; + states.put(state, stateID); + stateMap.add(NbtHelper.fromBlockState(state)); + } + CompoundTag block = new CompoundTag(); block.put("pos", NbtHelper.fromBlockPos(pos)); - block.putInt("state", Block.getRawIdFromState(state)); + block.putInt("state", stateID); map.add(block); }); + return tag; } }