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

custom wieldhand: toolcaps not used if not wielding empty slot #5200

Closed
sofar opened this issue Feb 10, 2017 · 4 comments
Closed

custom wieldhand: toolcaps not used if not wielding empty slot #5200

sofar opened this issue Feb 10, 2017 · 4 comments
Labels
Bug Issues that were confirmed to be a bug Request / Suggestion The issue makes a suggestion for something that should be done but isn't a new feature

Comments

@sofar
Copy link
Contributor

sofar commented Feb 10, 2017

Expectation:

If I make a custom wieldhand and equip it, when I wield a node without toolcaps, the equipped "hand" slot itemstack toolcaps should be used.

So let's say I make a "chainsaw hand" that can saw through wood fast, and equip it. Then I should expect it to saw fast even if I don't have an empty wieldhand.

Reality:

This works for the builtin wieldhand, but not custom wieldhands.

If you set a custom wieldhand, the toolcaps are not used if you wield a node (e.g. dirt node)

steps to reproduce:

  1. default wieldhand - remove all tool caps so the default wieldhand can't dig a single node
  2. make custom wieldhand itemstack with tool caps that allow digging nodes
  3. use inventory:set_stack("hand", 1, "custom_hand")
  4. observe player wields new hand if you have an empty itemstack selected in the inventory
  5. dig a node -> you can dig the node with the custom hand
  6. now you receive a node in the empty inventory slot, and your wielditem shows the node
  7. you can no longer dig nodes as long as you wield the node
@sofar sofar added the Bug Issues that were confirmed to be a bug label Feb 10, 2017
@sofar
Copy link
Contributor Author

sofar commented Mar 12, 2017

Reproduction code:

minetest.register_item("hand:super", {
	type = "none",
	description = "super hand",
	wield_image = "wieldhand.png",
	inventory_image = "wieldhand.png",
	wield_scale = {x = 1, y = 1, z = 2},
	range = 6,
	tool_capabilities = {
		full_punch_interval = 0.1,
		max_drop_level = 0,
		groupcaps = {
			choppy = {times={[1] = 0.2, [2] = 0.2, [3] = 0.2}, uses = 0, maxlevel = 1},
			crumbly = {times={[1] = 0.2, [2] = 0.2, [3] = 0.2}, uses = 0, maxlevel = 1},
			cracky = {times={[1] = 0.2, [2] = 0.2, [3] = 0.2}, uses = 0, maxlevel = 1},
		},
		damage_groups = {},
	},
	groups = {not_in_creative_inventory = 1},
})

minetest.register_on_joinplayer(function(player)
	player:get_inventory():set_stack("hand", 1, "hand:super")
end)

Throw this in a minimal game and call it hand/init.lua and enable.

If you have an empty slot selected, you can dig any node. If there is a node in the slot, you can't dig e.g. stone anymore.

@sofar
Copy link
Contributor Author

sofar commented Mar 12, 2017

Root cause:

https://github.com/minetest/minetest/blob/f2f9a923515386d787a245fac52f78e815b3a839/src/inventory.h#L116

The hand slot is never inspected, it always tries the default hand item only.

@sofar
Copy link
Contributor Author

sofar commented Mar 12, 2017

I'm lost in const * c++, I really don't know C++ well enough to fix this. Help?

@paramat paramat added the Request / Suggestion The issue makes a suggestion for something that should be done but isn't a new feature label Mar 12, 2017
@sofar
Copy link
Contributor Author

sofar commented Apr 7, 2017

a5c9174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug Request / Suggestion The issue makes a suggestion for something that should be done but isn't a new feature
Projects
None yet
Development

No branches or pull requests

2 participants