Replace BlockStates reading with new 1.16 logic (#1413)

* Replace BlockStates reading with new 1.16 logic

* Account for running on older platforms

Splits out the new reading to AnvilChunk16, uses data version to detect
the appropriate version.

* Move data versions to Constants

Also fixes some logic hiccups that become obvious with the new names.

* Fix LegacyMapper DFU handling

* Fix factor indexing

(cherry picked from commit 8c171f0929e8530aab1731d122649adc58c5161f)
This commit is contained in:
Octavia Togami
2020-07-03 21:44:19 -04:00
committed by MattBDev
parent 28767d6e0f
commit f7e1f70e19
6 changed files with 61 additions and 240 deletions

View File

@ -39,7 +39,7 @@ import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
@ -97,7 +97,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
int liveDataVersion = platform.getDataVersion();
if (schematicVersion == 1) {
dataVersion = 1631; // this is a relatively safe assumption unless someone imports a schematic from 1.12, e.g. sponge 7.1-
dataVersion = Constants.DATA_VERSION_MC_1_13_2; // this is a relatively safe assumption unless someone imports a schematic from 1.12, e.g. sponge 7.1-
fixer = platform.getDataFixer();
return readVersion1(schematicTag);
} else if (schematicVersion == 2) {
@ -128,7 +128,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
CompoundTag schematicTag = getBaseTag();
Map<String, Tag> schematic = schematicTag.getValue();
if (schematicVersion == 1) {
return OptionalInt.of(1631);
return OptionalInt.of(Constants.DATA_VERSION_MC_1_13_2);
} else if (schematicVersion == 2) {
return OptionalInt.of(requireTag(schematic, "DataVersion", IntTag.class).getValue());
}
@ -322,7 +322,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
BiomeType biome = BiomeTypes.get(key);
if (biome == null) {
log.warn("Unknown biome type :" + key +
" in palette. Are you missing a mod or using a schematic made in a newer version of Minecraft?");
" in palette. Are you missing a mod or using a schematic made in a newer version of Minecraft?");
}
Tag idTag = palettePart.getValue();
if (!(idTag instanceof IntTag)) {
@ -338,7 +338,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
int biomeJ = 0;
int bVal;
int varIntLength;
BlockVector2 min = clipboard.getMinimumPoint().toBlockVector2();
BlockVector3 min = clipboard.getMinimumPoint();
while (biomeJ < biomes.length) {
bVal = 0;
varIntLength = 0;
@ -357,7 +357,9 @@ public class SpongeSchematicReader extends NBTSchematicReader {
int z = biomeIndex / width;
int x = biomeIndex % width;
BiomeType type = palette.get(bVal);
clipboard.setBiome(min.add(x, z), type);
for (int y = 0; y < clipboard.getRegion().getHeight(); y++) {
clipboard.setBiome(min.add(x, y, z), type);
}
biomeIndex++;
}
}

View File

@ -1,50 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.extent.world;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
/**
* Handles quirks when placing biomes.
*/
public class BiomeQuirkExtent extends AbstractDelegateExtent {
/**
* Create a new instance.
*
* @param extent the extent
*/
public BiomeQuirkExtent(Extent extent) {
super(extent);
}
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
boolean success = false;
if (!fullySupports3DBiomes()) {
// Also place at Y = 0 for proper handling
success = super.setBiome(position.withY(0), biome);
}
return super.setBiome(position, biome) || success;
}
}