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