mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 12:25:12 -04:00
fix chunk reading on custom servers, fixes GH-4
This commit is contained in:
parent
7a9ee5779d
commit
29550d9788
@ -51,6 +51,8 @@ class SimpleContainerAction(
|
||||
val target = container.slots[slot]
|
||||
try {
|
||||
if (slot == null) {
|
||||
// slot id is null, we are not targeting anything
|
||||
// -> drop item into the void
|
||||
if (count == ContainerCounts.ALL) {
|
||||
floatingItem.item._count = 0
|
||||
} else {
|
||||
@ -62,6 +64,7 @@ class SimpleContainerAction(
|
||||
val matches = floatingItem.matches(target)
|
||||
|
||||
if (target != null && matches) {
|
||||
// we can remove or merge the item
|
||||
if (slotType?.canPut(container, slot, floatingItem) == true) {
|
||||
// merge
|
||||
val subtract = if (count == ContainerCounts.ALL) minOf(target.item.item.maxStackSize - target.item._count, floatingItem.item._count) else 1
|
||||
@ -85,9 +88,12 @@ class SimpleContainerAction(
|
||||
return
|
||||
}
|
||||
if (target != null && slotType?.canRemove(container, slot, target) != true) {
|
||||
// we can not remove the item from the slot, cancelling
|
||||
return
|
||||
}
|
||||
|
||||
if (slotType?.canPut(container, slot, floatingItem) != true) {
|
||||
// when can not put any item in there, cancel
|
||||
return
|
||||
}
|
||||
// swap
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* Copyright (C) 2020-2022 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.
|
||||
*
|
||||
@ -21,15 +21,23 @@ class ArrayPaletteData(
|
||||
val elementBits: Int,
|
||||
override val size: Int,
|
||||
) : PaletteData {
|
||||
private lateinit var data: LongArray
|
||||
|
||||
init {
|
||||
check(elementBits in 0..32)
|
||||
}
|
||||
|
||||
private lateinit var data: LongArray
|
||||
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer) {
|
||||
data = buffer.readLongArray()
|
||||
buffer.readVarInt() // minecraft ignores the length prefix
|
||||
val longs: Int = if (versionId < V_1_16) { // ToDo: When did this changed? is just a guess
|
||||
val bits = size * elementBits
|
||||
|
||||
(bits + (Long.SIZE_BITS - 1)) / Long.SIZE_BITS // divide up
|
||||
} else {
|
||||
val elementsPerLong = Long.SIZE_BITS / elementBits
|
||||
(size + elementsPerLong - 1) / elementsPerLong
|
||||
}
|
||||
data = buffer.readLongArray(longs)
|
||||
}
|
||||
|
||||
override operator fun get(index: Int): Int {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2021 Moritz Zwerger
|
||||
* Copyright (C) 2020-2022 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.
|
||||
*
|
||||
@ -21,6 +21,7 @@ class ArrayPalette<T>(private val registry: AbstractRegistry<T>, override val bi
|
||||
|
||||
override fun read(buffer: PlayInByteBuffer) {
|
||||
array = arrayOfNulls(buffer.readVarInt())
|
||||
|
||||
for (i in array.indices) {
|
||||
array[i] = registry[buffer.readVarInt()]
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ class ItemElement(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onDragMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions, count: Int, draggable: Dragged): Element? {
|
||||
override fun onDragMouseAction(position: Vec2i, button: MouseButtons, action: MouseActions, count: Int, draggable: Dragged): Element {
|
||||
if (action != MouseActions.PRESS) {
|
||||
return this
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user