mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 04:15:14 -04:00
improve item picking, fix some network errors
This commit is contained in:
parent
388e596a04
commit
4fba857e30
@ -87,6 +87,17 @@ class ItemPickInteractionHandler(
|
|||||||
interactionManager.hotbar.selectSlot(i)
|
interactionManager.hotbar.selectSlot(i)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var slot = connection.player.selectedHotbarSlot
|
||||||
|
if (connection.player.inventory.getHotbarSlot(slot) != null) {
|
||||||
|
for (i in 0 until PlayerInventory.HOTBAR_SLOTS) {
|
||||||
|
val item = connection.player.inventory.getHotbarSlot(i)
|
||||||
|
if (item == null) {
|
||||||
|
slot = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
interactionManager.hotbar.selectSlot(slot)
|
||||||
val selectedSlot = connection.player.selectedHotbarSlot + PlayerInventory.HOTBAR_OFFSET
|
val selectedSlot = connection.player.selectedHotbarSlot + PlayerInventory.HOTBAR_OFFSET
|
||||||
|
|
||||||
rateLimiter += { connection.sendPacket(ItemStackCreateC2SP(selectedSlot, itemStack)) }
|
rateLimiter += { connection.sendPacket(ItemStackCreateC2SP(selectedSlot, itemStack)) }
|
||||||
|
@ -30,6 +30,7 @@ import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
|||||||
import de.bixilon.minosoft.protocol.protocol.Protocol
|
import de.bixilon.minosoft.protocol.protocol.Protocol
|
||||||
import io.netty.channel.ChannelHandlerContext
|
import io.netty.channel.ChannelHandlerContext
|
||||||
import io.netty.handler.codec.MessageToMessageDecoder
|
import io.netty.handler.codec.MessageToMessageDecoder
|
||||||
|
import java.lang.reflect.InvocationTargetException
|
||||||
|
|
||||||
class PacketDecoder(
|
class PacketDecoder(
|
||||||
private val client: NettyClient,
|
private val client: NettyClient,
|
||||||
@ -55,8 +56,12 @@ class PacketDecoder(
|
|||||||
packetType.onError(exception, client.connection)
|
packetType.onError(exception, client.connection)
|
||||||
throw exception
|
throw exception
|
||||||
} catch (error: Throwable) {
|
} catch (error: Throwable) {
|
||||||
packetType.onError(error, client.connection)
|
var realError = error
|
||||||
throw PacketReadException(error)
|
if (error is InvocationTargetException) {
|
||||||
|
error.cause?.let { realError = it }
|
||||||
|
}
|
||||||
|
packetType.onError(realError, client.connection)
|
||||||
|
throw PacketReadException(realError)
|
||||||
}
|
}
|
||||||
|
|
||||||
out += QueuedS2CP(packetType, packet)
|
out += QueuedS2CP(packetType, packet)
|
||||||
|
@ -20,6 +20,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
|||||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_15W34A
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_15W34A
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_18W19A
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_18W19A
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_19W02A
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_12_2
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_12_2
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_20W46A
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_20W46A
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
@ -31,7 +32,8 @@ import glm_.vec2.Vec2i
|
|||||||
class MapS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
class MapS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val id = buffer.readVarInt()
|
val id = buffer.readVarInt()
|
||||||
val scale = buffer.readUnsignedByte()
|
val scale = buffer.readUnsignedByte()
|
||||||
val trackPosition = if (buffer.versionId >= V_15W34A) buffer.readBoolean() else true
|
val trackPosition = if (buffer.versionId in V_15W34A until V_20W46A) buffer.readBoolean() else true
|
||||||
|
val locked = if (buffer.versionId >= V_19W02A) buffer.readBoolean() else true
|
||||||
val pins: Map<Vec2i, MapPin>
|
val pins: Map<Vec2i, MapPin>
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class UnlockRecipesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
val action = Actions[if (buffer.versionId < V_1_12) buffer.readInt() else buffer.readVarInt()]
|
val action = Actions[if (buffer.versionId < V_1_12) buffer.readInt() else buffer.readVarInt()]
|
||||||
|
|
||||||
val crafting = RecipeBookState(buffer)
|
val crafting = RecipeBookState(buffer)
|
||||||
val smelting: RecipeBookState? = if (buffer.versionId >= V_17W48A) RecipeBookState(buffer) else null
|
val smelting: RecipeBookState? = if (buffer.versionId >= V_17W48A) RecipeBookState(buffer) else null // ToDo
|
||||||
val blasting: RecipeBookState? = if (buffer.versionId >= V_20W27A) RecipeBookState(buffer) else null
|
val blasting: RecipeBookState? = if (buffer.versionId >= V_20W27A) RecipeBookState(buffer) else null
|
||||||
val smoking: RecipeBookState? = if (buffer.versionId >= V_20W27A) RecipeBookState(buffer) else null
|
val smoking: RecipeBookState? = if (buffer.versionId >= V_20W27A) RecipeBookState(buffer) else null
|
||||||
|
|
||||||
@ -51,10 +51,12 @@ class UnlockRecipesS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val tagged: MutableList<Recipe> = mutableListOf()
|
val tagged: MutableList<Recipe> = mutableListOf()
|
||||||
|
if (action == Actions.INITIALIZE) {
|
||||||
val recipes = buffer.connection.registries.recipes
|
val recipes = buffer.connection.registries.recipes
|
||||||
for (i in 0 until buffer.readVarInt()) {
|
for (i in 0 until buffer.readVarInt()) {
|
||||||
tagged += recipes[if (buffer.versionId < V_17W48A) buffer.readVarInt() else buffer.readResourceLocation()] ?: continue
|
tagged += recipes[if (buffer.versionId < V_17W48A) buffer.readVarInt() else buffer.readResourceLocation()] ?: continue
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.tagged = tagged
|
this.tagged = tagged
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user