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

Fix overrideable hand ToolCapabilities and range #15743

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cx384
Copy link
Contributor

@cx384 cx384 commented Feb 1, 2025

Solves #15740

To avoid confusion, notice:
selected_item is the item selected in the hotbar, ("" if empty)
hand_item is the overwritten hand ("" by default).
tool_item/playeritem/punchitem is what should be used for getToolCapabilities (getWieldedItem returns this)

getToolCapabilities needs both tool_item and hand_item as a fallback.

Callbacks and node placement still only uses selected_item.

To do

Ready for Review.

How to test

  • Like explained in the issue, try e.g.
core.register_item("default:hand", {
	type = "none",
	range = 20,
	tool_capabilities = {
		groupcaps = {
			crumbly = {times={[1] = 0.1, [2] = 0.1, [3] = 0.1}, uses = 0, maxlevel = 1},
			cracky = {times={[1] = 0.1, [2] = 0.1, [3] = 0.1}, uses = 0, maxlevel = 1},
		}
	}
})

core.register_chatcommand('hand', {
	func = function(name, param)
		local player = core.get_player_by_name(name)

		local handitem
		if param == 'reset' then
			handitem = ''
		else
			handitem = 'default:hand'
		end

		local inv = player:get_inventory()
		inv:set_size('hand', 1)
		inv:set_stack('hand', 1, ItemStack(handitem))
	end
})
  • See that it works while wielding nothing, and while e.g. a node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix 🐛 PRs that fix a bug @ Script API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant