mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +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();
|
getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static volatile boolean hasWarnedImplError = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) {
|
public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
@ -420,13 +422,14 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
try {
|
try {
|
||||||
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position)).toImmutableState();
|
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position)).toImmutableState();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
if (!hasWarnedImplError) {
|
||||||
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
|
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
|
@Override
|
||||||
|
@ -73,5 +73,6 @@ public interface BlockRegistry {
|
|||||||
* @param id The internal ID
|
* @param id The internal ID
|
||||||
* @return the block state, if available
|
* @return the block state, if available
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
BlockState getBlockStateByInternalId(int id);
|
BlockState getBlockStateByInternalId(int id);
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.forge;
|
package com.sk89q.worldedit.forge;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
@ -63,6 +61,8 @@ import java.util.Map;
|
|||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public final class ForgeAdapter {
|
public final class ForgeAdapter {
|
||||||
|
|
||||||
private ForgeAdapter() {
|
private ForgeAdapter() {
|
||||||
|
@ -27,8 +27,11 @@ import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.state.IProperty;
|
import net.minecraft.state.IProperty;
|
||||||
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
import net.minecraftforge.fml.loading.FMLLoader;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
|
import net.minecraftforge.registries.GameData;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -40,6 +43,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
public class ForgeBlockRegistry extends BundledBlockRegistry {
|
public class ForgeBlockRegistry extends BundledBlockRegistry {
|
||||||
|
|
||||||
|
private final int airId = Block.getStateId(Blocks.AIR.getDefaultState());
|
||||||
private Map<Material, ForgeBlockMaterial> materialMap = new HashMap<>();
|
private Map<Material, ForgeBlockMaterial> materialMap = new HashMap<>();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -82,4 +86,13 @@ public class ForgeBlockRegistry extends BundledBlockRegistry {
|
|||||||
return OptionalInt.of(Block.getStateId(equivalent));
|
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()));
|
ItemCategory.REGISTRY.register(name.toString(), new ItemCategory(name.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config = new ForgeConfiguration(this);
|
|
||||||
config.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
Loading…
Reference in New Issue
Block a user