mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Clean-up some misc. parts of the code
This commit is contained in:
parent
dc21b4df58
commit
8c17aab9c5
@ -413,6 +413,8 @@ public class BukkitWorld extends AbstractWorld {
|
||||
getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally();
|
||||
}
|
||||
|
||||
private static volatile boolean hasWarnedImplError = false;
|
||||
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
@ -420,13 +422,14 @@ public class BukkitWorld extends AbstractWorld {
|
||||
try {
|
||||
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position)).toImmutableState();
|
||||
} catch (Exception e) {
|
||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
|
||||
if (!hasWarnedImplError) {
|
||||
hasWarnedImplError = true;
|
||||
logger.warn("Unable to retrieve block via impl adapter", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
|
||||
}
|
||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,7 +65,7 @@ public class BlockState implements BlockStateHolder<BlockState> {
|
||||
this.values = new LinkedHashMap<>();
|
||||
this.emptyBaseBlock = new BaseBlock(this);
|
||||
}
|
||||
|
||||
|
||||
BlockState initializeId(BlockRegistry registry) {
|
||||
this.internalId = registry.getInternalBlockStateId(this);
|
||||
return this;
|
||||
|
@ -73,5 +73,6 @@ public interface BlockRegistry {
|
||||
* @param id The internal ID
|
||||
* @return the block state, if available
|
||||
*/
|
||||
@Nullable
|
||||
BlockState getBlockStateByInternalId(int id);
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
@ -63,6 +61,8 @@ import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public final class ForgeAdapter {
|
||||
|
||||
private ForgeAdapter() {
|
||||
|
@ -27,8 +27,11 @@ import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -40,6 +43,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class ForgeBlockRegistry extends BundledBlockRegistry {
|
||||
|
||||
private final int airId = Block.getStateId(Blocks.AIR.getDefaultState());
|
||||
private Map<Material, ForgeBlockMaterial> materialMap = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
@ -82,4 +86,13 @@ public class ForgeBlockRegistry extends BundledBlockRegistry {
|
||||
return OptionalInt.of(Block.getStateId(equivalent));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockStateByInternalId(int id) {
|
||||
IBlockState equivalent = Block.getStateById(id);
|
||||
if (equivalent.equals(Blocks.AIR.getDefaultState()) && id != airId) {
|
||||
// We didn't find a match.
|
||||
return null;
|
||||
}
|
||||
return ForgeAdapter.adapt(equivalent);
|
||||
}
|
||||
}
|
||||
|
@ -175,9 +175,6 @@ public class ForgeWorldEdit {
|
||||
ItemCategory.REGISTRY.register(name.toString(), new ItemCategory(name.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
config = new ForgeConfiguration(this);
|
||||
config.load();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@ -211,7 +208,7 @@ public class ForgeWorldEdit {
|
||||
InternalPacketHandler.getHandler().sendToServer(new LeftClickAirEventMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
boolean isLeftDeny = event instanceof PlayerInteractEvent.LeftClickBlock
|
||||
&& ((PlayerInteractEvent.LeftClickBlock) event)
|
||||
.getUseItem() == Event.Result.DENY;
|
||||
|
Loading…
Reference in New Issue
Block a user