Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 08:10:09 +01:00
Merge pull request #25 from HugoDaBosss/master
Fix USE_ITEM using correct item. Fix SPAWN_OBJECT velocity.
Dieser Commit ist enthalten in:
Commit
0db43e612e
@ -2,7 +2,10 @@ package us.myles.ViaVersion.transformers;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import us.myles.ViaVersion.*;
|
import us.myles.ViaVersion.*;
|
||||||
import us.myles.ViaVersion.handlers.ViaVersionInitializer;
|
import us.myles.ViaVersion.handlers.ViaVersionInitializer;
|
||||||
import us.myles.ViaVersion.packets.PacketType;
|
import us.myles.ViaVersion.packets.PacketType;
|
||||||
@ -91,11 +94,8 @@ public class IncomingTransformer {
|
|||||||
throw new CancelException();
|
throw new CancelException();
|
||||||
}
|
}
|
||||||
output.writeByte(status);
|
output.writeByte(status);
|
||||||
// read position
|
// write remaining bytes
|
||||||
Long pos = input.readLong();
|
output.writeBytes(input);
|
||||||
output.writeLong(pos);
|
|
||||||
short face = input.readUnsignedByte();
|
|
||||||
output.writeByte(face);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (packet == PacketType.PLAY_CLICK_WINDOW) {
|
if (packet == PacketType.PLAY_CLICK_WINDOW) {
|
||||||
@ -207,16 +207,30 @@ public class IncomingTransformer {
|
|||||||
}
|
}
|
||||||
if (packet == PacketType.PLAY_USE_ITEM) {
|
if (packet == PacketType.PLAY_USE_ITEM) {
|
||||||
output.clear();
|
output.clear();
|
||||||
PacketUtil.writeVarInt(PacketType.PLAY_PLAYER_BLOCK_PLACEMENT.getPacketID(), output);
|
PacketUtil.writeVarInt(PacketType.PLAY_PLAYER_BLOCK_PLACEMENT.getPacketID(), output);
|
||||||
// Simulate using item :)
|
// Simulate using item :)
|
||||||
output.writeLong(-1L);
|
output.writeLong(-1L);
|
||||||
output.writeByte(-1);
|
output.writeByte(255);
|
||||||
// write item in hand
|
// write item in hand
|
||||||
output.writeShort(-1);
|
ItemStack inHand = Core.getHandItem(info);
|
||||||
|
Object item = null;
|
||||||
|
try {
|
||||||
|
Method m = ReflectionUtil.obc("inventory.CraftItemStack").getDeclaredMethod("asNMSCopy", ItemStack.class);
|
||||||
|
item = m.invoke(null, inHand);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
PacketUtil.writeItem(item, output);
|
||||||
|
|
||||||
output.writeByte(-1);
|
output.writeByte(-1);
|
||||||
output.writeByte(-1);
|
output.writeByte(-1);
|
||||||
output.writeByte(-1);
|
output.writeByte(-1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
output.writeBytes(input);
|
output.writeBytes(input);
|
||||||
|
@ -281,11 +281,15 @@ public class OutgoingTransformer {
|
|||||||
int data = input.readInt();
|
int data = input.readInt();
|
||||||
output.writeInt(data);
|
output.writeInt(data);
|
||||||
|
|
||||||
short vX = input.readableBytes() >= 16 ? input.readShort() : 0;
|
short vX = 0, vY = 0, vZ = 0;
|
||||||
|
if(data > 0)
|
||||||
|
{
|
||||||
|
vX = input.readShort();
|
||||||
|
vY = input.readShort();
|
||||||
|
vZ = input.readShort();
|
||||||
|
}
|
||||||
output.writeShort(vX);
|
output.writeShort(vX);
|
||||||
short vY = input.readableBytes() >= 16 ? input.readShort() : 0;
|
|
||||||
output.writeShort(vY);
|
output.writeShort(vY);
|
||||||
short vZ = input.readableBytes() >= 16 ? input.readShort() : 0;
|
|
||||||
output.writeShort(vZ);
|
output.writeShort(vZ);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren