mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-28 19:11:45 +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"
|
api "com.github.Minestom:DependencyGetter:v1.0.1"
|
||||||
implementation 'com.github.Minestom:MinestomDataGenerator:bbb3cde8fb8220b91db5d03cb34463cabaf8a88e'
|
implementation 'com.github.Minestom:MinestomDataGenerator:cd5fa6e35dd199f885cb23f9e49ba0092daabbc3'
|
||||||
|
|
||||||
// Adventure, for user-interface
|
// Adventure, for user-interface
|
||||||
api "net.kyori:adventure-api:$adventureVersion"
|
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.writeByte((byte) ((point.blockX() & 15) << 4 | point.blockZ() & 15)); // xz
|
||||||
writer.writeShort((short) point.blockY()); // y
|
writer.writeShort((short) point.blockY()); // y
|
||||||
|
|
||||||
writer.writeVarInt(0); // TODO block entity id
|
writer.writeVarInt(registry.blockEntityId());
|
||||||
|
|
||||||
|
|
||||||
final NBTCompound resultNbt = new NBTCompound();
|
final NBTCompound resultNbt = new NBTCompound();
|
||||||
|
@ -157,6 +157,7 @@ public final class Registry {
|
|||||||
private final boolean solid;
|
private final boolean solid;
|
||||||
private final boolean liquid;
|
private final boolean liquid;
|
||||||
private final String blockEntity;
|
private final String blockEntity;
|
||||||
|
private final int blockEntityId;
|
||||||
private final Supplier<Material> materialSupplier;
|
private final Supplier<Material> materialSupplier;
|
||||||
|
|
||||||
private BlockEntry(String namespace, Map<String, Object> main, Map<String, Object> override) {
|
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.solid = getBoolean("solid");
|
||||||
this.liquid = getBoolean("liquid", false);
|
this.liquid = getBoolean("liquid", false);
|
||||||
|
|
||||||
|
// Block entity
|
||||||
{
|
{
|
||||||
Map<String, Object> blockEntity = element("blockEntity");
|
final JsonElement entityElement = element("blockEntity");
|
||||||
if (blockEntity != null) {
|
if (entityElement instanceof JsonObject) {
|
||||||
this.blockEntity = (String) blockEntity.get("namespace");
|
JsonObject entityObject = (JsonObject) entityElement;
|
||||||
|
this.blockEntity = entityObject.get("namespace").getAsString();
|
||||||
|
this.blockEntityId = entityObject.get("id").getAsInt();
|
||||||
} else {
|
} else {
|
||||||
this.blockEntity = null;
|
this.blockEntity = null;
|
||||||
|
this.blockEntityId = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -244,6 +249,10 @@ public final class Registry {
|
|||||||
return blockEntity;
|
return blockEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int blockEntityId() {
|
||||||
|
return blockEntityId;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable Material material() {
|
public @Nullable Material material() {
|
||||||
return materialSupplier.get();
|
return materialSupplier.get();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user