Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.8-1.12 version support #1

Closed
unldenis opened this issue Jan 21, 2022 · 1 comment
Closed

1.8-1.12 version support #1

unldenis opened this issue Jan 21, 2022 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@unldenis
Copy link
Owner

unldenis commented Jan 21, 2022

As you may have noticed versions 1.8 -1.12 are not supported, why?
Because from 1.13 it is possible to set the pose of the npc to SLEEPING.
In previous versions instead you have to use a PacketPlayOutBed, which causes problems.

Using this code I can make him sleep, however I cannot make the bed invisible.

Location location=...
player.sendBlockChange(location, Material.valueOf("BED_BLOCK"), (byte) 0);
player.sendBlockChange(location.add(0, 0, 1), Material.valueOf("BED_BLOCK"), (byte) 2);

PacketContainer packet = new PacketContainer(PacketType.Play.Server.BED);
BlockPosition blockPos = new BlockPosition(location.getBlock().getX(), location.getBlock().getY(), location.getBlock().getZ());
packet.getIntegers().write(0, id);
packet.getBlockPositionModifier().write(0, blockPos);

Preview Result

As you can see in the image the npc skin is not visible, why? because in this version(1.8.8) a ClassNotFoundException is thrown referring to the Guava MultiMap.
The solution is * not * to import the entire library as it weighs 3MB.

@unldenis unldenis added the help wanted Extra attention is needed label Jan 21, 2022
@Happy-FZM
Copy link
Contributor

Happy-FZM commented Jan 26, 2022

I tested this code and it works (1.12.2).
I found that it only works when use ProtocolLibrary.getProtocolManager().sendServerPacket().
If you use ProtocolLibrary.getProtocolManager().broadcastServerPacket() it not works.

  public static PacketContainer PLAYER_SLEEPING(Location loc, int entityId) {
      PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.BED);
      packet.getIntegers().write(0, entityId);
      packet.getBlockPositionModifier().write(0, new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
      return packet;
  }

Done #2!

@unldenis unldenis closed this as completed Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants