Allow players to accelerate a minecart with a boat

In Minecraft you can put a boat in a minecart and steer the minecart
from the boat, which is quite useful to move mobs around – minecarts
have one seat, boats have two.
This commit is contained in:
Nils Dagsson Moskopp 2021-08-01 19:32:08 +02:00
parent cf3c335c37
commit 93b19d1588
Signed by untrusted user who does not match committer: erle
GPG Key ID: A3BC671C35191080
1 changed files with 20 additions and 0 deletions

View File

@ -269,6 +269,25 @@ function boat.on_step(self, dtime, moveresult)
self.object:set_animation({x=0, y=40}, paddling_speed, 0, true)
self._animation = 1
end
-- If boat is in a minecart, punch that cart.
--
-- Why? In Minecraft you can put a boat in a
-- minecart and steer the cart from the boat,
-- which is quite useful to move mobs around.
-- (Minecarts have one seat, boats have two.)
--
-- No, this is not a bug. Mojang has known it
-- for years and they never fixed that “bug”.
local parent = self.object:get_attach()
if parent then
local parent_name =
parent:get_luaentity().name
if parent_name == "mcl_minecarts:minecart" then
-- The driver must punch so
-- the steering works here.
parent:punch(self._driver, 1, {})
end
end
elseif ctrl.down then
-- Backwards
self._v = self._v - 0.1 * v_factor
@ -278,6 +297,7 @@ function boat.on_step(self, dtime, moveresult)
self.object:set_animation({x=0, y=40}, -paddling_speed, 0, true)
self._animation = -1
end
-- TODO: If boat is in a minecart, slow cart.
else
-- Stop paddling animation if no control pressed
if self._animation ~= 0 then