mirror of
https://github.com/Bixilon/Minosoft.git
synced 2026-12-06 00:08:23 +00:00
registries: map_pin_types
Removes the enum, minosoft does not care what type of marker there is
This commit is contained in:
9 files changed
+117
-75
No files matched your search
@@ -61,6 +61,8 @@ object FallbackRegistries {
|
||||
val GAME_EVENT: PerVersionRegistry<ResourceLocation, ResourceLocationRegistry> = PerVersionRegistry { ResourceLocationRegistry() }.register(minecraft("game_events"))
|
||||
val WORLD_EVENT: PerVersionRegistry<ResourceLocation, ResourceLocationRegistry> = PerVersionRegistry { ResourceLocationRegistry() }.register(minecraft("world_events"))
|
||||
|
||||
val MAP_PIN_TYPES: PerVersionRegistry<ResourceLocation, ResourceLocationRegistry> = PerVersionRegistry { ResourceLocationRegistry() }.register(minecraft("map_pin_types"))
|
||||
|
||||
|
||||
fun load() {
|
||||
Log.log(LogMessageType.LOADING, LogLevels.VERBOSE) { "Loading default registries..." }
|
||||
|
||||
@@ -134,6 +134,7 @@ class Registries(
|
||||
val gameEvent: ResourceLocationRegistry = ResourceLocationRegistry()
|
||||
val worldEvent: ResourceLocationRegistry = ResourceLocationRegistry()
|
||||
val vibrationSource: ResourceLocationRegistry = ResourceLocationRegistry()
|
||||
val mapPinTypes: ResourceLocationRegistry = ResourceLocationRegistry()
|
||||
|
||||
val argumentType: ResourceLocationRegistry = ResourceLocationRegistry()
|
||||
val messageType: Registry<ChatMessageType> = register("chat_type", Registry(codec = ChatMessageType))
|
||||
@@ -175,6 +176,7 @@ class Registries(
|
||||
worker += TreeTask(this::gameEvent.i) { gameEvent.updatePixlyzer(pixlyzerData["game_events"]?.toJsonObject(), version, this) }
|
||||
worker += TreeTask(this::worldEvent.i) { worldEvent.updatePixlyzer(pixlyzerData["world_events"]?.toJsonObject(), version, this) }
|
||||
worker += TreeTask(this::vibrationSource.i) { vibrationSource.updatePixlyzer(pixlyzerData["vibration_source"]?.toJsonObject(), version, this) }
|
||||
worker += TreeTask(this::mapPinTypes.i) { mapPinTypes.updatePixlyzer(pixlyzerData["map_pin_types"]?.toJsonObject(), version, this) }
|
||||
worker += TreeTask(this::argumentType.i) { argumentType.updatePixlyzer(pixlyzerData["argument_type"]?.toJsonObject(), version, this) }
|
||||
worker += TreeTask(this::messageType.i) { messageType.updatePixlyzer(pixlyzerData["message_types"]?.toJsonObject(), version, this) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 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.
|
||||
*
|
||||
@@ -44,5 +44,7 @@ object RegistriesLoader {
|
||||
blockDataType.parent = FallbackRegistries.BLOCK_DATA_TYPE.forVersion(version)
|
||||
vibrationSource.parent = FallbackRegistries.VIBRATION_SOURCE.forVersion(version)
|
||||
catVariants.parent = FallbackRegistries.CAT_VARIANT.forVersion(version)
|
||||
|
||||
mapPinTypes.parent = FallbackRegistries.MAP_PIN_TYPES.forVersion(version)
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,13 @@ import de.bixilon.kutil.collections.map.SynchronizedMap
|
||||
class Map(
|
||||
val id: Int,
|
||||
var scale: Int,
|
||||
val data: IntArray = IntArray(128 * 128),
|
||||
val data: IntArray = IntArray(WIDTH * HEIGHT),
|
||||
val pins: SynchronizedMap<Vec2i, MapPin> = synchronizedMapOf(),
|
||||
)
|
||||
) {
|
||||
|
||||
|
||||
companion object {
|
||||
const val WIDTH = 128
|
||||
const val HEIGHT = 128
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
* Copyright (C) 2020-2025 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.
|
||||
*
|
||||
@@ -13,10 +13,11 @@
|
||||
|
||||
package de.bixilon.minosoft.data.world.map
|
||||
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
|
||||
class MapPin(
|
||||
val direction: Int,
|
||||
val type: MapPinTypes,
|
||||
val type: ResourceLocation,
|
||||
val displayName: ChatComponent? = null,
|
||||
)
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* 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.
|
||||
*
|
||||
* 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.world.map
|
||||
|
||||
import de.bixilon.kutil.enums.EnumUtil
|
||||
import de.bixilon.kutil.enums.ValuesEnum
|
||||
import kotlin.collections.Map
|
||||
|
||||
enum class MapPinTypes {
|
||||
WHITE_ARROW,
|
||||
GREEN_ARROW,
|
||||
RED_ARROW,
|
||||
BLUE_ARROW,
|
||||
WHITE_CROSS,
|
||||
RED_POINTER,
|
||||
WHITE_CIRCLE,
|
||||
BLUE_SQUARE,
|
||||
SMALL_WHITE_CIRCLE,
|
||||
MANSION,
|
||||
TEMPLE,
|
||||
WHITE_BANNER,
|
||||
ORANGE_BANNER,
|
||||
MAGENTA_BANNER,
|
||||
LIGHT_BLUE_BANNER,
|
||||
YELLOW_BANNER,
|
||||
LIME_BANNER,
|
||||
PINK_BANNER,
|
||||
GRAY_BANNER,
|
||||
LIGHT_GRAY_BANNER,
|
||||
CYAN_BANNER,
|
||||
PURPLE_BANNER,
|
||||
BLUE_BANNER,
|
||||
BROWN_BANNER,
|
||||
GREEN_BANNER,
|
||||
RED_BANNER,
|
||||
BLACK_BANNER,
|
||||
TREASURE_MARKER,
|
||||
;
|
||||
|
||||
companion object : ValuesEnum<MapPinTypes> {
|
||||
override val VALUES: Array<MapPinTypes> = values()
|
||||
override val NAME_MAP: Map<String, MapPinTypes> = EnumUtil.getEnumValues(VALUES)
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ package de.bixilon.minosoft.protocol.packets.s2c.play.map
|
||||
|
||||
import de.bixilon.kmath.vec.vec2.i.Vec2i
|
||||
import de.bixilon.minosoft.data.world.map.MapPin
|
||||
import de.bixilon.minosoft.data.world.map.MapPinTypes
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_15W34A
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_18W19A
|
||||
@@ -36,30 +35,30 @@ class MapS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
|
||||
|
||||
init {
|
||||
val pinCount = when {
|
||||
val count = when {
|
||||
buffer.versionId < V_20W46A -> buffer.readVarInt()
|
||||
else -> buffer.readOptional { buffer.readVarInt() } ?: 0
|
||||
}
|
||||
val pins: MutableMap<Vec2i, MapPin> = mutableMapOf()
|
||||
for (i in 0 until pinCount) {
|
||||
for (i in 0 until count) {
|
||||
if (buffer.versionId < V_18W19A) {
|
||||
val rawDirection = buffer.readUnsignedByte()
|
||||
val raw = buffer.readUnsignedByte()
|
||||
val position = Vec2i(buffer.readByte().toInt(), buffer.readByte().toInt())
|
||||
|
||||
val direction: Int
|
||||
val type: MapPinTypes
|
||||
val type: Int
|
||||
if (buffer.versionId >= V_1_12_2) { // ToDo
|
||||
type = MapPinTypes[rawDirection shr 4]
|
||||
direction = rawDirection and 0x0F
|
||||
type = raw shr 4
|
||||
direction = raw and 0x0F
|
||||
} else {
|
||||
direction = rawDirection shr 4
|
||||
type = MapPinTypes[rawDirection and 0x0F]
|
||||
direction = raw shr 4
|
||||
type = raw and 0x0F
|
||||
}
|
||||
|
||||
pins[position] = MapPin(direction, type)
|
||||
pins[position] = MapPin(direction, buffer.session.registries.mapPinTypes[type])
|
||||
continue
|
||||
}
|
||||
val type = MapPinTypes[buffer.readVarInt()]
|
||||
val type = buffer.readRegistryItem(buffer.session.registries.mapPinTypes)
|
||||
val position = Vec2i(buffer.readByte().toInt(), buffer.readByte().toInt())
|
||||
val direction = buffer.readUnsignedByte()
|
||||
val displayName = buffer.readOptional { buffer.readChatComponent() }
|
||||
|
||||
+3
-4
@@ -15,7 +15,6 @@ package de.bixilon.minosoft.protocol.packets.s2c.play.map.legacy
|
||||
|
||||
import de.bixilon.kmath.vec.vec2.i.Vec2i
|
||||
import de.bixilon.minosoft.data.world.map.MapPin
|
||||
import de.bixilon.minosoft.data.world.map.MapPinTypes
|
||||
import de.bixilon.minosoft.protocol.protocol.buffers.play.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
@@ -30,11 +29,11 @@ class PinsLegacyMapS2CP(
|
||||
init {
|
||||
val pins: MutableMap<Vec2i, MapPin> = mutableMapOf()
|
||||
for (i in 0 until buffer.size / 3) {
|
||||
val rawDirection = buffer.readUnsignedByte()
|
||||
val raw = buffer.readUnsignedByte()
|
||||
val position = Vec2i(buffer.readByte().toInt(), buffer.readByte().toInt())
|
||||
|
||||
val direction = rawDirection shr 4
|
||||
val type = MapPinTypes[rawDirection and 0x0F]
|
||||
val direction = raw shr 4
|
||||
val type = buffer.session.registries.mapPinTypes[raw and 0x0F]
|
||||
|
||||
pins[position] = MapPin(direction, type)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"0": {
|
||||
"minecraft:white_marker": {
|
||||
"id": 0
|
||||
},
|
||||
"minecraft:green_marker": {
|
||||
"id": 1
|
||||
},
|
||||
"minecraft:red_marker": {
|
||||
"id": 2
|
||||
},
|
||||
"minecraft:blue_marker": {
|
||||
"id": 3
|
||||
},
|
||||
"minecraft:white_cross": {
|
||||
"id": 4
|
||||
},
|
||||
"minecraft:red_pointer": {
|
||||
"id": 5
|
||||
},
|
||||
"minecraft:white_dot": {
|
||||
"id": 6
|
||||
},
|
||||
"minecraft:small_white_circle": {
|
||||
"id": 7
|
||||
},
|
||||
"minecraft:mansion": {
|
||||
"id": 8
|
||||
},
|
||||
"minecraft:monument": {
|
||||
"id": 9
|
||||
},
|
||||
"minecraft:white_banner": {
|
||||
"id": 10
|
||||
},
|
||||
"minecraft:orange_banner": {
|
||||
"id": 11
|
||||
},
|
||||
"minecraft:magenta_banner": {
|
||||
"id": 12
|
||||
},
|
||||
"minecraft:light_blue_banner": {
|
||||
"id": 13
|
||||
},
|
||||
"minecraft:yellow_banner": {
|
||||
"id": 14
|
||||
},
|
||||
"minecraft:lime_banner": {
|
||||
"id": 15
|
||||
},
|
||||
"minecraft:pink_banner": {
|
||||
"id": 16
|
||||
},
|
||||
"minecraft:gray_banner": {
|
||||
"id": 17
|
||||
},
|
||||
"minecraft:light_gray_banner": {
|
||||
"id": 18
|
||||
},
|
||||
"minecraft:cyan_banner": {
|
||||
"id": 19
|
||||
},
|
||||
"minecraft:purple_banner": {
|
||||
"id": 20
|
||||
},
|
||||
"minecraft:blue_banner": {
|
||||
"id": 21
|
||||
},
|
||||
"minecraft:brown_banner": {
|
||||
"id": 22
|
||||
},
|
||||
"minecraft:green_banner": {
|
||||
"id": 23
|
||||
},
|
||||
"minecraft:red_banner": {
|
||||
"id": 24
|
||||
},
|
||||
"minecraft:black_banner": {
|
||||
"id": 25
|
||||
},
|
||||
"minecraft:teasure_marker": {
|
||||
"id": 26
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user