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

Update entity API #7

Merged
merged 5 commits into from
Sep 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update CmdInventory
`unsafeGive` and `give` now support `minecraft.block.BLOCK`.
  • Loading branch information
Red-exe-Engineer authored Sep 4, 2023
commit 141504d9310e11932da7a11ec27abdca4c832a32
6 changes: 6 additions & 0 deletions mcpi_addons/minecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,17 @@ def getHeldItem(self):

def unsafeGive(self, id=-2, auxiliary=-2, count=-2):
"""Sets the current slot to something else, this is unsafe and may crash the game"""
if isinstance(id, Block):
id, auxiliary = id.id, (id.data if auxiliary == -2 else auxiliary)

args = "|".join(map(str, [id, auxiliary, count]))
self.conn.sendReceive(b"custom.inventory.unsafeGive", args)

def give(self, id=-2, auxiliary=-2, count=-2):
"""Sets the current slot to something else"""
if isinstance(id, Block):
id, auxiliary = id.id, (id.data if auxiliary == -2 else auxiliary)

args = "|".join(map(str, [id, auxiliary, count]))
self.conn.sendReceive(b"custom.inventory.give", args)

Expand Down