diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index 4e588855f..1c2df41f3 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 diff --git a/mods/ENTITIES/mobs_mc/slime+magma_cube.lua b/mods/ENTITIES/mobs_mc/slime+magma_cube.lua index 7c21fb812..fd1f92bb4 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 diff --git a/tools/remove_end.py b/tools/remove_end.py new file mode 100644 index 000000000..3b73e5575 --- /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")