geforkt von Mirrors/FastAsyncWorldEdit
Make the base fuzzy cached per block type
Dieser Commit ist enthalten in:
Ursprung
8da984d9f9
Commit
b544782f3b
@ -48,6 +48,7 @@ public class BlockType {
|
|||||||
private final String id;
|
private final String id;
|
||||||
private final Function<BlockState, BlockState> values;
|
private final Function<BlockState, BlockState> values;
|
||||||
private final AtomicReference<BlockState> defaultState = new AtomicReference<>();
|
private final AtomicReference<BlockState> defaultState = new AtomicReference<>();
|
||||||
|
private final AtomicReference<FuzzyBlockState> emptyFuzzy = new AtomicReference<>();
|
||||||
private final AtomicReference<Map<String, ? extends Property<?>>> properties = new AtomicReference<>();
|
private final AtomicReference<Map<String, ? extends Property<?>>> properties = new AtomicReference<>();
|
||||||
private final AtomicReference<BlockMaterial> blockMaterial = new AtomicReference<>();
|
private final AtomicReference<BlockMaterial> blockMaterial = new AtomicReference<>();
|
||||||
private final AtomicReference<Map<Map<Property<?>, Object>, BlockState>> blockStatesMap = new AtomicReference<>();
|
private final AtomicReference<Map<Map<Property<?>, Object>, BlockState>> blockStatesMap = new AtomicReference<>();
|
||||||
@ -156,6 +157,10 @@ public class BlockType {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FuzzyBlockState getFuzzyMatcher() {
|
||||||
|
return updateField(emptyFuzzy, () -> new FuzzyBlockState(this));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of all possible states for this BlockType.
|
* Gets a list of all possible states for this BlockType.
|
||||||
*
|
*
|
||||||
|
@ -37,11 +37,16 @@ public class FuzzyBlockState extends BlockState {
|
|||||||
super(blockType);
|
super(blockType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
/**
|
||||||
@Override
|
* Gets a full BlockState from this fuzzy one, filling in
|
||||||
public BlockState toImmutableState() {
|
* properties with default values where necessary.
|
||||||
|
*
|
||||||
|
* @return The full BlockState
|
||||||
|
*/
|
||||||
|
public BlockState getFullState() {
|
||||||
BlockState state = getBlockType().getDefaultState();
|
BlockState state = getBlockType().getDefaultState();
|
||||||
for (Map.Entry<Property<?>, Object> entry : getStates().entrySet()) {
|
for (Map.Entry<Property<?>, Object> entry : getStates().entrySet()) {
|
||||||
|
//noinspection unchecked
|
||||||
state = state.with((Property<Object>) entry.getKey(), entry.getValue());
|
state = state.with((Property<Object>) entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
return getBlockType().getDefaultState();
|
return getBlockType().getDefaultState();
|
||||||
@ -110,6 +115,9 @@ public class FuzzyBlockState extends BlockState {
|
|||||||
*/
|
*/
|
||||||
public FuzzyBlockState build() {
|
public FuzzyBlockState build() {
|
||||||
checkNotNull(internalState);
|
checkNotNull(internalState);
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
return internalState.getBlockType().getFuzzyMatcher();
|
||||||
|
}
|
||||||
FuzzyBlockState blockState = new FuzzyBlockState(internalState.getBlockType());
|
FuzzyBlockState blockState = new FuzzyBlockState(internalState.getBlockType());
|
||||||
for (Map.Entry<Property<?>, Object> entry : values.entrySet()) {
|
for (Map.Entry<Property<?>, Object> entry : values.entrySet()) {
|
||||||
blockState.setState(entry.getKey(), entry.getValue());
|
blockState.setState(entry.getKey(), entry.getValue());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren