mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
fix multiple block placing packets when right-clicking once
This commit is contained in:
parent
7e6fc7c933
commit
c08d5936f8
@ -25,8 +25,6 @@ import de.bixilon.minosoft.gui.rendering.input.camera.hit.BlockRaycastHit
|
|||||||
import de.bixilon.minosoft.gui.rendering.input.camera.hit.RaycastHit
|
import de.bixilon.minosoft.gui.rendering.input.camera.hit.RaycastHit
|
||||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.plus
|
import de.bixilon.minosoft.gui.rendering.util.VecUtil.plus
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.play.BlockPlaceC2SP
|
|
||||||
import glm_.vec3.Vec3
|
|
||||||
|
|
||||||
open class BlockItem(
|
open class BlockItem(
|
||||||
resourceLocation: ResourceLocation,
|
resourceLocation: ResourceLocation,
|
||||||
@ -72,16 +70,6 @@ open class BlockItem(
|
|||||||
placeBlockState.placeSoundEvent?.let {
|
placeBlockState.placeSoundEvent?.let {
|
||||||
connection.world.playSoundEvent(it, placePosition, placeBlockState.soundEventVolume, placeBlockState.soundEventPitch)
|
connection.world.playSoundEvent(it, placePosition, placeBlockState.soundEventVolume, placeBlockState.soundEventPitch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
connection.sendPacket(BlockPlaceC2SP(
|
|
||||||
position = placePosition,
|
|
||||||
direction = raycastHit.hitDirection,
|
|
||||||
cursorPosition = Vec3(raycastHit.hitPosition),
|
|
||||||
item = connection.player.inventory.getHotbarSlot(),
|
|
||||||
hand = Hands.MAIN_HAND,
|
|
||||||
insideBlock = false, // ToDo
|
|
||||||
))
|
|
||||||
return BlockUsages.SUCCESS
|
return BlockUsages.SUCCESS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,12 +106,11 @@ class World(
|
|||||||
VersionTweaker.transformBlock(blockState, sections, blockPosition.inChunkSectionPosition, blockPosition.sectionHeight)
|
VersionTweaker.transformBlock(blockState, sections, blockPosition.inChunkSectionPosition, blockPosition.sectionHeight)
|
||||||
}
|
}
|
||||||
val inChunkPosition = blockPosition.inChunkPosition
|
val inChunkPosition = blockPosition.inChunkPosition
|
||||||
if (it[inChunkPosition] == blockState) {
|
val previousBlock = it[inChunkPosition]
|
||||||
|
if (previousBlock == transformedBlockState) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
it[inChunkPosition]?.let { oldBlockState ->
|
previousBlock?.block?.onBreak(connection, blockPosition, previousBlock, it.getBlockEntity(inChunkPosition))
|
||||||
oldBlockState.block.onBreak(connection, blockPosition, oldBlockState, it.getBlockEntity(inChunkPosition))
|
|
||||||
}
|
|
||||||
blockState?.block?.onPlace(connection, blockPosition, blockState)
|
blockState?.block?.onPlace(connection, blockPosition, blockState)
|
||||||
it[inChunkPosition] = transformedBlockState
|
it[inChunkPosition] = transformedBlockState
|
||||||
connection.fireEvent(BlockSetEvent(
|
connection.fireEvent(BlockSetEvent(
|
||||||
|
@ -41,6 +41,6 @@ class BlockSetS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun log() {
|
override fun log() {
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Block change (position=${blockPosition}, block=$blockState)" }
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Block set (position=${blockPosition}, blockState=$blockState)" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user