mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
fix motif reading (<1.13), motif name fixer
This commit is contained in:
parent
d4565770e8
commit
35db62583a
@ -12,7 +12,7 @@
|
||||
*/
|
||||
package de.bixilon.minosoft.data.registries
|
||||
|
||||
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||
import de.bixilon.kutil.primitive.IntUtil.toInt
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||
@ -29,11 +29,13 @@ data class Motif(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationCodec<Motif> {
|
||||
const val DEFAULT_SIZE = 16
|
||||
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: Map<String, Any>): Motif {
|
||||
return Motif(
|
||||
identifier = resourceLocation,
|
||||
width = data["width"].unsafeCast(),
|
||||
height = data["height"].unsafeCast(),
|
||||
width = data["width"]?.toInt() ?: DEFAULT_SIZE,
|
||||
height = data["height"]?.toInt() ?: DEFAULT_SIZE,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ class Registries(
|
||||
|
||||
worker += WorkerTask(this::entityType) { entityType.update(pixlyzerData["entities"]?.toJsonObject(), version, this) }
|
||||
|
||||
worker += WorkerTask(this::motif) { motif.update(pixlyzerData["motives"]?.toJsonObject(), version, this) }
|
||||
worker += WorkerTask(this::motif) { motif.update(pixlyzerData["motives", "motif"]?.toJsonObject(), version, this) }
|
||||
worker += WorkerTask(this::soundEvent) { soundEvent.update(pixlyzerData["sound_events"]?.toJsonObject(), version, null) }
|
||||
worker += WorkerTask(this::soundGroup, dependencies = arrayOf(this::soundEvent)) { soundGroup.update(pixlyzerData["sound_groups"]?.unsafeCast(), this) }
|
||||
worker += WorkerTask(this::particleType) { particleType.update(pixlyzerData["particles", "particle_type"]?.toJsonObject(), version, this) }
|
||||
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.datafixer
|
||||
import de.bixilon.minosoft.datafixer.enumeration.EntityDataTypesFixer
|
||||
import de.bixilon.minosoft.datafixer.rls.BlockEntityFixer
|
||||
import de.bixilon.minosoft.datafixer.rls.EntityAttributeFixer
|
||||
import de.bixilon.minosoft.datafixer.rls.MotifFixer
|
||||
import de.bixilon.minosoft.datafixer.rls.RegistryFixer
|
||||
|
||||
object DataFixer {
|
||||
@ -25,6 +26,7 @@ object DataFixer {
|
||||
BlockEntityFixer,
|
||||
EntityAttributeFixer,
|
||||
RegistryFixer,
|
||||
MotifFixer,
|
||||
)
|
||||
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2023 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.datafixer.rls
|
||||
|
||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||
|
||||
object MotifFixer : ResourceLocationFixer(minosoft("motif")) {
|
||||
|
||||
fun ResourceLocation.fixMotif() = fix(this)
|
||||
}
|
@ -16,7 +16,7 @@ import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.minosoft.data.direction.Directions
|
||||
import de.bixilon.minosoft.data.entities.data.EntityData
|
||||
import de.bixilon.minosoft.data.entities.entities.decoration.Painting
|
||||
import de.bixilon.minosoft.data.registries.Motif
|
||||
import de.bixilon.minosoft.datafixer.rls.MotifFixer.fixMotif
|
||||
import de.bixilon.minosoft.modding.event.events.EntitySpawnEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
@ -39,8 +39,8 @@ class EntityPaintingS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
|
||||
|
||||
init {
|
||||
val motif: Motif? = if (buffer.versionId < ProtocolVersions.V_18W02A) {
|
||||
buffer.readLegacyRegistryItem(buffer.connection.registries.motif)
|
||||
val motif = if (buffer.versionId < ProtocolVersions.V_18W02A) {
|
||||
buffer.connection.registries.motif[buffer.readResourceLocation().fixMotif()]!!
|
||||
} else {
|
||||
buffer.readRegistryItem(buffer.connection.registries.motif)
|
||||
}
|
||||
@ -53,7 +53,8 @@ class EntityPaintingS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||
position = buffer.readBlockPosition()
|
||||
direction = Directions[buffer.readUnsignedByte()]
|
||||
}
|
||||
entity = Painting(buffer.connection, buffer.connection.registries.entityType[Painting.identifier]!!, EntityData(buffer.connection), position, direction, motif!!)
|
||||
val type = buffer.connection.registries.entityType[Painting.identifier]!!
|
||||
entity = Painting(buffer.connection, type, EntityData(buffer.connection), position, direction, motif)
|
||||
entity.startInit()
|
||||
}
|
||||
|
||||
|
28
src/main/resources/assets/minosoft/fixer/motif.json
Normal file
28
src/main/resources/assets/minosoft/fixer/motif.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"Kebab": "kebab",
|
||||
"Aztec": "aztec",
|
||||
"Alban": "alban",
|
||||
"Aztec2": "aztec2",
|
||||
"Bomb": "bomb",
|
||||
"Plant": "plant",
|
||||
"Wasteland": "wasteland",
|
||||
"Wanderer": "wanderer",
|
||||
"Graham": "graham",
|
||||
"Pool": "pool",
|
||||
"Courbet": "courbet",
|
||||
"Sunset": "sunset",
|
||||
"Sea": "sea",
|
||||
"Creebet": "creebet",
|
||||
"Match": "match",
|
||||
"Bust": "bust",
|
||||
"Stage": "stage",
|
||||
"Void": "void",
|
||||
"SkullAndRoses": "skull_and_roses",
|
||||
"Wither": "wither",
|
||||
"Fighters": "fighters",
|
||||
"Skeleton": "skeleton",
|
||||
"DonkeyKong": "donkey_kong",
|
||||
"Pointer": "pointer",
|
||||
"Pigscene": "pigscene",
|
||||
"BurningSkull": "burning_skull"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user