diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/BlastBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/BlastBlockEntity.kt
new file mode 100644
index 000000000..240d17716
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/entities/block/BlastBlockEntity.kt
@@ -0,0 +1,34 @@
+/*
+ * Minosoft
+ * Copyright (C) 2021 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.entities.block
+
+import de.bixilon.minosoft.data.mappings.ResourceLocation
+import de.bixilon.minosoft.protocol.network.connection.PlayConnection
+import de.bixilon.minosoft.util.nbt.tag.CompoundTag
+
+class BlastBlockEntity(connection: PlayConnection) : BlockEntity(connection) {
+
+
+ override fun updateNBT(nbt: CompoundTag) {
+
+ }
+
+ companion object : BlockEntityFactory {
+ override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:blast_furnace")
+
+ override fun build(connection: PlayConnection): BlastBlockEntity {
+ return BlastBlockEntity(connection)
+ }
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/CampfireBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/CampfireBlockEntity.kt
new file mode 100644
index 000000000..e69c5a8e0
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/entities/block/CampfireBlockEntity.kt
@@ -0,0 +1,47 @@
+/*
+ * Minosoft
+ * Copyright (C) 2021 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.entities.block
+
+import de.bixilon.minosoft.data.inventory.ItemStack
+import de.bixilon.minosoft.data.mappings.ResourceLocation
+import de.bixilon.minosoft.gui.rendering.RenderConstants
+import de.bixilon.minosoft.protocol.network.connection.PlayConnection
+import de.bixilon.minosoft.util.nbt.tag.CompoundTag
+import de.bixilon.minosoft.util.nbt.tag.NBTTag
+
+class CampfireBlockEntity(connection: PlayConnection) : BlockEntity(connection) {
+ val items: Array = arrayOfNulls(RenderConstants.CAMPFIRE_ITEMS)
+
+
+ override fun updateNBT(nbt: CompoundTag) {
+ val itemArray = nbt.getListTag("Items")?.getValue() as List? ?: return
+ for (slot in itemArray) {
+ check(slot is CompoundTag)
+
+ val itemStack = ItemStack(connection.mapping.itemRegistry.get(slot.getStringTag("id").value)!!, connection.version)
+
+ itemStack.itemCount = slot.getNumberTag("Count").asInt
+
+ items[slot.getNumberTag("Slot").asInt] = itemStack
+ }
+ }
+
+ companion object : BlockEntityFactory {
+ override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:campfire")
+
+ override fun build(connection: PlayConnection): CampfireBlockEntity {
+ return CampfireBlockEntity(connection)
+ }
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/DefaultBlockEntityMetaDataFactory.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/DefaultBlockEntityMetaDataFactory.kt
index d3f7d8777..520c3981b 100644
--- a/src/main/java/de/bixilon/minosoft/data/entities/block/DefaultBlockEntityMetaDataFactory.kt
+++ b/src/main/java/de/bixilon/minosoft/data/entities/block/DefaultBlockEntityMetaDataFactory.kt
@@ -22,7 +22,12 @@ object DefaultBlockEntityMetaDataFactory {
init {
val entityFactories: List> = listOf(
- BedBlockEntity
+ BedBlockEntity,
+ HopperBlockEntity,
+ SignBlockEntity,
+ BlastBlockEntity,
+ FurnaceBlockEntity,
+ CampfireBlockEntity,
)
val ret: MutableMap> = mutableMapOf()
diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/FurnaceBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/FurnaceBlockEntity.kt
new file mode 100644
index 000000000..80d6066bc
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/entities/block/FurnaceBlockEntity.kt
@@ -0,0 +1,34 @@
+/*
+ * Minosoft
+ * Copyright (C) 2021 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.entities.block
+
+import de.bixilon.minosoft.data.mappings.ResourceLocation
+import de.bixilon.minosoft.protocol.network.connection.PlayConnection
+import de.bixilon.minosoft.util.nbt.tag.CompoundTag
+
+class FurnaceBlockEntity(connection: PlayConnection) : BlockEntity(connection) {
+
+
+ override fun updateNBT(nbt: CompoundTag) {
+
+ }
+
+ companion object : BlockEntityFactory {
+ override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:furnace")
+
+ override fun build(connection: PlayConnection): FurnaceBlockEntity {
+ return FurnaceBlockEntity(connection)
+ }
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/HopperBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/HopperBlockEntity.kt
new file mode 100644
index 000000000..65207149a
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/entities/block/HopperBlockEntity.kt
@@ -0,0 +1,34 @@
+/*
+ * Minosoft
+ * Copyright (C) 2021 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.entities.block
+
+import de.bixilon.minosoft.data.mappings.ResourceLocation
+import de.bixilon.minosoft.protocol.network.connection.PlayConnection
+import de.bixilon.minosoft.util.nbt.tag.CompoundTag
+
+class HopperBlockEntity(connection: PlayConnection) : BlockEntity(connection) {
+
+
+ override fun updateNBT(nbt: CompoundTag) {
+
+ }
+
+ companion object : BlockEntityFactory {
+ override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:hopper")
+
+ override fun build(connection: PlayConnection): HopperBlockEntity {
+ return HopperBlockEntity(connection)
+ }
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/SignBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/SignBlockEntity.kt
new file mode 100644
index 000000000..44a30d229
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/entities/block/SignBlockEntity.kt
@@ -0,0 +1,41 @@
+/*
+ * Minosoft
+ * Copyright (C) 2021 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program.If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.data.entities.block
+
+import de.bixilon.minosoft.data.mappings.ResourceLocation
+import de.bixilon.minosoft.data.text.ChatComponent
+import de.bixilon.minosoft.gui.rendering.RenderConstants
+import de.bixilon.minosoft.protocol.network.connection.PlayConnection
+import de.bixilon.minosoft.util.nbt.tag.CompoundTag
+
+class SignBlockEntity(connection: PlayConnection) : BlockEntity(connection) {
+ var lines: Array = Array(RenderConstants.SIGN_LINES) { ChatComponent.valueOf(raw = "") }
+
+
+ override fun updateNBT(nbt: CompoundTag) {
+ for (i in 0 until RenderConstants.SIGN_LINES) {
+ val tag = nbt.getStringTag("Text$i") ?: continue
+
+ lines[i] = ChatComponent.valueOf(translator = connection.version.localeManager, raw = tag.value)
+ }
+ }
+
+ companion object : BlockEntityFactory {
+ override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:sign")
+
+ override fun build(connection: PlayConnection): SignBlockEntity {
+ return SignBlockEntity(connection)
+ }
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/registry/Registry.kt b/src/main/java/de/bixilon/minosoft/data/mappings/registry/Registry.kt
index 653c85687..008547bf4 100644
--- a/src/main/java/de/bixilon/minosoft/data/mappings/registry/Registry.kt
+++ b/src/main/java/de/bixilon/minosoft/data/mappings/registry/Registry.kt
@@ -32,6 +32,10 @@ open class Registry(
return resourceLocationMap[resourceLocation] ?: parentRegistry?.get(resourceLocation)
}
+ open fun get(resourceLocation: String): T? {
+ return get(ResourceLocation.getPathResourceLocation(resourceLocation))
+ }
+
open fun get(id: Int): T {
return idValueMap[id] ?: parentRegistry?.get(id)!!
}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/RenderConstants.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/RenderConstants.kt
index 3e93cdff0..b15ab3259 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/RenderConstants.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/RenderConstants.kt
@@ -68,4 +68,7 @@ object RenderConstants {
val PIXEL_UV_PIXEL_ADD = Vec2(0, 0.1f)
+
+ const val SIGN_LINES = 4
+ const val CAMPFIRE_ITEMS = 4
}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/c2s/play/ClientSettingsC2SPacket.kt b/src/main/java/de/bixilon/minosoft/protocol/packets/c2s/play/ClientSettingsC2SPacket.kt
index dc193d8fc..285b295d4 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/c2s/play/ClientSettingsC2SPacket.kt
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/c2s/play/ClientSettingsC2SPacket.kt
@@ -41,6 +41,6 @@ class ClientSettingsC2SPacket(private val locale: String = "en_US", private val
}
override fun log() {
- Log.protocol(String.format("[OUT] Sending settings (locale=%s, renderDistance=%d)", locale, renderDistance))
+ Log.protocol("[OUT] Sending settings (locale=$locale, renderDistance=$renderDistance)")
}
}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/PacketChunkData.kt b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/PacketChunkData.kt
index 035d705c5..f3e1943d1 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/PacketChunkData.kt
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/PacketChunkData.kt
@@ -137,6 +137,6 @@ class PacketChunkData() : PlayS2CPacket() {
}
override fun log() {
- Log.protocol(String.format("[IN] Chunk packet received (position=%s)", chunkPosition))
+ Log.protocol("[IN] Chunk packet received (chunkPosition=$chunkPosition)")
}
}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/PlayInByteBuffer.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/PlayInByteBuffer.java
index d331d8bb0..5e1639113 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/protocol/PlayInByteBuffer.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/PlayInByteBuffer.java
@@ -63,7 +63,7 @@ public class PlayInByteBuffer extends InByteBuffer {
int x = (int) (raw >> 38);
if (this.versionId < V_18W43A) {
int y = (int) ((raw >> 26) & 0xFFF);
- int z = (int) (raw & 0x3FFFFFF);
+ int z = (int) (raw << 38 >> 38);
return new Vec3i(x, y, z);
}
int y = (int) (raw << 52 >> 52);