Few fixes for worldedit changes

Dieser Commit ist enthalten in:
Matthew Miller 2019-04-29 19:59:41 +10:00
Ursprung a3a175ab8c
Commit 2571efb5c3
6 geänderte Dateien mit 53 neuen und 32 gelöschten Zeilen

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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<BlockState> {
static {
BlockStateIdAcess.setBlockStateStateId(x -> x.internalId);
BlockStateIdAccess.setBlockStateStateId(x -> x.internalId);
}
private final BlockType blockType;

Datei anzeigen

@ -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");
}

Datei anzeigen

@ -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));
}

Datei anzeigen

@ -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;