mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
I guarantee this is broken. Start some form of string ID for blocks
This commit is contained in:
@ -110,7 +110,7 @@ public abstract class AbstractWorld implements World {
|
||||
|
||||
@Override
|
||||
public int getBlockType(Vector pt) {
|
||||
return getLazyBlock(pt).getType();
|
||||
return getLazyBlock(pt).getType().getLegacyId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
|
@ -46,6 +46,7 @@ public interface BlockRegistry {
|
||||
* @return the block, which may be null if no block exists
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
BaseBlock createFromId(int id);
|
||||
|
||||
/**
|
||||
|
@ -128,6 +128,22 @@ public class BundledBlockData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given legacy numeric ID to a string ID.
|
||||
*
|
||||
* @param id the legacy ID
|
||||
* @return the ID, which may be null if the block does not have a ID
|
||||
*/
|
||||
@Nullable
|
||||
public String fromLegacyId(Integer id) {
|
||||
BlockEntry entry = findById(id);
|
||||
if (entry != null) {
|
||||
return entry.id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the material properties for the given block.
|
||||
*
|
||||
@ -135,6 +151,7 @@ public class BundledBlockData {
|
||||
* @return the material's properties, or null
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public BlockMaterial getMaterialById(int id) {
|
||||
BlockEntry entry = findById(id);
|
||||
if (entry != null) {
|
||||
@ -144,6 +161,22 @@ public class BundledBlockData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the material properties for the given block.
|
||||
*
|
||||
* @param id the string ID
|
||||
* @return the material's properties, or null
|
||||
*/
|
||||
@Nullable
|
||||
public BlockMaterial getMaterialById(String id) {
|
||||
BlockEntry entry = findById(id);
|
||||
if (entry != null) {
|
||||
return entry.material;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the states for the given block.
|
||||
*
|
||||
@ -151,6 +184,7 @@ public class BundledBlockData {
|
||||
* @return the block's states, or null if no information is available
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public Map<String, ? extends State> getStatesById(int id) {
|
||||
BlockEntry entry = findById(id);
|
||||
if (entry != null) {
|
||||
@ -160,6 +194,22 @@ public class BundledBlockData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the states for the given block.
|
||||
*
|
||||
* @param id the string ID
|
||||
* @return the block's states, or null if no information is available
|
||||
*/
|
||||
@Nullable
|
||||
public Map<String, ? extends State> getStatesById(String id) {
|
||||
BlockEntry entry = findById(id);
|
||||
if (entry != null) {
|
||||
return entry.states;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a singleton instance of this object.
|
||||
*
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
@ -34,30 +35,30 @@ public class LegacyBlockRegistry implements BlockRegistry {
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBlock createFromId(String id) {
|
||||
Integer legacyId = BundledBlockData.getInstance().toLegacyId(id);
|
||||
if (legacyId != null) {
|
||||
return createFromId(legacyId);
|
||||
return new BaseBlock(BlockTypes.getBlockType(id));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBlock createFromId(int legacyId) {
|
||||
String id = BundledBlockData.getInstance().fromLegacyId(legacyId);
|
||||
if (id != null) {
|
||||
return createFromId(id);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBlock createFromId(int id) {
|
||||
return new BaseBlock(id);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockMaterial getMaterial(BaseBlock block) {
|
||||
return BundledBlockData.getInstance().getMaterialById(block.getId());
|
||||
return BundledBlockData.getInstance().getMaterialById(block.getType().getId());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Map<String, ? extends State> getStates(BaseBlock block) {
|
||||
return BundledBlockData.getInstance().getStatesById(block.getId());
|
||||
return BundledBlockData.getInstance().getStatesById(block.getType().getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user