mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-27 19:47:44 +01:00
Retrieve block entity id
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
5897fcb6e3
commit
eb6b37f20b
@ -161,7 +161,7 @@ dependencies {
|
||||
}
|
||||
|
||||
api "com.github.Minestom:DependencyGetter:v1.0.1"
|
||||
implementation 'com.github.Minestom:MinestomDataGenerator:bbb3cde8fb8220b91db5d03cb34463cabaf8a88e'
|
||||
implementation 'com.github.Minestom:MinestomDataGenerator:cd5fa6e35dd199f885cb23f9e49ba0092daabbc3'
|
||||
|
||||
// Adventure, for user-interface
|
||||
api "net.kyori:adventure-api:$adventureVersion"
|
||||
|
@ -44,7 +44,7 @@ public final class ChunkData implements Writeable {
|
||||
writer.writeByte((byte) ((point.blockX() & 15) << 4 | point.blockZ() & 15)); // xz
|
||||
writer.writeShort((short) point.blockY()); // y
|
||||
|
||||
writer.writeVarInt(0); // TODO block entity id
|
||||
writer.writeVarInt(registry.blockEntityId());
|
||||
|
||||
|
||||
final NBTCompound resultNbt = new NBTCompound();
|
||||
|
@ -157,6 +157,7 @@ public final class Registry {
|
||||
private final boolean solid;
|
||||
private final boolean liquid;
|
||||
private final String blockEntity;
|
||||
private final int blockEntityId;
|
||||
private final Supplier<Material> materialSupplier;
|
||||
|
||||
private BlockEntry(String namespace, Map<String, Object> main, Map<String, Object> override) {
|
||||
@ -174,12 +175,16 @@ public final class Registry {
|
||||
this.solid = getBoolean("solid");
|
||||
this.liquid = getBoolean("liquid", false);
|
||||
|
||||
// Block entity
|
||||
{
|
||||
Map<String, Object> blockEntity = element("blockEntity");
|
||||
if (blockEntity != null) {
|
||||
this.blockEntity = (String) blockEntity.get("namespace");
|
||||
final JsonElement entityElement = element("blockEntity");
|
||||
if (entityElement instanceof JsonObject) {
|
||||
JsonObject entityObject = (JsonObject) entityElement;
|
||||
this.blockEntity = entityObject.get("namespace").getAsString();
|
||||
this.blockEntityId = entityObject.get("id").getAsInt();
|
||||
} else {
|
||||
this.blockEntity = null;
|
||||
this.blockEntityId = 0;
|
||||
}
|
||||
}
|
||||
{
|
||||
@ -244,6 +249,10 @@ public final class Registry {
|
||||
return blockEntity;
|
||||
}
|
||||
|
||||
public int blockEntityId() {
|
||||
return blockEntityId;
|
||||
}
|
||||
|
||||
public @Nullable Material material() {
|
||||
return materialSupplier.get();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user