mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-13 22:25:53 +01:00
Fix Block#withProperty
This commit is contained in:
parent
77ef11ef30
commit
408e80799e
@ -41,10 +41,6 @@ class BlockRegistry {
|
||||
return entry.propertyMap.get(properties);
|
||||
}
|
||||
|
||||
static @Nullable Block getProperties(Block block, Map<String, String> properties) {
|
||||
return getProperties(block.namespace().asString(), properties);
|
||||
}
|
||||
|
||||
static {
|
||||
// Load data from file
|
||||
JsonObject blocks = Registry.load(Registry.Resource.BLOCK);
|
||||
|
@ -11,7 +11,6 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
class BlockTest implements Block {
|
||||
@ -45,8 +44,12 @@ class BlockTest implements Block {
|
||||
public @NotNull Block withProperty(@NotNull String property, @NotNull String value) {
|
||||
var properties = new HashMap<>(this.properties);
|
||||
properties.put(property, value);
|
||||
final Block block = BlockRegistry.getProperties(this, properties);
|
||||
return Objects.requireNonNull(block);
|
||||
Block block = BlockRegistry.getProperties(name(), properties);
|
||||
if (block == null)
|
||||
throw new IllegalArgumentException("Invalid property: " + property + ":" + value);
|
||||
if (nbt != null || handler != null)
|
||||
return new BlockTest(block.registry(), block.properties(), nbt, handler);
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user