mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Add perf. improvments for Forge
This commit is contained in:
committed by
Matthew Miller
parent
8c17aab9c5
commit
27c7d488a2
@ -27,23 +27,18 @@ 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 javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.TreeMap;
|
||||
|
||||
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
|
||||
@ -85,14 +80,4 @@ public class ForgeBlockRegistry extends BundledBlockRegistry {
|
||||
IBlockState equivalent = ForgeAdapter.adapt(state);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
@ -92,6 +90,7 @@ import net.minecraft.world.gen.feature.TallTaigaTreeFeature;
|
||||
import net.minecraft.world.gen.feature.TreeFeature;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
@ -101,7 +100,7 @@ import java.util.Random;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* An adapter to Minecraft worlds for WorldEdit.
|
||||
@ -464,13 +463,19 @@ public class ForgeWorld extends AbstractWorld {
|
||||
position.getBlockZ()
|
||||
);
|
||||
|
||||
BlockState matchingBlock = BlockStateIdAccess.getBlockStateById(Block.getStateId(mcState));
|
||||
if (matchingBlock != null) {
|
||||
return matchingBlock;
|
||||
}
|
||||
|
||||
return ForgeAdapter.adapt(mcState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
TileEntity tile = getWorld().getTileEntity(pos);
|
||||
// Avoid creation by using the CHECK mode -- if it's needed, it'll be re-created anyways
|
||||
TileEntity tile = getWorld().getChunk(pos).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK);
|
||||
|
||||
if (tile != null) {
|
||||
return getBlock(position).toBaseBlock(NBTConverter.fromNative(TileEntityUtils.copyNbtData(tile)));
|
||||
|
Reference in New Issue
Block a user