mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Small cleanup
This commit is contained in:
parent
2d57235198
commit
235100e87b
@ -43,7 +43,7 @@ public interface Block extends ProtocolObject, TagReadable, BlockConstants {
|
||||
|
||||
@Nullable BlockHandler getHandler();
|
||||
|
||||
@NotNull Map<String, String> createPropertiesMap();
|
||||
@NotNull Map<String, String> getPropertiesMap();
|
||||
|
||||
@NotNull Registry.BlockEntry registry();
|
||||
|
||||
|
@ -53,7 +53,7 @@ class BlockRegistry {
|
||||
JsonObject stateOverride = stateEntry.getValue().getAsJsonObject();
|
||||
final int stateId = stateOverride.get("stateId").getAsInt();
|
||||
final var propertyMap = getPropertyMap(query);
|
||||
final Block block = new BlockTest(object, stateOverride, propertyMap);
|
||||
final Block block = new BlockTest(Registry.block(object, stateOverride), propertyMap);
|
||||
BLOCK_STATE_MAP.put(stateId, block);
|
||||
propertyEntry.propertyMap.put(propertyMap, block);
|
||||
});
|
||||
|
@ -1,12 +1,12 @@
|
||||
package net.minestom.server.instance.block;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minestom.server.registry.Registry;
|
||||
import net.minestom.server.tag.Tag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -34,11 +34,6 @@ class BlockTest implements Block {
|
||||
this(registry, properties, null, null);
|
||||
}
|
||||
|
||||
BlockTest(JsonObject jsonObject, JsonObject override,
|
||||
Map<String, String> properties) {
|
||||
this(Registry.block(jsonObject, override), properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Block withProperty(@NotNull String property, @NotNull String value) {
|
||||
var properties = new HashMap<>(this.properties);
|
||||
@ -48,9 +43,9 @@ class BlockTest implements Block {
|
||||
|
||||
@Override
|
||||
public @NotNull <T> Block withTag(@NotNull Tag<T> tag, @Nullable T value) {
|
||||
var block = new BlockTest(registry, properties, compound.deepClone(), handler);
|
||||
tag.write(block.compound, value);
|
||||
return block;
|
||||
var compound = this.compound != null ? this.compound.deepClone() : new NBTCompound();
|
||||
tag.write(compound, value);
|
||||
return new BlockTest(registry, properties, compound, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,8 +74,8 @@ class BlockTest implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Map<String, String> createPropertiesMap() {
|
||||
return new HashMap<>(properties);
|
||||
public @NotNull Map<String, String> getPropertiesMap() {
|
||||
return Collections.unmodifiableMap(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,7 @@ public class BiomeParticles {
|
||||
NBTCompound nbtCompound = new NBTCompound();
|
||||
nbtCompound.setString("type", type);
|
||||
nbtCompound.setString("Name", block.getName());
|
||||
Map<String, String> propertiesMap = block.createPropertiesMap();
|
||||
Map<String, String> propertiesMap = block.getPropertiesMap();
|
||||
if (propertiesMap.size() != 0) {
|
||||
NBTCompound properties = new NBTCompound();
|
||||
propertiesMap.forEach(properties::setString);
|
||||
|
Loading…
Reference in New Issue
Block a user