From 3f9b91c8aa8334fdac158c94c17345c561d6c15c Mon Sep 17 00:00:00 2001 From: Bixilon Date: Thu, 6 May 2021 19:19:34 +0200 Subject: [PATCH] replace block actions with block entity meta data --- .../de/bixilon/minosoft/data/Directions.kt | 15 ++-- .../data/entities/block/BeaconBlockEntity.kt | 6 +- .../data/entities/block/BellBlockEntity.kt | 9 ++- .../block/BlockActionEntity.kt} | 7 +- .../DefaultBlockEntityMetaDataFactory.kt | 5 ++ .../entities/block/EndGatewayBlockEntity.kt | 35 +++++++++ .../entities/block/MobSpawnerBlockEntity.kt | 6 +- .../entities/block/NoteblockBlockEntity.kt | 21 ++++- .../storage/ShulkerBoxBlockEntity.kt | 1 + .../container/storage/StorageBlockEntity.kt | 10 ++- .../block/piston/PistonBlockEntity.kt | 55 +++++++++++++ .../block/piston/StickyPistonBlockEntity.kt} | 21 ++--- .../mappings/blocks/actions/BeaconAction.java | 26 ------- .../mappings/blocks/actions/BellAction.java | 33 -------- .../mappings/blocks/actions/ChestAction.java | 27 ------- .../blocks/actions/EndGatewayAction.java | 26 ------- .../blocks/actions/NoteBlockAction.java | 43 ----------- .../mappings/blocks/actions/PistonAction.java | 42 ---------- .../gui/rendering/chunk/WorldRenderer.kt | 4 +- .../chunk/models/renderable/BlockRenderer.kt | 12 +-- .../models/renderable/ElementRenderer.kt | 6 +- .../chunk/models/renderable/FluidRenderer.kt | 6 +- .../models/renderable/MultipartRenderer.kt | 2 +- .../event/events/BlockActionEvent.java | 47 ----------- .../packets/s2c/play/BlockActionS2CP.kt | 70 +++++++++++++++++ .../packets/s2c/play/PacketBlockAction.java | 77 ------------------- .../protocol/protocol/InByteBuffer.kt | 2 +- .../minosoft/protocol/protocol/PacketTypes.kt | 2 +- 28 files changed, 255 insertions(+), 361 deletions(-) rename src/main/java/de/bixilon/minosoft/data/{mappings/blocks/actions/BlockAction.java => entities/block/BlockActionEntity.kt} (81%) create mode 100644 src/main/java/de/bixilon/minosoft/data/entities/block/EndGatewayBlockEntity.kt create mode 100644 src/main/java/de/bixilon/minosoft/data/entities/block/piston/PistonBlockEntity.kt rename src/main/java/de/bixilon/minosoft/data/{mappings/blocks/actions/MobSpawnerAction.java => entities/block/piston/StickyPistonBlockEntity.kt} (55%) delete mode 100644 src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BeaconAction.java delete mode 100644 src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BellAction.java delete mode 100644 src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/ChestAction.java delete mode 100644 src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/EndGatewayAction.java delete mode 100644 src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/NoteBlockAction.java delete mode 100644 src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/PistonAction.java delete mode 100644 src/main/java/de/bixilon/minosoft/modding/event/events/BlockActionEvent.java create mode 100644 src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/BlockActionS2CP.kt delete mode 100644 src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/PacketBlockAction.java diff --git a/src/main/java/de/bixilon/minosoft/data/Directions.kt b/src/main/java/de/bixilon/minosoft/data/Directions.kt index 78cf29f06..466d82067 100644 --- a/src/main/java/de/bixilon/minosoft/data/Directions.kt +++ b/src/main/java/de/bixilon/minosoft/data/Directions.kt @@ -14,6 +14,8 @@ package de.bixilon.minosoft.data import de.bixilon.minosoft.gui.rendering.chunk.models.FaceSize import de.bixilon.minosoft.gui.rendering.chunk.models.loading.BlockModelElement +import de.bixilon.minosoft.util.KUtil +import de.bixilon.minosoft.util.enum.ValuesEnum import glm_.vec2.Vec2i import glm_.vec3.Vec3 import glm_.vec3.Vec3i @@ -83,22 +85,23 @@ enum class Directions(val directionVector: Vec3i) { } - companion object { - val DIRECTIONS = values() + companion object : ValuesEnum { + override val VALUES = values() + override val NAME_MAP: Map = KUtil.getEnumValues(VALUES) val SIDES = arrayOf(NORTH, SOUTH, WEST, EAST) const val SIDES_OFFSET = 2 @JvmStatic fun byId(id: Int): Directions { - return DIRECTIONS[id] + return VALUES[id] } private const val MIN_ERROR = 0.0001f fun byDirection(direction: Vec3): Directions { - var minDirection = DIRECTIONS[0] + var minDirection = VALUES[0] var minError = 2.0f - for (testDirection in DIRECTIONS) { + for (testDirection in VALUES) { val error = (testDirection.floatDirectionVector - direction).length() if (error < MIN_ERROR) { return testDirection @@ -112,7 +115,7 @@ enum class Directions(val directionVector: Vec3i) { init { - for (direction in DIRECTIONS) { + for (direction in VALUES) { direction.inverted = direction.inverse() } } diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/BeaconBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/BeaconBlockEntity.kt index 0df5f1a77..281605129 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/BeaconBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/BeaconBlockEntity.kt @@ -16,7 +16,11 @@ package de.bixilon.minosoft.data.entities.block import de.bixilon.minosoft.data.mappings.ResourceLocation import de.bixilon.minosoft.protocol.network.connection.PlayConnection -class BeaconBlockEntity(connection: PlayConnection) : BlockEntity(connection) { +class BeaconBlockEntity(connection: PlayConnection) : BlockEntity(connection), BlockActionEntity { + + override fun setBlockActionData(data1: Byte, data2: Byte) { + // no data used, just recalculates the beam + } override fun updateNBT(nbt: Map) { // ToDO: {Secondary: -1, Paper.Range: -1.0D, Primary: -1, x: -90, y: 4, Levels: 0, z: 212, id: "minecraft:beacon"} diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/BellBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/BellBlockEntity.kt index 983fa6c8d..4ac876118 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/BellBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/BellBlockEntity.kt @@ -13,10 +13,17 @@ package de.bixilon.minosoft.data.entities.block +import de.bixilon.minosoft.data.Directions import de.bixilon.minosoft.data.mappings.ResourceLocation import de.bixilon.minosoft.protocol.network.connection.PlayConnection -class BellBlockEntity(connection: PlayConnection) : BlockEntity(connection) { +class BellBlockEntity(connection: PlayConnection) : BlockEntity(connection), BlockActionEntity { + var shakingDirection: Directions = Directions.NORTH + private set + + override fun setBlockActionData(data1: Byte, data2: Byte) { + shakingDirection = Directions[data2.toInt()] + } companion object : BlockEntityFactory { override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:bell") diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BlockAction.java b/src/main/java/de/bixilon/minosoft/data/entities/block/BlockActionEntity.kt similarity index 81% rename from src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BlockAction.java rename to src/main/java/de/bixilon/minosoft/data/entities/block/BlockActionEntity.kt index 0fdfde935..2806067d0 100644 --- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BlockAction.java +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/BlockActionEntity.kt @@ -1,6 +1,6 @@ /* * Minosoft - * Copyright (C) 2020 Moritz Zwerger + * 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. * @@ -11,7 +11,8 @@ * This software is not affiliated with Mojang AB, the original developer of Minecraft. */ -package de.bixilon.minosoft.data.mappings.blocks.actions; +package de.bixilon.minosoft.data.entities.block -public interface BlockAction { +interface BlockActionEntity { + fun setBlockActionData(data1: Byte, data2: Byte) } 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 bcf057dc4..e4791aeff 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 @@ -15,6 +15,8 @@ package de.bixilon.minosoft.data.entities.block import de.bixilon.minosoft.data.entities.block.container.* import de.bixilon.minosoft.data.entities.block.container.storage.* +import de.bixilon.minosoft.data.entities.block.piston.PistonBlockEntity +import de.bixilon.minosoft.data.entities.block.piston.StickyPistonBlockEntity import de.bixilon.minosoft.data.mappings.ResourceLocation import de.bixilon.minosoft.protocol.network.connection.PlayConnection @@ -55,6 +57,9 @@ object DefaultBlockEntityMetaDataFactory { TrappedChestBlockEntity, BeehiveBlockEntity, NoteblockBlockEntity, + EndGatewayBlockEntity, + PistonBlockEntity, + StickyPistonBlockEntity, ) val ret: MutableMap> = mutableMapOf() diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/EndGatewayBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/EndGatewayBlockEntity.kt new file mode 100644 index 000000000..cd7cc2d46 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/EndGatewayBlockEntity.kt @@ -0,0 +1,35 @@ +/* + * 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 + +class EndGatewayBlockEntity(connection: PlayConnection) : BlockEntity(connection), BlockActionEntity { + + override fun setBlockActionData(data1: Byte, data2: Byte) { + // just emits the beacon like beam + } + + override fun updateNBT(nbt: Map) { + } + + companion object : BlockEntityFactory { + override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:end_gateway") + + override fun build(connection: PlayConnection): EndGatewayBlockEntity { + return EndGatewayBlockEntity(connection) + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/MobSpawnerBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/MobSpawnerBlockEntity.kt index cd6d59286..909fc30c2 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/MobSpawnerBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/MobSpawnerBlockEntity.kt @@ -16,9 +16,13 @@ package de.bixilon.minosoft.data.entities.block import de.bixilon.minosoft.data.mappings.ResourceLocation import de.bixilon.minosoft.protocol.network.connection.PlayConnection -class MobSpawnerBlockEntity(connection: PlayConnection) : BlockEntity(connection) { +class MobSpawnerBlockEntity(connection: PlayConnection) : BlockEntity(connection), BlockActionEntity { + override fun setBlockActionData(data1: Byte, data2: Byte) { + // ToDo + } + override fun updateNBT(nbt: Map) { // ToDo: {MaxNearbyEntities: 6s, RequiredPlayerRange: 16s, SpawnCount: 4s, x: -80, y: 4, SpawnData: {id: "minecraft:zombie"}, z: 212, id: "minecraft:mob_spawner", MaxSpawnDelay: 800s, SpawnRange: 4s, Delay: 0s, MinSpawnDelay: 200s} } diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/NoteblockBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/NoteblockBlockEntity.kt index e4c0b3106..17905110f 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/NoteblockBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/NoteblockBlockEntity.kt @@ -14,9 +14,27 @@ package de.bixilon.minosoft.data.entities.block import de.bixilon.minosoft.data.mappings.ResourceLocation +import de.bixilon.minosoft.data.mappings.blocks.properties.Instruments import de.bixilon.minosoft.protocol.network.connection.PlayConnection -class NoteblockBlockEntity(connection: PlayConnection) : BlockEntity(connection) { +class NoteblockBlockEntity(connection: PlayConnection) : BlockEntity(connection), BlockActionEntity { + var instrument: Instruments? = null + private set + var pitch: Int? = null + private set + + override fun setBlockActionData(data1: Byte, data2: Byte) { + instrument = when (data1.toInt()) { + 0 -> Instruments.HARP + 1 -> Instruments.BASS + 2 -> Instruments.SNARE + 3 -> Instruments.BANJO // ToDo: Was CLICKS_STICKS before + 4 -> Instruments.BASE_DRUM + else -> null + } + + pitch = data2.toInt() + } companion object : BlockEntityFactory { override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:noteblock") @@ -25,4 +43,5 @@ class NoteblockBlockEntity(connection: PlayConnection) : BlockEntity(connection) return NoteblockBlockEntity(connection) } } + } diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ShulkerBoxBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ShulkerBoxBlockEntity.kt index f1515ad57..a8e409a8d 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ShulkerBoxBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/ShulkerBoxBlockEntity.kt @@ -19,6 +19,7 @@ import de.bixilon.minosoft.protocol.network.connection.PlayConnection class ShulkerBoxBlockEntity(connection: PlayConnection) : StorageBlockEntity(connection) { + companion object : BlockEntityFactory { override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:shulker_box") diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/StorageBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/StorageBlockEntity.kt index 48d7315be..456b5525a 100644 --- a/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/StorageBlockEntity.kt +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/container/storage/StorageBlockEntity.kt @@ -13,7 +13,15 @@ package de.bixilon.minosoft.data.entities.block.container.storage +import de.bixilon.minosoft.data.entities.block.BlockActionEntity import de.bixilon.minosoft.data.entities.block.container.ContainerBlockEntity import de.bixilon.minosoft.protocol.network.connection.PlayConnection -abstract class StorageBlockEntity(connection: PlayConnection) : ContainerBlockEntity(connection) +abstract class StorageBlockEntity(connection: PlayConnection) : ContainerBlockEntity(connection), BlockActionEntity { + var playersLookingIntoStorage: Int = 0 + private set + + override fun setBlockActionData(data1: Byte, data2: Byte) { + playersLookingIntoStorage = data2.toInt() + } +} diff --git a/src/main/java/de/bixilon/minosoft/data/entities/block/piston/PistonBlockEntity.kt b/src/main/java/de/bixilon/minosoft/data/entities/block/piston/PistonBlockEntity.kt new file mode 100644 index 000000000..855ba7908 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/piston/PistonBlockEntity.kt @@ -0,0 +1,55 @@ +/* + * 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.piston + +import de.bixilon.minosoft.data.Directions +import de.bixilon.minosoft.data.entities.block.BlockActionEntity +import de.bixilon.minosoft.data.entities.block.BlockEntity +import de.bixilon.minosoft.data.entities.block.BlockEntityFactory +import de.bixilon.minosoft.data.mappings.ResourceLocation +import de.bixilon.minosoft.protocol.network.connection.PlayConnection +import de.bixilon.minosoft.util.KUtil +import de.bixilon.minosoft.util.enum.ValuesEnum + +open class PistonBlockEntity(connection: PlayConnection) : BlockEntity(connection), BlockActionEntity { + var state: PistonStates = PistonStates.PULL + private set + var direction: Directions = Directions.NORTH + private set + + override fun setBlockActionData(data1: Byte, data2: Byte) { + state = PistonStates[data1.toInt()] + direction = Directions[data2.toInt()] + } + + companion object : BlockEntityFactory { + override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:piston") + + override fun build(connection: PlayConnection): PistonBlockEntity { + return PistonBlockEntity(connection) + } + } + + enum class PistonStates { + PUSH, + PULL, + ; + + companion object : ValuesEnum { + override val VALUES: Array = values() + override val NAME_MAP: Map = KUtil.getEnumValues(VALUES) + + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/MobSpawnerAction.java b/src/main/java/de/bixilon/minosoft/data/entities/block/piston/StickyPistonBlockEntity.kt similarity index 55% rename from src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/MobSpawnerAction.java rename to src/main/java/de/bixilon/minosoft/data/entities/block/piston/StickyPistonBlockEntity.kt index 5b976de3b..25a1f8901 100644 --- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/MobSpawnerAction.java +++ b/src/main/java/de/bixilon/minosoft/data/entities/block/piston/StickyPistonBlockEntity.kt @@ -1,6 +1,6 @@ /* * Minosoft - * Copyright (C) 2020 Moritz Zwerger + * 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. * @@ -11,16 +11,19 @@ * This software is not affiliated with Mojang AB, the original developer of Minecraft. */ -package de.bixilon.minosoft.data.mappings.blocks.actions; +package de.bixilon.minosoft.data.entities.block.piston -public class MobSpawnerAction implements BlockAction { +import de.bixilon.minosoft.data.entities.block.BlockEntityFactory +import de.bixilon.minosoft.data.mappings.ResourceLocation +import de.bixilon.minosoft.protocol.network.connection.PlayConnection - public MobSpawnerAction(int status, int ignored) { - // only 1 action (id 1) - } +class StickyPistonBlockEntity(connection: PlayConnection) : PistonBlockEntity(connection) { - @Override - public String toString() { - return "MOB_SPAWNER_RESET_DELAY"; + companion object : BlockEntityFactory { + override val RESOURCE_LOCATION: ResourceLocation = ResourceLocation("minecraft:sticky_piston") + + override fun build(connection: PlayConnection): StickyPistonBlockEntity { + return StickyPistonBlockEntity(connection) + } } } diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BeaconAction.java b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BeaconAction.java deleted file mode 100644 index fcfad6209..000000000 --- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BeaconAction.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Minosoft - * Copyright (C) 2020 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.mappings.blocks.actions; - -public class BeaconAction implements BlockAction { - - public BeaconAction(int status, int ignored) { - // only 1 action (id 1) - } - - @Override - public String toString() { - return "BEACON_RECALCULATE_BEAM"; - } -} diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BellAction.java b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BellAction.java deleted file mode 100644 index a2ec95a25..000000000 --- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/BellAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Minosoft - * Copyright (C) 2020 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.mappings.blocks.actions; - -import de.bixilon.minosoft.data.Directions; - -public class BellAction implements BlockAction { - private final Directions direction; - - public BellAction(short unused, short direction) { - this.direction = Directions.byId(direction); - } - - public Directions getDirection() { - return this.direction; - } - - @Override - public String toString() { - return String.format("BELL_HIT_%s", this.direction); - } -} diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/ChestAction.java b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/ChestAction.java deleted file mode 100644 index faed68e93..000000000 --- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/ChestAction.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Minosoft - * Copyright (C) 2020 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.mappings.blocks.actions; - -public class ChestAction implements BlockAction { - private final int playersLookingInChest; - - public ChestAction(int unused, int playersLookingInChest) { - this.playersLookingInChest = playersLookingInChest; - } - - @Override - public String toString() { - return this.playersLookingInChest > 0 ? String.format("CHEST_OPEN (%d)", this.playersLookingInChest) : "CHEST_CLOSE"; - } -} diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/EndGatewayAction.java b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/EndGatewayAction.java deleted file mode 100644 index 81c3e5b0c..000000000 --- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/EndGatewayAction.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Minosoft - * Copyright (C) 2020 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.mappings.blocks.actions; - -public class EndGatewayAction implements BlockAction { - - public EndGatewayAction(int status, int ignored) { - // only 1 action (id 1) - } - - @Override - public String toString() { - return "END_GATEWAY_EMIT_BEAM"; - } -} diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/NoteBlockAction.java b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/NoteBlockAction.java deleted file mode 100644 index fd81fd3a7..000000000 --- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/NoteBlockAction.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Minosoft - * Copyright (C) 2020 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.mappings.blocks.actions; - -public class NoteBlockAction implements BlockAction { - private final Instruments instrument; - private final int pitch; - - public NoteBlockAction(int instrument, int pitch) { - this.instrument = Instruments.byId(instrument); - this.pitch = pitch; - } - - @Override - public String toString() { - return String.format("NOTEBLOCK_%s:%d", this.instrument, this.pitch); - } - - public enum Instruments { - HARP, - DOUBLE_BASS, - SNARE_DRUM, - CLICKS_STICKS, - BASS_DRUM; - - private static final Instruments[] INSTRUMENTS = values(); - - public static Instruments byId(int id) { - return INSTRUMENTS[id]; - } - } -} diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/PistonAction.java b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/PistonAction.java deleted file mode 100644 index 9ff45254d..000000000 --- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/actions/PistonAction.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Minosoft - * Copyright (C) 2020 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.mappings.blocks.actions; - -import de.bixilon.minosoft.data.Directions; - -public class PistonAction implements BlockAction { - private final PistonStates status; - private final Directions direction; - - public PistonAction(int status, int direction) { - this.status = PistonStates.byId(status); - this.direction = Directions.byId(direction); - } - - @Override - public String toString() { - return String.format("PISTON_%s:%s", this.status, this.direction); - } - - public enum PistonStates { - PUSH, - PULL; - - private static final PistonStates[] PISTON_STATES = values(); - - public static PistonStates byId(int id) { - return PISTON_STATES[id]; - } - } -} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt index 4f957c8ed..6c6fa63e6 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt @@ -80,8 +80,8 @@ class WorldRenderer( } val blockPosition = Vec3i.of(chunkPosition, sectionHeight, index.indexPosition) - val neighborBlocks: Array = arrayOfNulls(Directions.DIRECTIONS.size) - for (direction in Directions.DIRECTIONS) { + val neighborBlocks: Array = arrayOfNulls(Directions.VALUES.size) + for (direction in Directions.VALUES) { neighborBlocks[direction.ordinal] = world.getBlockState(blockPosition + direction) } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/BlockRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/BlockRenderer.kt index 713181442..2a3ab1547 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/BlockRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/BlockRenderer.kt @@ -35,12 +35,12 @@ import glm_.vec3.Vec3 import glm_.vec3.Vec3i class BlockRenderer(data: JsonObject, parent: BlockModel) : BlockLikeRenderer { - private val cullFaces: Array = arrayOfNulls(Directions.DIRECTIONS.size) + private val cullFaces: Array = arrayOfNulls(Directions.VALUES.size) val textures: MutableMap = mutableMapOf() private val elements: MutableSet = mutableSetOf() private val textureMapping: MutableMap = mutableMapOf() - override val faceBorderSizes: Array?> = arrayOfNulls(Directions.DIRECTIONS.size) - override val transparentFaces: BooleanArray = BooleanArray(Directions.DIRECTIONS.size) + override val faceBorderSizes: Array?> = arrayOfNulls(Directions.VALUES.size) + override val transparentFaces: BooleanArray = BooleanArray(Directions.VALUES.size) val directionMapping: HashBiMap = HashBiMap.create() init { @@ -52,7 +52,7 @@ class BlockRenderer(data: JsonObject, parent: BlockModel) : BlockLikeRenderer { } private fun createDirectionMapping(rotation: Vec3) { - for (direction in Directions.DIRECTIONS) { + for (direction in Directions.VALUES) { try { directionMapping[direction] = ElementRenderer.getRotatedDirection(rotation, direction) } catch (_: IllegalArgumentException) { @@ -69,7 +69,7 @@ class BlockRenderer(data: JsonObject, parent: BlockModel) : BlockLikeRenderer { } override fun postInit() { - for (direction in Directions.DIRECTIONS) { + for (direction in Directions.VALUES) { var directionIsCullFace: Boolean? = null var directionIsNotTransparent: Boolean? = null val faceBorderSites: MutableList = mutableListOf() @@ -109,7 +109,7 @@ class BlockRenderer(data: JsonObject, parent: BlockModel) : BlockLikeRenderer { var tintColor: RGBColor? = null var biome: Biome? = null - for (direction in Directions.DIRECTIONS) { + for (direction in Directions.VALUES) { val rotatedDirection = directionMapping[direction] ?: direction val invertedDirection = direction.inverted var isNeighbourTransparent = false diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt index e7dc4e4a8..93ad4bef5 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt @@ -40,7 +40,7 @@ class ElementRenderer( rescale: Boolean, private val directionMapping: HashBiMap, ) { - val faceBorderSize: Array = arrayOfNulls(Directions.DIRECTIONS.size) + val faceBorderSize: Array = arrayOfNulls(Directions.VALUES.size) private val faces: MutableMap = mutableMapOf() private var transformedPositions: Array = parent.transformedPositions.clone() private val from = parent.from @@ -48,7 +48,7 @@ class ElementRenderer( init { rotatePositionsAxes(transformedPositions, rotation, rescale) - for (direction in Directions.DIRECTIONS) { + for (direction in Directions.VALUES) { direction.getFaceBorderSizes(from, to)?.let { faceBorderSize[direction.ordinal] = it } @@ -57,7 +57,7 @@ class ElementRenderer( } } if (uvLock) { - for (direction in Directions.DIRECTIONS) { + for (direction in Directions.VALUES) { val axis = Axes.byDirection(direction) val angle = Axes.choose(axis, rotation) * Axes.choose(axis, direction.directionVector) faces[direction]?.rotate(-angle) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/FluidRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/FluidRenderer.kt index 6c5dfc4cf..bf78d857f 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/FluidRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/FluidRenderer.kt @@ -27,8 +27,8 @@ class FluidRenderer( private val stillFluid: Fluid, private val flowingFluid: Fluid, ) : BlockLikeRenderer { - override val faceBorderSizes: Array?> = arrayOfNulls(Directions.DIRECTIONS.size) - override val transparentFaces: BooleanArray = BooleanArray(Directions.DIRECTIONS.size) + override val faceBorderSizes: Array?> = arrayOfNulls(Directions.VALUES.size) + override val transparentFaces: BooleanArray = BooleanArray(Directions.VALUES.size) private lateinit var stillTexture: Texture private lateinit var flowingTexture: Texture @@ -46,7 +46,7 @@ class FluidRenderer( var biome: Biome? = null val positions = calculatePositions(heights) - for (direction in Directions.DIRECTIONS) { + for (direction in Directions.VALUES) { val face = BlockModelFace(positions, direction) if (isFlowing || Directions.SIDES.contains(direction)) { face.scale(0.5) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/MultipartRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/MultipartRenderer.kt index 6a0d1340a..0ace5f872 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/MultipartRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/MultipartRenderer.kt @@ -27,7 +27,7 @@ class MultipartRenderer( val models: List, ) : BlockLikeRenderer { override val faceBorderSizes: Array?> - override val transparentFaces: BooleanArray = BooleanArray(Directions.DIRECTIONS.size) + override val transparentFaces: BooleanArray = BooleanArray(Directions.VALUES.size) init { val faceBorderSizes: MutableList?> = mutableListOf() diff --git a/src/main/java/de/bixilon/minosoft/modding/event/events/BlockActionEvent.java b/src/main/java/de/bixilon/minosoft/modding/event/events/BlockActionEvent.java deleted file mode 100644 index 6a820cdbc..000000000 --- a/src/main/java/de/bixilon/minosoft/modding/event/events/BlockActionEvent.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Minosoft - * Copyright (C) 2020 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.modding.event.events; - -import de.bixilon.minosoft.data.mappings.blocks.actions.BlockAction; -import de.bixilon.minosoft.protocol.network.connection.PlayConnection; -import de.bixilon.minosoft.protocol.packets.s2c.play.PacketBlockAction; -import glm_.vec3.Vec3i; - -/** - * Fired when a block actions happens (like opening a chest, changing instrument/note/etc on a note block, etc) - */ -public class BlockActionEvent extends CancelableEvent { - private final Vec3i position; - private final BlockAction data; - - public BlockActionEvent(PlayConnection connection, Vec3i position, BlockAction data) { - super(connection); - this.position = position; - this.data = data; - } - - public BlockActionEvent(PlayConnection connection, PacketBlockAction pkg) { - super(connection); - this.position = pkg.getPosition(); - this.data = pkg.getData(); - } - - public Vec3i getPosition() { - return this.position; - } - - public BlockAction getData() { - return this.data; - } -} diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/BlockActionS2CP.kt b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/BlockActionS2CP.kt new file mode 100644 index 000000000..0e584f4ae --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/BlockActionS2CP.kt @@ -0,0 +1,70 @@ +/* + * Minosoft + * Copyright (C) 2020 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.protocol.packets.s2c.play + +import de.bixilon.minosoft.data.entities.block.BlockActionEntity +import de.bixilon.minosoft.data.entities.block.DefaultBlockEntityMetaDataFactory +import de.bixilon.minosoft.data.mappings.blocks.Block +import de.bixilon.minosoft.protocol.network.connection.PlayConnection +import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket +import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer +import de.bixilon.minosoft.protocol.protocol.ProtocolVersions +import de.bixilon.minosoft.util.KUtil.asResourceLocation +import de.bixilon.minosoft.util.logging.Log +import de.bixilon.minosoft.util.logging.LogLevels +import de.bixilon.minosoft.util.logging.LogMessageType +import glm_.vec3.Vec3i + +class BlockActionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() { + val position: Vec3i = if (buffer.versionId < ProtocolVersions.V_14W03B) { + buffer.readShortBlockPosition() + } else { + buffer.readBlockPosition() + } + val data1: Byte = buffer.readByte() + val data2: Byte = buffer.readByte() + val block: Block = buffer.connection.mapping.blockRegistry.get(buffer.readVarInt()) + + override fun handle(connection: PlayConnection) { + val blockEntityTypeResourceLocation = when (block.resourceLocation.full) { + "minecraft:white_shulker_box", "minecraft:orange_shulker_box", "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", + "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", + "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", + "minecraft:brown_shulker_box", "minecraft:green_shulker_box", "minecraft:red_shulker_box", "minecraft:black_shulker_box", + -> "minecraft:shulker_box" + else -> block.resourceLocation.full + }.asResourceLocation() + + val blockEntity = connection.world.getBlockEntity(position) ?: let { + val factory = connection.mapping.blockEntityRegistry.get(blockEntityTypeResourceLocation)?.factory + ?: DefaultBlockEntityMetaDataFactory.getEntityFactory(blockEntityTypeResourceLocation) + ?: let { + Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN) { "Unknown block entity $blockEntityTypeResourceLocation" } + return + } + val blockEntity = factory.build(connection) + connection.world.setBlockEntity(position, blockEntity) + blockEntity + } + + if (blockEntity !is BlockActionEntity) { + Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.WARN) { "Block entity $blockEntity can not accept block entity actions!" } + return + } + blockEntity.setBlockActionData(data1, data2) + } + + override fun log() { + Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Block action (position=$position, data1=$data1, data2=$data2, block=$block)" } + } +} diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/PacketBlockAction.java b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/PacketBlockAction.java deleted file mode 100644 index d4e99f476..000000000 --- a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/PacketBlockAction.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Minosoft - * Copyright (C) 2020 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.protocol.packets.s2c.play; - -import de.bixilon.minosoft.data.mappings.blocks.Block; -import de.bixilon.minosoft.data.mappings.blocks.actions.*; -import de.bixilon.minosoft.modding.event.events.BlockActionEvent; -import de.bixilon.minosoft.protocol.network.connection.PlayConnection; -import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket; -import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer; -import de.bixilon.minosoft.util.logging.Log; -import glm_.vec3.Vec3i; - -import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_14W03B; - -public class PacketBlockAction extends PlayS2CPacket { - private final Vec3i position; - private final BlockAction data; - - public PacketBlockAction(PlayInByteBuffer buffer) { - // that's the only difference here - if (buffer.getVersionId() < V_14W03B) { - this.position = buffer.readShortBlockPosition(); - } else { - this.position = buffer.readBlockPosition(); - } - int byte1 = buffer.readUnsignedByte(); - int byte2 = buffer.readUnsignedByte(); - Block blockId = buffer.getConnection().getMapping().getBlockRegistry().get(buffer.readVarInt()); - if (blockId == null) { - this.data = null; - return; - } - - this.data = switch (blockId.getResourceLocation().getFull()) { - case "minecraft:noteblock" -> new NoteBlockAction(byte1, byte2); // ToDo: was replaced in 17w47a (346) with the block id - case "minecraft:sticky_piston", "minecraft:piston" -> new PistonAction(byte1, byte2); - case "minecraft:chest", "minecraft:ender_chest", "minecraft:trapped_chest", "minecraft:white_shulker_box", "minecraft:shulker_box", "minecraft:orange_shulker_box", "minecraft:magenta_shulker_box", "minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box", "minecraft:lime_shulker_box", "minecraft:pink_shulker_box", "minecraft:gray_shulker_box", "minecraft:silver_shulker_box", "minecraft:cyan_shulker_box", "minecraft:purple_shulker_box", "minecraft:blue_shulker_box", "minecraft:brown_shulker_box", "minecraft:green_shulker_box", "minecraft:red_shulker_box", "minecraft:black_shulker_box" -> new ChestAction(byte1, byte2); - case "minecraft:beacon" -> new BeaconAction(byte1, byte2); - case "minecraft:mob_spawner" -> new MobSpawnerAction(byte1, byte2); - case "minecraft:end_gateway" -> new EndGatewayAction(byte1, byte2); - default -> null; - }; - } - - @Override - public void handle(PlayConnection connection) { - BlockActionEvent event = new BlockActionEvent(connection, this); - if (connection.fireEvent(event)) { - return; - } - } - - public Vec3i getPosition() { - return this.position; - } - - public BlockAction getData() { - return this.data; - } - - @Override - public void log() { - Log.protocol(String.format("[IN] Block action received %s at %s", this.data, this.position)); - } -} diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.kt b/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.kt index ce92d3581..ce6de14a0 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.kt +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.kt @@ -260,7 +260,7 @@ open class InByteBuffer { } fun readDirection(): Directions { - return Directions.DIRECTIONS[readVarInt()] + return Directions.VALUES[readVarInt()] } fun readPose(): Poses { diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketTypes.kt b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketTypes.kt index 454b3be92..d39cfc453 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketTypes.kt +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketTypes.kt @@ -162,7 +162,7 @@ class PacketTypes { PLAY_BLOCK_BREAK_ACK({ BlockBreakAckS2CP(it) }), PLAY_BLOCK_BREAK_ANIMATION({ BlockBreakAnimationS2CP(it) }), PLAY_BLOCK_ENTITY_META_DATA({ BlockEntityMetaDataS2CP(it) }), - PLAY_BLOCK_ACTION({ PacketBlockAction(it) }), + PLAY_BLOCK_ACTION({ BlockActionS2CP(it) }), PLAY_BLOCK_SET({ BlockSetS2CP(it) }), PLAY_BOSS_BAR({ PacketBossBar(it) }), PLAY_SERVER_DIFFICULTY({ ServerDifficultyS2CP(it) }),