Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. package net.minecraft.network.play.client;
  2.  
  3. import java.io.IOException;
  4. import net.minecraft.network.Packet;
  5. import net.minecraft.network.PacketBuffer;
  6. import net.minecraft.network.play.INetHandlerPlayServer;
  7. import net.minecraft.util.EnumFacing;
  8. import net.minecraft.util.math.BlockPos;
  9.  
  10. public class CPacketPlayerDigging implements Packet<INetHandlerPlayServer>
  11. {
  12. private BlockPos position;
  13. private EnumFacing facing;
  14. /** Status of the digging (started, ongoing, broken). */
  15. private CPacketPlayerDigging.Action action;
  16.  
  17. public CPacketPlayerDigging()
  18. {
  19. }
  20.  
  21. public CPacketPlayerDigging(CPacketPlayerDigging.Action actionIn, BlockPos posIn, EnumFacing facingIn)
  22. {
  23. this.action = actionIn;
  24. this.position = posIn;
  25. this.facing = facingIn;
  26. }
  27.  
  28. /**
  29. * Reads the raw packet data from the data stream.
  30. */
  31. public void readPacketData(PacketBuffer buf) throws IOException
  32. {
  33. this.action = (CPacketPlayerDigging.Action)buf.readEnumValue(CPacketPlayerDigging.Action.class);
  34. this.position = buf.readBlockPos();
  35. this.facing = EnumFacing.byIndex(buf.readUnsignedByte());
  36. }
  37.  
  38. /**
  39. * Writes the raw packet data to the data stream.
  40. */
  41. public void writePacketData(PacketBuffer buf) throws IOException
  42. {
  43. buf.writeEnumValue(this.action);
  44. buf.writeBlockPos(this.position);
  45. buf.writeByte(this.facing.getIndex());
  46. }
  47.  
  48. /**
  49. * Passes this Packet on to the NetHandler for processing.
  50. */
  51. public void processPacket(INetHandlerPlayServer handler)
  52. {
  53. handler.processPlayerDigging(this);
  54. }
  55.  
  56. public BlockPos getPosition()
  57. {
  58. return this.position;
  59. }
  60.  
  61. public EnumFacing getFacing()
  62. {
  63. return this.facing;
  64. }
  65.  
  66. public CPacketPlayerDigging.Action getAction()
  67. {
  68. return this.action;
  69. }
  70.  
  71. public static enum Action
  72. {
  73. START_DESTROY_BLOCK,
  74. ABORT_DESTROY_BLOCK,
  75. STOP_DESTROY_BLOCK,
  76. DROP_ALL_ITEMS,
  77. DROP_ITEM,
  78. RELEASE_USE_ITEM,
  79. SWAP_HELD_ITEMS;
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement