mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-21 23:51:36 +01:00
Fix item meta writing
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
e4a3a3dbae
commit
fbf6479135
@ -153,7 +153,6 @@ public class ItemMeta implements TagReadable, Writeable {
|
|||||||
w.writeNBT("", nbt);
|
w.writeNBT("", nbt);
|
||||||
this.cachedBuffer = w.getBuffer();
|
this.cachedBuffer = w.getBuffer();
|
||||||
}
|
}
|
||||||
writer.write(cachedBuffer);
|
writer.write(cachedBuffer.flip());
|
||||||
this.cachedBuffer.position(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,9 +211,7 @@ public class NettyPlayerConnection extends PlayerConnection {
|
|||||||
serverPacket = ((ComponentHoldingServerPacket) serverPacket).copyWithOperator(component ->
|
serverPacket = ((ComponentHoldingServerPacket) serverPacket).copyWithOperator(component ->
|
||||||
GlobalTranslator.render(component, Objects.requireNonNullElseGet(getPlayer().getLocale(), MinestomAdventure::getDefaultLocale)));
|
GlobalTranslator.render(component, Objects.requireNonNullElseGet(getPlayer().getLocale(), MinestomAdventure::getDefaultLocale)));
|
||||||
}
|
}
|
||||||
synchronized (tickBufferLock) {
|
attemptWrite(PacketUtils.createFramedPacket(serverPacket));
|
||||||
PacketUtils.writeFramedPacket(tickBuffer, serverPacket);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
} else if (message instanceof ByteBuffer) {
|
} else if (message instanceof ByteBuffer) {
|
||||||
attemptWrite((ByteBuffer) message);
|
attemptWrite((ByteBuffer) message);
|
||||||
|
@ -7,7 +7,6 @@ import net.minestom.server.network.player.NettyPlayerConnection;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.nio.channels.SelectionKey;
|
import java.nio.channels.SelectionKey;
|
||||||
import java.nio.channels.Selector;
|
import java.nio.channels.Selector;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
@ -140,7 +139,7 @@ public class Worker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ByteBuffer allocate(int size) {
|
private static ByteBuffer allocate(int size) {
|
||||||
return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
|
return ByteBuffer.allocateDirect(size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package net.minestom.server.utils;
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.shorts.Short2ShortLinkedOpenHashMap;
|
import it.unimi.dsi.fastutil.shorts.Short2ShortLinkedOpenHashMap;
|
||||||
import net.minestom.server.instance.palette.Palette;
|
import net.minestom.server.instance.palette.Palette;
|
||||||
import net.minestom.server.utils.binary.BinaryWriter;
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -89,14 +88,14 @@ public final class Utils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeVarLong(BinaryWriter writer, long value) {
|
public static void writeVarLong(ByteBuffer buffer, long value) {
|
||||||
do {
|
do {
|
||||||
byte temp = (byte) (value & 0b01111111);
|
byte temp = (byte) (value & 0b01111111);
|
||||||
value >>>= 7;
|
value >>>= 7;
|
||||||
if (value != 0) {
|
if (value != 0) {
|
||||||
temp |= 0b10000000;
|
temp |= 0b10000000;
|
||||||
}
|
}
|
||||||
writer.writeByte(temp);
|
buffer.put(temp);
|
||||||
} while (value != 0);
|
} while (value != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ public class BinaryWriter extends OutputStream {
|
|||||||
* @param l the long to write
|
* @param l the long to write
|
||||||
*/
|
*/
|
||||||
public void writeVarLong(long l) {
|
public void writeVarLong(long l) {
|
||||||
Utils.writeVarLong(this, l);
|
Utils.writeVarLong(buffer, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -292,7 +292,10 @@ public class BinaryWriter extends OutputStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void write(@NotNull BinaryWriter writer) {
|
public void write(@NotNull BinaryWriter writer) {
|
||||||
write(writer.getBuffer());
|
var buffer = writer.buffer;
|
||||||
|
final int pos = buffer.position();
|
||||||
|
write(buffer.position(0));
|
||||||
|
buffer.position(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user