mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 10:56:42 +00:00
Merge current FAWE master (227d6d91
) into new-vector-system
Signed-off-by: Byron Marohn <combustible@live.com>
This commit is contained in:
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
@ -99,7 +101,7 @@ public interface BlockType extends FawePattern, Comparable<BlockTypes> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the properties of this BlockType in a key->property mapping.
|
||||
* Gets the properties of this BlockType in a {@code key->property} mapping.
|
||||
*
|
||||
* @return The properties map
|
||||
*/
|
||||
@ -138,7 +140,9 @@ public interface BlockType extends FawePattern, Comparable<BlockTypes> {
|
||||
*/
|
||||
@Deprecated
|
||||
default <V> Property<V> getProperty(String name) {
|
||||
return getPropertyMap().get(name);
|
||||
Property<V> property = getPropertyMap().get(name);
|
||||
checkArgument(property != null, "%s has no property named %s", this, name);
|
||||
return property;
|
||||
}
|
||||
|
||||
default boolean hasProperty(PropertyKey key) {
|
||||
@ -146,7 +150,9 @@ public interface BlockType extends FawePattern, Comparable<BlockTypes> {
|
||||
}
|
||||
|
||||
default <V> Property<V> getProperty(PropertyKey key) {
|
||||
return getPropertyMap().get(key.getId());
|
||||
Property<V> property = getPropertyMap().get(key.getId());
|
||||
checkArgument(property != null, "%s has no property named %s", this, key.getId());
|
||||
return property;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,6 +169,13 @@ public interface BlockType extends FawePattern, Comparable<BlockTypes> {
|
||||
*/
|
||||
List<BlockState> getAllStates();
|
||||
|
||||
/**
|
||||
* Gets a state of this BlockType with the given properties.
|
||||
*
|
||||
* @return The state, if it exists
|
||||
*/
|
||||
BlockState getState(Map<Property<?>, Object> key);
|
||||
|
||||
/**
|
||||
* Gets whether this block type has an item representation.
|
||||
*
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.command.SuggestInputParseException;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
@ -219,19 +221,24 @@ public enum BlockTypes implements BlockType {
|
||||
DARK_PRISMARINE_SLAB,
|
||||
DARK_PRISMARINE_STAIRS,
|
||||
DAYLIGHT_DETECTOR,
|
||||
DEAD_BRAIN_CORAL,
|
||||
DEAD_BRAIN_CORAL_BLOCK,
|
||||
DEAD_BRAIN_CORAL_FAN,
|
||||
DEAD_BRAIN_CORAL_WALL_FAN,
|
||||
DEAD_BUBBLE_CORAL,
|
||||
DEAD_BUBBLE_CORAL_BLOCK,
|
||||
DEAD_BUBBLE_CORAL_FAN,
|
||||
DEAD_BUBBLE_CORAL_WALL_FAN,
|
||||
DEAD_BUSH,
|
||||
DEAD_FIRE_CORAL,
|
||||
DEAD_FIRE_CORAL_BLOCK,
|
||||
DEAD_FIRE_CORAL_FAN,
|
||||
DEAD_FIRE_CORAL_WALL_FAN,
|
||||
DEAD_HORN_CORAL,
|
||||
DEAD_HORN_CORAL_BLOCK,
|
||||
DEAD_HORN_CORAL_FAN,
|
||||
DEAD_HORN_CORAL_WALL_FAN,
|
||||
DEAD_TUBE_CORAL,
|
||||
DEAD_TUBE_CORAL_BLOCK,
|
||||
DEAD_TUBE_CORAL_FAN,
|
||||
DEAD_TUBE_CORAL_WALL_FAN,
|
||||
@ -654,11 +661,6 @@ public enum BlockTypes implements BlockType {
|
||||
YELLOW_WOOL,
|
||||
ZOMBIE_HEAD,
|
||||
ZOMBIE_WALL_HEAD,
|
||||
DEAD_BRAIN_CORAL,
|
||||
DEAD_BUBBLE_CORAL,
|
||||
DEAD_FIRE_CORAL,
|
||||
DEAD_HORN_CORAL,
|
||||
DEAD_TUBE_CORAL,
|
||||
|
||||
;
|
||||
|
||||
@ -825,6 +827,24 @@ public enum BlockTypes implements BlockType {
|
||||
return IntStream.of(settings.stateOrdinals).filter(i -> i != -1).mapToObj(i -> states[i]).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public BlockState getState(Map<Property<?>, Object> key) {
|
||||
int id = getInternalId();
|
||||
for (Map.Entry<Property<?>, Object> iter : key.entrySet()) {
|
||||
Property<?> prop = iter.getKey();
|
||||
Object value = iter.getValue();
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* This is likely wrong. The only place this seems to currently (Dec 23 2018)
|
||||
* be invoked is via ForgeWorld, and value is a String when invoked there...
|
||||
*/
|
||||
AbstractProperty btp = settings.propertiesMap.get(prop.getName());
|
||||
checkArgument(btp != null, "%s has no property named %s", this, prop.getName());
|
||||
id = btp.modify(id, btp.getValueFor((String)value));
|
||||
}
|
||||
return withStateId(id);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getMaxStateId() {
|
||||
return settings.permutations;
|
||||
|
Reference in New Issue
Block a user