mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
Few fixes for worldedit changes
This commit is contained in:
parent
a3a175ab8c
commit
2571efb5c3
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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.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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -27,7 +27,7 @@ import com.google.common.collect.Table;
|
|||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
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.registry.state.Property;
|
||||||
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ import java.util.Set;
|
|||||||
public class BlockState implements BlockStateHolder<BlockState> {
|
public class BlockState implements BlockStateHolder<BlockState> {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BlockStateIdAcess.setBlockStateStateId(x -> x.internalId);
|
BlockStateIdAccess.setBlockStateStateId(x -> x.internalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BlockType blockType;
|
private final BlockType blockType;
|
||||||
|
@ -75,7 +75,7 @@ public class BundledItemData {
|
|||||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||||
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
|
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
|
||||||
Gson gson = gsonBuilder.create();
|
Gson gson = gsonBuilder.create();
|
||||||
URL url = ResourceLoader.getResource(BundledItemData.class,"items.json");F
|
URL url = ResourceLoader.getResource(BundledItemData.class,"items.json");
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
throw new IOException("Could not find items.json");
|
throw new IOException("Could not find items.json");
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class ForgeBlockRegistry extends BundledBlockRegistry {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionalInt getInternalBlockStateId(BlockState state) {
|
public OptionalInt getInternalBlockStateId(BlockState state) {
|
||||||
IBlockState equivalent = ForgeAdapter.adaptState(state);
|
IBlockState equivalent = ForgeAdapter.adapt(state);
|
||||||
return OptionalInt.of(Block.getStateId(equivalent));
|
return OptionalInt.of(Block.getStateId(equivalent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
|
|||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.internal.Constants;
|
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.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
@ -96,7 +96,6 @@ import java.io.File;
|
|||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
@ -177,8 +176,8 @@ public class ForgeWorld extends AbstractWorld {
|
|||||||
Chunk chunk = world.getChunk(x >> 4, z >> 4);
|
Chunk chunk = world.getChunk(x >> 4, z >> 4);
|
||||||
BlockPos pos = new BlockPos(x, y, z);
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
IBlockState old = chunk.getBlockState(pos);
|
IBlockState old = chunk.getBlockState(pos);
|
||||||
OptionalInt stateId = BlockStateIdAcess.getBlockStateId(block.toImmutableState());
|
OptionalInt stateId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
|
||||||
IBlockState newState = stateId.isPresent() ? Block.getStateById(stateId.getAsInt()) : ForgeAdapter.adaptState(block.toImmutableState());
|
IBlockState newState = stateId.isPresent() ? Block.getStateById(stateId.getAsInt()) : ForgeAdapter.adapt(block.toImmutableState());
|
||||||
IBlockState successState = chunk.setBlockState(pos, newState, false);
|
IBlockState successState = chunk.setBlockState(pos, newState, false);
|
||||||
boolean successful = successState != null;
|
boolean successful = successState != null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user