mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Add DFUs. Currently used by //restore.
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.extension.platform;
|
||||
|
||||
import com.sk89q.worldedit.world.DataFixer;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -39,4 +40,8 @@ public abstract class AbstractPlatform implements Platform {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataFixer getDataFixer() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.platform;
|
||||
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.world.DataFixer;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.registry.Registries;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
@ -51,6 +52,13 @@ public interface Platform {
|
||||
*/
|
||||
int getDataVersion();
|
||||
|
||||
/**
|
||||
* Get a DataFixer capable of upgrading old data.
|
||||
*
|
||||
* @return a data fixer, or null if not supported by this platform
|
||||
*/
|
||||
DataFixer getDataFixer();
|
||||
|
||||
/**
|
||||
* Checks if a mob type is valid.
|
||||
*
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.world;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
|
||||
@Beta
|
||||
public interface DataFixer {
|
||||
|
||||
/**
|
||||
* API SUBJECT TO CHANGE. DON'T USE THIS.
|
||||
*/
|
||||
@Beta
|
||||
CompoundTag fixChunk(CompoundTag originalChunk);
|
||||
|
||||
}
|
@ -35,12 +35,11 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The chunk format for Minecraft 1.13 and newer
|
||||
*/
|
||||
@ -160,11 +159,13 @@ public class AnvilChunk13 implements Chunk {
|
||||
* @throws DataException
|
||||
*/
|
||||
private void populateTileEntities() throws DataException {
|
||||
tileEntities = new HashMap<>();
|
||||
if (!rootTag.getValue().containsKey("TileEntities")) {
|
||||
return;
|
||||
}
|
||||
List<Tag> tags = NBTUtils.getChildTag(rootTag.getValue(),
|
||||
"TileEntities", ListTag.class).getValue();
|
||||
|
||||
tileEntities = new HashMap<>();
|
||||
|
||||
for (Tag tag : tags) {
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new InvalidFormatException("CompoundTag expected in TileEntities");
|
||||
|
@ -21,9 +21,13 @@ package com.sk89q.worldedit.world.storage;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
import com.sk89q.worldedit.world.DataFixer;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.chunk.AnvilChunk;
|
||||
import com.sk89q.worldedit.world.chunk.AnvilChunk13;
|
||||
@ -42,7 +46,7 @@ public abstract class ChunkStore implements Closeable {
|
||||
/**
|
||||
* The DataVersion for Minecraft 1.13
|
||||
*/
|
||||
public static final int DATA_VERSION_MC_1_13 = 1519;
|
||||
private static final int DATA_VERSION_MC_1_13 = 1519;
|
||||
|
||||
/**
|
||||
* {@code >>} - to chunk
|
||||
@ -102,6 +106,14 @@ public abstract class ChunkStore implements Closeable {
|
||||
}
|
||||
|
||||
int dataVersion = rootTag.getInt("DataVersion");
|
||||
final Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
|
||||
final int currentDataVersion = platform.getDataVersion();
|
||||
if (dataVersion < currentDataVersion) {
|
||||
final DataFixer dataFixer = platform.getDataFixer();
|
||||
if (dataFixer != null) {
|
||||
return new AnvilChunk13((CompoundTag) dataFixer.fixChunk(rootTag).getValue().get("Level"));
|
||||
}
|
||||
}
|
||||
if (dataVersion >= DATA_VERSION_MC_1_13) {
|
||||
return new AnvilChunk13(tag);
|
||||
}
|
||||
@ -114,6 +126,7 @@ public abstract class ChunkStore implements Closeable {
|
||||
return new OldChunk(world, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user