mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 12:06:41 +00:00
Almost finished the state system. Just got to have it actually load in the values.
This commit is contained in:
@ -20,10 +20,10 @@
|
||||
package com.sk89q.worldedit.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -33,15 +33,6 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public interface BlockRegistry {
|
||||
|
||||
/**
|
||||
* Create a new block using its ID.
|
||||
*
|
||||
* @param id the id
|
||||
* @return the block, which may be null if no block exists
|
||||
*/
|
||||
@Nullable
|
||||
BlockState createFromId(String id);
|
||||
|
||||
/**
|
||||
* Get the material for the given block.
|
||||
*
|
||||
@ -51,13 +42,21 @@ public interface BlockRegistry {
|
||||
@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);
|
||||
|
||||
/**
|
||||
* Get an unmodifiable map of states for this block.
|
||||
*
|
||||
* @param block the block
|
||||
* @param blockType the block
|
||||
* @return a map of states where the key is the state's ID
|
||||
*/
|
||||
@Nullable
|
||||
Map<String, ? extends Property> getStates(BlockStateHolder block);
|
||||
Map<String, ? extends Property> getProperties(BlockType blockType);
|
||||
|
||||
}
|
||||
|
@ -25,11 +25,8 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.gson.VectorAdapter;
|
||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
@ -39,6 +36,8 @@ import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Provides block data based on the built-in block database that is bundled
|
||||
* with WorldEdit.
|
||||
@ -86,7 +85,6 @@ public class BundledBlockData {
|
||||
|
||||
for (BlockEntry entry : entries) {
|
||||
idMap.put(entry.id, entry);
|
||||
entry.postDeserialization();
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,22 +119,6 @@ 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 Property> getStatesById(String id) {
|
||||
BlockEntry entry = findById(id);
|
||||
if (entry != null) {
|
||||
return entry.states;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a singleton instance of this object.
|
||||
*
|
||||
@ -151,14 +133,7 @@ public class BundledBlockData {
|
||||
private String unlocalizedName;
|
||||
public String localizedName;
|
||||
private List<String> aliases;
|
||||
public Map<String, AbstractProperty> states = new HashMap<>();
|
||||
private SimpleBlockMaterial material = new SimpleBlockMaterial();
|
||||
|
||||
void postDeserialization() {
|
||||
for (Map.Entry<String, AbstractProperty> state : states.entrySet()) {
|
||||
state.getValue().setName(state.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,10 +21,10 @@ package com.sk89q.worldedit.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -35,22 +35,21 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class BundledBlockRegistry implements BlockRegistry {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState createFromId(String id) {
|
||||
return BlockTypes.get(id).getDefaultState();
|
||||
}
|
||||
|
||||
@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
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Map<String, ? extends Property> getStates(BlockStateHolder block) {
|
||||
return BundledBlockData.getInstance().getStatesById(block.getBlockType().getId());
|
||||
public Map<String, ? extends Property> getProperties(BlockType blockType) {
|
||||
return Collections.emptyMap(); // Oof
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user