diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/Block.kt b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/Block.kt index 4ef4dccd7..5e702e47a 100644 --- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/Block.kt +++ b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/Block.kt @@ -103,6 +103,7 @@ open class Block( "FluidBlock" -> FluidBlock(resourceLocation, mappings, data) "DoorBlock" -> DoorBlock(resourceLocation, mappings, data) "LeverBlock" -> LeverBlock(resourceLocation, mappings, data) + "NoteBlock" -> NoteBlock(resourceLocation, mappings, data) else -> Block(resourceLocation, mappings, data) } diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/NoteBlock.kt b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/NoteBlock.kt new file mode 100644 index 000000000..46fb1d0f9 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/NoteBlock.kt @@ -0,0 +1,33 @@ +/* + * 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.mappings.blocks.types + +import com.google.gson.JsonObject +import de.bixilon.minosoft.data.inventory.ItemStack +import de.bixilon.minosoft.data.mappings.ResourceLocation +import de.bixilon.minosoft.data.mappings.blocks.BlockState +import de.bixilon.minosoft.data.mappings.blocks.BlockUsages +import de.bixilon.minosoft.data.mappings.versions.Registries +import de.bixilon.minosoft.data.player.Hands +import de.bixilon.minosoft.gui.rendering.input.camera.RaycastHit +import de.bixilon.minosoft.protocol.network.connection.PlayConnection +import glm_.vec3.Vec3i + +open class NoteBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : Block(resourceLocation, mappings, data) { + + override fun use(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, raycastHit: RaycastHit, hands: Hands, itemStack: ItemStack?): BlockUsages { + return BlockUsages.SUCCESS + } +} + diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/input/RightClickHandler.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/input/RightClickHandler.kt index a1bb7ed61..111ee3520 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/input/RightClickHandler.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/input/RightClickHandler.kt @@ -57,16 +57,18 @@ class RightClickHandler( raycastHit.blockState.block.use(renderWindow.connection, raycastHit.blockState, raycastHit.blockPosition, raycastHit, Hands.MAIN_HAND, itemInHand) } + if (currentTime - lastInteractionSent < ProtocolDefinition.TICK_TIME) { + return + } + lastInteractionSent = currentTime lastInteraction = currentTime when (usage) { - BlockUsages.SUCCESS -> { - if (currentTime - lastInteractionSent < ProtocolDefinition.TICK_TIME) { - return + BlockUsages.CONSUME, BlockUsages.SUCCESS -> { + if (usage == BlockUsages.SUCCESS) { + connection.sendPacket(ArmSwingC2SP(Hands.MAIN_HAND)) } - connection.sendPacket(ArmSwingC2SP(Hands.MAIN_HAND)) - connection.sendPacket(BlockPlaceC2SP( position = raycastHit.blockPosition, direction = raycastHit.hitDirection,