Expose a way of switching between ItemType and BlockType for ItemBlocks.

This commit is contained in:
Matthew Miller
2018-07-01 23:20:07 +10:00
parent b06937d1c8
commit 93b225ca3c
17 changed files with 110 additions and 1243 deletions

View File

@ -19,15 +19,15 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.blocks.type.BlockState;
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
import com.sk89q.worldedit.world.registry.state.State;
import javax.annotation.Nullable;
import java.util.Map;
import javax.annotation.Nullable;
/**
* Provides information on blocks and provides methods to create them.
*/
@ -45,11 +45,11 @@ public interface BlockRegistry {
/**
* Get the material for the given block.
*
* @param block the block
* @param id the block
* @return the material, or null if the material information is not known
*/
@Nullable
BlockMaterial getMaterial(BaseBlock block);
BlockMaterial getMaterial(String id);
/**
* Get an unmodifiable map of states for this block.

View File

@ -19,16 +19,16 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.blocks.type.BlockState;
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.world.registry.state.State;
import javax.annotation.Nullable;
import java.util.Map;
import javax.annotation.Nullable;
/**
* A block registry that uses {@link BundledBlockData} to serve information
* about blocks.
@ -43,8 +43,8 @@ public class BundledBlockRegistry implements BlockRegistry {
@Nullable
@Override
public BlockMaterial getMaterial(BaseBlock block) {
return BundledBlockData.getInstance().getMaterialById(block.getBlockType().getId());
public BlockMaterial getMaterial(String id) {
return BundledBlockData.getInstance().getMaterialById(id);
}
@Nullable