Run of fresh-snapshots for minetest-mod-throwing

Try this locally (using silver-platter):

debian-svp new-upstream --snapshot minetest-mod-throwing 

Merge these changes:

Summary

Merged new upstream version: 1.1+git20200510.4c50e6b (was: 1.1).

Diff

diff --git a/README.md b/README.md
index 81837d9..007394c 100644
--- a/README.md
+++ b/README.md
@@ -36,15 +36,15 @@ throwing.toolranks = true
 
 By default, the trajectory of the arrow is a simple parabola. You can set the vertical acceleration (acceleration of gravity) using `throwing.vertical_acceleration`.
 
-If you want a more realistic trajectory that uses a first-order modelling of air friction, you can set `throwing.realistic_trajectory` to true. In this mode, `throwing.frictional_coefficient` indicates the ratio between the friction force on the arrow and its velocity. It should be negative. The acceleration of the arrow is subsequently determined by dividing the force by the "mass" of the arrow, the reference mass of 1 being the mass of a simple steel arrow. Generally, the frictional coefficient should be quite small; a value of -1 will already drastically shorten the range of the arrow. The default is -0.5.
+If you want a more realistic trajectory that uses a first-order modelling of air friction, you can set `throwing.realistic_trajectory` to true. In this mode, `throwing.frictional_coefficient` indicates the ratio between the friction force on the arrow and its velocity. It should be negative. The acceleration of the arrow is subsequently determined by dividing the force by the "mass" of the arrow, the reference mass of 1 being the mass of the steel arrow in `throwing_arrows`. Generally, the frictional coefficient should be quite small; a value of -1 will already drastically shorten the range of the arrow. The default is -0.5.
 
 ### Initial velocity computation
 
-The mod provides three modes to compute the initial speed of an arrow: simple, strength or strengthmass.
+The mod provides three modes to compute the initial velocity of an arrow after it is shot: simple, strength and momentum.
 
-In simple mode, the initial velocity of the arrow is always the same. The `throwing.velocity_factor` contains the value of this velocity.
+In simple mode, the initial velocity of the arrow is always the same. The value of this velocity is controlled by the `throwing.velocity_factor` setting, which defaults to 19.
 
-In strength mode (the default), the initial velocity of the arrow only depends on the bow that is used---the more expensive the bow, the faster the arrow. The arrow strength is multiplied by the velocity factor to compute the speed of the arrow, an arrow strength of 1 is about the strength of the steel bow in `throwing_arrows`.
+In strength mode (the default), the initial velocity of the arrow only depends on the bow that is used---the more expensive the bow, the faster the arrow. The bow strength is multiplied by the velocity factor to compute the speed of the arrow. For reference, the steel bow in `throwing_arrows` has a strength of about 1.
 
 Finally, momentum mode is the most realistic. It computes the velocity of the arrow based on the bow strength, as in the strength mode, and on the mass of the arrow: the heavier the arrow, the slower it will be shot. It is called the momentum mode because, in this mode, the strength of a bow indicates the initial momentum of the arrow rather than its initial speed.
 
@@ -76,6 +76,7 @@ Definition: definition table, containing:
   * sound: sound to be played when the bow is used
   * delay: delay before throwing the arrow
   * no_toolranks: If true, toolranks support is disabled for this item. Defaults to false.
+  * strength: strength of the bow, see above. Defaults to 1.
 ]]
 
 -- Example:
@@ -93,6 +94,7 @@ Definition: definition table, containing:
   * tiles (essential): tiles of the arrow.
   * target (optional, defaulting to throwing.target_both): what the arrow is able to hit (throwing.target_node, throwing.target_object, throwing.target_both).
   * allow_protected (optional, defaulting to false): whether the arrow can be throw in a protected area
+  * mass (optional, defaulting to 1): the mass of the arrow (see above)
   * on_hit_sound (optional): sound played when the arrow hits a node or an object.
   * on_hit(self, pos, last_pos, node, object, hitter, data) (optional but very useful): callback function:
     - pos: the position of the hit node or object.
diff --git a/debian/changelog b/debian/changelog
index a86629b..3ba3706 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+minetest-mod-throwing (1.1+git20200510.4c50e6b-1) UNRELEASED; urgency=medium
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Mon, 06 Jul 2020 03:31:52 +0000
+
 minetest-mod-throwing (1.1-1) unstable; urgency=medium
 
   * New upstream release.
diff --git a/init.lua b/init.lua
index 4656126..4d7abee 100644
--- a/init.lua
+++ b/init.lua
@@ -109,13 +109,7 @@ local function shoot_arrow(def, toolranks_data, player, bow_index, throw_itself,
 	end
 
 	if not minetest.settings:get_bool("creative_mode") then
-		if new_stack then
-			inventory:set_stack("main", arrrow_index, new_stack)
-		else
-			local stack = inventory:get_stack("main", arrow_index)
-			stack:take_item()
-			inventory:set_stack("main", arrow_index, stack)
-		end
+		inventory:set_stack("main", arrow_index, new_stack)
 	end
 
 	return true
@@ -203,8 +197,9 @@ function throwing.arrow_step(self, dtime)
 		if self.toolranks then
 			local inventory = player:get_inventory()
 			-- Check that the player did not move the bow
-			if inventory:get_stack("main", self.toolranks.index):get_name() == self.toolranks.itemstack:get_name() then
-				local new_itemstack = toolranks.new_afteruse(self.toolranks.itemstack, player, nil, {wear = self.toolranks.wear})
+			local current_stack = inventory:get_stack("main", self.toolranks.index)
+			if current_stack:get_name() == self.toolranks.name then
+				local new_itemstack = toolranks.new_afteruse(current_stack, player, nil, {wear = self.toolranks.wear})
 				inventory:set_stack("main", self.toolranks.index, new_itemstack)
 			end
 		end
@@ -401,12 +396,20 @@ function throwing.register_bow(name, def)
 		minetest.after(def.delay or 0, function()
 			-- Re-check that the arrow can be thrown. Overwrite the new_stack
 			local old_new_stack = new_stack
-			res, new_stack = def.allow_shot(user, user:get_inventory():get_stack("main", arrow_index), arrow_index, true)
+
+			local arrow_stack = user:get_inventory():get_stack("main", arrow_index)
+
+			res, new_stack = def.allow_shot(user, arrow_stack, arrow_index, true)
+			if not res then
+				return
+			end
+
 			if not new_stack then
 				new_stack = old_new_stack
 			end
-			if not res then
-				return
+			if not new_stack then
+				arrow_stack:take_item()
+				new_stack = arrow_stack
 			end
 
 			-- Shoot arrow
@@ -414,7 +417,7 @@ function throwing.register_bow(name, def)
 			local toolranks_data
 			if enable_toolranks then
 				toolranks_data = {
-					itemstack = itemstack,
+					name = itemstack:get_name(),
 					index = bow_index,
 					wear = uses
 				}
@@ -428,7 +431,7 @@ function throwing.register_bow(name, def)
 
 			if def.throw_itself then
 				-- This is a bug. If we return ItemStack(nil), the player punches the entity,
-				-- and if the entity if a __builtin:item, it gets back to his inventory.
+				-- and if the entity is a __builtin:item, it gets back to his inventory.
 				minetest.after(0.1, function()
 					user:get_inventory():remove_item("main", itemstack)
 				end)

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

Full worker log Full build log