From 2571efb5c3df99236f06bf892deb0a9a65dec7f5 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Mon, 29 Apr 2019 19:59:41 +1000 Subject: [PATCH] Few fixes for worldedit changes --- .../internal/block/BlockStateIdAccess.java | 46 +++++++++++++++++++ .../internal/block/BlockStateIdAcess.java | 24 ---------- .../worldedit/world/block/BlockState.java | 4 +- .../world/registry/BundledItemData.java | 2 +- .../worldedit/forge/ForgeBlockRegistry.java | 2 +- .../com/sk89q/worldedit/forge/ForgeWorld.java | 7 ++- 6 files changed, 53 insertions(+), 32 deletions(-) create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAcess.java diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java new file mode 100644 index 000000000..f7f9d66f0 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java @@ -0,0 +1,46 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * 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 . + */ + +package com.sk89q.worldedit.internal.block; + +import com.sk89q.worldedit.world.block.BlockState; + +import java.util.OptionalInt; + +public class BlockStateIdAccess { + + private BlockStateIdAccess() { + } + + public interface Provider { + + OptionalInt getBlockStateId(BlockState holder); + } + + private static Provider blockStateStateId; + + public static void setBlockStateStateId(Provider blockStateStateId) { + BlockStateIdAccess.blockStateStateId = blockStateStateId; + } + + public static OptionalInt getBlockStateId(BlockState holder) { + return blockStateStateId.getBlockStateId((BlockState) holder); + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAcess.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAcess.java deleted file mode 100644 index 766537776..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAcess.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.sk89q.worldedit.internal.block; - -import com.sk89q.worldedit.world.block.BlockState; - -import java.util.OptionalInt; - -public class BlockStateIdAcess { - - public interface Provider { - - OptionalInt getBlockStateId(BlockState holder); - } - - private static Provider blockStateStateId; - - public static void setBlockStateStateId(Provider blockStateStateId) { - BlockStateIdAcess.blockStateStateId = blockStateStateId; - } - - public static OptionalInt getBlockStateId(BlockState holder) { - return blockStateStateId.getBlockStateId((BlockState) holder); - } - -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java index 7fed9efde..7463fefb1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java @@ -27,7 +27,7 @@ import com.google.common.collect.Table; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Capability; -import com.sk89q.worldedit.internal.block.BlockStateIdAcess; +import com.sk89q.worldedit.internal.block.BlockStateIdAccess; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.registry.BlockRegistry; @@ -48,7 +48,7 @@ import java.util.Set; public class BlockState implements BlockStateHolder { static { - BlockStateIdAcess.setBlockStateStateId(x -> x.internalId); + BlockStateIdAccess.setBlockStateStateId(x -> x.internalId); } private final BlockType blockType; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java index 86bd253a7..4e1af0422 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledItemData.java @@ -75,7 +75,7 @@ public class BundledItemData { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter()); Gson gson = gsonBuilder.create(); - URL url = ResourceLoader.getResource(BundledItemData.class,"items.json");F + URL url = ResourceLoader.getResource(BundledItemData.class,"items.json"); if (url == null) { throw new IOException("Could not find items.json"); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockRegistry.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockRegistry.java index a44b19e3c..042d9e230 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockRegistry.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBlockRegistry.java @@ -78,7 +78,7 @@ public class ForgeBlockRegistry extends BundledBlockRegistry { @Override public OptionalInt getInternalBlockStateId(BlockState state) { - IBlockState equivalent = ForgeAdapter.adaptState(state); + IBlockState equivalent = ForgeAdapter.adapt(state); return OptionalInt.of(Block.getStateId(equivalent)); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java index fe3abdee7..3b1dabeb2 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java @@ -34,7 +34,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.internal.Constants; -import com.sk89q.worldedit.internal.block.BlockStateIdAcess; +import com.sk89q.worldedit.internal.block.BlockStateIdAccess; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; @@ -96,7 +96,6 @@ import java.io.File; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.OptionalInt; import java.util.Random; import java.util.concurrent.ExecutionException; @@ -177,8 +176,8 @@ public class ForgeWorld extends AbstractWorld { Chunk chunk = world.getChunk(x >> 4, z >> 4); BlockPos pos = new BlockPos(x, y, z); IBlockState old = chunk.getBlockState(pos); - OptionalInt stateId = BlockStateIdAcess.getBlockStateId(block.toImmutableState()); - IBlockState newState = stateId.isPresent() ? Block.getStateById(stateId.getAsInt()) : ForgeAdapter.adaptState(block.toImmutableState()); + OptionalInt stateId = BlockStateIdAccess.getBlockStateId(block.toImmutableState()); + IBlockState newState = stateId.isPresent() ? Block.getStateById(stateId.getAsInt()) : ForgeAdapter.adapt(block.toImmutableState()); IBlockState successState = chunk.setBlockState(pos, newState, false); boolean successful = successState != null;