Basically finish the state system. Just 1 more bug that I'm encountering.

This commit is contained in:
Matthew Miller
2018-07-18 00:42:09 +10:00
parent 4938f419ad
commit 6b5f218809
21 changed files with 158 additions and 98 deletions

View File

@ -36,20 +36,11 @@ public interface BlockRegistry {
/**
* Get the material for the given block.
*
* @param id the block
* @param blockType the block
* @return the material, or null if the material information is not known
*/
@Nullable
BlockMaterial getMaterial(String id);
/**
* Get an unmodifiable list of values for this property.
*
* @param blockType The block
* @param property the property
* @return the list of values
*/
List<Object> getPropertyValues(BlockType blockType, Property<?> property);
BlockMaterial getMaterial(BlockType blockType);
/**
* Get an unmodifiable map of states for this block.

View File

@ -52,7 +52,7 @@ import javax.annotation.Nullable;
public class BundledBlockData {
private static final Logger log = Logger.getLogger(BundledBlockData.class.getCanonicalName());
private static final BundledBlockData INSTANCE = new BundledBlockData();
private static BundledBlockData INSTANCE;
private final Map<String, BlockEntry> idMap = new HashMap<>();
@ -125,6 +125,9 @@ public class BundledBlockData {
* @return the instance
*/
public static BundledBlockData getInstance() {
if (INSTANCE == null) {
INSTANCE = new BundledBlockData();
}
return INSTANCE;
}

View File

@ -24,7 +24,6 @@ import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
@ -37,13 +36,8 @@ public class BundledBlockRegistry implements BlockRegistry {
@Nullable
@Override
public BlockMaterial getMaterial(String id) {
return new PassthroughBlockMaterial(BundledBlockData.getInstance().getMaterialById(id));
}
@Override
public List<Object> getPropertyValues(BlockType blockType, Property<?> property) {
return Collections.emptyList(); // Oof
public BlockMaterial getMaterial(BlockType blockType) {
return new PassthroughBlockMaterial(BundledBlockData.getInstance().getMaterialById(blockType.getId()));
}
@Nullable

View File

@ -51,7 +51,7 @@ import javax.annotation.Nullable;
public class BundledItemData {
private static final Logger log = Logger.getLogger(BundledItemData.class.getCanonicalName());
private static final BundledItemData INSTANCE = new BundledItemData();
private static BundledItemData INSTANCE;
private final Map<String, ItemEntry> idMap = new HashMap<>();
@ -108,6 +108,9 @@ public class BundledItemData {
* @return the instance
*/
public static BundledItemData getInstance() {
if (INSTANCE == null) {
INSTANCE = new BundledItemData();
}
return INSTANCE;
}

View File

@ -46,7 +46,7 @@ import javax.annotation.Nullable;
public class LegacyMapper {
private static final Logger log = Logger.getLogger(LegacyMapper.class.getCanonicalName());
private static final LegacyMapper INSTANCE = new LegacyMapper();
private static LegacyMapper INSTANCE;
private BiMap<String, BlockState> blockMap = HashBiMap.create();
private BiMap<String, ItemType> itemMap = HashBiMap.create();
@ -141,6 +141,9 @@ public class LegacyMapper {
}
public static LegacyMapper getInstance() {
if (INSTANCE == null) {
INSTANCE = new LegacyMapper();
}
return INSTANCE;
}