cursed 1.7.10 translation

This commit is contained in:
creeper123123321 2021-03-30 22:11:28 -03:00
parent 577560dffa
commit 1b327b1a2b
16 changed files with 1981 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import com.github.creeper123123321.viaaas.config.VIAaaSConfig
import com.github.creeper123123321.viaaas.handler.FrontEndInit
import com.github.creeper123123321.viaaas.handler.MinecraftHandler
import com.github.creeper123123321.viaaas.platform.*
import com.github.creeper123123321.viaaas.protocol.registerAspirinProtocols
import com.github.creeper123123321.viaaas.web.ViaWebApp
import com.github.creeper123123321.viaaas.web.WebDashboardServer
import com.google.gson.JsonParser
@ -164,6 +165,7 @@ private fun initVia() {
ProtocolVersion.register(-2, "AUTO")
AspirinRewind.init(ViaRewindConfigImpl(File("config/viarewind.yml")))
AspirinBackwards.init(File("config/viabackwards"))
registerAspirinProtocols()
}
private fun bindPorts(args: Array<String>) {

View File

@ -0,0 +1,13 @@
package com.github.creeper123123321.viaaas.protocol
import com.github.creeper123123321.viaaas.protocol.id47toid5.Protocol1_8To1_7_6
import com.github.creeper123123321.viaaas.protocol.id5toid4.Protocol1_7_6to1_7_2
import us.myles.ViaVersion.api.Via
import us.myles.ViaVersion.api.protocol.ProtocolVersion
// cursed 1.7 -> 1.8 from https://github.com/Gerrygames/ClientViaVersion
// + https://github.com/creeper123123321/ViaRewind/tree/17to18
fun registerAspirinProtocols() {
Via.getManager().protocolManager.registerProtocol(Protocol1_7_6to1_7_2, ProtocolVersion.v1_7_6, ProtocolVersion.v1_7_1)
Via.getManager().protocolManager.registerProtocol(Protocol1_8To1_7_6, ProtocolVersion.v1_8, ProtocolVersion.v1_7_6)
}

View File

@ -0,0 +1,16 @@
package com.github.creeper123123321.viaaas.protocol
import us.myles.ViaVersion.api.PacketWrapper
import us.myles.ViaVersion.api.remapper.ValueTransformer
import us.myles.ViaVersion.api.type.Type
val INSERT_DASHES: ValueTransformer<String, String> = object : ValueTransformer<String, String>(Type.STRING) {
override fun transform(packetWrapper: PacketWrapper, s: String?): String {
val builder = StringBuilder(s)
builder.insert(20, "-")
builder.insert(16, "-")
builder.insert(12, "-")
builder.insert(8, "-")
return builder.toString()
}
}

View File

@ -0,0 +1,108 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.chunks
class Chunk1_8to1_7_6_10(data: ByteArray?, private val primaryBitMask: Int, addBitMask: Int, private val skyLight: Boolean, private val groundUp: Boolean) {
var storageArrays = arrayOfNulls<ExtendedBlockStorage>(16)
var blockBiomeArray = ByteArray(256)
fun get1_8Data(): ByteArray {
var finalSize = 0
val columns = Integer.bitCount(primaryBitMask)
val buffer = ByteArray(columns * 10240 + (if (skyLight) columns * 2048 else 0) + 256)
for (i in storageArrays.indices) {
if (storageArrays[i] != null && primaryBitMask and 1 shl i != 0 && (!groundUp || storageArrays[i]!!.isEmpty)) {
val blockIds = storageArrays[i]!!.blockLSBArray
val nibblearray = storageArrays[i]!!.metadataArray
for (ind in blockIds.indices) {
val id = blockIds[ind].toInt() and 255
val px = ind and 15
val py = ind shr 8 and 15
val pz = ind shr 4 and 15
val data = nibblearray[px, py, pz].toInt()
//data = SpigotDebreakifier.getCorrectedData(id, data);
val `val` = (id shl 4 or data).toChar()
buffer[finalSize++] = (`val`.toInt() and 255).toByte()
buffer[finalSize++] = (`val`.toInt() shr 8 and 255).toByte()
}
}
}
for (i in storageArrays.indices) {
if (storageArrays[i] != null && primaryBitMask and 1 shl i != 0 && (!groundUp || storageArrays[i]!!.isEmpty)) {
val nibblearray = storageArrays[i]!!.blocklightArray
System.arraycopy(nibblearray.handle, 0, buffer, finalSize, nibblearray.handle.size)
finalSize += nibblearray.handle.size
}
}
if (skyLight) {
for (i in storageArrays.indices) {
if (storageArrays[i] != null && primaryBitMask and 1 shl i != 0 && (!groundUp || storageArrays[i]!!.isEmpty)) {
val nibblearray = storageArrays[i]!!.skylightArray
System.arraycopy(nibblearray!!.handle, 0, buffer, finalSize, nibblearray!!.handle.size)
finalSize += nibblearray!!.handle.size
}
}
}
if (groundUp) {
System.arraycopy(blockBiomeArray, 0, buffer, finalSize, blockBiomeArray.size)
finalSize += blockBiomeArray.size
}
val finaldata = ByteArray(finalSize)
System.arraycopy(buffer, 0, finaldata, 0, finalSize)
return finaldata
}
init {
var dataSize = 0
for (i in storageArrays.indices) {
if (primaryBitMask and 1 shl i != 0) {
if (storageArrays[i] == null) storageArrays[i] = ExtendedBlockStorage(i shl 4, skyLight)
val blockIds = storageArrays[i]!!.blockLSBArray
System.arraycopy(data, dataSize, blockIds, 0, blockIds!!.size)
dataSize += blockIds!!.size
} else if (storageArrays[i] != null && groundUp) {
storageArrays[i] = null
}
}
for (i in storageArrays.indices) {
if (primaryBitMask and 1 shl i != 0 && storageArrays[i] != null) {
val nibblearray = storageArrays[i]!!.metadataArray
System.arraycopy(data, dataSize, nibblearray!!.handle, 0, nibblearray!!.handle.size)
dataSize += nibblearray!!.handle.size
}
}
for (i in storageArrays.indices) {
if (primaryBitMask and 1 shl i != 0 && storageArrays[i] != null) {
val nibblearray = storageArrays[i]!!.blocklightArray
System.arraycopy(data, dataSize, nibblearray!!.handle, 0, nibblearray!!.handle.size)
dataSize += nibblearray!!.handle.size
}
}
if (skyLight) {
for (i in storageArrays.indices) {
if (primaryBitMask and 1 shl i != 0 && storageArrays[i] != null) {
val nibblearray = storageArrays[i]!!.skylightArray
System.arraycopy(data, dataSize, nibblearray!!.handle, 0, nibblearray!!.handle.size)
dataSize += nibblearray!!.handle.size
}
}
}
for (i in storageArrays.indices) {
if (addBitMask and 1 shl i != 0) {
if (storageArrays[i] == null) {
dataSize += 2048
} else {
var nibblearray = storageArrays[i]!!.blockMSBArray
if (nibblearray == null) {
nibblearray = storageArrays[i]!!.createBlockMSBArray()
}
System.arraycopy(data, dataSize, nibblearray!!.handle, 0, nibblearray!!.handle.size)
dataSize += nibblearray!!.handle.size
}
} else if (groundUp && storageArrays[i] != null && storageArrays[i]!!.blockMSBArray != null) {
storageArrays[i]!!.clearMSBArray()
}
}
if (groundUp) {
System.arraycopy(data, dataSize, blockBiomeArray, 0, blockBiomeArray.size)
}
}
}

View File

@ -0,0 +1,161 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.chunks
import io.netty.buffer.ByteBuf
import us.myles.ViaVersion.api.PacketWrapper
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord1_8
import us.myles.ViaVersion.api.type.Type
import us.myles.ViaVersion.api.type.types.CustomByteType
import java.io.IOException
import java.util.*
import java.util.stream.IntStream
import java.util.zip.DataFormatException
import java.util.zip.Inflater
import kotlin.streams.toList
object ChunkPacketTransformer {
@Throws(Exception::class)
fun transformChunk(packetWrapper: PacketWrapper) {
val chunkX = packetWrapper.read(Type.INT)
val chunkZ = packetWrapper.read(Type.INT)
val groundUp = packetWrapper.read(Type.BOOLEAN)
val primaryBitMask = packetWrapper.read(Type.SHORT).toInt()
val addBitMask = packetWrapper.read(Type.SHORT).toInt()
val compressedSize = packetWrapper.read(Type.INT)
val customByteType = CustomByteType(compressedSize)
val data = packetWrapper.read(customByteType)
var k = 0
var l = 0
for (j in 0..15) {
k += primaryBitMask shr j and 1
l += addBitMask shr j and 1
}
var uncompressedSize = 12288 * k
uncompressedSize += 2048 * l
if (groundUp) {
uncompressedSize += 256
}
val uncompressedData = ByteArray(uncompressedSize)
val inflater = Inflater()
inflater.setInput(data, 0, compressedSize)
try {
inflater.inflate(uncompressedData)
} catch (ex: DataFormatException) {
throw IOException("Bad compressed data format")
} finally {
inflater.end()
}
val chunk = Chunk1_8to1_7_6_10(uncompressedData, primaryBitMask, addBitMask, true, groundUp)
var field = PacketWrapper::class.java.getDeclaredField("packetValues")
field.isAccessible = true
(field[packetWrapper] as MutableList<*>).clear()
field = PacketWrapper::class.java.getDeclaredField("readableObjects")
field.isAccessible = true
(field[packetWrapper] as LinkedList<*>).clear()
field = PacketWrapper::class.java.getDeclaredField("inputBuffer")
field.isAccessible = true
val buffer = field[packetWrapper] as ByteBuf
buffer.clear()
buffer.writeInt(chunkX)
buffer.writeInt(chunkZ)
buffer.writeBoolean(groundUp)
buffer.writeShort(primaryBitMask)
val finaldata = chunk.get1_8Data()
Type.VAR_INT.write(buffer, finaldata.size)
buffer.writeBytes(finaldata)
}
@Throws(Exception::class)
fun transformChunkBulk(packetWrapper: PacketWrapper) {
val columnCount = packetWrapper.read(Type.SHORT).toInt() //short1
val size = packetWrapper.read(Type.INT) //size
val skyLightSent = packetWrapper.read(Type.BOOLEAN) //h
val chunkX = IntArray(columnCount) //a
val chunkZ = IntArray(columnCount) //b
val primaryBitMask = IntArray(columnCount) //c
val addBitMask = IntArray(columnCount) //d
val inflatedBuffers = arrayOfNulls<ByteArray>(columnCount.toInt()) //inflatedBuffers
var customByteType = CustomByteType(size)
val buildBuffer = packetWrapper.read(customByteType) //buildBuffer
var data = ByteArray(196864 * columnCount) //abyte
val inflater = Inflater()
inflater.setInput(buildBuffer, 0, size)
try {
inflater.inflate(data)
} catch (ex: DataFormatException) {
throw IOException("Bad compressed data format")
} finally {
inflater.end()
}
var i = 0
for (j in 0 until columnCount) {
chunkX[j] = packetWrapper.read(Type.INT)
chunkZ[j] = packetWrapper.read(Type.INT)
primaryBitMask[j] = packetWrapper.read(Type.SHORT).toInt()
addBitMask[j] = packetWrapper.read(Type.SHORT).toInt()
var k = 0
var l = 0
var i1: Int
i1 = 0
while (i1 < 16) {
k += primaryBitMask[j] shr i1 and 1
l += addBitMask[j] shr i1 and 1
++i1
}
i1 = 8192 * k + 256
i1 += 2048 * l
if (skyLightSent) {
i1 += 2048 * k
}
inflatedBuffers[j] = ByteArray(i1)
System.arraycopy(data, i, inflatedBuffers[j], 0, i1)
i += i1
}
val chunks = arrayOfNulls<Chunk1_8to1_7_6_10>(columnCount.toInt())
i = 0
while (i < columnCount) {
chunks[i] = Chunk1_8to1_7_6_10(inflatedBuffers[i], primaryBitMask[i], addBitMask[i], skyLightSent, true)
i++
}
packetWrapper.write(Type.BOOLEAN, skyLightSent)
packetWrapper.write(Type.VAR_INT, columnCount as Int)
i = 0
while (i < columnCount) {
packetWrapper.write(Type.INT, chunkX[i])
packetWrapper.write(Type.INT, chunkZ[i])
packetWrapper.write(Type.UNSIGNED_SHORT, primaryBitMask[i])
++i
}
i = 0
while (i < columnCount) {
data = chunks[i]!!.get1_8Data()
customByteType = CustomByteType(data.size)
packetWrapper.write(customByteType, data)
++i
}
}
@Throws(Exception::class)
fun transformMultiBlockChange(packetWrapper: PacketWrapper) {
val chunkX = packetWrapper.read(Type.INT)
val chunkZ = packetWrapper.read(Type.INT)
val size = packetWrapper.read(Type.SHORT).toInt()
packetWrapper.read(Type.INT)
val blocks = ShortArray(size)
val positions = ShortArray(size)
for (i in 0 until size) {
positions[i] = packetWrapper.read(Type.SHORT)
blocks[i] = packetWrapper.read(Type.SHORT)
}
packetWrapper.write(Type.INT, chunkX)
packetWrapper.write(Type.INT, chunkZ)
packetWrapper.write(Type.BLOCK_CHANGE_RECORD_ARRAY, IntStream.range(0, size)
.mapToObj {
val encodedPos = (positions[it].toInt())
val x = encodedPos.ushr(12).and(0xF)
val y = encodedPos.and(0xFF)
val z = encodedPos.ushr(8).and(0xF)
BlockChangeRecord1_8(x, y, z, blocks[it].toInt())
}
.toList().toTypedArray())
}
}

View File

@ -0,0 +1,59 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.chunks
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray
class ExtendedBlockStorage(val yLocation: Int, paramBoolean: Boolean) {
var blockLSBArray: ByteArray = ByteArray(4096)
var blockMSBArray: NibbleArray? = null
var metadataArray: NibbleArray
private set
var blocklightArray: NibbleArray
var skylightArray: NibbleArray? = null
fun getExtBlockMetadata(paramInt1: Int, paramInt2: Int, paramInt3: Int): Int {
return metadataArray[paramInt1, paramInt2, paramInt3].toInt()
}
fun setExtBlockMetadata(paramInt1: Int, paramInt2: Int, paramInt3: Int, paramInt4: Int) {
metadataArray[paramInt1, paramInt2, paramInt3] = paramInt4
}
fun setExtSkylightValue(paramInt1: Int, paramInt2: Int, paramInt3: Int, paramInt4: Int) {
skylightArray!![paramInt1, paramInt2, paramInt3] = paramInt4
}
fun getExtSkylightValue(paramInt1: Int, paramInt2: Int, paramInt3: Int): Int {
return skylightArray!![paramInt1, paramInt2, paramInt3].toInt()
}
fun setExtBlocklightValue(paramInt1: Int, paramInt2: Int, paramInt3: Int, paramInt4: Int) {
blocklightArray[paramInt1, paramInt2, paramInt3] = paramInt4
}
fun getExtBlocklightValue(paramInt1: Int, paramInt2: Int, paramInt3: Int): Int {
return blocklightArray[paramInt1, paramInt2, paramInt3].toInt()
}
val isEmpty: Boolean
get() = blockMSBArray == null
fun clearMSBArray() {
blockMSBArray = null
}
fun setBlockMetadataArray(paramNibbleArray: NibbleArray) {
metadataArray = paramNibbleArray
}
fun createBlockMSBArray(): NibbleArray? {
blockMSBArray = NibbleArray(blockLSBArray.size)
return blockMSBArray
}
init {
metadataArray = NibbleArray(blockLSBArray.size)
blocklightArray = NibbleArray(blockLSBArray.size)
if (paramBoolean) {
skylightArray = NibbleArray(blockLSBArray.size)
}
}
}

View File

@ -0,0 +1,41 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.data
enum class Particle1_8to1_7 constructor(val identifier: String, val extra: Int = 0) {
EXPLOSION_NORMAL("explode"),
EXPLOSION_LARGE("largeexplode"),
EXPLOSION_HUGE("hugeexplosion"),
FIREWORKS_SPARK("fireworksSpark"),
WATER_BUBBLE("bubble"),
WATER_SPLASH("splash"),
WATER_WAKE("wake"),
SUSPENDED("suspended"),
SUSPENDED_DEPTH("depthsuspend"),
CRIT("crit"),
CRIT_MAGIC("magicCrit"),
SMOKE_NORMAL("smoke"),
SMOKE_LARGE("largesmoke"),
SPELL("spell"),
SPELL_INSTANT("instantSpell"),
SPELL_MOB("mobSpell"),
SPELL_MOB_AMBIENT("mobSpellAmbient"),
SPELL_WITCH("witchMagic"),
DRIP_WATER("dripWater"),
DRIP_LAVA("dripLava"),
VILLAGER_ANGRY("angryVillager"),
VILLAGER_HAPPY("happyVillager"),
TOWN_AURA("townaura"), NOTE("note"), PORTAL("portal"), ENCHANTMENT_TABLE("enchantmenttable"), FLAME("flame"), LAVA("lava"), FOOTSTEP("footstep"), CLOUD("cloud"), REDSTONE("reddust"), SNOWBALL("snowballpoof"), SNOW_SHOVEL("snowshovel"), SLIME("slime"), HEART("heart"), BARRIER("barrier"), ICON_CRACK("iconcrack", 2), BLOCK_CRACK("blockcrack", 1), BLOCK_DUST("blockdust", 1), WATER_DROP("droplet"), ITEM_TAKE("take"), MOB_APPEARANCE("mobappearance");
companion object {
private val particleMap = HashMap<String, Particle1_8to1_7>()
fun find(part: String): Particle1_8to1_7? {
return particleMap[part]
}
init {
val particles = values()
particles.forEach { particle ->
particleMap[particle.identifier] = particle
}
}
}
}

View File

@ -0,0 +1,52 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.metadata
import de.gerrygames.viarewind.protocol.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6_10
import us.myles.ViaVersion.api.Via
import us.myles.ViaVersion.api.entities.Entity1_10Types
import us.myles.ViaVersion.api.minecraft.metadata.Metadata
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_8
import java.util.*
object MetadataRewriter {
fun transform(type: Entity1_10Types.EntityType?, list: MutableList<Metadata>) {
for (entry in ArrayList(list)) {
val metaIndex = MetaIndex1_8to1_7_6_10.searchIndex(type, entry.id)
try {
if (metaIndex == null) throw Exception("Could not find valid metadata")
if (metaIndex.newType == MetaType1_8.NonExistent) {
list.remove(entry)
return
}
val value = entry.value
if (!value.javaClass.isAssignableFrom(metaIndex.oldType.type.outputClass)) {
list.remove(entry)
return
}
entry.metaType = metaIndex.newType
entry.id = metaIndex.newIndex
when (metaIndex.newType) {
MetaType1_8.Int -> entry.value = (value as Number).toInt()
MetaType1_8.Byte -> {
var byteValue = (value as Number).toByte()
entry.value = byteValue
if (metaIndex == MetaIndex1_8to1_7_6_10.HUMAN_SKIN_FLAGS) {
val cape = byteValue.toInt() == 2
byteValue = (if (cape) 127 else 125).toByte()
entry.value = byteValue
}
}
MetaType1_8.Short -> entry.value = (value as Number).toShort()
MetaType1_8.String -> entry.value = value.toString()
MetaType1_8.Float -> entry.value = (value as Number).toFloat()
MetaType1_8.Slot, MetaType1_8.Position, MetaType1_8.Rotation -> entry.value = value
else -> {
Via.getPlatform().logger.warning("[Out] Unhandled MetaDataType: " + metaIndex.newType)
list.remove(entry)
}
}
} catch (e: Exception) {
list.remove(entry)
}
}
}
}

View File

@ -0,0 +1,45 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.storage
import com.github.creeper123123321.viaaas.protocol.id47toid5.Protocol1_8To1_7_6
import com.github.creeper123123321.viaaas.protocol.id47toid5.metadata.MetadataRewriter
import us.myles.ViaVersion.api.PacketWrapper
import us.myles.ViaVersion.api.data.StoredObject
import us.myles.ViaVersion.api.data.UserConnection
import us.myles.ViaVersion.api.entities.Entity1_10Types
import us.myles.ViaVersion.api.minecraft.metadata.Metadata
import us.myles.ViaVersion.api.type.Type
import us.myles.ViaVersion.api.type.types.version.Types1_8
import java.lang.Exception
import java.util.concurrent.ConcurrentHashMap
class EntityTracker(user: UserConnection) : StoredObject(user) {
val clientEntityTypes = ConcurrentHashMap<Int, Entity1_10Types.EntityType>()
private val metadataBuffer = ConcurrentHashMap<Int, MutableList<Metadata>>()
fun removeEntity(entityId: Int) {
clientEntityTypes.remove(entityId)
}
fun addMetadataToBuffer(entityID: Int, metadataList: MutableList<Metadata>) {
metadataBuffer.computeIfAbsent(entityID) { mutableListOf() }.addAll(metadataList)
}
fun getBufferedMetadata(entityId: Int): List<Metadata> {
return metadataBuffer[entityId]!!
}
fun sendMetadataBuffer(entityId: Int) {
if (!metadataBuffer.containsKey(entityId)) return
val wrapper = PacketWrapper(0x1C, null, this.user)
wrapper.write(Type.VAR_INT, entityId)
wrapper.write<List<Metadata>>(Types1_8.METADATA_LIST, metadataBuffer[entityId])
MetadataRewriter.transform(clientEntityTypes[entityId], metadataBuffer[entityId]!!)
if (metadataBuffer[entityId]!!.isNotEmpty()) {
try {
wrapper.send(Protocol1_8To1_7_6::class.java)
} catch (ex: Exception) {
ex.printStackTrace()
}
}
metadataBuffer.remove(entityId)
}
}

View File

@ -0,0 +1,22 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.storage
import us.myles.ViaVersion.api.data.StoredObject
import us.myles.ViaVersion.api.data.UserConnection
import java.util.*
class MapStorage(user: UserConnection) : StoredObject(user) {
private val maps: MutableMap<Int, MapData> = HashMap()
fun getMapData(id: Int): MapData? {
return maps[id]
}
fun putMapData(id: Int, mapData: MapData) {
maps[id] = mapData
}
class MapData {
var scale: Byte = 0
var mapIcons = arrayOf<MapIcon>()
}
class MapIcon(var direction: Byte, var type: Byte, var x: Byte, var z: Byte)
}

View File

@ -0,0 +1,16 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.storage
import us.myles.ViaVersion.api.data.StoredObject
import us.myles.ViaVersion.api.data.UserConnection
import java.util.*
class Scoreboard(user: UserConnection) : StoredObject(user) {
private val objectives = HashMap<String, String>()
fun put(name: String, objective: String) {
objectives[name] = objective
}
operator fun get(name: String): String {
return objectives.getOrDefault(name, "null")
}
}

View File

@ -0,0 +1,39 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.storage
import us.myles.ViaVersion.api.data.StoredObject
import us.myles.ViaVersion.api.data.UserConnection
import java.util.*
class Tablist(user: UserConnection?) : StoredObject(user) {
private val tablist = ArrayList<TabListEntry>()
fun getTabListEntry(name: String): TabListEntry? {
for (entry in tablist) if (name == entry.name) return entry
return null
}
fun getTabListEntry(uuid: UUID): TabListEntry? {
for (entry in tablist) if (uuid == entry.uuid) return entry
return null
}
fun remove(entry: TabListEntry) {
tablist.remove(entry)
}
fun add(entry: TabListEntry) {
tablist.add(entry)
}
class TabListEntry(var name: String, var uuid: UUID) {
var displayName: String? = null
var ping = 0
var properties: List<Property> = ArrayList()
}
class Property(var name: String?, var value: String?, var signature: String?)
companion object {
fun shouldUpdateDisplayName(oldName: String?, newName: String?): Boolean {
return oldName == null && newName != null || oldName != null && newName == null || oldName != null && oldName != newName
}
}
}

View File

@ -0,0 +1,9 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.storage
import us.myles.ViaVersion.api.data.StoredObject
import us.myles.ViaVersion.api.data.UserConnection
class Windows(user: UserConnection?) : StoredObject(user) {
var types = mutableMapOf<Short, Short>()
operator fun get(windowId: Short): Short = types.getOrDefault(windowId, (-1).toShort())
}

View File

@ -0,0 +1,14 @@
package com.github.creeper123123321.viaaas.protocol.id47toid5.type
import io.netty.buffer.ByteBuf
import us.myles.ViaVersion.api.type.PartialType
class CustomIntType(amount: Int) : PartialType<IntArray, Int>(amount, IntArray::class.java) {
override fun read(p0: ByteBuf, p1: Int): IntArray {
return IntArray(p1) { p0.readInt() }
}
override fun write(p0: ByteBuf, p1: Int, p2: IntArray) {
p2.forEach { p0.writeInt(it) }
}
}

View File

@ -0,0 +1,33 @@
package com.github.creeper123123321.viaaas.protocol.id5toid4
import com.github.creeper123123321.viaaas.protocol.INSERT_DASHES
import us.myles.ViaVersion.api.data.UserConnection
import us.myles.ViaVersion.api.protocol.SimpleProtocol
import us.myles.ViaVersion.api.remapper.PacketRemapper
import us.myles.ViaVersion.api.type.Type
import us.myles.ViaVersion.packets.State
// Based on https://github.com/Gerrygames/ClientViaVersion
object Protocol1_7_6to1_7_2 : SimpleProtocol() {
override fun registerPackets() {
//Login Success
this.registerOutgoing(State.LOGIN, 0x02, 0x02, object : PacketRemapper() {
override fun registerMap() {
map(Type.STRING, INSERT_DASHES)
}
})
//Spawn Player
this.registerOutgoing(State.PLAY, 0x0C, 0x0C, object : PacketRemapper() {
override fun registerMap() {
map(Type.VAR_INT)
map(Type.STRING, INSERT_DASHES)
map(Type.STRING)
create { packetWrapper -> packetWrapper.write(Type.VAR_INT, 0) }
}
})
}
override fun init(userConnection: UserConnection) {}
}