Skip to content

Instantly share code, notes, and snippets.

@hach-que
Created July 6, 2019 22:52
Show Gist options
  • Save hach-que/e062ddb0fb75103aec03b899fd7ed71b to your computer and use it in GitHub Desktop.
Save hach-que/e062ddb0fb75103aec03b899fd7ed71b to your computer and use it in GitHub Desktop.
It captures the UpdateBlockPacket message for the actual 200, 0, 200 block, and detects it's runtime entity ID as 2231:
INFO 2019-07-06 15:38:33,064 [games.redpoint.App.main()][ConditionalCommandNode.java:73] : on success: switching to success node
WARN 2019-07-06 15:38:33,086 [Network Listener - #2][PapyrusBot.java:272] : Found bed, it's runtime entity ID is 2231
DEBUG 2019-07-06 15:38:33,086 [Network Listener - #2][DefaultBatchHandler.java:27] : Unhandled packet for /34.94.110.9:19132: BlockEntityDataPacket(blockPosition=(200, 0, 200), data=TAG_Compound: 6 entries
(
TAG_Byte("color"): 14
TAG_Int("x"): 200
TAG_Int("y"): 0
TAG_Byte("isMovable"): 1
TAG_Int("z"): 200
TAG_String("id"): Bed
))
DEBUG 2019-07-06 15:38:33,087 [Network Listener - #2][DefaultBatchHandler.java:27] : Unhandled packet for /34.94.110.9:19132: UpdateBlockPacket(flags=[NETWORK], blockPosition=(200, 0, 199), runtimeId=3064, dataLayer=0)
DEBUG 2019-07-06 15:38:33,087 [Network Listener - #2][DefaultBatchHandler.java:27] : Unhandled packet for /34.94.110.9:19132: BlockEntityDataPacket(blockPosition=(200, 0, 199), data=TAG_Compound: 6 entries
(
TAG_Byte("color"): 14
TAG_Int("x"): 200
TAG_Int("y"): 0
TAG_Byte("isMovable"): 1
TAG_Int("z"): 199
TAG_String("id"): Bed
))
Once the bot has the position of the bed, it tries to use interact and player action packets to actually start sleeping:
.add(new SetBlockCommandNode(new Vector3i(200, 1, 199), "torch"))
.add(new DelegatingCommandNode((StatefulCommandGraph graph, PapyrusBot bot) -> {
if (this.bedRuntimeEntityId == 0) {
return CommandNodeState.PENDING;
}
return CommandNodeState.SUCCESS;
})).add(new StateChangeCommandNode("sleep")));
Random r = new Random();
this.commandGraph.add("sleep",
new SequentialCommandNode().add(new ExecuteCommandNode("time set midnight", RetryPolicy.ALWAYS_RETRY))
.add(new ExecuteCommandNode("tp @s 201 0 199 90 45", RetryPolicy.ALWAYS_RETRY))
.add(new DelegatingCommandNode((StatefulCommandGraph graph, PapyrusBot bot) -> {
LOG.info("Sending player action packet");
PlayerActionPacket packet = new PlayerActionPacket();
packet.setRuntimeEntityId(this.bedRuntimeEntityId);
packet.setBlockPosition(new Vector3i(200, 0, 200));
packet.setAction(Action.START_SLEEP);
session.sendPacketImmediately(packet);
LOG.info("Sending interact packet");
InteractPacket packet2 = new InteractPacket();
packet2.setRuntimeEntityId(this.bedRuntimeEntityId);
packet2.setMousePosition(new Vector3f(r.nextDouble(), r.nextDouble(), r.nextDouble()));
packet2.setAction(2);
session.sendPacketImmediately(packet2);
LOG.info("Sending interact packet");
InteractPacket packet3 = new InteractPacket();
packet3.setRuntimeEntityId(this.bedRuntimeEntityId);
packet3.setMousePosition(new Vector3f(r.nextDouble(), r.nextDouble(), r.nextDouble()));
packet3.setAction(0);
session.sendPacketImmediately(packet3);
return CommandNodeState.PENDING;
})));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment