mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
Noteblocks, Fix sending block interactions to server
This commit is contained in:
parent
b4d04229ff
commit
ed06322f07
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
@ -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(BlockPlaceC2SP(
|
||||
position = raycastHit.blockPosition,
|
||||
direction = raycastHit.hitDirection,
|
||||
|
Loading…
x
Reference in New Issue
Block a user