Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Ursprung
ca23750c28
Commit
e5169378fc
@ -2,6 +2,7 @@ package us.myles.ViaVersion.api;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -330,7 +331,7 @@ public class PacketWrapper {
|
||||
// Apply other protocols
|
||||
apply(Direction.OUTGOING, user().get(ProtocolInfo.class).getState(), index, protocols);
|
||||
// Send
|
||||
ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
|
||||
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
|
||||
writeToBuffer(output);
|
||||
|
||||
return output;
|
||||
@ -378,7 +379,7 @@ public class PacketWrapper {
|
||||
public void send() throws Exception {
|
||||
if (!isCancelled()) {
|
||||
// Send
|
||||
ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
|
||||
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
|
||||
writeToBuffer(output);
|
||||
user().sendRawPacket(output);
|
||||
}
|
||||
@ -473,7 +474,7 @@ public class PacketWrapper {
|
||||
*/
|
||||
public void sendToServer() throws Exception {
|
||||
if (!isCancelled()) {
|
||||
ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
|
||||
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
|
||||
writeToBuffer(output);
|
||||
|
||||
user().getChannel().pipeline().context(Via.getManager().getInjector().getDecoderName()).fireChannelRead(output);
|
||||
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
@ -82,7 +83,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
|
||||
output.writeBoolean(chunk.isGroundUp());
|
||||
Type.VAR_INT.write(output, chunk.getBitmask());
|
||||
|
||||
ByteBuf buf = output.alloc().buffer();
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) continue; // Section not set
|
||||
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
@ -350,15 +351,12 @@ public class ChunkSection1_9_3_4 implements ChunkSection {
|
||||
|
||||
private int countBytes(int value) throws Exception {
|
||||
// Count amount of bytes that would be sent if the value were sent as a VarInt
|
||||
if ((value & (~0 << 7)) == 0)
|
||||
return 1;
|
||||
if ((value & (~0 << 14)) == 0)
|
||||
return 2;
|
||||
if ((value & (~0 << 21)) == 0)
|
||||
return 3;
|
||||
if ((value & (~0 << 28)) == 0)
|
||||
return 4;
|
||||
return 5;
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
Type.VAR_INT.write(buf, value);
|
||||
buf.readerIndex(0);
|
||||
int bitCount = buf.readableBytes();
|
||||
buf.release();
|
||||
return bitCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
@ -80,7 +81,7 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
|
||||
output.writeBoolean(chunk.isGroundUp());
|
||||
Type.VAR_INT.write(output, chunk.getBitmask());
|
||||
|
||||
ByteBuf buf = output.alloc().buffer();
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) continue; // Section not set
|
||||
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.chunks;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
@ -347,14 +348,11 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
|
||||
|
||||
private int countBytes(int value) throws Exception {
|
||||
// Count amount of bytes that would be sent if the value were sent as a VarInt
|
||||
if ((value & (~0 << 7)) == 0)
|
||||
return 1;
|
||||
if ((value & (~0 << 14)) == 0)
|
||||
return 2;
|
||||
if ((value & (~0 << 21)) == 0)
|
||||
return 3;
|
||||
if ((value & (~0 << 28)) == 0)
|
||||
return 4;
|
||||
return 5;
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
Type.VAR_INT.write(buf, value);
|
||||
buf.readerIndex(0);
|
||||
int bitCount = buf.readableBytes();
|
||||
buf.release();
|
||||
return bitCount;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
@ -78,7 +79,7 @@ public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
|
||||
output.writeBoolean(chunk.isGroundUp());
|
||||
Type.VAR_INT.write(output, chunk.getBitmask());
|
||||
|
||||
ByteBuf buf = output.alloc().buffer();
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) continue; // Section not set
|
||||
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
@ -250,14 +251,11 @@ public class ChunkSection1_9to1_8 implements ChunkSection {
|
||||
|
||||
private int countBytes(int value) throws Exception {
|
||||
// Count amount of bytes that would be sent if the value were sent as a VarInt
|
||||
if ((value & (~0 << 7)) == 0)
|
||||
return 1;
|
||||
if ((value & (~0 << 14)) == 0)
|
||||
return 2;
|
||||
if ((value & (~0 << 21)) == 0)
|
||||
return 3;
|
||||
if ((value & (~0 << 28)) == 0)
|
||||
return 4;
|
||||
return 5;
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
Type.VAR_INT.write(buf, value);
|
||||
buf.readerIndex(0);
|
||||
int bitCount = buf.readableBytes();
|
||||
buf.release();
|
||||
return bitCount;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.google.common.base.Optional;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
@ -157,7 +158,7 @@ public class WorldPackets {
|
||||
throw new IOException("transformMapChunkBulk returned the wrong object type");
|
||||
|
||||
PacketWrapper output = (PacketWrapper) obj;
|
||||
ByteBuf buffer = wrapper.user().getChannel().alloc().buffer();
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
output.setId(-1); // -1 for no writing of id
|
||||
output.writeToBuffer(buffer);
|
||||
PacketWrapper chunkPacket = new PacketWrapper(0x21, buffer, wrapper.user());
|
||||
|
@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.types;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
@ -153,7 +154,7 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
|
||||
output.writeByte(chunk.isGroundUp() ? 0x01 : 0x00);
|
||||
Type.VAR_INT.write(output, chunk.getPrimaryBitmask());
|
||||
|
||||
ByteBuf buf = output.alloc().buffer();
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
for (int i = 0; i < SECTION_COUNT; i++) {
|
||||
ChunkSection1_9to1_8 section = chunk.getSections()[i];
|
||||
if (section == null) continue; // Section not set
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren