mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-11-21 11:35:16 +01:00
remove viarewind, viabackwards and 1.7 -> 1.8 protocol, update viaversion
This commit is contained in:
parent
cf8c25308e
commit
35f9ea3d01
@ -46,12 +46,8 @@ tasks.named<ProcessResources>("processResources") {
|
||||
|
||||
dependencies {
|
||||
// transitive = false because Guava is conflicting on runClient
|
||||
compile("us.myles:viaversion:2.1.2-1.14.3-pre1") { isTransitive = false }
|
||||
include("us.myles:viaversion:2.1.2-1.14.3-pre1")
|
||||
compile("de.gerrygames:viarewind-all:1.4.0") { isTransitive = false }
|
||||
include("de.gerrygames:viarewind-all:1.4.0")
|
||||
compile("nl.matsv:viabackwards-all:3.0.0-SNAPSHOT") { isTransitive = false }
|
||||
include("nl.matsv:viabackwards-all:3.0.0-SNAPSHOT")
|
||||
compile("us.myles:viaversion:2.1.2-1.14.3-pre2") { isTransitive = false }
|
||||
include("us.myles:viaversion:2.1.2-1.14.3-pre2")
|
||||
|
||||
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
|
||||
|
||||
|
@ -25,9 +25,9 @@
|
||||
package com.github.creeper123123321.viafabric;
|
||||
|
||||
import com.github.creeper123123321.viafabric.commands.VRCommandHandler;
|
||||
import com.github.creeper123123321.viafabric.platform.*;
|
||||
import com.github.creeper123123321.viafabric.protocol.protocol1_7_6_10to1_7_1_5.Protocol1_7_6_10To1_7_1_5;
|
||||
import com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.Protocol1_8To1_7_6_10;
|
||||
import com.github.creeper123123321.viafabric.platform.VRInjector;
|
||||
import com.github.creeper123123321.viafabric.platform.VRLoader;
|
||||
import com.github.creeper123123321.viafabric.platform.VRPlatform;
|
||||
import com.github.creeper123123321.viafabric.util.JLoggerToLog4j;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
@ -42,10 +42,7 @@ import net.minecraft.server.command.CommandSource;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import us.myles.ViaVersion.ViaManager;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
@ -86,10 +83,6 @@ public class ViaFabric implements ModInitializer {
|
||||
.commandHandler(new VRCommandHandler())
|
||||
.platform(new VRPlatform()).build());
|
||||
Via.getManager().init();
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_7_6_10To1_7_1_5(), Collections.singletonList(ProtocolVersion.v1_7_6.getId()), ProtocolVersion.v1_7_1.getId());
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_8To1_7_6_10(), Collections.singletonList(ProtocolVersion.v1_8.getId()), ProtocolVersion.v1_7_6.getId());
|
||||
new VRRewindPlatform().init();
|
||||
new VRBackwardsPlatform().init();
|
||||
|
||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.platform;
|
||||
|
||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class VRBackwardsPlatform implements ViaBackwardsPlatform {
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return ViaFabric.JLOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.platform;
|
||||
|
||||
import com.github.creeper123123321.viafabric.ViaFabric;
|
||||
import de.gerrygames.viarewind.api.ViaRewindConfig;
|
||||
import de.gerrygames.viarewind.api.ViaRewindConfigImpl;
|
||||
import de.gerrygames.viarewind.api.ViaRewindPlatform;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class VRRewindPlatform implements ViaRewindPlatform {
|
||||
private static ViaRewindConfig config = new ViaRewindConfigImpl(FabricLoader.getInstance().getConfigDirectory().toPath().resolve("ViaFabric").resolve("viarewind.yml").toFile());
|
||||
|
||||
public void init() {
|
||||
init(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return ViaFabric.JLOGGER;
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.protocol.protocol1_7_6_10to1_7_1_5;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
// Based on https://github.com/Gerrygames/ClientViaVersion
|
||||
public class Protocol1_7_6_10To1_7_1_5 extends Protocol {
|
||||
public static final ValueTransformer<String, String> INSERT_DASHES = new ValueTransformer<String, String>(Type.STRING) {
|
||||
@Override
|
||||
public String transform(PacketWrapper packetWrapper, String s) {
|
||||
StringBuilder builder = new StringBuilder(s);
|
||||
builder.insert(20, "-");
|
||||
builder.insert(16, "-");
|
||||
builder.insert(12, "-");
|
||||
builder.insert(8, "-");
|
||||
return builder.toString();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
//Login Success
|
||||
this.registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING, INSERT_DASHES);
|
||||
}
|
||||
});
|
||||
|
||||
//Spawn Player
|
||||
this.registerOutgoing(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.STRING, INSERT_DASHES);
|
||||
map(Type.STRING);
|
||||
create(new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper packetWrapper) {
|
||||
packetWrapper.write(Type.VAR_INT, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,149 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.chunks;
|
||||
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
|
||||
|
||||
public class Chunk1_8to1_7_6_10 {
|
||||
public ExtendedBlockStorage[] storageArrays = new ExtendedBlockStorage[16];
|
||||
public byte[] blockBiomeArray = new byte[256];
|
||||
private boolean skyLight;
|
||||
private int primaryBitMask;
|
||||
private boolean groundUp;
|
||||
|
||||
public Chunk1_8to1_7_6_10(byte[] data, int primaryBitMask, int addBitMask, boolean skyLight, boolean groundUp) {
|
||||
this.primaryBitMask = primaryBitMask;
|
||||
this.skyLight = skyLight;
|
||||
this.groundUp = groundUp;
|
||||
int dataSize = 0;
|
||||
for (int i = 0; i < this.storageArrays.length; i++) {
|
||||
if ((primaryBitMask & 1 << i) != 0) {
|
||||
if (this.storageArrays[i] == null) this.storageArrays[i] = new ExtendedBlockStorage(i << 4, skyLight);
|
||||
byte[] blockIds = this.storageArrays[i].getBlockLSBArray();
|
||||
System.arraycopy(data, dataSize, blockIds, 0, blockIds.length);
|
||||
dataSize += blockIds.length;
|
||||
} else if (this.storageArrays[i] != null && groundUp) {
|
||||
this.storageArrays[i] = null;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < this.storageArrays.length; i++) {
|
||||
if ((primaryBitMask & 1 << i) != 0 && this.storageArrays[i] != null) {
|
||||
NibbleArray nibblearray = this.storageArrays[i].getMetadataArray();
|
||||
System.arraycopy(data, dataSize, nibblearray.getHandle(), 0, nibblearray.getHandle().length);
|
||||
dataSize += nibblearray.getHandle().length;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < this.storageArrays.length; i++) {
|
||||
if ((primaryBitMask & 1 << i) != 0 && this.storageArrays[i] != null) {
|
||||
NibbleArray nibblearray = this.storageArrays[i].getBlocklightArray();
|
||||
System.arraycopy(data, dataSize, nibblearray.getHandle(), 0, nibblearray.getHandle().length);
|
||||
dataSize += nibblearray.getHandle().length;
|
||||
}
|
||||
}
|
||||
if (skyLight) {
|
||||
for (int i = 0; i < this.storageArrays.length; i++) {
|
||||
if ((primaryBitMask & 1 << i) != 0 && this.storageArrays[i] != null) {
|
||||
NibbleArray nibblearray = this.storageArrays[i].getSkylightArray();
|
||||
System.arraycopy(data, dataSize, nibblearray.getHandle(), 0, nibblearray.getHandle().length);
|
||||
dataSize += nibblearray.getHandle().length;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < this.storageArrays.length; i++) {
|
||||
if ((addBitMask & 1 << i) != 0) {
|
||||
if (this.storageArrays[i] == null) {
|
||||
dataSize += 2048;
|
||||
} else {
|
||||
NibbleArray nibblearray = this.storageArrays[i].getBlockMSBArray();
|
||||
if (nibblearray == null) {
|
||||
nibblearray = this.storageArrays[i].createBlockMSBArray();
|
||||
}
|
||||
System.arraycopy(data, dataSize, nibblearray.getHandle(), 0, nibblearray.getHandle().length);
|
||||
dataSize += nibblearray.getHandle().length;
|
||||
}
|
||||
} else if (groundUp && this.storageArrays[i] != null && this.storageArrays[i].getBlockMSBArray() != null) {
|
||||
this.storageArrays[i].clearMSBArray();
|
||||
}
|
||||
}
|
||||
if (groundUp) {
|
||||
System.arraycopy(data, dataSize, this.blockBiomeArray, 0, this.blockBiomeArray.length);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] get1_8Data() {
|
||||
int finalSize = 0;
|
||||
int columns = Integer.bitCount(this.primaryBitMask);
|
||||
byte[] buffer = new byte[columns * 10240 + (this.skyLight ? columns * 2048 : 0) + 256];
|
||||
|
||||
for (int i = 0; i < storageArrays.length; ++i) {
|
||||
if (storageArrays[i] != null && (this.primaryBitMask & 1 << i) != 0 && (!this.groundUp || storageArrays[i].isEmpty())) {
|
||||
byte[] blockIds = storageArrays[i].getBlockLSBArray();
|
||||
NibbleArray nibblearray = storageArrays[i].getMetadataArray();
|
||||
|
||||
for (int ind = 0; ind < blockIds.length; ++ind) {
|
||||
int id = blockIds[ind] & 255;
|
||||
int px = ind & 15;
|
||||
int py = ind >> 8 & 15;
|
||||
int pz = ind >> 4 & 15;
|
||||
int data = nibblearray.get(px, py, pz);
|
||||
|
||||
//data = SpigotDebreakifier.getCorrectedData(id, data);
|
||||
|
||||
char val = (char) (id << 4 | data);
|
||||
buffer[finalSize++] = (byte) (val & 255);
|
||||
buffer[finalSize++] = (byte) (val >> 8 & 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < storageArrays.length; ++i) {
|
||||
if (storageArrays[i] != null && (this.primaryBitMask & 1 << i) != 0 && (!this.groundUp || storageArrays[i].isEmpty())) {
|
||||
NibbleArray nibblearray = storageArrays[i].getBlocklightArray();
|
||||
System.arraycopy(nibblearray.getHandle(), 0, buffer, finalSize, nibblearray.getHandle().length);
|
||||
finalSize += nibblearray.getHandle().length;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.skyLight) {
|
||||
for (int i = 0; i < storageArrays.length; ++i) {
|
||||
if (storageArrays[i] != null && (this.primaryBitMask & 1 << i) != 0 && (!this.groundUp || storageArrays[i].isEmpty())) {
|
||||
NibbleArray nibblearray = storageArrays[i].getSkylightArray();
|
||||
System.arraycopy(nibblearray.getHandle(), 0, buffer, finalSize, nibblearray.getHandle().length);
|
||||
finalSize += nibblearray.getHandle().length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.groundUp) {
|
||||
System.arraycopy(blockBiomeArray, 0, buffer, finalSize, blockBiomeArray.length);
|
||||
finalSize += blockBiomeArray.length;
|
||||
}
|
||||
|
||||
byte[] finaldata = new byte[finalSize];
|
||||
System.arraycopy(buffer, 0, finaldata, 0, finalSize);
|
||||
|
||||
return finaldata;
|
||||
}
|
||||
}
|
@ -1,194 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.chunks;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.CustomByteType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
public class ChunkPacketTransformer {
|
||||
public static void transformChunk(PacketWrapper packetWrapper) throws Exception {
|
||||
int chunkX = packetWrapper.read(Type.INT);
|
||||
int chunkZ = packetWrapper.read(Type.INT);
|
||||
boolean groundUp = packetWrapper.read(Type.BOOLEAN);
|
||||
int primaryBitMask = packetWrapper.read(Type.SHORT);
|
||||
int addBitMask = packetWrapper.read(Type.SHORT);
|
||||
int compressedSize = packetWrapper.read(Type.INT);
|
||||
CustomByteType customByteType = new CustomByteType(compressedSize);
|
||||
byte[] data = packetWrapper.read(customByteType);
|
||||
|
||||
int k = 0;
|
||||
int l = 0;
|
||||
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
k += primaryBitMask >> j & 1;
|
||||
l += addBitMask >> j & 1;
|
||||
}
|
||||
|
||||
int uncompressedSize = 12288 * k;
|
||||
uncompressedSize += 2048 * l;
|
||||
if (groundUp) {
|
||||
uncompressedSize += 256;
|
||||
}
|
||||
|
||||
byte[] uncompressedData = new byte[uncompressedSize];
|
||||
Inflater inflater = new Inflater();
|
||||
inflater.setInput(data, 0, compressedSize);
|
||||
try {
|
||||
inflater.inflate(uncompressedData);
|
||||
} catch (DataFormatException ex) {
|
||||
throw new IOException("Bad compressed data format");
|
||||
} finally {
|
||||
inflater.end();
|
||||
}
|
||||
|
||||
Chunk1_8to1_7_6_10 chunk = new Chunk1_8to1_7_6_10(uncompressedData, primaryBitMask, addBitMask, true, groundUp);
|
||||
|
||||
Field field = PacketWrapper.class.getDeclaredField("packetValues");
|
||||
field.setAccessible(true);
|
||||
((List) field.get(packetWrapper)).clear();
|
||||
field = PacketWrapper.class.getDeclaredField("readableObjects");
|
||||
field.setAccessible(true);
|
||||
((LinkedList) field.get(packetWrapper)).clear();
|
||||
field = PacketWrapper.class.getDeclaredField("inputBuffer");
|
||||
field.setAccessible(true);
|
||||
ByteBuf buffer = (ByteBuf) field.get(packetWrapper);
|
||||
buffer.clear();
|
||||
|
||||
buffer.writeInt(chunkX);
|
||||
buffer.writeInt(chunkZ);
|
||||
buffer.writeBoolean(groundUp);
|
||||
buffer.writeShort(primaryBitMask);
|
||||
byte[] finaldata = chunk.get1_8Data();
|
||||
Type.VAR_INT.write(buffer, finaldata.length);
|
||||
buffer.writeBytes(finaldata);
|
||||
}
|
||||
|
||||
public static void transformChunkBulk(PacketWrapper packetWrapper) throws Exception {
|
||||
short columnCount = packetWrapper.read(Type.SHORT); //short1
|
||||
int size = packetWrapper.read(Type.INT); //size
|
||||
boolean skyLightSent = packetWrapper.read(Type.BOOLEAN); //h
|
||||
int[] chunkX = new int[columnCount]; //a
|
||||
int[] chunkZ = new int[columnCount]; //b
|
||||
int[] primaryBitMask = new int[columnCount]; //c
|
||||
int[] addBitMask = new int[columnCount]; //d
|
||||
byte[][] inflatedBuffers = new byte[columnCount][]; //inflatedBuffers
|
||||
CustomByteType customByteType = new CustomByteType(size);
|
||||
byte[] buildBuffer = packetWrapper.read(customByteType); //buildBuffer
|
||||
|
||||
byte[] data = new byte[196864 * columnCount]; //abyte
|
||||
Inflater inflater = new Inflater();
|
||||
inflater.setInput(buildBuffer, 0, size);
|
||||
|
||||
try {
|
||||
inflater.inflate(data);
|
||||
} catch (DataFormatException ex) {
|
||||
throw new IOException("Bad compressed data format");
|
||||
} finally {
|
||||
inflater.end();
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (int j = 0; j < columnCount; ++j) {
|
||||
chunkX[j] = packetWrapper.read(Type.INT);
|
||||
chunkZ[j] = packetWrapper.read(Type.INT);
|
||||
primaryBitMask[j] = packetWrapper.read(Type.SHORT);
|
||||
addBitMask[j] = packetWrapper.read(Type.SHORT);
|
||||
int k = 0;
|
||||
int l = 0;
|
||||
|
||||
int i1;
|
||||
for (i1 = 0; i1 < 16; ++i1) {
|
||||
k += primaryBitMask[j] >> i1 & 1;
|
||||
l += addBitMask[j] >> i1 & 1;
|
||||
}
|
||||
|
||||
i1 = 8192 * k + 256;
|
||||
i1 += 2048 * l;
|
||||
if (skyLightSent) {
|
||||
i1 += 2048 * k;
|
||||
}
|
||||
|
||||
inflatedBuffers[j] = new byte[i1];
|
||||
System.arraycopy(data, i, inflatedBuffers[j], 0, i1);
|
||||
i += i1;
|
||||
}
|
||||
|
||||
Chunk1_8to1_7_6_10[] chunks = new Chunk1_8to1_7_6_10[columnCount];
|
||||
for (i = 0; i < columnCount; i++) {
|
||||
chunks[i] = new Chunk1_8to1_7_6_10(inflatedBuffers[i], primaryBitMask[i], addBitMask[i], skyLightSent, true);
|
||||
}
|
||||
|
||||
|
||||
packetWrapper.write(Type.BOOLEAN, skyLightSent);
|
||||
packetWrapper.write(Type.VAR_INT, (int) columnCount);
|
||||
|
||||
for (i = 0; i < columnCount; ++i) {
|
||||
packetWrapper.write(Type.INT, chunkX[i]);
|
||||
packetWrapper.write(Type.INT, chunkZ[i]);
|
||||
packetWrapper.write(Type.UNSIGNED_SHORT, primaryBitMask[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < columnCount; ++i) {
|
||||
data = chunks[i].get1_8Data();
|
||||
customByteType = new CustomByteType(data.length);
|
||||
packetWrapper.write(customByteType, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void transformMultiBlockChange(PacketWrapper packetWrapper) throws Exception {
|
||||
int chunkX = packetWrapper.read(Type.INT);
|
||||
int chunkZ = packetWrapper.read(Type.INT);
|
||||
int size = packetWrapper.read(Type.SHORT);
|
||||
packetWrapper.read(Type.INT);
|
||||
short[] blocks = new short[size];
|
||||
short[] positions = new short[size];
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
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(it -> new BlockChangeRecord(
|
||||
(short) (positions[it] >>> 8),
|
||||
(short) (positions[it] & 0xFFFF),
|
||||
blocks[it]))
|
||||
.toArray(BlockChangeRecord[]::new));
|
||||
}
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.chunks;
|
||||
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
|
||||
|
||||
public class ExtendedBlockStorage {
|
||||
private int yBase;
|
||||
private byte[] blockLSBArray;
|
||||
private NibbleArray blockMSBArray;
|
||||
private NibbleArray blockMetadataArray;
|
||||
private NibbleArray blocklightArray;
|
||||
private NibbleArray skylightArray;
|
||||
|
||||
public ExtendedBlockStorage(int paramInt, boolean paramBoolean) {
|
||||
this.yBase = paramInt;
|
||||
this.blockLSBArray = new byte[4096];
|
||||
this.blockMetadataArray = new NibbleArray(this.blockLSBArray.length);
|
||||
this.blocklightArray = new NibbleArray(this.blockLSBArray.length);
|
||||
if (paramBoolean) {
|
||||
this.skylightArray = new NibbleArray(this.blockLSBArray.length);
|
||||
}
|
||||
}
|
||||
|
||||
public int getExtBlockMetadata(int paramInt1, int paramInt2, int paramInt3) {
|
||||
return this.blockMetadataArray.get(paramInt1, paramInt2, paramInt3);
|
||||
}
|
||||
|
||||
public void setExtBlockMetadata(int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
|
||||
this.blockMetadataArray.set(paramInt1, paramInt2, paramInt3, paramInt4);
|
||||
}
|
||||
|
||||
public int getYLocation() {
|
||||
return this.yBase;
|
||||
}
|
||||
|
||||
public void setExtSkylightValue(int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
|
||||
this.skylightArray.set(paramInt1, paramInt2, paramInt3, paramInt4);
|
||||
}
|
||||
|
||||
public int getExtSkylightValue(int paramInt1, int paramInt2, int paramInt3) {
|
||||
return this.skylightArray.get(paramInt1, paramInt2, paramInt3);
|
||||
}
|
||||
|
||||
public void setExtBlocklightValue(int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
|
||||
this.blocklightArray.set(paramInt1, paramInt2, paramInt3, paramInt4);
|
||||
}
|
||||
|
||||
public int getExtBlocklightValue(int paramInt1, int paramInt2, int paramInt3) {
|
||||
return this.blocklightArray.get(paramInt1, paramInt2, paramInt3);
|
||||
}
|
||||
|
||||
public byte[] getBlockLSBArray() {
|
||||
return this.blockLSBArray;
|
||||
}
|
||||
|
||||
public void setBlockLSBArray(byte[] paramArrayOfByte) {
|
||||
this.blockLSBArray = paramArrayOfByte;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.blockMSBArray == null;
|
||||
}
|
||||
|
||||
public void clearMSBArray() {
|
||||
this.blockMSBArray = null;
|
||||
}
|
||||
|
||||
public NibbleArray getBlockMSBArray() {
|
||||
return this.blockMSBArray;
|
||||
}
|
||||
|
||||
public void setBlockMSBArray(NibbleArray paramNibbleArray) {
|
||||
this.blockMSBArray = paramNibbleArray;
|
||||
}
|
||||
|
||||
public NibbleArray getMetadataArray() {
|
||||
return this.blockMetadataArray;
|
||||
}
|
||||
|
||||
public NibbleArray getBlocklightArray() {
|
||||
return this.blocklightArray;
|
||||
}
|
||||
|
||||
public void setBlocklightArray(NibbleArray paramNibbleArray) {
|
||||
this.blocklightArray = paramNibbleArray;
|
||||
}
|
||||
|
||||
public NibbleArray getSkylightArray() {
|
||||
return this.skylightArray;
|
||||
}
|
||||
|
||||
public void setSkylightArray(NibbleArray paramNibbleArray) {
|
||||
this.skylightArray = paramNibbleArray;
|
||||
}
|
||||
|
||||
public void setBlockMetadataArray(NibbleArray paramNibbleArray) {
|
||||
this.blockMetadataArray = paramNibbleArray;
|
||||
}
|
||||
|
||||
public NibbleArray createBlockMSBArray() {
|
||||
this.blockMSBArray = new NibbleArray(this.blockLSBArray.length);
|
||||
return this.blockMSBArray;
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.metadata;
|
||||
|
||||
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.MetaType1_7_6_10;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter {
|
||||
|
||||
public static void transform(Entity1_10Types.EntityType type, List<Metadata> list) {
|
||||
for (Metadata entry : new ArrayList<>(list)) {
|
||||
MetaIndex1_8to1_7_6_10 metaIndex = MetaIndex1_8to1_7_6_10.searchIndex(type, entry.getId());
|
||||
try {
|
||||
if (metaIndex == null) throw new Exception("Could not find valid metadata");
|
||||
if (metaIndex.getNewType() == MetaType1_8.NonExistent) {
|
||||
list.remove(entry);
|
||||
return;
|
||||
}
|
||||
Object value = entry.getValue();
|
||||
if (!value.getClass().isAssignableFrom(metaIndex.getOldType().getType().getOutputClass())) {
|
||||
list.remove(entry);
|
||||
return;
|
||||
}
|
||||
entry.setMetaType(metaIndex.getNewType());
|
||||
entry.setId(metaIndex.getNewIndex());
|
||||
switch (metaIndex.getNewType()) {
|
||||
case Int:
|
||||
if (metaIndex.getOldType() == MetaType1_7_6_10.Byte) {
|
||||
entry.setValue(((Byte) value).intValue());
|
||||
}
|
||||
if (metaIndex.getOldType() == MetaType1_7_6_10.Short) {
|
||||
entry.setValue(((Short) value).intValue());
|
||||
}
|
||||
if (metaIndex.getOldType() == MetaType1_7_6_10.Int) {
|
||||
entry.setValue(value);
|
||||
}
|
||||
break;
|
||||
case Byte:
|
||||
if (metaIndex.getOldType() == MetaType1_7_6_10.Int) {
|
||||
entry.setValue(((Integer) value).byteValue());
|
||||
}
|
||||
if (metaIndex.getOldType() == MetaType1_7_6_10.Byte) {
|
||||
entry.setValue(value);
|
||||
}
|
||||
if (metaIndex == MetaIndex1_8to1_7_6_10.HUMAN_SKIN_FLAGS) {
|
||||
byte flags = (byte) value;
|
||||
boolean cape = flags == 2;
|
||||
flags = (byte) (cape ? 127 : 125);
|
||||
entry.setValue(flags);
|
||||
}
|
||||
break;
|
||||
case Slot:
|
||||
entry.setValue(value);
|
||||
break;
|
||||
case Float:
|
||||
entry.setValue(value);
|
||||
break;
|
||||
case Short:
|
||||
entry.setValue(value);
|
||||
break;
|
||||
case String:
|
||||
entry.setValue(value);
|
||||
break;
|
||||
case Position:
|
||||
entry.setValue(value);
|
||||
break;
|
||||
case Rotation:
|
||||
entry.setValue(value);
|
||||
break;
|
||||
default:
|
||||
Via.getPlatform().getLogger().warning("[Out] Unhandled MetaDataType: " + metaIndex.getNewType());
|
||||
list.remove(entry);
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
list.remove(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.storage;
|
||||
|
||||
import com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.Protocol1_8To1_7_6_10;
|
||||
import com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.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.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class EntityTracker extends StoredObject {
|
||||
private final Map<Integer, Entity1_10Types.EntityType> clientEntityTypes = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, List<Metadata>> metadataBuffer = new ConcurrentHashMap<>();
|
||||
|
||||
public EntityTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public void removeEntity(int entityId) {
|
||||
clientEntityTypes.remove(entityId);
|
||||
}
|
||||
|
||||
public Map<Integer, Entity1_10Types.EntityType> getClientEntityTypes() {
|
||||
return this.clientEntityTypes;
|
||||
}
|
||||
|
||||
public void addMetadataToBuffer(int entityID, List<Metadata> metadataList) {
|
||||
if (this.metadataBuffer.containsKey(entityID)) {
|
||||
this.metadataBuffer.get(entityID).addAll(metadataList);
|
||||
} else if (!metadataList.isEmpty()) {
|
||||
this.metadataBuffer.put(entityID, metadataList);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Metadata> getBufferedMetadata(int entityId) {
|
||||
return metadataBuffer.get(entityId);
|
||||
}
|
||||
|
||||
public void sendMetadataBuffer(int entityId) {
|
||||
if (!this.metadataBuffer.containsKey(entityId)) return;
|
||||
PacketWrapper wrapper = new PacketWrapper(0x1C, null, this.getUser());
|
||||
wrapper.write(Type.VAR_INT, entityId);
|
||||
wrapper.write(Types1_8.METADATA_LIST, this.metadataBuffer.get(entityId));
|
||||
MetadataRewriter.transform(this.getClientEntityTypes().get(entityId), this.metadataBuffer.get(entityId));
|
||||
if (!this.metadataBuffer.get(entityId).isEmpty()) {
|
||||
try {
|
||||
wrapper.send(Protocol1_8To1_7_6_10.class);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
this.metadataBuffer.remove(entityId);
|
||||
}
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MapStorage extends StoredObject {
|
||||
private Map<Integer, MapData> maps = new HashMap<>();
|
||||
|
||||
public MapStorage(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public MapData getMapData(int id) {
|
||||
return maps.get(id);
|
||||
}
|
||||
|
||||
public void putMapData(int id, MapData mapData) {
|
||||
maps.put(id, mapData);
|
||||
}
|
||||
|
||||
public static class MapData {
|
||||
public byte scale = 0;
|
||||
public MapIcon[] mapIcons = {};
|
||||
}
|
||||
|
||||
public static class MapIcon {
|
||||
public byte direction;
|
||||
public byte type;
|
||||
public byte x;
|
||||
public byte z;
|
||||
|
||||
public MapIcon(byte direction, byte type, byte x, byte z) {
|
||||
this.direction = direction;
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Scoreboard extends StoredObject {
|
||||
|
||||
private HashMap<String, String> objectives = new HashMap<>();
|
||||
|
||||
public Scoreboard(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public void put(String name, String objective) {
|
||||
objectives.put(name, objective);
|
||||
}
|
||||
|
||||
public String get(String name) {
|
||||
return objectives.getOrDefault(name, "null");
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Tablist extends StoredObject {
|
||||
|
||||
private ArrayList<TabListEntry> tablist = new ArrayList<>();
|
||||
|
||||
public Tablist(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public static boolean shouldUpdateDisplayName(String oldName, String newName) {
|
||||
return oldName == null && newName != null || oldName != null && newName == null || oldName != null && !oldName.equals(newName);
|
||||
}
|
||||
|
||||
public TabListEntry getTabListEntry(String name) {
|
||||
for (TabListEntry entry : tablist) if (name.equals(entry.name)) return entry;
|
||||
return null;
|
||||
}
|
||||
|
||||
public TabListEntry getTabListEntry(UUID uuid) {
|
||||
for (TabListEntry entry : tablist) if (uuid.equals(entry.uuid)) return entry;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void remove(TabListEntry entry) {
|
||||
tablist.remove(entry);
|
||||
}
|
||||
|
||||
public void add(TabListEntry entry) {
|
||||
tablist.add(entry);
|
||||
}
|
||||
|
||||
public static class TabListEntry {
|
||||
public String name;
|
||||
public String displayName;
|
||||
public UUID uuid;
|
||||
public int ping;
|
||||
public List<Property> properties = new ArrayList<>();
|
||||
|
||||
public TabListEntry(String name, UUID uuid) {
|
||||
this.name = name;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Property {
|
||||
public String name;
|
||||
public String value;
|
||||
public String signature;
|
||||
|
||||
public Property(String name, String value, String signature) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.signature = signature;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018 creeper123123321 and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.github.creeper123123321.viafabric.protocol.protocol1_8to1_7_6_10.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Windows extends StoredObject {
|
||||
|
||||
public HashMap<Short, Short> types = new HashMap<>();
|
||||
|
||||
public Windows(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public short get(short windowId) {
|
||||
return types.getOrDefault(windowId, (short) -1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user