- My IJ is broke but this should work. Dunno if I got all nms changes, but we will see.
This commit is contained in:
N0tMyFaultOG
2020-08-23 17:18:29 +02:00
parent 1e070b3a71
commit 6cb8352686
31 changed files with 226 additions and 122 deletions

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.blocks;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.internal.util.DeprecationUtil;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -94,7 +95,7 @@ public class SkullBlock extends BaseBlock {
Map<String, Tag> values = new HashMap<>();
Map<String, Tag> inner = new HashMap<>();
inner.put("Name", new StringTag(owner));
values.put("Owner", new CompoundTag(inner));
values.put(DeprecationUtil.getHeadOwnerKey(), new CompoundTag(inner));
return new CompoundTag(values);
}
@ -113,7 +114,7 @@ public class SkullBlock extends BaseBlock {
throw new RuntimeException(String.format("'%s' tile entity expected", getNbtId()));
}
t = values.get("Owner");
t = values.get(DeprecationUtil.getHeadOwnerKey());
if (t instanceof CompoundTag) {
setOwner(((CompoundTag) t).getValue().get("Name").getValue().toString());
}

View File

@ -43,6 +43,7 @@ import com.sk89q.worldedit.extension.platform.PlatformManager;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.SchematicsEventListener;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.invoke.ReturnException;
import com.sk89q.worldedit.math.BlockVector3;
@ -130,6 +131,7 @@ public final class WorldEdit {
}
private WorldEdit() {
eventBus.register(new SchematicsEventListener());
}
/**

View File

@ -639,14 +639,22 @@ public class RegionCommands {
List<String> expression,
@Switch(name = 'r', desc = "Use the game's coordinate origin")
boolean useRawCoords,
@Switch(name = 'o', desc = "Use the selection's center as origin")
boolean offset) throws WorldEditException {
@Switch(name = 'o', desc = "Use the placement's coordinate origin")
boolean offset,
@Switch(name = 'c', desc = "Use the selection's center as origin")
boolean offsetCenter) throws WorldEditException {
final Vector3 zero;
Vector3 unit;
if (useRawCoords) {
zero = Vector3.ZERO;
unit = Vector3.ONE;
} else if (offsetCenter) {
final Vector3 min = region.getMinimumPoint().toVector3();
final Vector3 max = region.getMaximumPoint().toVector3();
zero = max.add(min).multiply(0.5);
unit = Vector3.ONE;
} else if (offset) {
zero = session.getPlacementPosition(actor).toVector3();
unit = Vector3.ONE;

View File

@ -42,4 +42,30 @@ public final class Constants {
));
}
/**
* The DataVersion for Minecraft 1.13
*/
public static final int DATA_VERSION_MC_1_13 = 1519;
/**
* The DataVersion for Minecraft 1.13.2
*/
public static final int DATA_VERSION_MC_1_13_2 = 1631;
/**
* The DataVersion for Minecraft 1.16
*/
public static final int DATA_VERSION_MC_1_14 = 1952;
/**
* The DataVersion for Minecraft 1.16
*/
public static final int DATA_VERSION_MC_1_15 = 2225;
/**
* The DataVersion for Minecraft 1.16
*/
public static final int DATA_VERSION_MC_1_16 = 2566;
}

View File

@ -0,0 +1,44 @@
/*
* 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.internal;
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
import com.sk89q.worldedit.util.eventbus.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class SchematicsEventListener {
private static final Logger LOGGER = LoggerFactory.getLogger(SchematicsEventListener.class);
@Subscribe
public void onConfigLoad(ConfigurationLoadEvent event) {
Path config = event.getConfiguration().getWorkingDirectory().toPath();
try {
Files.createDirectories(config.resolve(event.getConfiguration().saveDir));
} catch (IOException e) {
LOGGER.warn("Failed to create schematics directory", e);
}
}
}

View File

@ -21,6 +21,9 @@ package com.sk89q.worldedit.internal.util;
import com.google.common.base.Joiner;
import com.google.common.base.Throwables;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -106,4 +109,10 @@ public class DeprecationUtil {
|| BlockCategories.SIGNS.contains(blockType);
}
public static String getHeadOwnerKey() {
int dataVersion = WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getDataVersion();
return dataVersion >= Constants.DATA_VERSION_MC_1_16 ? "SkullOwner" : "Owner";
}
}

View File

@ -74,7 +74,7 @@ public final class BiomeTypes {
@Nullable public static final BiomeType MOUNTAINS = get("minecraft:mountains");
@Nullable public static final BiomeType MUSHROOM_FIELD_SHORE = get("minecraft:mushroom_field_shore");
@Nullable public static final BiomeType MUSHROOM_FIELDS = get("minecraft:mushroom_fields");
@Nullable @Deprecated public static final BiomeType NETHER = get("minecraft:nether");
@Deprecated @Nullable public static final BiomeType NETHER = get("minecraft:nether");
@Nullable public static final BiomeType NETHER_WASTES = get("minecraft:nether_wastes");
@Nullable public static final BiomeType OCEAN = get("minecraft:ocean");
@Nullable public static final BiomeType PLAINS = get("minecraft:plains");

View File

@ -28,6 +28,8 @@ public final class BlockCategories {
public static final BlockCategory ANVIL = get("minecraft:anvil");
public static final BlockCategory BAMBOO_PLANTABLE_ON = get("minecraft:bamboo_plantable_on");
public static final BlockCategory BANNERS = get("minecraft:banners");
public static final BlockCategory BASE_STONE_NETHER = get("minecraft:base_stone_nether");
public static final BlockCategory BASE_STONE_OVERWORLD = get("minecraft:base_stone_overworld");
public static final BlockCategory BEDS = get("minecraft:beds");
public static final BlockCategory BEE_GROWABLES = get("minecraft:bee_growables");
public static final BlockCategory BEEHIVES = get("minecraft:beehives");
@ -51,6 +53,8 @@ public final class BlockCategories {
public static final BlockCategory JUNGLE_LOGS = get("minecraft:jungle_logs");
public static final BlockCategory LEAVES = get("minecraft:leaves");
public static final BlockCategory LOGS = get("minecraft:logs");
public static final BlockCategory LOGS_THAT_BURN = get("minecraft:logs_that_burn");
public static final BlockCategory MUSHROOM_GROW_BLOCK = get("minecraft:mushroom_grow_block");
public static final BlockCategory OAK_LOGS = get("minecraft:oak_logs");
public static final BlockCategory PLANKS = get("minecraft:planks");
public static final BlockCategory PORTALS = get("minecraft:portals");

View File

@ -87,6 +87,7 @@ public class EntityTypes {
@Nullable public static final EntityType PHANTOM = get("minecraft:phantom");
@Nullable public static final EntityType PIG = get("minecraft:pig");
@Nullable public static final EntityType PIGLIN = get("minecraft:piglin");
@Nullable public static final EntityType PIGLIN_BRUTE = get("minecraft:piglin_brute");
@Nullable public static final EntityType PILLAGER = get("minecraft:pillager");
@Nullable public static final EntityType PLAYER = get("minecraft:player");
@Nullable public static final EntityType POLAR_BEAR = get("minecraft:polar_bear");

View File

@ -42,7 +42,7 @@ public final class ItemCategories {
public static final ItemCategory FENCES = get("minecraft:fences");
public static final ItemCategory FISHES = get("minecraft:fishes");
public static final ItemCategory FLOWERS = get("minecraft:flowers");
public static final ItemCategory FURNACE_MATERIALS = get("minecraft:furnace_materials");
@Deprecated public static final ItemCategory FURNACE_MATERIALS = get("minecraft:furnace_materials");
public static final ItemCategory GOLD_ORES = get("minecraft:gold_ores");
public static final ItemCategory JUNGLE_LOGS = get("minecraft:jungle_logs");
public static final ItemCategory LEAVES = get("minecraft:leaves");
@ -65,6 +65,7 @@ public final class ItemCategories {
public static final ItemCategory SPRUCE_LOGS = get("minecraft:spruce_logs");
public static final ItemCategory STAIRS = get("minecraft:stairs");
public static final ItemCategory STONE_BRICKS = get("minecraft:stone_bricks");
public static final ItemCategory STONE_CRAFTING_MATERIALS = get("minecraft:stone_crafting_materials");
public static final ItemCategory STONE_TOOL_MATERIALS = get("minecraft:stone_tool_materials");
public static final ItemCategory TALL_FLOWERS = get("minecraft:tall_flowers");
public static final ItemCategory TRAPDOORS = get("minecraft:trapdoors");

View File

@ -629,6 +629,8 @@ public final class ItemTypes {
@Nullable public static final ItemType PHANTOM_MEMBRANE = init();
@Nullable public static final ItemType PHANTOM_SPAWN_EGG = init();
@Nullable public static final ItemType PIG_SPAWN_EGG = init();
@Nullable public static final ItemType PIGLIN_BRUTE_SPAWN_EGG = init();
@Nullable public static final ItemType PIGLIN_BANNER_PATTERN = init();
@Nullable public static final ItemType PILLAGER_SPAWN_EGG = init();
@Nullable public static final ItemType PINK_BANNER = init();
@Nullable public static final ItemType PINK_BED = init();

View File

@ -90,7 +90,9 @@ public final class BundledBlockData {
Gson gson = gsonBuilder.create();
URL url = null;
final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
if (dataVersion > 2224) { // > MC 1.14
if (dataVersion > 2577) { // > MC 1.15
url = ResourceLoader.getResource(BundledBlockData.class, "blocks.116.json");
} else if (dataVersion > 2224) { // > MC 1.14
url = ResourceLoader.getResource(BundledBlockData.class, "blocks.115.json");
} else if (dataVersion > 1900) { // > MC 1.13
url = ResourceLoader.getResource(BundledBlockData.class, "blocks.114.json");

View File

@ -79,7 +79,9 @@ public final class BundledItemData {
Gson gson = gsonBuilder.create();
URL url = null;
final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();
if (dataVersion > 2224) { // > MC 1.14
if (dataVersion > 2577) { // > MC 1.15
url = ResourceLoader.getResource(BundledBlockData.class, "items.116.json");
} else if (dataVersion > 2224) { // > MC 1.14
url = ResourceLoader.getResource(BundledBlockData.class, "items.115.json");
} else if (dataVersion > 1900) { // > MC 1.13
url = ResourceLoader.getResource(BundledBlockData.class, "items.114.json");

View File

@ -93,7 +93,11 @@ public class FileSystemSnapshotDatabase implements SnapshotDatabase {
public FileSystemSnapshotDatabase(Path root, ArchiveNioSupport archiveNioSupport) {
checkArgument(Files.isDirectory(root), "Database root is not a directory");
this.root = root.toAbsolutePath();
try {
this.root = root.toRealPath();
} catch (IOException e) {
throw new RuntimeException("Failed to resolve snapshot database path", e);
}
this.archiveNioSupport = archiveNioSupport;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long