From c5e1734c1c8796a8dd857ef5bd7025eae8e42624 Mon Sep 17 00:00:00 2001 From: Saku Laesvuori Date: Sun, 4 Apr 2021 23:24:28 +0300 Subject: [PATCH 1/3] Make horse taming more similar to minecraft (#1249) In minecraft horses are tamed by trying to ride them and they can also be fed to speed up taming. This commit implements both of those features and disables the old and broken taming system for horses. --- mods/ENTITIES/mobs_mc/horse.lua | 74 +++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index 4e588855f4..1c2df41f35 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -157,8 +157,29 @@ local horse = { self._regentimer = 0 end - -- if driver present allow control of horse - if self.driver then + -- Some weird human is riding. Buck them off? + if self.driver and not self.tamed and self.buck_off_time <= 0 then + if math.random() < 0.2 then + mobs.detach(self.driver, {x = 1, y = 0, z = 1}) + -- TODO bucking animation + else + -- Nah, can't be bothered. Think about it again in one second + self.buck_off_time = 20 + end + end + + -- Tick the timer for trying to buck the player off + if self.buck_off_time then + if self.driver then + self.buck_off_time = self.buck_off_time - 1 + else + -- Player isn't riding anymore so no need to count + self.buck_off_time = nil + end + end + + -- if driver present and horse has a saddle allow control of horse + if self.driver and self._saddle then mobs.drive(self, "walk", "stand", false, dtime) @@ -191,6 +212,50 @@ local horse = { local item = clicker:get_wielded_item() local iname = item:get_name() local heal = 0 + + -- Taming + self.temper = self.temper or (math.random(1,100)) + + if not self.tamed then + local temper_increase = 0 + + -- Feeding, intentionally not using mobs:feed_tame because horse taming is + -- different and more complicated + if (iname == mobs_mc.items.sugar) then + temper_increase = 3 + elseif (iname == mobs_mc.items.wheat) then + temper_increase = 3 + elseif (iname == mobs_mc.items.apple) then + temper_increase = 3 + elseif (iname == mobs_mc.items.golden_carrot) then + temper_increase = 5 + elseif (iname == mobs_mc.items.golden_apple) then + temper_increase = 10 + + -- Trying to ride + elseif not self.driver then + self.object:set_properties({stepheight = 1.1}) + mobs.attach(self, clicker) + self.buck_off_time = 40 -- TODO how long does it take in minecraft? + if self.temper > 100 then + self.tamed = true -- NOTE taming can only be finished by riding the horse + if not self.owner or self.owner == "" then + self.owner = clicker:get_player_name() + end + end + temper_increase = 5 + + -- Clicking on the horse while riding ==> unmount + elseif self.driver and self.driver == clicker then + mobs.detach(clicker, {x = 1, y = 0, z = 1}) + end + + -- If nothing happened temper_increase = 0 and addition does nothing + self.temper = self.temper + temper_increase + + return + end + if can_breed(self.name) then -- Breed horse with golden apple or golden carrot if (iname == mobs_mc.items.golden_apple) then @@ -202,7 +267,8 @@ local horse = { return end end - -- Feed/tame with anything else + -- Feed with anything else + -- TODO heal amounts don't work if (iname == mobs_mc.items.sugar) then heal = 1 elseif (iname == mobs_mc.items.wheat) then @@ -212,7 +278,7 @@ local horse = { elseif (iname == mobs_mc.items.hay_bale) then heal = 20 end - if heal > 0 and mobs:feed_tame(self, clicker, heal, false, true) then + if heal > 0 and mobs:feed_tame(self, clicker, heal, false, false) then return end From 8bb8a0e3b29d2779d8c811a8a549608941fde345 Mon Sep 17 00:00:00 2001 From: Tianyang Zhang Date: Sun, 4 Apr 2021 15:40:10 -0700 Subject: [PATCH 2/3] Fix large and small slimes and magma cubes not dropping xp and loot --- mods/ENTITIES/mobs_mc/slime+magma_cube.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 7c21fb8124..fd1f92bb49 100644 --- a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua +++ b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua @@ -51,7 +51,6 @@ local spawn_children_on_die = function(child_mob, children_count, spawn_distance end end, children, self.attack) end - return true end end From 5fc3bb11ef9f8ea7d3198ba7a776f5b742b196f8 Mon Sep 17 00:00:00 2001 From: kay27 Date: Mon, 5 Apr 2021 04:54:58 +0400 Subject: [PATCH 3/3] [tools] Add simple python script to entirely reset End dimension generated before and get fresh one, improved (but please stop server & backup world before) --- tools/remove_end.py | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tools/remove_end.py diff --git a/tools/remove_end.py b/tools/remove_end.py new file mode 100644 index 0000000000..3b73e55753 --- /dev/null +++ b/tools/remove_end.py @@ -0,0 +1,46 @@ +world_name = "world" +path_to_map_sqlite = "../../../worlds/" + world_name + "/map.sqlite" + +import sqlite3, sys + +try: + conn = sqlite3.connect(path_to_map_sqlite) +except Error as e: + print(e) + sys.exit() + +def unsignedToSigned(i, max_positive): + if i < max_positive: + return i + else: + return i - 2*max_positive + +cursor = conn.cursor() +cursor.execute("SELECT pos FROM blocks") +poses = cursor.fetchall() +end_blocks = [] +for i0 in (poses): + i = int(i0[0]) + blockpos = i + x = unsignedToSigned(i % 4096, 2048) + i = int((i - x) / 4096) + y = unsignedToSigned(i % 4096, 2048) + i = int((i - y) / 4096) + z = unsignedToSigned(i % 4096, 2048) + + node_pos_y = y * 16 + if node_pos_y > -28811 and node_pos_y + 15 < -67: + end_blocks.append(blockpos) + +if len(end_blocks) < 1: + print ("End blocks not found") + sys.exit() + +counter = 0 +for blockpos in end_blocks: + print("Deleting ", blockpos) + cursor.execute("DELETE FROM blocks WHERE pos=" + str(blockpos)) + counter += 1 +conn.commit() + +print(counter, " block(s) deleted")