1
0
Fork 0

Merge branch 'mineclone5' into netherite

This commit is contained in:
Lizzy Fleckenstein 2021-04-23 13:43:27 +02:00
commit 99ee5f05d3
117 changed files with 6388 additions and 3981 deletions

View File

@ -212,7 +212,7 @@ local function trace_explode(pos, strength, raydirs, radius, info, puncher)
npos_x - emin_x + 1
local cid = data[idx]
local br = node_blastres[cid]
local br = node_blastres[cid] or INDESTRUCT_BLASTRES
if br < INDESTRUCT_BLASTRES and br > max_blast_resistance then
br = max_blast_resistance
end

View File

@ -124,7 +124,6 @@ local strider = {
if wielditem:get_name() ~= controlitem then
if mobs:feed_tame(self, clicker, 1, true, true) then return end
end
if mobs:protect(self, clicker) then return end
if self.child then
return
@ -190,9 +189,6 @@ local strider = {
inv:set_stack("main",self.driver:get_wield_index(), wielditem)
end
return
elseif not self.driver and clicker:get_wielded_item():get_name() ~= "" then
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
end
end,
}

View File

@ -502,20 +502,6 @@ and damages any entity caught inside the blast radius. Protection will limit
node destruction but not entity damage.
mobs:capture_mob
----------------
mobs:capture_mob(...)
Does nothing and returns false.
This function is provided for compability with Mobs Redo for an attempt to
capture a mob.
Mobs cannot be captured in MineClone 2.
In Mobs Redo, this is generally called inside the on_rightclick section of the mob
api code, it provides a chance of capturing the mob. See Mobs Redo documentation
of parameters.
Feeding and Taming/Breeding
---------------------------
@ -535,19 +521,6 @@ Will return true when mob is fed with item it likes.
them up
Protecting Mobs
---------------
mobs:protect(self, clicker)
This function can be used to right-click any tamed mob with mobs:protector item,
this will protect the mob from harm inside of a protected area from other
players. Will return true when mob right-clicked with mobs:protector item.
'self' mob information
'clicker' player information
Riding Mobs
-----------
@ -781,8 +754,5 @@ mobs:register_mob("mob_horse:horse", {
inv:remove_item("main", "mobs:saddle")
end
end
-- used to capture horse with magic lasso
mobs:capture_mob(self, clicker, 0, 0, 80, false, nil)
end
})

View File

@ -0,0 +1,690 @@
-- API for Mobs Redo: MineClone 2 Delux 2.0 DRM Free Early Access Super Extreme Edition
-- mobs library
mobs = {}
-- lua locals - can grab from this to easily plop them into the api lua files
--localize minetest functions
local minetest_settings = minetest.settings
local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
local minetest_get_modpath = minetest.get_modpath
local minetest_registered_nodes = minetest.registered_nodes
local minetest_get_node = minetest.get_node
local minetest_get_item_group = minetest.get_item_group
local minetest_registered_entities = minetest.registered_entities
local minetest_line_of_sight = minetest.line_of_sight
local minetest_after = minetest.after
local minetest_sound_play = minetest.sound_play
local minetest_add_particlespawner = minetest.add_particlespawner
local minetest_registered_items = minetest.registered_items
local minetest_set_node = minetest.set_node
local minetest_add_item = minetest.add_item
local minetest_get_craft_result = minetest.get_craft_result
local minetest_find_path = minetest.find_path
local minetest_is_protected = minetest.is_protected
local minetest_is_creative_enabled = minetest.is_creative_enabled
local minetest_find_node_near = minetest.find_node_near
local minetest_find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air
local minetest_raycast = minetest.raycast
local minetest_get_us_time = minetest.get_us_time
local minetest_add_entity = minetest.add_entity
local minetest_get_natural_light = minetest.get_natural_light
local minetest_get_node_or_nil = minetest.get_node_or_nil
-- localize math functions
local math_pi = math.pi
local math_sin = math.sin
local math_cos = math.cos
local math_abs = math.abs
local math_min = math.min
local math_max = math.max
local math_atan = math.atan
local math_random = math.random
local math_floor = math.floor
-- localize vector functions
local vector_new = vector.new
local vector_length = vector.length
local vector_direction = vector.direction
local vector_normalize = vector.normalize
local vector_multiply = vector.multiply
-- mob constants
local MAX_MOB_NAME_LENGTH = 30
local BREED_TIME = 30
local BREED_TIME_AGAIN = 300
local CHILD_GROW_TIME = 60*20
local DEATH_DELAY = 0.5
local DEFAULT_FALL_SPEED = -10
local FLOP_HEIGHT = 5.0
local FLOP_HOR_SPEED = 1.5
local GRAVITY = minetest_settings:get("movement_gravity")-- + 9.81
local MOB_CAP = {}
MOB_CAP.hostile = 70
MOB_CAP.passive = 10
MOB_CAP.ambient = 15
MOB_CAP.water = 15
-- Load main settings
local damage_enabled = minetest_settings:get_bool("enable_damage")
local disable_blood = minetest_settings:get_bool("mobs_disable_blood")
local mobs_drop_items = minetest_settings:get_bool("mobs_drop_items") ~= false
local mobs_griefing = minetest_settings:get_bool("mobs_griefing") ~= false
local spawn_protected = minetest_settings:get_bool("mobs_spawn_protected") ~= false
local remove_far = true
local difficulty = tonumber(minetest_settings:get("mob_difficulty")) or 1.0
local show_health = false
local max_per_block = tonumber(minetest_settings:get("max_objects_per_block") or 64)
local mobs_spawn_chance = tonumber(minetest_settings:get("mobs_spawn_chance") or 2.5)
-- pathfinding settings
local enable_pathfinding = true
local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching
local stuck_path_timeout = 10 -- how long will mob follow path before giving up
-- default nodes
local node_ice = "mcl_core:ice"
local node_snowblock = "mcl_core:snowblock"
local node_snow = "mcl_core:snow"
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
local mod_weather = minetest_get_modpath("mcl_weather") ~= nil
local mod_explosions = minetest_get_modpath("mcl_explosions") ~= nil
local mod_mobspawners = minetest_get_modpath("mcl_mobspawners") ~= nil
local mod_hunger = minetest_get_modpath("mcl_hunger") ~= nil
local mod_worlds = minetest_get_modpath("mcl_worlds") ~= nil
local mod_armor = minetest_get_modpath("mcl_armor") ~= nil
local mod_experience = minetest_get_modpath("mcl_experience") ~= nil
-- random locals I found
local los_switcher = false
local height_switcher = false
-- Get translator
local S = minetest.get_translator("mcl_mobs")
-- CMI support check
local use_cmi = minetest.global_exists("cmi")
-- Invisibility mod check
mobs.invis = {}
if minetest.global_exists("invisibility") then
mobs.invis = invisibility
end
-- creative check
function mobs.is_creative(name)
return minetest_is_creative_enabled(name)
end
local atan = function(x)
if not x or x ~= x then
return 0
else
return math_atan(x)
end
end
-- Shows helpful debug info above each mob
local mobs_debug = minetest_settings:get_bool("mobs_debug", false)
-- Peaceful mode message so players will know there are no monsters
if minetest_settings:get_bool("only_peaceful_mobs", false) then
minetest.register_on_joinplayer(function(player)
minetest.chat_send_player(player:get_player_name(),
S("Peaceful mode active! No monsters will spawn."))
end)
end
local api_path = minetest.get_modpath(minetest.get_current_modname()).."/api/mob_functions/"
--ignite all parts of the api
dofile(api_path .. "ai.lua")
dofile(api_path .. "animation.lua")
dofile(api_path .. "collision.lua")
dofile(api_path .. "environment.lua")
dofile(api_path .. "interaction.lua")
dofile(api_path .. "movement.lua")
dofile(api_path .. "set_up.lua")
dofile(api_path .. "attack_type_instructions.lua")
dofile(api_path .. "sound_handling.lua")
dofile(api_path .. "death_logic.lua")
dofile(api_path .. "mob_effects.lua")
mobs.spawning_mobs = {}
-- register mob entity
function mobs:register_mob(name, def)
local collisionbox = def.collisionbox or {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}
-- Workaround for <https://github.com/minetest/minetest/issues/5966>:
-- Increase upper Y limit to avoid mobs glitching through solid nodes.
-- FIXME: Remove workaround if it's no longer needed.
if collisionbox[5] < 0.79 then
collisionbox[5] = 0.79
end
mobs.spawning_mobs[name] = true
local can_despawn
if def.can_despawn ~= nil then
can_despawn = def.can_despawn
elseif def.spawn_class == "passive" then
can_despawn = false
else
can_despawn = true
end
local function scale_difficulty(value, default, min, special)
if (not value) or (value == default) or (value == special) then
return default
else
return math_max(min, value * difficulty)
end
end
minetest.register_entity(name, {
use_texture_alpha = def.use_texture_alpha,
stepheight = def.stepheight or 0.6,
name = name,
type = def.type,
attack_type = def.attack_type,
fly = def.fly,
fly_in = def.fly_in or {"air", "__airlike"},
owner = def.owner or "",
order = def.order or "",
on_die = def.on_die,
spawn_small_alternative = def.spawn_small_alternative,
do_custom = def.do_custom,
jump_height = def.jump_height or 4, -- was 6
rotate = def.rotate or 0, -- 0=front, 90=side, 180=back, 270=side2
lifetimer = def.lifetimer or 57.73,
hp_min = scale_difficulty(def.hp_min, 5, 1),
hp_max = scale_difficulty(def.hp_max, 10, 1),
xp_min = def.xp_min or 0,
xp_max = def.xp_max or 3,
xp_timestamp = 0,
breath_max = def.breath_max or 15,
breathes_in_water = def.breathes_in_water or false,
physical = true,
collisionbox = collisionbox,
collide_with_objects = def.collide_with_objects or false,
selectionbox = def.selectionbox or def.collisionbox,
visual = def.visual,
visual_size = def.visual_size or {x = 1, y = 1},
mesh = def.mesh,
makes_footstep_sound = def.makes_footstep_sound or false,
view_range = def.view_range or 16,
walk_velocity = def.walk_velocity or 1,
run_velocity = def.run_velocity or 2,
damage = scale_difficulty(def.damage, 0, 0),
light_damage = def.light_damage or 0,
sunlight_damage = def.sunlight_damage or 0,
water_damage = def.water_damage or 0,
lava_damage = def.lava_damage or 8,
fire_damage = def.fire_damage or 1,
suffocation = def.suffocation or true,
fall_damage = def.fall_damage or 1,
fall_speed = def.fall_speed or DEFAULT_FALL_SPEED, -- must be lower than -2
drops = def.drops or {},
armor = def.armor or 100,
on_rightclick = mobs.create_mob_on_rightclick(def.on_rightclick),
arrow = def.arrow,
shoot_interval = def.shoot_interval,
sounds = def.sounds or {},
animation = def.animation,
follow = def.follow,
jump = def.jump ~= false,
walk_chance = def.walk_chance or 50,
attacks_monsters = def.attacks_monsters or false,
group_attack = def.group_attack or false,
passive = def.passive or false,
knock_back = def.knock_back ~= false,
shoot_offset = def.shoot_offset or 0,
floats = def.floats or 1, -- floats in water by default
floats_on_lava = def.floats_on_lava or 0,
replace_rate = def.replace_rate,
replace_what = def.replace_what,
replace_with = def.replace_with,
replace_offset = def.replace_offset or 0,
on_replace = def.on_replace,
timer = 0,
state_timer = 0,
env_damage_timer = 0,
tamed = false,
pause_timer = 0,
horny = false,
hornytimer = 0,
gotten = false,
health = 0,
reach = def.reach or 3,
htimer = 0,
texture_list = def.textures,
child_texture = def.child_texture,
docile_by_day = def.docile_by_day or false,
time_of_day = 0.5,
fear_height = def.fear_height or 0,
runaway = def.runaway,
runaway_timer = 0,
pathfinding = def.pathfinding,
immune_to = def.immune_to or {},
explosion_radius = def.explosion_radius, -- LEGACY
explosion_damage_radius = def.explosion_damage_radius, -- LEGACY
explosiontimer_reset_radius = def.explosiontimer_reset_radius,
explosion_timer = def.explosion_timer or 3,
allow_fuse_reset = def.allow_fuse_reset ~= false,
stop_to_explode = def.stop_to_explode ~= false,
custom_attack = def.custom_attack,
double_melee_attack = def.double_melee_attack,
dogshoot_switch = def.dogshoot_switch,
dogshoot_count = 0,
dogshoot_count_max = def.dogshoot_count_max or 5,
dogshoot_count2_max = def.dogshoot_count2_max or (def.dogshoot_count_max or 5),
attack_animals = def.attack_animals or false,
specific_attack = def.specific_attack,
runaway_from = def.runaway_from,
owner_loyal = def.owner_loyal,
facing_fence = false,
_cmi_is_mob = true,
pushable = def.pushable or true,
--j4i stuff
yaw = 0,
automatic_face_movement_dir = def.rotate or 0, -- 0=front, 90=side, 180=back, 270=side2
automatic_face_movement_max_rotation_per_sec = 360, --degrees
backface_culling = true,
walk_timer = 0,
stand_timer = 0,
current_animation = "",
gravity = GRAVITY,
swim = def.swim,
swim_in = def.swim_in or {mobs_mc.items.water_source, "mcl_core:water_flowing", mobs_mc.items.river_water_source},
pitch_switch = "static",
jump_only = def.jump_only,
hostile = def.hostile,
neutral = def.neutral,
attacking = nil,
visual_size_origin = def.visual_size or {x = 1, y = 1, z = 1},
punch_timer_cooloff = def.punch_timer_cooloff or 0.5,
projectile_cooldown = def.projectile_cooldown or 2,
death_animation_timer = 0,
--end j4i stuff
-- MCL2 extensions
teleport = teleport,
do_teleport = def.do_teleport,
spawn_class = def.spawn_class,
ignores_nametag = def.ignores_nametag or false,
rain_damage = def.rain_damage or 0,
glow = def.glow,
can_despawn = can_despawn,
child = def.child or false,
texture_mods = {},
shoot_arrow = def.shoot_arrow,
sounds_child = def.sounds_child,
explosion_strength = def.explosion_strength,
suffocation_timer = 0,
follow_velocity = def.follow_velocity or 2.4,
instant_death = def.instant_death or false,
fire_resistant = def.fire_resistant or false,
fire_damage_resistant = def.fire_damage_resistant or false,
ignited_by_sunlight = def.ignited_by_sunlight or false,
eye_height = def.eye_height or 1.5,
defuse_reach = def.defuse_reach or 4,
hostile_cooldown = def.hostile_cooldown or 15,
tilt_fly = def.tilt_fly,
tilt_swim = def.tilt_swim,
-- End of MCL2 extensions
on_spawn = def.on_spawn,
--on_blast = def.on_blast or do_tnt,
on_step = mobs.mob_step,
--do_punch = def.do_punch,
on_punch = mobs.mob_punch,
--on_breed = def.on_breed,
--on_grown = def.on_grown,
--on_detach_child = mob_detach_child,
on_activate = function(self, staticdata, dtime)
self.object:set_acceleration(vector_new(0,-GRAVITY, 0))
return mobs.mob_activate(self, staticdata, def, dtime)
end,
get_staticdata = function(self)
return mobs.mob_staticdata(self)
end,
--harmed_by_heal = def.harmed_by_heal,
})
if minetest_get_modpath("doc_identifier") ~= nil then
doc.sub.identifier.register_object(name, "basics", "mobs")
end
end -- END mobs:register_mob function
-- register arrow for shoot attack
function mobs:register_arrow(name, def)
-- errorcheck
if not name or not def then
print("failed to register arrow entity")
return
end
minetest.register_entity(name.."_entity", {
physical = false,
visual = def.visual,
visual_size = def.visual_size,
textures = def.textures,
velocity = def.velocity,
hit_player = def.hit_player,
hit_node = def.hit_node,
hit_mob = def.hit_mob,
hit_object = def.hit_object,
drop = def.drop or false, -- drops arrow as registered item when true
collisionbox = {0, 0, 0, 0, 0, 0}, -- remove box around arrows
timer = 0,
switch = 0,
owner_id = def.owner_id,
rotate = def.rotate,
speed = def.speed or nil,
on_step = function(self)
local vel = self.object:get_velocity()
local pos = self.object:get_pos()
if self.timer > 150
or not mobs.within_limits(pos, 0) then
mcl_burning.extinguish(self.object)
print("removing 1")
self.object:remove();
return
end
-- does arrow have a tail (fireball)
if def.tail
and def.tail == 1
and def.tail_texture then
minetest.add_particle({
pos = pos,
velocity = {x = 0, y = 0, z = 0},
acceleration = {x = 0, y = 0, z = 0},
expirationtime = def.expire or 0.25,
collisiondetection = false,
texture = def.tail_texture,
size = def.tail_size or 5,
glow = def.glow or 0,
})
end
if self.hit_node then
local node = minetest_get_node(pos).name
if minetest_registered_nodes[node].walkable then
self.hit_node(self, pos, node)
if self.drop == true then
pos.y = pos.y + 1
self.lastpos = (self.lastpos or pos)
minetest_add_item(self.lastpos, self.object:get_luaentity().name)
end
self.object:remove();
return
end
end
if self.hit_player or self.hit_mob or self.hit_object then
for _,player in pairs(minetest_get_objects_inside_radius(pos, 1.5)) do
if self.hit_player
and player:is_player() then
if self.hit_player then
self.hit_player(self, player)
else
mobs.arrow_hit(self, player)
end
self.object:remove();
return
end
--[[
local entity = player:get_luaentity()
if entity
and self.hit_mob
and entity._cmi_is_mob == true
and tostring(player) ~= self.owner_id
and entity.name ~= self.object:get_luaentity().name
and (self._shooter and entity.name ~= self._shooter:get_luaentity().name) then
--self.hit_mob(self, player)
self.object:remove();
return
end
]]--
--[[
if entity
and self.hit_object
and (not entity._cmi_is_mob)
and tostring(player) ~= self.owner_id
and entity.name ~= self.object:get_luaentity().name
and (self._shooter and entity.name ~= self._shooter:get_luaentity().name) then
--self.hit_object(self, player)
self.object:remove();
return
end
]]--
end
end
self.lastpos = pos
end
})
end
-- Register spawn eggs
-- Note: This also introduces the “spawn_egg” group:
-- * spawn_egg=1: Spawn egg (generic mob, no metadata)
-- * spawn_egg=2: Spawn egg (captured/tamed mob, metadata)
function mobs:register_egg(mob, desc, background, addegg, no_creative)
local grp = {spawn_egg = 1}
-- do NOT add this egg to creative inventory (e.g. dungeon master)
if no_creative == true then
grp.not_in_creative_inventory = 1
end
local invimg = background
if addegg == 1 then
invimg = "mobs_chicken_egg.png^(" .. invimg ..
"^[mask:mobs_chicken_egg_overlay.png)"
end
-- register old stackable mob egg
minetest.register_craftitem(mob, {
description = desc,
inventory_image = invimg,
groups = grp,
_doc_items_longdesc = S("This allows you to place a single mob."),
_doc_items_usagehelp = S("Just place it where you want the mob to appear. Animals will spawn tamed, unless you hold down the sneak key while placing. If you place this on a mob spawner, you change the mob it spawns."),
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
-- am I clicking on something with existing on_rightclick function?
local under = minetest_get_node(pointed_thing.under)
local def = minetest_registered_nodes[under.name]
if def and def.on_rightclick then
return def.on_rightclick(pointed_thing.under, under, placer, itemstack)
end
if pos
--and within_limits(pos, 0)
and not minetest_is_protected(pos, placer:get_player_name()) then
local name = placer:get_player_name()
local privs = minetest.get_player_privs(name)
if mod_mobspawners and under.name == "mcl_mobspawners:spawner" then
if minetest_is_protected(pointed_thing.under, name) then
minetest.record_protection_violation(pointed_thing.under, name)
return itemstack
end
if not privs.maphack then
minetest.chat_send_player(name, S("You need the “maphack” privilege to change the mob spawner."))
return itemstack
end
mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name())
if not mobs.is_creative(name) then
itemstack:take_item()
end
return itemstack
end
if not minetest_registered_entities[mob] then
return itemstack
end
if minetest_settings:get_bool("only_peaceful_mobs", false)
and minetest_registered_entities[mob].type == "monster" then
minetest.chat_send_player(name, S("Only peaceful mobs allowed!"))
return itemstack
end
pos.y = pos.y - 0.5
local mob = minetest_add_entity(pos, mob)
minetest.log("action", "Mob spawned: "..name.." at "..minetest.pos_to_string(pos))
local ent = mob:get_luaentity()
-- don't set owner if monster or sneak pressed
--[[
if ent.type ~= "monster"
and not placer:get_player_control().sneak then
ent.owner = placer:get_player_name()
ent.tamed = true
end
]]--
-- set nametag
local nametag = itemstack:get_meta():get_string("name")
if nametag ~= "" then
if string.len(nametag) > MAX_MOB_NAME_LENGTH then
nametag = string.sub(nametag, 1, MAX_MOB_NAME_LENGTH)
end
ent.nametag = nametag
update_tag(ent)
end
-- if not in creative then take item
if not mobs.is_creative(placer:get_player_name()) then
itemstack:take_item()
end
end
return itemstack
end,
})
end

View File

@ -0,0 +1,716 @@
local math_random = math.random
local math_pi = math.pi
local vector_multiply = vector.multiply
local vector_add = vector.add
local vector_new = vector.new
local minetest_yaw_to_dir = minetest.yaw_to_dir
local minetest_get_item_group = minetest.get_item_group
local minetest_get_node = minetest.get_node
local minetest_line_of_sight = minetest.line_of_sight
local DOUBLE_PI = math.pi * 2
local THIRTY_SECONDTH_PI = DOUBLE_PI * 0.03125
--a simple helper function which is too small to move into movement.lua
local quick_rotate = function(self,dtime)
self.yaw = self.yaw + THIRTY_SECONDTH_PI
if self.yaw > DOUBLE_PI then
self.yaw = self.yaw - DOUBLE_PI
end
end
--[[
_ _
| | | |
| | __ _ _ __ __| |
| | / _` | '_ \ / _` |
| |___| (_| | | | | (_| |
\_____/\__,_|_| |_|\__,_|
]]--
--this is basically reverse jump_check
local cliff_check = function(self,dtime)
--mobs will flip out if they are falling without this
if self.object:get_velocity().y ~= 0 then
return false
end
local pos = self.object:get_pos()
local dir = minetest_yaw_to_dir(self.yaw)
local collisionbox = self.object:get_properties().collisionbox
local radius = collisionbox[4] + 0.5
dir = vector_multiply(dir,radius)
local free_fall, blocker = minetest_line_of_sight(
{x = pos.x + dir.x, y = pos.y, z = pos.z + dir.z},
{x = pos.x + dir.x, y = pos.y - self.fear_height, z = pos.z + dir.z})
return free_fall
end
-- state switching logic (stand, walk, run, attacks)
local land_state_list_wandering = {"stand", "walk"}
local land_state_switch = function(self, dtime)
if self.hostile and self.attacking then
self.state = "attack"
return
end
--do math after sure not attacking
self.state_timer = self.state_timer - dtime
if self.state_timer <= 0 then
self.state_timer = math.random(4,10) + math.random()
self.state = land_state_list_wandering[math.random(1,#land_state_list_wandering)]
end
end
-- states are executed here
local land_state_execution = function(self,dtime)
local pos = self.object:get_pos()
local collisionbox = self.object:get_properties().collisionbox
--get the center of the mob
pos.y = pos.y + (collisionbox[2] + collisionbox[5] / 2)
local current_node = minetest_get_node(pos).name
local float_now = false
--recheck if in water or lava
if minetest_get_item_group(current_node, "water") ~= 0 or minetest_get_item_group(current_node, "lava") ~= 0 then
float_now = true
end
if self.state == "stand" then
--do animation
mobs.set_mob_animation(self, "stand")
--set the velocity of the mob
mobs.set_velocity(self,0)
--animation fixes for explosive mobs
if self.attack_type == "explode" then
mobs.reverse_explosion_animation(self,dtime)
end
elseif self.state == "walk" then
self.walk_timer = self.walk_timer - dtime
--reset the walk timer
if self.walk_timer <= 0 then
--re-randomize the walk timer
self.walk_timer = math.random(1,6) + math.random()
--set the mob into a random direction
self.yaw = (math_random() * (math.pi * 2))
end
--do animation
mobs.set_mob_animation(self, "walk")
--enable rotation locking
mobs.movement_rotation_lock(self)
--check for nodes to jump over
local node_in_front_of = mobs.jump_check(self)
if node_in_front_of == 1 then
mobs.jump(self)
--turn if on the edge of cliff
--(this is written like this because unlike
--jump_check which simply tells the mob to jump
--this requires a mob to turn, removing the
--ease of a full implementation for it in a single
--function)
elseif node_in_front_of == 2 or (self.fear_height ~= 0 and cliff_check(self,dtime)) then
--turn 45 degrees if so
quick_rotate(self,dtime)
--stop the mob so it doesn't fall off
mobs.set_velocity(self,0)
end
--only move forward if path is clear
if node_in_front_of == 0 or node_in_front_of == 1 then
--set the velocity of the mob
mobs.set_velocity(self,self.walk_velocity)
end
--animation fixes for explosive mobs
if self.attack_type == "explode" then
mobs.reverse_explosion_animation(self,dtime)
end
elseif self.state == "run" then
print("run")
elseif self.state == "attack" then
--execute mob attack type
if self.attack_type == "explode" then
mobs.explode_attack_walk(self, dtime)
elseif self.attack_type == "punch" then
mobs.punch_attack_walk(self,dtime)
elseif self.attack_type == "projectile" then
mobs.projectile_attack_walk(self,dtime)
end
end
if float_now then
mobs.float(self)
end
end
--[[
_____ _
/ ___| (_)
\ `--.__ ___ _ __ ___
`--. \ \ /\ / / | '_ ` _ \
/\__/ /\ V V /| | | | | | |
\____/ \_/\_/ |_|_| |_| |_|
]]--
-- state switching logic (stand, walk, run, attacks)
local swim_state_list_wandering = {"stand", "swim"}
local swim_state_switch = function(self, dtime)
self.state_timer = self.state_timer - dtime
if self.state_timer <= 0 then
self.state_timer = math.random(4,10) + math.random()
self.state = swim_state_list_wandering[math.random(1,#swim_state_list_wandering)]
end
end
--check if a mob needs to turn while swimming
local swim_turn_check = function(self,dtime)
local pos = self.object:get_pos()
pos.y = pos.y + 0.1
local dir = minetest_yaw_to_dir(self.yaw)
local collisionbox = self.object:get_properties().collisionbox
local radius = collisionbox[4] + 0.5
vector_multiply(dir, radius)
local test_dir = vector.add(pos,dir)
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
return(green_flag_1)
end
--this is to swap the built in engine acceleration modifier
local swim_physics_swapper = function(self,inside_swim_node)
--should be swimming, gravity is applied, switch to floating
if inside_swim_node and self.object:get_acceleration().y ~= 0 then
self.object:set_acceleration(vector_new(0,0,0))
--not be swim, gravity isn't applied, switch to falling
elseif not inside_swim_node and self.object:get_acceleration().y == 0 then
self.pitch = 0
self.object:set_acceleration(vector_new(0,-self.gravity,0))
end
end
local random_pitch_multiplier = {-1,1}
-- states are executed here
local swim_state_execution = function(self,dtime)
local pos = self.object:get_pos()
pos.y = pos.y + self.object:get_properties().collisionbox[5]
local current_node = minetest_get_node(pos).name
local inside_swim_node = false
--quick scan everything to see if inside swim node
for _,id in pairs(self.swim_in) do
if id == current_node then
inside_swim_node = true
break
end
end
--turn gravity on or off
swim_physics_swapper(self,inside_swim_node)
--swim properly if inside swim node
if inside_swim_node then
if self.state == "stand" then
--do animation
mobs.set_mob_animation(self, "stand")
mobs.set_swim_velocity(self,0)
if self.tilt_swim then
mobs.set_static_pitch(self)
end
elseif self.state == "swim" then
self.walk_timer = self.walk_timer - dtime
--reset the walk timer
if self.walk_timer <= 0 then
--re-randomize the walk timer
self.walk_timer = math.random(1,6) + math.random()
--set the mob into a random direction
self.yaw = (math_random() * (math.pi * 2))
--create a truly random pitch, since there is no easy access to pitch math that I can find
self.pitch = math_random() * random_pitch_multiplier[math_random(1,2)]
end
--do animation
mobs.set_mob_animation(self, "walk")
--do a quick turn to make mob continuously move
--if in a fish tank or something
if swim_turn_check(self,dtime) then
quick_rotate(self,dtime)
end
mobs.set_swim_velocity(self,self.walk_velocity)
--only enable tilt swimming if enabled
if self.tilt_swim then
mobs.set_dynamic_pitch(self)
end
end
--flop around if not inside swim node
else
--do animation
mobs.set_mob_animation(self, "stand")
mobs.flop(self)
if self.tilt_swim then
mobs.set_static_pitch(self)
end
end
end
--[[
______ _
| ___| |
| |_ | |_ _
| _| | | | | |
| | | | |_| |
\_| |_|\__, |
__/ |
|___/
]]--
-- state switching logic (stand, walk, run, attacks)
local fly_state_list_wandering = {"stand", "fly"}
local fly_state_switch = function(self, dtime)
if self.hostile and self.attacking then
self.state = "attack"
return
end
self.state_timer = self.state_timer - dtime
if self.state_timer <= 0 then
self.state_timer = math.random(4,10) + math.random()
self.state = fly_state_list_wandering[math.random(1,#fly_state_list_wandering)]
end
end
--check if a mob needs to turn while flying
local fly_turn_check = function(self,dtime)
local pos = self.object:get_pos()
pos.y = pos.y + 0.1
local dir = minetest_yaw_to_dir(self.yaw)
local collisionbox = self.object:get_properties().collisionbox
local radius = collisionbox[4] + 0.5
vector_multiply(dir, radius)
local test_dir = vector.add(pos,dir)
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
return(green_flag_1)
end
--this is to swap the built in engine acceleration modifier
local fly_physics_swapper = function(self,inside_fly_node)
--should be flyming, gravity is applied, switch to floating
if inside_fly_node and self.object:get_acceleration().y ~= 0 then
self.object:set_acceleration(vector_new(0,0,0))
--not be fly, gravity isn't applied, switch to falling
elseif not inside_fly_node and self.object:get_acceleration().y == 0 then
self.pitch = 0
self.object:set_acceleration(vector_new(0,-self.gravity,0))
end
end
local random_pitch_multiplier = {-1,1}
-- states are executed here
local fly_state_execution = function(self,dtime)
local pos = self.object:get_pos()
local current_node = minetest_get_node(pos).name
local inside_fly_node = minetest_get_item_group(current_node, "solid") == 0
local float_now = false
--recheck if in water or lava
if minetest_get_item_group(current_node, "water") ~= 0 or minetest_get_item_group(current_node, "lava") ~= 0 then
inside_fly_node = false
float_now = true
end
--turn gravity on or off
fly_physics_swapper(self,inside_fly_node)
--fly properly if inside fly node
if inside_fly_node then
if self.state == "stand" then
--do animation
mobs.set_mob_animation(self, "stand")
mobs.set_fly_velocity(self,0)
if self.tilt_fly then
mobs.set_static_pitch(self)
end
elseif self.state == "fly" then
self.walk_timer = self.walk_timer - dtime
--reset the walk timer
if self.walk_timer <= 0 then
--re-randomize the walk timer
self.walk_timer = math.random(1,6) + math.random()
--set the mob into a random direction
self.yaw = (math_random() * (math.pi * 2))
--create a truly random pitch, since there is no easy access to pitch math that I can find
self.pitch = math_random() * random_pitch_multiplier[math_random(1,2)]
end
--do animation
mobs.set_mob_animation(self, "walk")
--do a quick turn to make mob continuously move
--if in a bird cage or something
if fly_turn_check(self,dtime) then
quick_rotate(self,dtime)
end
if self.tilt_fly then
mobs.set_dynamic_pitch(self)
end
mobs.set_fly_velocity(self,self.walk_velocity)
elseif self.state == "attack" then
--execute mob attack type
--if self.attack_type == "explode" then
--mobs.explode_attack_fly(self, dtime)
--elseif self.attack_type == "punch" then
--mobs.punch_attack_fly(self,dtime)
if self.attack_type == "projectile" then
mobs.projectile_attack_fly(self,dtime)
end
end
else
--make the mob float
if self.floats and float_now then
mobs.set_velocity(self, 0)
mobs.float(self)
if self.tilt_fly then
mobs.set_static_pitch(self)
end
end
end
end
--[[
___
|_ |
| |_ _ _ __ ___ _ __
| | | | | '_ ` _ \| '_ \
/\__/ / |_| | | | | | | |_) |
\____/ \__,_|_| |_| |_| .__/
| |
|_|
]]--
--check if a mob needs to turn while jumping
local jump_turn_check = function(self,dtime)
local pos = self.object:get_pos()
pos.y = pos.y + 0.1
local dir = minetest_yaw_to_dir(self.yaw)
local collisionbox = self.object:get_properties().collisionbox
local radius = collisionbox[4] + 0.5
vector_multiply(dir, radius)
local test_dir = vector.add(pos,dir)
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
return(green_flag_1)
end
-- state switching logic (stand, jump, run, attacks)
local jump_state_list_wandering = {"stand", "jump"}
local jump_state_switch = function(self, dtime)
self.state_timer = self.state_timer - dtime
if self.state_timer <= 0 then
self.state_timer = math.random(4,10) + math.random()
self.state = jump_state_list_wandering[math.random(1,#jump_state_list_wandering)]
end
end
-- states are executed here
local jump_state_execution = function(self,dtime)
local pos = self.object:get_pos()
local collisionbox = self.object:get_properties().collisionbox
--get the center of the mob
pos.y = pos.y + (collisionbox[2] + collisionbox[5] / 2)
local current_node = minetest_get_node(pos).name
local float_now = false
--recheck if in water or lava
if minetest_get_item_group(current_node, "water") ~= 0 or minetest_get_item_group(current_node, "lava") ~= 0 then
float_now = true
end
if self.state == "stand" then
--do animation
mobs.set_mob_animation(self, "stand")
--set the velocity of the mob
mobs.set_velocity(self,0)
elseif self.state == "jump" then
self.walk_timer = self.walk_timer - dtime
--reset the jump timer
if self.walk_timer <= 0 then
--re-randomize the jump timer
self.walk_timer = math.random(1,6) + math.random()
--set the mob into a random direction
self.yaw = (math_random() * (math.pi * 2))
end
--do animation
mobs.set_mob_animation(self, "walk")
--enable rotation locking
mobs.movement_rotation_lock(self)
--jumping mobs are more loosey goosey
if node_in_front_of == 1 then
quick_rotate(self,dtime)
end
--only move forward if path is clear
mobs.jump_move(self,self.walk_velocity)
elseif self.state == "run" then
print("run")
elseif self.state == "attack" then
print("attack")
end
if float_now then
mobs.float(self)
end
end
--[[
___ ___ _ _ _
| \/ | (_) | | (_)
| . . | __ _ _ _ __ | | ___ __ _ _ ___
| |\/| |/ _` | | '_ \ | | / _ \ / _` | |/ __|
| | | | (_| | | | | | | |___| (_) | (_| | | (__
\_| |_/\__,_|_|_| |_| \_____/\___/ \__, |_|\___|
__/ |
|___/
]]--
--the main loop
mobs.mob_step = function(self, dtime)
--do not continue if non-existent
if not self or not self.object or not self.object:get_luaentity() then
self.object:remove()
return false
end
--do death logic (animation, poof, explosion, etc)
if self.health <= 0 then
mobs.death_logic(self, dtime)
--this is here because the mob must continue to move
--while stunned before coming to a complete halt even during
--the death tilt
if self.pause_timer > 0 then
self.pause_timer = self.pause_timer - dtime
--perfectly reset pause_timer
if self.pause_timer < 0 then
self.pause_timer = 0
end
end
return
end
local attacking = nil
--scan for players within eyesight
if self.hostile then
--true for line_of_sight is debug
attacking = mobs.detect_closest_player_within_radius(self,true,self.view_range,self.eye_height)
--go get the closest player
if attacking then
--set initial punch timer
if self.attacking == nil then
if self.attack_type == "punch" then
self.punch_timer = -1
end
end
self.attacking = attacking
--no player in area
else
--reset states when coming out of hostile state
if self.attacking ~= nil then
self.state_timer = -1
end
self.attacking = nil
end
end
--count down hostile cooldown timer when no players in range
if self.neutral and self.hostile and not attacking and self.hostile_cooldown_timer then
self.hostile_cooldown_timer = self.hostile_cooldown_timer - dtime
if self.hostile_cooldown_timer <= 0 then
self.hostile = false
self.hostile_cooldown_timer = 0
end
end
--mob is stunned after being hit
if self.pause_timer > 0 then
self.pause_timer = self.pause_timer - dtime
--don't break eye contact
if self.hostile and self.attacking then
mobs.set_yaw_while_attacking(self)
end
--perfectly reset pause_timer
if self.pause_timer < 0 then
self.pause_timer = 0
end
return -- don't allow collision detection
--do normal ai
else
--jump only (like slimes)
if self.jump_only then
jump_state_switch(self, dtime)
jump_state_execution(self, dtime)
--swimming
elseif self.swim then
swim_state_switch(self, dtime)
swim_state_execution(self, dtime)
--flying
elseif self.fly then
fly_state_switch(self, dtime)
fly_state_execution(self,dtime)
--regular mobs that walk around
else
land_state_switch(self, dtime)
land_state_execution(self,dtime)
end
end
-- can mob be pushed, if so calculate direction -- do this last (overrides everything)
if self.pushable then
mobs.collision(self)
end
self.old_velocity = self.object:get_velocity()
self.old_pos = self.object:get_pos()
end

View File

@ -0,0 +1,202 @@
local math_pi = math.pi
local math_floor = math.floor
local math_random = math.random
local HALF_PI = math_pi/2
local vector_direction = vector.direction
local vector_distance = vector.distance
local vector_new = vector.new
local minetest_dir_to_yaw = minetest.dir_to_yaw
-- set defined animation
mobs.set_mob_animation = function(self, anim, fixed_frame)
if not self.animation or not anim then
return
end
if self.state == "die" and anim ~= "die" and anim ~= "stand" then
return
end
if (not self.animation[anim .. "_start"] or not self.animation[anim .. "_end"]) then
return
end
--animations break if they are constantly set
--so we put this return gate to check if it is
--already at the animation we are trying to implement
if self.current_animation == anim then
return
end
local a_start = self.animation[anim .. "_start"]
local a_end
if fixed_frame then
a_end = a_start
else
a_end = self.animation[anim .. "_end"]
end
self.object:set_animation({
x = a_start,
y = a_end},
self.animation[anim .. "_speed"] or self.animation.speed_normal or 15,
0, self.animation[anim .. "_loop"] ~= false)
self.current_animation = anim
end
mobs.death_effect = function(pos, yaw, collisionbox, rotate)
local min, max
if collisionbox then
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
else
min = { x = -0.5, y = 0, z = -0.5 }
max = { x = 0.5, y = 0.5, z = 0.5 }
end
if rotate then
min = vector.rotate(min, {x=0, y=yaw, z=math_pi/2})
max = vector.rotate(max, {x=0, y=yaw, z=math_pi/2})
min, max = vector.sort(min, max)
min = vector.multiply(min, 0.5)
max = vector.multiply(max, 0.5)
end
minetest_add_particlespawner({
amount = 50,
time = 0.001,
minpos = vector.add(pos, min),
maxpos = vector.add(pos, max),
minvel = vector_new(-5,-5,-5),
maxvel = vector_new(5,5,5),
minexptime = 1.1,
maxexptime = 1.5,
minsize = 1,
maxsize = 2,
collisiondetection = false,
vertical = false,
texture = "mcl_particles_mob_death.png^[colorize:#000000:255",
})
minetest_sound_play("mcl_mobs_mob_poof", {
pos = pos,
gain = 1.0,
max_hear_distance = 8,
}, true)
end
--this allows auto facedir rotation while making it so mobs
--don't look like wet noodles flopping around
mobs.movement_rotation_lock = function(self)
local current_engine_yaw = self.object:get_yaw()
local current_lua_yaw = self.yaw
if current_engine_yaw > math.pi * 2 then
current_engine_yaw = current_engine_yaw - (math.pi * 2)
end
if math.abs(current_engine_yaw - current_lua_yaw) <= 0.05 and self.object:get_properties().automatic_face_movement_dir then
self.object:set_properties{automatic_face_movement_dir = false}
elseif math.abs(current_engine_yaw - current_lua_yaw) > 0.05 and self.object:get_properties().automatic_face_movement_dir == false then
self.object:set_properties{automatic_face_movement_dir = self.rotate}
end
end
--this is used when a mob is chasing a player
mobs.set_yaw_while_attacking = function(self)
if self.object:get_properties().automatic_face_movement_dir then
self.object:set_properties{automatic_face_movement_dir = false}
end
--turn positions into pseudo 2d vectors
local pos1 = self.object:get_pos()
pos1.y = 0
local pos2 = self.attacking:get_pos()
pos2.y = 0
local new_direction = vector_direction(pos1,pos2)
local new_yaw = minetest_dir_to_yaw(new_direction)
self.object:set_yaw(new_yaw)
self.yaw = new_yaw
end
local calculate_pitch = function(self)
local pos = self.object:get_pos()
local pos2 = self.old_pos
if pos == nil or pos2 == nil then
return false
end
return(minetest_dir_to_yaw(vector_new(vector_distance(vector_new(pos.x,0,pos.z),vector_new(pos2.x,0,pos2.z)),0,pos.y - pos2.y)) + HALF_PI)
end
--this is a helper function used to make mobs pitch rotation dynamically flow when flying/swimming
mobs.set_dynamic_pitch = function(self)
local pitch = calculate_pitch(self)
if not pitch then
return
end
local current_rotation = self.object:get_rotation()
current_rotation.x = pitch
self.object:set_rotation(current_rotation)
self.pitch_switch = "dynamic"
end
--this is a helper function used to make mobs pitch rotation reset when flying/swimming
mobs.set_static_pitch = function(self)
if self.pitch_switch == "static" then
return
end
local current_rotation = self.object:get_rotation()
current_rotation.x = 0
self.object:set_rotation(current_rotation)
self.pitch_switch = "static"
end
--this is a helper function for mobs explosion animation
mobs.handle_explosion_animation = function(self)
--secondary catch-all
if not self.explosion_animation then
self.explosion_animation = 0
end
--the timer works from 0 for sense of a 0 based counting
--but this just bumps it up so it's usable in here
local explosion_timer_adjust = self.explosion_animation + 1
local visual_size_modified = table.copy(self.visual_size_origin)
visual_size_modified.x = visual_size_modified.x * (explosion_timer_adjust ^ 3)
visual_size_modified.y = visual_size_modified.y * explosion_timer_adjust
self.object:set_properties({visual_size = visual_size_modified})
end

View File

@ -0,0 +1,303 @@
local vector_direction = vector.direction
local minetest_dir_to_yaw = minetest.dir_to_yaw
local vector_distance = vector.distance
local vector_multiply = vector.multiply
--[[
_ _ _ _
| | | | | | | |
| | | | __ _ _ __ __| | | |
| | | | / _` | '_ \ / _` | | |
|_| | |___| (_| | | | | (_| | |_|
(_) \_____/\__,_|_| |_|\__,_| (_)
]]--
--[[
_____ _ _
| ___| | | | |
| |____ ___ __ | | ___ __| | ___
| __\ \/ / '_ \| |/ _ \ / _` |/ _ \
| |___> <| |_) | | (_) | (_| | __/
\____/_/\_\ .__/|_|\___/ \__,_|\___|
| |
|_|
]]--
mobs.explode_attack_walk = function(self,dtime)
--this needs an exception
if self.attacking == nil or not self.attacking:is_player() then
self.attacking = nil
return
end
mobs.set_yaw_while_attacking(self)
local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos())
--make mob walk up to player within 2 nodes distance then start exploding
if distance_from_attacking >= self.reach and
--don't allow explosion to cancel unless out of the reach boundary
not (self.explosion_animation ~= nil and self.explosion_animation > 0 and distance_from_attacking <= self.defuse_reach) then
mobs.set_velocity(self, self.run_velocity)
mobs.set_mob_animation(self,"run")
mobs.reverse_explosion_animation(self,dtime)
else
mobs.set_velocity(self,0)
--this is the only way I can reference this without dumping extra data on all mobs
if not self.explosion_animation then
self.explosion_animation = 0
end
--play ignite sound
if self.explosion_animation == 0 then
mobs.play_sound(self,"attack")
end
mobs.set_mob_animation(self,"stand")
mobs.handle_explosion_animation(self)
self.explosion_animation = self.explosion_animation + (dtime/2.5)
end
--make explosive mobs jump
--check for nodes to jump over
--explosive mobs will just ride against walls for now
local node_in_front_of = mobs.jump_check(self)
if node_in_front_of == 1 then
mobs.jump(self)
end
--do biggening explosion thing
if self.explosion_animation and self.explosion_animation > self.explosion_timer then
mcl_explosions.explode(self.object:get_pos(), self.explosion_strength,{ drop_chance = 1.0 })
self.object:remove()
end
end
--this is a small helper function to make working with explosion animations easier
mobs.reverse_explosion_animation = function(self,dtime)
--if explosion animation was greater than 0 then reverse it
if self.explosion_animation ~= nil and self.explosion_animation > 0 then
self.explosion_animation = self.explosion_animation - dtime
if self.explosion_animation < 0 then
self.explosion_animation = 0
end
end
mobs.handle_explosion_animation(self)
end
--[[
______ _
| ___ \ | |
| |_/ / _ _ __ ___| |__
| __/ | | | '_ \ / __| '_ \
| | | |_| | | | | (__| | | |
\_| \__,_|_| |_|\___|_| |_|
]]--
mobs.punch_attack_walk = function(self,dtime)
--this needs an exception
if self.attacking == nil or not self.attacking:is_player() then
self.attacking = nil
return
end
mobs.set_yaw_while_attacking(self)
mobs.set_velocity(self, self.run_velocity)
mobs.set_mob_animation(self, "run")
--make punchy mobs jump
--check for nodes to jump over
--explosive mobs will just ride against walls for now
local node_in_front_of = mobs.jump_check(self)
if node_in_front_of == 1 then
mobs.jump(self)
end
if self.punch_timer > 0 then
self.punch_timer = self.punch_timer - dtime
end
end
mobs.punch_attack = function(self)
self.attacking:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = self.damage}
}, nil)
self.punch_timer = self.punch_timer_cooloff
--knockback
local pos1 = self.object:get_pos()
pos1.y = 0
local pos2 = self.attacking:get_pos()
pos2.y = 0
local dir = vector_direction(pos1,pos2)
dir = vector_multiply(dir,3)
if self.attacking:get_velocity().y <= 1 then
dir.y = 5
end
self.attacking:add_velocity(dir)
end
--[[
______ _ _ _ _
| ___ \ (_) | | (_) |
| |_/ / __ ___ _ ___ ___| |_ _| | ___
| __/ '__/ _ \| |/ _ \/ __| __| | |/ _ \
| | | | | (_) | | __/ (__| |_| | | __/
\_| |_| \___/| |\___|\___|\__|_|_|\___|
_/ |
|__/
]]--
mobs.projectile_attack_walk = function(self,dtime)
--this needs an exception
if self.attacking == nil or not self.attacking:is_player() then
self.attacking = nil
return
end
mobs.set_yaw_while_attacking(self)
local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos())
if distance_from_attacking >= self.reach then
mobs.set_velocity(self, self.run_velocity)
mobs.set_mob_animation(self,"run")
else
mobs.set_velocity(self,0)
mobs.set_mob_animation(self,"stand")
end
--do this to not load data into other mobs
if not self.projectile_timer then
self.projectile_timer = self.projectile_cooldown
end
--run projectile timer
if self.projectile_timer > 0 then
self.projectile_timer = self.projectile_timer - dtime
--shoot
if self.projectile_timer <= 0 then
--reset timer
self.projectile_timer = self.projectile_cooldown
mobs.shoot_projectile(self)
end
end
--make shooty mobs jump
--check for nodes to jump over
--explosive mobs will just ride against walls for now
local node_in_front_of = mobs.jump_check(self)
if node_in_front_of == 1 then
mobs.jump(self)
end
end
--[[
_ ______ _ _
| | | ___| | | |
| | | |_ | |_ _ | |
| | | _| | | | | | | |
|_| | | | | |_| | |_|
(_) \_| |_|\__, | (_)
__/ |
|___/
]]--
--[[
______ _ _ _ _
| ___ \ (_) | | (_) |
| |_/ / __ ___ _ ___ ___| |_ _| | ___
| __/ '__/ _ \| |/ _ \/ __| __| | |/ _ \
| | | | | (_) | | __/ (__| |_| | | __/
\_| |_| \___/| |\___|\___|\__|_|_|\___|
_/ |
|__/
]]--
mobs.projectile_attack_fly = function(self, dtime)
--this needs an exception
if self.attacking == nil or not self.attacking:is_player() then
self.attacking = nil
return
end
local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos())
if distance_from_attacking >= self.reach then
mobs.set_yaw_while_attacking(self)
mobs.set_pitch_while_attacking(self)
mobs.set_fly_velocity(self, self.run_velocity)
mobs.set_mob_animation(self,"run")
else
mobs.set_yaw_while_attacking(self)
mobs.set_pitch_while_attacking(self)
mobs.set_fly_velocity(self, 0)
mobs.set_mob_animation(self,"stand")
end
--do this to not load data into other mobs
if not self.projectile_timer then
self.projectile_timer = self.projectile_cooldown
end
--run projectile timer
if self.projectile_timer > 0 then
self.projectile_timer = self.projectile_timer - dtime
--shoot
if self.projectile_timer <= 0 then
--reset timer
self.projectile_timer = self.projectile_cooldown
mobs.shoot_projectile(self)
end
end
end

View File

@ -0,0 +1,138 @@
local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
local math_random = math.random
local vector_multiply = vector.multiply
local vector_direction = vector.direction
local integer_test = {-1,1}
mobs.collision = function(self)
local pos = self.object:get_pos()
if not self or not self.object or not self.object:get_luaentity() then
return
end
--do collision detection from the base of the mob
local collisionbox = self.object:get_properties().collisionbox
pos.y = pos.y + collisionbox[2]
local collision_boundary = collisionbox[4]
local radius = collision_boundary
if collisionbox[5] > collision_boundary then
radius = collisionbox[5]
end
local collision_count = 0
local check_for_attack = false
if self.attack_type == "punch" and self.hostile and self.attacking then
check_for_attack = true
end
for _,object in ipairs(minetest_get_objects_inside_radius(pos, radius*1.25)) do
if object and object ~= self.object and (object:is_player() or object:get_luaentity()._cmi_is_mob == true) then--and
--don't collide with rider, rider don't collide with thing
--(not object:get_attach() or (object:get_attach() and object:get_attach() ~= self.object)) and
--(not self.object:get_attach() or (self.object:get_attach() and self.object:get_attach() ~= object)) then
--stop infinite loop
collision_count = collision_count + 1
if collision_count > 100 then
break
end
local pos2 = object:get_pos()
local object_collisionbox = object:get_properties().collisionbox
pos2.y = pos2.y + object_collisionbox[2]
local object_collision_boundary = object_collisionbox[4]
--this is checking the difference of the object collided with's possision
--if positive top of other object is inside (y axis) of current object
local y_base_diff = (pos2.y + object_collisionbox[5]) - pos.y
local y_top_diff = (pos.y + collisionbox[5]) - pos2.y
local distance = vector.distance(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z))
if distance <= collision_boundary + object_collision_boundary and y_base_diff >= 0 and y_top_diff >= 0 then
local dir = vector.direction(pos,pos2)
dir.y = 0
--eliminate mob being stuck in corners
if dir.x == 0 and dir.z == 0 then
--slightly adjust mob position to prevent equal length
--corner/wall sticking
dir.x = dir.x + ((math_random()/10)*integer_test[math.random(1,2)])
dir.z = dir.z + ((math_random()/10)*integer_test[math.random(1,2)])
end
local velocity = dir
--0.5 is the max force multiplier
local force = 0.5 - (0.5 * distance / (collision_boundary + object_collision_boundary))
local vel1 = vector.multiply(velocity, -1.5)
local vel2 = vector.multiply(velocity, 1.5)
vel1 = vector.multiply(vel1, force * 10)
vel2 = vector.multiply(vel2, force)
if object:is_player() then
vel2 = vector_multiply(vel2, 2.5)
--integrate mob punching into collision detection
if check_for_attack and self.punch_timer <= 0 then
if object == self.attacking then
mobs.punch_attack(self)
end
end
end
self.object:add_velocity(vel1)
object:add_velocity(vel2)
end
end
end
end
--this is used for arrow collisions
mobs.arrow_hit = function(self, player)
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = self._damage}
}, nil)
--knockback
local pos1 = self.object:get_pos()
pos1.y = 0
local pos2 = player:get_pos()
pos2.y = 0
local dir = vector_direction(pos1,pos2)
dir = vector_multiply(dir,3)
if player:get_velocity().y <= 1 then
dir.y = 5
end
player:add_velocity(dir)
end

View File

@ -0,0 +1,133 @@
local minetest_add_item = minetest.add_item
local minetest_sound_play = minetest.sound_play
local math_pi = math.pi
local math_random = math.random
local math_floor = math.floor
local HALF_PI = math_pi / 2
local vector_new = vector.new
-- drop items
local item_drop = function(self, cooked, looting_level)
looting_level = looting_level or 0
-- no drops for child mobs (except monster)
if (self.child and self.type ~= "monster") then
return
end
local obj, item, num
local pos = self.object:get_pos()
self.drops = self.drops or {} -- nil check
for n = 1, #self.drops do
local dropdef = self.drops[n]
local chance = 1 / dropdef.chance
local looting_type = dropdef.looting
if looting_level > 0 then
local chance_function = dropdef.looting_chance_function
if chance_function then
chance = chance_function(looting_level)
elseif looting_type == "rare" then
chance = chance + (dropdef.looting_factor or 0.01) * looting_level
end
end
local num = 0
local do_common_looting = (looting_level > 0 and looting_type == "common")
if math_random() < chance then
num = math_random(dropdef.min or 1, dropdef.max or 1)
elseif not dropdef.looting_ignore_chance then
do_common_looting = false
end
if do_common_looting then
num = num + math_floor(math_random(0, looting_level) + 0.5)
end
if num > 0 then
item = dropdef.name
-- cook items when true
if cooked then
local output = minetest_get_craft_result({
method = "cooking", width = 1, items = {item}})
if output and output.item and not output.item:is_empty() then
item = output.item:get_name()
end
end
-- add item if it exists
for x = 1, num do
obj = minetest_add_item(pos, ItemStack(item .. " " .. 1))
end
if obj and obj:get_luaentity() then
obj:set_velocity({
x = math_random(-10, 10) / 9,
y = 6,
z = math_random(-10, 10) / 9,
})
elseif obj then
obj:remove() -- item does not exist
end
end
end
self.drops = {}
end
mobs.death_logic = function(self, dtime)
self.death_animation_timer = self.death_animation_timer + dtime
--the final POOF of a mob despawning
if self.death_animation_timer >= 1.25 then
item_drop(self,false,1)
mobs.death_effect(self)
self.object:remove()
return
end
--I'm sure there's a more efficient way to do this
--but this is the easiest, easier to work with 1 variable synced
--this is also not smooth
local death_animation_roll = self.death_animation_timer * 2 -- * 2 to make it faster
if death_animation_roll > 1 then
death_animation_roll = 1
end
local rot = self.object:get_rotation() --(no pun intended)
rot.z = death_animation_roll * HALF_PI
self.object:set_rotation(rot)
mobs.set_mob_animation(self,"stand", true)
--flying and swimming mobs just fall down
if self.fly or self.swim then
if self.object:get_acceleration().y ~= -self.gravity then
self.object:set_acceleration(vector_new(0,-self.gravity,0))
end
end
--when landing allow mob to slow down and just fall if in air
if self.pause_timer <= 0 then
mobs.set_velocity(self,0)
end
end

View File

@ -0,0 +1,200 @@
local minetest_line_of_sight = minetest.line_of_sight
local minetest_dir_to_yaw = minetest.dir_to_yaw
local minetest_yaw_to_dir = minetest.yaw_to_dir
local minetest_get_node = minetest.get_node
local minetest_get_item_group = minetest.get_item_group
local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
local minetest_get_node_or_nil = minetest.get_node_or_nil
local minetest_registered_nodes = minetest.registered_nodes
local vector_new = vector.new
local vector_multiply = vector.multiply
local table_copy = table.copy
-- default function when mobs are blown up with TNT
local do_tnt = function(obj, damage)
obj.object:punch(obj.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = damage},
}, nil)
return false, true, {}
end
--a fast function to be able to detect only players without using objects_in_radius
mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius, object_height_adder)
local pos1 = self.object:get_pos()
local players_in_area = {}
local winner_player = nil
local players_detected = 0
--get players in radius
for _,player in pairs(minetest.get_connected_players()) do
if player and player:get_hp() > 0 then
local pos2 = player:get_pos()
local distance = vector.distance(pos1,pos2)
if distance <= radius then
if line_of_sight then
--must add eye height or stuff breaks randomly because of
--seethrough nodes being a blocker (like grass)
if minetest_line_of_sight(
vector_new(pos1.x, pos1.y + object_height_adder, pos1.z),
vector_new(pos2.x, pos2.y + player:get_properties().eye_height, pos2.z)
) then
players_detected = players_detected + 1
players_in_area[player] = distance
end
else
players_detected = players_detected + 1
players_in_area[player] = distance
end
end
end
end
--return if there's no one near by
if players_detected <= 0 then --handle negative numbers for some crazy error that could possibly happen
return nil
end
--do a default radius max
local shortest_disance = radius + 1
--sort through players and find the closest player
for player,distance in pairs(players_in_area) do
if distance < shortest_disance then
shortest_disance = distance
winner_player = player
end
end
return(winner_player)
end
--check if a mob needs to jump
mobs.jump_check = function(self,dtime)
local pos = self.object:get_pos()
pos.y = pos.y + 0.1
local dir = minetest_yaw_to_dir(self.yaw)
local collisionbox = self.object:get_properties().collisionbox
local radius = collisionbox[4] + 0.5
vector_multiply(dir, radius)
--only jump if there's a node and a non-solid node above it
local test_dir = vector.add(pos,dir)
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
test_dir.y = test_dir.y + 1
local green_flag_2 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") == 0
if green_flag_1 and green_flag_2 then
--can jump over node
return(1)
elseif green_flag_1 and not green_flag_2 then
--wall in front of mob
return(2)
end
--nothing to jump over
return(0)
end
-- a helper function to quickly turn neutral passive mobs hostile
local turn_hostile = function(self,detected_mob)
--drop in variables for attacking (stops crash)
detected_mob.punch_timer = 0
--set to hostile
detected_mob.hostile = true
--hostile_cooldown timer is initialized here
detected_mob.hostile_cooldown_timer = detected_mob.hostile_cooldown
--set target to the same
detected_mob.attacking = self.attacking
end
--allow hostile mobs to signal to other mobs
--to switch from neutal passive to neutral hostile
mobs.group_attack_initialization = function(self)
--get basic data
local friends_list = table_copy(self.group_attack)
local objects_in_area = minetest_get_objects_inside_radius(self.object:get_pos(), self.view_range)
--get the player's name
local name = self.attacking:get_player_name()
--re-use local variable
local detected_mob
--run through mobs in viewing distance
for _,object in pairs(objects_in_area) do
if object and object:get_luaentity() then
detected_mob = object:get_luaentity()
-- only alert members of same mob or friends
if detected_mob._cmi_is_mob and detected_mob.state ~= "attack" and detected_mob.owner ~= name then
if detected_mob.name == self.name then
turn_hostile(self,detected_mob)
elseif type(detected_mob.group_attack) == "table" then
for _,id in pairs(self.group_attack) do
if detected_mob.name == id then
turn_hostile(self,detected_mob)
break
end
end
end
end
--THIS NEEDS TO BE RE-IMPLEMENTED AS A GLOBAL HIT IN MOB_PUNCH!!
-- have owned mobs attack player threat
--if obj.owner == name and obj.owner_loyal then
-- do_attack(obj, self.object)
--end
end
end
end
-- check if within physical map limits (-30911 to 30927)
-- within_limits, wmin, wmax = nil, -30913, 30928
mobs.within_limits = function(pos, radius)
if mcl_vars then
if mcl_vars.mapgen_edge_min and mcl_vars.mapgen_edge_max then
wmin, wmax = mcl_vars.mapgen_edge_min, mcl_vars.mapgen_edge_max
within_limits = function(pos, radius)
return pos
and (pos.x - radius) > wmin and (pos.x + radius) < wmax
and (pos.y - radius) > wmin and (pos.y + radius) < wmax
and (pos.z - radius) > wmin and (pos.z + radius) < wmax
end
end
end
return pos
and (pos.x - radius) > wmin and (pos.x + radius) < wmax
and (pos.y - radius) > wmin and (pos.y + radius) < wmax
and (pos.z - radius) > wmin and (pos.z + radius) < wmax
end
-- get node but use fallback for nil or unknown
mobs.node_ok = function(pos, fallback)
fallback = fallback or mobs.fallback_node
local node = minetest_get_node_or_nil(pos)
if node and minetest_registered_nodes[node.name] then
return node
end
return minetest_registered_nodes[fallback]
end

View File

@ -0,0 +1,310 @@
local minetest_after = minetest.after
local minetest_sound_play = minetest.sound_play
local math_floor = math.floor
local math_min = math.min
local math_random = math.random
local vector_direction = vector.direction
local vector_multiply = vector.multiply
mobs.feed_tame = function(self)
return nil
end
-- Code to execute before custom on_rightclick handling
local on_rightclick_prefix = function(self, clicker)
local item = clicker:get_wielded_item()
-- Name mob with nametag
if not self.ignores_nametag and item:get_name() == "mcl_mobs:nametag" then
local tag = item:get_meta():get_string("name")
if tag ~= "" then
if string.len(tag) > MAX_MOB_NAME_LENGTH then
tag = string.sub(tag, 1, MAX_MOB_NAME_LENGTH)
end
self.nametag = tag
update_tag(self)
if not mobs.is_creative(clicker:get_player_name()) then
item:take_item()
clicker:set_wielded_item(item)
end
return true
end
end
return false
end
-- I have no idea what this does
mobs.create_mob_on_rightclick = function(on_rightclick)
return function(self, clicker)
--don't allow rightclicking dead mobs
if self.health <= 0 then
return
end
local stop = on_rightclick_prefix(self, clicker)
if (not stop) and (on_rightclick) then
on_rightclick(self, clicker)
end
end
end
-- deal damage and effects when mob punched
mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
--don't do anything if the mob is already dead
if self.health <= 0 then
return
end
--neutral passive mobs switch to neutral hostile
if self.neutral then
--drop in variables for attacking (stops crash)
self.attacking = hitter
self.punch_timer = 0
self.hostile = true
--hostile_cooldown timer is initialized here
self.hostile_cooldown_timer = self.hostile_cooldown
--initialize the group attack (check for other mobs in area, make them neutral hostile)
if self.group_attack then
mobs.group_attack_initialization(self)
end
end
-- custom punch function
if self.do_punch then
-- when false skip going any further
if self.do_punch(self, hitter, tflp, tool_capabilities, dir) == false then
return
end
end
--don't do damage until pause timer resets
if self.pause_timer > 0 then
return
end
-- error checking when mod profiling is enabled
if not tool_capabilities then
minetest.log("warning", "[mobs_mc] Mod profiling enabled, damage not enabled")
return
end
local is_player = hitter:is_player()
-- punch interval
local weapon = hitter:get_wielded_item()
local punch_interval = 1.4
-- exhaust attacker
if mod_hunger and is_player then
mcl_hunger.exhaust(hitter:get_player_name(), mcl_hunger.EXHAUST_ATTACK)
end
-- calculate mob damage
local damage = 0
local armor = self.object:get_armor_groups() or {}
local tmp
--calculate damage groups
for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do
damage = damage + (tool_capabilities.damage_groups[group] or 0) * ((armor[group] or 0) / 100.0)
end
if weapon then
local fire_aspect_level = mcl_enchanting.get_enchantment(weapon, "fire_aspect")
if fire_aspect_level > 0 then
mcl_burning.set_on_fire(self.object, fire_aspect_level * 4)
end
end
-- check for tool immunity or special damage
for n = 1, #self.immune_to do
if self.immune_to[n][1] == weapon:get_name() then
damage = self.immune_to[n][2] or 0
break
end
end
-- healing
if damage <= -1 then
self.health = self.health - math_floor(damage)
return
end
if tool_capabilities then
punch_interval = tool_capabilities.full_punch_interval or 1.4
end
-- add weapon wear manually
-- Required because we have custom health handling ("health" property)
--minetest_is_creative_enabled("") ~= true --removed for now
if tool_capabilities then
if tool_capabilities.punch_attack_uses then
-- Without this delay, the wear does not work. Quite hacky ...
minetest_after(0, function(name)
local player = minetest.get_player_by_name(name)
if not player then return end
local weapon = hitter:get_wielded_item(player)
local def = weapon:get_definition()
if def.tool_capabilities and def.tool_capabilities.punch_attack_uses then
local wear = math_floor(65535/tool_capabilities.punch_attack_uses)
weapon:add_wear(wear)
hitter:set_wielded_item(weapon)
end
end, hitter:get_player_name())
end
end
--if player is falling multiply damage by 1.5
--critical hit
if hitter:get_velocity().y < 0 then
damage = damage * 1.5
mobs.critical_effect(self)
end
local die = false
-- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately.
if damage >= 0.1 then
-- weapon sounds
if weapon:get_definition().sounds ~= nil then
local s = math_random(0, #weapon:get_definition().sounds)
minetest_sound_play(weapon:get_definition().sounds[s], {
object = self.object, --hitter,
max_hear_distance = 8
}, true)
else
minetest_sound_play("default_punch", {
object = self.object,
max_hear_distance = 5
}, true)
end
--damage_effect(self, damage)
-- do damage
self.health = self.health - damage
-- skip future functions if dead, except alerting others
--if check_for_death(self, "hit", {type = "punch", puncher = hitter}) then
-- die = true
--end
-- knock back effect
local velocity = self.object:get_velocity()
--2d direction
local pos1 = self.object:get_pos()
pos1.y = 0
local pos2 = hitter:get_pos()
pos2.y = 0
local dir = vector.direction(pos2,pos1)
local up = 3
-- if already in air then dont go up anymore when hit
if velocity.y ~= 0 then
up = 0
end
--0.75 for perfect distance to not be too easy, and not be too hard
local multiplier = 0.75
-- check if tool already has specific knockback value
local knockback_enchant = mcl_enchanting.get_enchantment(hitter:get_wielded_item(), "knockback")
if knockback_enchant and knockback_enchant > 0 then
multiplier = knockback_enchant + 1 --(starts from 1, 1 would be no change)
end
local luaentity
--[[ --why does this multiply it again???
if hitter then
luaentity = hitter:get_luaentity()
end
if hitter and is_player then
local wielditem = hitter:get_wielded_item()
kb = kb + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback")
elseif luaentity and luaentity._knockback then
kb = kb + luaentity._knockback
end
]]--
dir = vector_multiply(dir,multiplier)
dir.y = up
--add velocity breaks momentum - use set velocity
self.object:set_velocity(dir)
--0.4 seconds until you can hurt the mob again
self.pause_timer = 0.4
end
-- END if damage
-- if skittish then run away
--[[
if not die and self.runaway == true and self.state ~= "flop" then
local lp = hitter:get_pos()
local s = self.object:get_pos()
local vec = {
x = lp.x - s.x,
y = lp.y - s.y,
z = lp.z - s.z
}
local yaw = (atan(vec.z / vec.x) + 3 * math_pi / 2) - self.rotate
if lp.x > s.x then
yaw = yaw + math_pi
end
yaw = set_yaw(self, yaw, 6)
self.state = "runaway"
self.runaway_timer = 0
self.following = nil
end
]]--
end
--do internal per mob projectile calculations
mobs.shoot_projectile = function(self)
local pos1 = self.object:get_pos()
--add mob eye height
pos1.y = pos1.y + self.eye_height
local pos2 = self.attacking:get_pos()
--add player eye height
pos2.y = pos2.y + self.attacking:get_properties().eye_height
--get direction
local dir = vector_direction(pos1,pos2)
--call internal shoot_arrow function
self.shoot_arrow(self,pos1,dir)
end

View File

@ -0,0 +1,61 @@
local minetest_add_particlespawner = minetest.add_particlespawner
mobs.death_effect = function(self)
local pos = self.object:get_pos()
local yaw = self.object:get_yaw()
local collisionbox = self.object:get_properties().collisionbox
local min, max
if collisionbox then
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
end
minetest_add_particlespawner({
amount = 50,
time = 0.0001,
minpos = vector.add(pos, min),
maxpos = vector.add(pos, max),
minvel = vector.new(-0.5,0.5,-0.5),
maxvel = vector.new(0.5,1,0.5),
minexptime = 1.1,
maxexptime = 1.5,
minsize = 1,
maxsize = 2,
collisiondetection = false,
vertical = false,
texture = "mcl_particles_mob_death.png", -- this particle looks strange
})
end
mobs.critical_effect = function(self)
local pos = self.object:get_pos()
local yaw = self.object:get_yaw()
local collisionbox = self.object:get_properties().collisionbox
local min, max
if collisionbox then
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
end
minetest_add_particlespawner({
amount = 10,
time = 0.0001,
minpos = vector.add(pos, min),
maxpos = vector.add(pos, max),
minvel = vector.new(-1,1,-1),
maxvel = vector.new(1,3,1),
minexptime = 0.7,
maxexptime = 1,
minsize = 1,
maxsize = 2,
collisiondetection = false,
vertical = false,
texture = "heart.png^[colorize:black:255",
})
end

View File

@ -0,0 +1,309 @@
local math_pi = math.pi
local math_sin = math.sin
local math_cos = math.cos
local math_random = math.random
local HALF_PI = math_pi / 2
local DOUBLE_PI = math_pi * 2
-- localize vector functions
local vector_new = vector.new
local vector_length = vector.length
local vector_multiply = vector.multiply
local vector_distance = vector.distance
local minetest_yaw_to_dir = minetest.yaw_to_dir
local minetest_dir_to_yaw = minetest.dir_to_yaw
local DEFAULT_JUMP_HEIGHT = 5
local DEFAULT_FLOAT_SPEED = 4
--this is a generic float function
mobs.float = function(self)
local current_velocity = self.object:get_velocity()
local goal_velocity = {
x = 0,
y = DEFAULT_FLOAT_SPEED,
z = 0,
}
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
new_velocity_addition.x = 0
new_velocity_addition.z = 0
--smooths out mobs a bit
if vector_length(new_velocity_addition) >= 0.0001 then
self.object:add_velocity(new_velocity_addition)
end
end
--[[
_ _
| | | |
| | __ _ _ __ __| |
| | / _` | '_ \ / _` |
| |___| (_| | | | | (_| |
\_____/\__,_|_| |_|\__,_|
]]
-- move mob in facing direction
--this has been modified to be internal
--internal = lua (self.yaw)
--engine = c++ (self.object:get_yaw())
mobs.set_velocity = function(self, v)
local yaw = (self.yaw or 0)
local current_velocity = self.object:get_velocity()
local goal_velocity = {
x = (math_sin(yaw) * -v),
y = 0,
z = (math_cos(yaw) * v),
}
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
if vector_length(new_velocity_addition) > vector_length(goal_velocity) then
vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition)))
end
new_velocity_addition.y = 0
--smooths out mobs a bit
if vector_length(new_velocity_addition) >= 0.0001 then
self.object:add_velocity(new_velocity_addition)
end
end
-- calculate mob velocity
mobs.get_velocity = function(self)
local v = self.object:get_velocity()
v.y = 0
if v then
return vector_length(v)
end
return 0
end
--make mobs jump
mobs.jump = function(self, velocity)
if self.object:get_velocity().y ~= 0 or not self.old_velocity or (self.old_velocity and self.old_velocity.y > 0) then
return
end
--fallback velocity to allow modularity
velocity = velocity or DEFAULT_JUMP_HEIGHT
self.object:add_velocity(vector_new(0,velocity,0))
end
--[[
_____ _
/ ___| (_)
\ `--.__ ___ _ __ ___
`--. \ \ /\ / / | '_ ` _ \
/\__/ /\ V V /| | | | | | |
\____/ \_/\_/ |_|_| |_| |_|
]]--
--make mobs flop
mobs.flop = function(self, velocity)
if self.object:get_velocity().y ~= 0 or not self.old_velocity or (self.old_velocity and self.old_velocity.y > 0) then
return false
end
mobs.set_velocity(self, 0)
--fallback velocity to allow modularity
velocity = velocity or DEFAULT_JUMP_HEIGHT
--create a random direction (2d yaw)
local dir = DOUBLE_PI * math_random()
--create a random force value
local force = math_random(0,3) + math_random()
--convert the yaw to a direction vector then multiply it times the force
local final_additional_force = vector_multiply(minetest_yaw_to_dir(dir), force)
--place in the "flop" velocity to make the mob flop
final_additional_force.y = velocity
self.object:add_velocity(final_additional_force)
return true
end
-- move mob in facing direction
--this has been modified to be internal
--internal = lua (self.yaw)
--engine = c++ (self.object:get_yaw())
mobs.set_swim_velocity = function(self, v)
local yaw = (self.yaw or 0)
local pitch = (self.pitch or 0)
if v == 0 then
pitch = 0
end
local current_velocity = self.object:get_velocity()
local goal_velocity = {
x = (math_sin(yaw) * -v),
y = pitch,
z = (math_cos(yaw) * v),
}
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
if vector_length(new_velocity_addition) > vector_length(goal_velocity) then
vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition)))
end
--smooths out mobs a bit
if vector_length(new_velocity_addition) >= 0.0001 then
self.object:add_velocity(new_velocity_addition)
end
end
--[[
______ _
| ___| |
| |_ | |_ _
| _| | | | | |
| | | | |_| |
\_| |_|\__, |
__/ |
|___/
]]--
-- move mob in facing direction
--this has been modified to be internal
--internal = lua (self.yaw)
--engine = c++ (self.object:get_yaw())
mobs.set_fly_velocity = function(self, v)
local yaw = (self.yaw or 0)
local pitch = (self.pitch or 0)
if v == 0 then
pitch = 0
end
local current_velocity = self.object:get_velocity()
local goal_velocity = {
x = (math_sin(yaw) * -v),
y = pitch,
z = (math_cos(yaw) * v),
}
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
if vector_length(new_velocity_addition) > vector_length(goal_velocity) then
vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition)))
end
--smooths out mobs a bit
if vector_length(new_velocity_addition) >= 0.0001 then
self.object:add_velocity(new_velocity_addition)
end
end
--a quick and simple pitch calculation between two vector positions
mobs.calculate_pitch = function(pos1, pos2)
if pos1 == nil or pos2 == nil then
return false
end
return(minetest_dir_to_yaw(vector_new(vector_distance(vector_new(pos1.x,0,pos1.z),vector_new(pos2.x,0,pos2.z)),0,pos1.y - pos2.y)) + HALF_PI)
end
--make mobs fly up or down based on their y difference
mobs.set_pitch_while_attacking = function(self)
local pos1 = self.object:get_pos()
local pos2 = self.attacking:get_pos()
local pitch = mobs.calculate_pitch(pos2,pos1)
self.pitch = pitch
end
--[[
___
|_ |
| |_ _ _ __ ___ _ __
| | | | | '_ ` _ \| '_ \
/\__/ / |_| | | | | | | |_) |
\____/ \__,_|_| |_| |_| .__/
| |
|_|
]]--
--special mob jump movement
mobs.jump_move = function(self, velocity)
if self.object:get_velocity().y ~= 0 or not self.old_velocity or (self.old_velocity and self.old_velocity.y > 0) then
return
end
--make the mob stick for a split second
mobs.set_velocity(self,0)
--fallback velocity to allow modularity
jump_height = DEFAULT_JUMP_HEIGHT
local yaw = (self.yaw or 0)
local current_velocity = self.object:get_velocity()
local goal_velocity = {
x = (math_sin(yaw) * -velocity),
y = jump_height,
z = (math_cos(yaw) * velocity),
}
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
if vector_length(new_velocity_addition) > vector_length(goal_velocity) then
vector.multiply(new_velocity_addition, (vector_length(goal_velocity) / vector_length(new_velocity_addition)))
end
--smooths out mobs a bit
if vector_length(new_velocity_addition) >= 0.0001 then
self.object:add_velocity(new_velocity_addition)
end
end

View File

@ -0,0 +1,220 @@
local math_random = math.random
local minetest_settings = minetest.settings
-- get entity staticdata
mobs.mob_staticdata = function(self)
--[[
-- remove mob when out of range unless tamed
if remove_far
and self.can_despawn
and self.remove_ok
and ((not self.nametag) or (self.nametag == ""))
and self.lifetimer <= 20 then
minetest.log("action", "Mob "..name.." despawns in mob_staticdata at "..minetest.pos_to_string(self.object.get_pos(), 1))
mcl_burning.extinguish(self.object)
self.object:remove()
return ""-- nil
end
--]]
self.remove_ok = true
self.attack = nil
self.following = nil
if use_cmi then
self.serialized_cmi_components = cmi.serialize_components(self._cmi_components)
end
local tmp = {}
for _,stat in pairs(self) do
local t = type(stat)
if t ~= "function"
and t ~= "nil"
and t ~= "userdata"
and _ ~= "_cmi_components" then
tmp[_] = self[_]
end
end
return minetest.serialize(tmp)
end
-- activate mob and reload settings
mobs.mob_activate = function(self, staticdata, def, dtime)
-- remove monsters in peaceful mode
if self.type == "monster" and minetest_settings:get_bool("only_peaceful_mobs", false) then
mcl_burning.extinguish(self.object)
self.object:remove()
return
end
-- load entity variables
local tmp = minetest.deserialize(staticdata)
if tmp then
for _,stat in pairs(tmp) do
self[_] = stat
end
end
--set up wandering
if not self.wandering then
self.wandering = true
end
--clear animation
self.current_animation = nil
-- select random texture, set model and size
if not self.base_texture then
-- compatiblity with old simple mobs textures
if type(def.textures[1]) == "string" then
def.textures = {def.textures}
end
self.base_texture = def.textures[math_random(1, #def.textures)]
self.base_mesh = def.mesh
self.base_size = self.visual_size
self.base_colbox = self.collisionbox
self.base_selbox = self.selectionbox
end
-- for current mobs that dont have this set
if not self.base_selbox then
self.base_selbox = self.selectionbox or self.base_colbox
end
-- set texture, model and size
local textures = self.base_texture
local mesh = self.base_mesh
local vis_size = self.base_size
local colbox = self.base_colbox
local selbox = self.base_selbox
-- specific texture if gotten
if self.gotten == true
and def.gotten_texture then
textures = def.gotten_texture
end
-- specific mesh if gotten
if self.gotten == true
and def.gotten_mesh then
mesh = def.gotten_mesh
end
-- set child objects to half size
if self.child == true then
vis_size = {
x = self.base_size.x * .5,
y = self.base_size.y * .5,
}
if def.child_texture then
textures = def.child_texture[1]
end
colbox = {
self.base_colbox[1] * .5,
self.base_colbox[2] * .5,
self.base_colbox[3] * .5,
self.base_colbox[4] * .5,
self.base_colbox[5] * .5,
self.base_colbox[6] * .5
}
selbox = {
self.base_selbox[1] * .5,
self.base_selbox[2] * .5,
self.base_selbox[3] * .5,
self.base_selbox[4] * .5,
self.base_selbox[5] * .5,
self.base_selbox[6] * .5
}
end
if self.health == 0 then
self.health = math_random (self.hp_min, self.hp_max)
end
if self.breath == nil then
self.breath = self.breath_max
end
-- pathfinding init
self.path = {}
self.path.way = {} -- path to follow, table of positions
self.path.lastpos = {x = 0, y = 0, z = 0}
self.path.stuck = false
self.path.following = false -- currently following path?
self.path.stuck_timer = 0 -- if stuck for too long search for path
-- Armor groups
-- immortal=1 because we use custom health
-- handling (using "health" property)
local armor
if type(self.armor) == "table" then
armor = table.copy(self.armor)
armor.immortal = 1
else
armor = {immortal=1, fleshy = self.armor}
end
self.object:set_armor_groups(armor)
self.old_y = self.object:get_pos().y
self.old_health = self.health
self.sounds.distance = self.sounds.distance or 10
self.textures = textures
self.mesh = mesh
self.collisionbox = colbox
self.selectionbox = selbox
self.visual_size = vis_size
self.standing_in = "ignore"
self.standing_on = "ignore"
self.jump_sound_cooloff = 0 -- used to prevent jump sound from being played too often in short time
self.opinion_sound_cooloff = 0 -- used to prevent sound spam of particular sound types
self.texture_mods = {}
self.object:set_texture_mod("")
self.v_start = false
self.timer = 0
self.blinktimer = 0
self.blinkstatus = false
-- check existing nametag
if not self.nametag then
self.nametag = def.nametag
end
-- set anything changed above
self.object:set_properties(self)
--update_tag(self)
--mobs.set_animation(self, "stand")
-- run on_spawn function if found
if self.on_spawn and not self.on_spawn_run then
if self.on_spawn(self) then
self.on_spawn_run = true -- if true, set flag to run once only
end
end
-- run after_activate
if def.after_activate then
def.after_activate(self, staticdata, def, dtime)
end
if use_cmi then
self._cmi_components = cmi.activate_components(self.serialized_cmi_components)
cmi.notify_activate(self.object, dtime)
end
end

View File

@ -0,0 +1,32 @@
local math_random = math.random
--generic call for sound handler for mobs (data access)
mobs.play_sound = function(self,sound)
local soundinfo = self.sounds
if not soundinfo then
return
end
local play_sound = soundinfo[sound]
if not play_sound then
return
end
mobs.play_sound_handler(self, play_sound)
end
--generic sound handler for mobs
mobs.play_sound_handler = function(self, sound)
local pitch = (100 + math_random(-15,15) + math_random()) / 100
minetest.sound_play(sound, {
object = self.object,
gain = 1.0,
max_hear_distance = self.sounds.distance,
pitch = pitch,
}, true)
end

View File

@ -3,12 +3,21 @@ local get_node = minetest.get_node
local get_item_group = minetest.get_item_group
local get_node_light = minetest.get_node_light
local find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air
local new_vector = vector.new
local math_random = math.random
local get_biome_name = minetest.get_biome_name
local max = math.max
local get_objects_inside_radius = minetest.get_objects_inside_radius
local math_random = math.random
local math_floor = math.floor
local max = math.max
local vector_distance = vector.distance
local vector_new = vector.new
local vector_floor = vector.floor
local table_copy = table.copy
local table_remove = table.remove
-- range for mob count
local aoc_range = 32
@ -155,26 +164,15 @@ Overworld regular:
local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false
-- count how many mobs of one type are inside an area
local count_mobs = function(pos,mobtype)
-- count how many mobs are in an area
local count_mobs = function(pos)
local num = 0
local objs = get_objects_inside_radius(pos, aoc_range)
for n = 1, #objs do
local obj = objs[n]:get_luaentity()
if obj and obj.name and obj._cmi_is_mob then
-- count hostile mobs only
if mobtype == "hostile" then
if obj.spawn_class == "hostile" then
num = num + 1
end
-- count passive mobs only
else
for _,object in pairs(get_objects_inside_radius(pos, aoc_range)) do
if object and object:get_luaentity() and object:get_luaentity()._cmi_is_mob then
num = num + 1
end
end
end
return num
end
@ -484,23 +482,23 @@ end
local axis
--inner and outer part of square donut radius
local inner = 1
local outer = 65
local inner = 15
local outer = 64
local int = {-1,1}
local position_calculation = function(pos)
pos = vector.floor(pos)
pos = vector_floor(pos)
--this is used to determine the axis buffer from the player
axis = math.random(0,1)
axis = math_random(0,1)
--cast towards the direction
if axis == 0 then --x
pos.x = pos.x + math.random(inner,outer)*int[math.random(1,2)]
pos.z = pos.z + math.random(-outer,outer)
pos.x = pos.x + math_random(inner,outer)*int[math_random(1,2)]
pos.z = pos.z + math_random(-outer,outer)
else --z
pos.z = pos.z + math.random(inner,outer)*int[math.random(1,2)]
pos.x = pos.x + math.random(-outer,outer)
pos.z = pos.z + math_random(inner,outer)*int[math_random(1,2)]
pos.x = pos.x + math_random(-outer,outer)
end
return(pos)
end
@ -516,7 +514,7 @@ local decypher_limits_dictionary = {
local function decypher_limits(posy)
--local min_max_table = decypher_limits_dictionary[dimension]
--return min_max_table[1],min_max_table[2]
posy = math.floor(posy)
posy = math_floor(posy)
return posy - 32, posy + 32
end
@ -539,13 +537,16 @@ if mobs_spawn then
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer >= 8 then
if timer >= 10 then
timer = 0
for _,player in pairs(minetest.get_connected_players()) do
for i = 1,math_random(3,8) do
repeat -- after this line each "break" means "continue"
local player_pos = player:get_pos()
-- after this line each "break" means "continue"
local do_mob_spawning = true
repeat
--don't need to get these variables more than once
--they happen in a single server step
local player_pos = player:get_pos()
local _,dimension = mcl_worlds.y_to_layer(player_pos.y)
if dimension == "void" or dimension == "default" then
@ -554,9 +555,14 @@ if mobs_spawn then
local min,max = decypher_limits(player_pos.y)
for i = 1,math_random(1,4) do
-- after this line each "break" means "continue"
local do_mob_algorithm = true
repeat
local goal_pos = position_calculation(player_pos)
local spawning_position_list = find_nodes_in_area_under_air(new_vector(goal_pos.x,min,goal_pos.z), vector.new(goal_pos.x,max,goal_pos.z), {"group:solid", "group:water", "group:lava"})
local spawning_position_list = find_nodes_in_area_under_air(vector_new(goal_pos.x,min,goal_pos.z), vector_new(goal_pos.x,max,goal_pos.z), {"group:solid", "group:water", "group:lava"})
--couldn't find node
if #spawning_position_list <= 0 then
@ -565,8 +571,13 @@ if mobs_spawn then
local spawning_position = spawning_position_list[math_random(1,#spawning_position_list)]
--Prevent strange behavior/too close to player
if not spawning_position or vector_distance(player_pos, spawning_position) < 15 then
--Prevent strange behavior --- this is commented out: /too close to player --fixed with inner circle
if not spawning_position then -- or vector_distance(player_pos, spawning_position) < 15
break
end
--hard code mob limit in area to 5 for now
if count_mobs(spawning_position) >= 5 then
break
end
@ -584,51 +595,92 @@ if mobs_spawn then
gotten_biome = get_biome_name(gotten_biome.biome) --makes it easier to work with
--grab random mob
local mob_def = spawn_dictionary[math.random(1,#spawn_dictionary)]
if not mob_def then
break --skip if something ridiculous happens (nil mob def)
end
--skip if not correct dimension
if mob_def.dimension ~= dimension then
break
end
--skip if not in correct biome
if not biome_check(mob_def.biomes, gotten_biome) then
break
end
--add this so mobs don't spawn inside nodes
spawning_position.y = spawning_position.y + 1
if spawning_position.y < mob_def.min_height or spawning_position.y > mob_def.max_height then
break
end
--only need to poll for node light if everything else worked
local gotten_light = get_node_light(spawning_position)
--don't spawn if not in light limits
if gotten_light < mob_def.min_light or gotten_light > mob_def.max_light then
break
end
local is_water = get_item_group(gotten_node, "water") ~= 0
local is_lava = get_item_group(gotten_node, "lava") ~= 0
if mob_def.type_of_spawning == "ground" and is_water then
local mob_def = nil
--create a disconnected clone of the spawn dictionary
--prevents memory leak
local mob_library_worker_table = table_copy(spawn_dictionary)
--grab mob that fits into the spawning location
--randomly grab a mob, don't exclude any possibilities
local repeat_mob_search = true
repeat
--do not infinite loop
if #mob_library_worker_table <= 0 then
--print("breaking infinite loop")
break
end
if mob_def.type_of_spawning == "ground" and is_lava then
break
local skip = false
--use this for removing table elements of mobs that do not match
local temp_index = math_random(1,#mob_library_worker_table)
local temp_def = mob_library_worker_table[temp_index]
--skip if something ridiculous happens (nil mob def)
--something truly horrible has happened if skip gets
--activated at this point
if not temp_def then
skip = true
end
--finally do the heavy check (for now) of mobs in area
if count_mobs(spawning_position, mob_def.spawn_class) >= mob_def.aoc then
if not skip and (spawning_position.y < temp_def.min_height or spawning_position.y > temp_def.max_height) then
skip = true
end
--skip if not correct dimension
if not skip and (temp_def.dimension ~= dimension) then
skip = true
end
--skip if not in correct biome
if not skip and (not biome_check(temp_def.biomes, gotten_biome)) then
skip = true
end
--don't spawn if not in light limits
if not skip and (gotten_light < temp_def.min_light or gotten_light > temp_def.max_light) then
skip = true
end
--skip if not in correct spawning type
if not skip and (temp_def.type_of_spawning == "ground" and is_water) then
skip = true
end
if not skip and (temp_def.type_of_spawning == "ground" and is_lava) then
skip = true
end
--found a mob, exit out of loop
if not skip then
--minetest.log("warning", "found mob:"..temp_def.name)
--print("found mob:"..temp_def.name)
mob_def = table_copy(temp_def)
break
else
--minetest.log("warning", "deleting temp index "..temp_index)
--print("deleting temp index")
table_remove(mob_library_worker_table, temp_index)
end
until repeat_mob_search == false --this is needed to sort through mobs randomly
--catch if went through all mobs and something went horribly wrong
--could not find a valid mob to spawn that fits the environment
if not mob_def then
break
end
@ -637,10 +689,17 @@ if mobs_spawn then
spawning_position.y = spawning_position.y - 1
end
--print("spawning: " .. mob_def.name)
--everything is correct, spawn mob
minetest.add_entity(spawning_position, mob_def.name)
until true --this is a safety catch
break
until do_mob_algorithm == false --this is a safety catch
end
break
until do_mob_spawning == false --this is a performance catch
end
end
end)

View File

@ -1,14 +1,16 @@
local path = minetest.get_modpath(minetest.get_current_modname())
local api_path = path.."/api"
-- Mob API
dofile(path .. "/api.lua")
dofile(api_path .. "/api.lua")
-- Spawning Algorithm
dofile(path .. "/spawning.lua")
dofile(api_path .. "/spawning.lua")
-- Rideable Mobs
dofile(path .. "/mount.lua")
dofile(api_path .. "/mount.lua")
-- Mob Items
dofile(path .. "/crafts.lua")

View File

@ -1,8 +0,0 @@
if minetest.get_modpath("lucky_block") then
lucky_block:add_blocks({
{"dro", {"mcl_mobs:nametag"}, 1},
{"lig"},
})
end

View File

@ -0,0 +1 @@
--use vector.distance to count down mob despawn timer

View File

@ -81,7 +81,9 @@ mobs_mc.items = {
gunpowder = "tnt:gunpowder",
flint_and_steel = "fire:flint_and_steel",
water_source = "default:water_source",
water_flowing = "default:water_flowing",
river_water_source = "default:river_water_source",
water_flowing = "default:river_water_flowing",
black_dye = "dye:black",
poppy = "flowers:rose",
dandelion = "flowers:dandelion_yellow",

View File

@ -7,6 +7,9 @@ mobs:register_mob("mobs_mc:bat", {
spawn_class = "ambient",
can_despawn = true,
passive = true,
rotate = 270,
tilt_fly = true,
fly = true,
hp_min = 6,
hp_max = 6,
collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.89, 0.25},
@ -44,9 +47,7 @@ mobs:register_mob("mobs_mc:bat", {
fall_damage = 0,
view_range = 16,
fear_height = 0,
jump = false,
fly = true,
makes_footstep_sound = false,
})

View File

@ -17,6 +17,9 @@ mobs:register_mob("mobs_mc:blaze", {
hp_max = 20,
xp_min = 10,
xp_max = 10,
tilt_fly = false,
hostile = true,
rotate = 270,
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.79, 0.3},
rotate = -180,
visual = "mesh",
@ -35,7 +38,7 @@ mobs:register_mob("mobs_mc:blaze", {
walk_velocity = .8,
run_velocity = 1.6,
damage = 6,
reach = 2,
reach = 4, -- don't want blaze getting too close
pathfinding = 1,
drops = {
{name = mobs_mc.items.blaze_rod,
@ -63,7 +66,7 @@ mobs:register_mob("mobs_mc:blaze", {
fall_speed = -2.25,
light_damage = 0,
view_range = 16,
attack_type = "dogshoot",
attack_type = "projectile",
arrow = "mobs_mc:blaze_fireball",
shoot_interval = 3.5,
shoot_offset = 1.0,
@ -75,6 +78,13 @@ mobs:register_mob("mobs_mc:blaze", {
fear_height = 0,
glow = 14,
fire_resistant = true,
eye_height = 0.75,
shoot_arrow = function(self, pos, dir)
-- 2-4 damage per arrow
local dmg = math.random(2,4)
mcl_bows.shoot_arrow("mobs_mc:blaze_fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
end,
do_custom = function(self)
if self.state == "attack" and vector.distance(self.object:get_pos(), self.attack:get_pos()) < 1.2 then
mcl_burning.set_on_fire(self.attack, 5)
@ -147,6 +157,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
visual_size = {x = 0.3, y = 0.3},
textures = {"mcl_fire_fire_charge.png"},
velocity = 15,
speed = 5,
-- Direct hit, no fire... just plenty of pain
hit_player = function(self, player)
@ -179,7 +190,9 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
-- Node hit, make fire
hit_node = function(self, pos, node)
if node.name == "air" then
if node.name ~= "air" then
local pos_above = table.copy(pos)
pos_above.y = pos_above.y + 1
minetest.set_node(pos_above, {name=mobs_mc.items.fire})
else
local v = self.object:get_velocity()

View File

@ -25,7 +25,7 @@ mobs:register_mob("mobs_mc:chicken", {
{"mobs_mc_chicken.png"},
},
visual_size = {x=2.2, y=2.2},
rotate = 270,
makes_footstep_sound = true,
walk_velocity = 1,
drops = {
@ -69,8 +69,6 @@ mobs:register_mob("mobs_mc:chicken", {
on_rightclick = function(self, clicker)
if mobs:feed_tame(self, clicker, 1, true, true) then return end
if mobs:protect(self, clicker) then return end
if mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end
end,
do_custom = function(self, dtime)

View File

@ -9,6 +9,7 @@ local cow_def = {
hp_max = 10,
xp_min = 1,
xp_max = 3,
rotate = 270,
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.39, 0.45},
visual = "mesh",
mesh = "mobs_mc_cow.b3d",
@ -49,7 +50,6 @@ local cow_def = {
follow = mobs_mc.follow.cow,
on_rightclick = function(self, clicker)
if mobs:feed_tame(self, clicker, 1, true, true) then return end
if mobs:protect(self, clicker) then return end
if self.child then
return
@ -70,7 +70,6 @@ local cow_def = {
end
return
end
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
end,
follow = mobs_mc.items.wheat,
view_range = 10,
@ -86,7 +85,6 @@ mooshroom_def.mesh = "mobs_mc_cow.b3d"
mooshroom_def.textures = { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, {"mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } }
mooshroom_def.on_rightclick = function(self, clicker)
if mobs:feed_tame(self, clicker, 1, true, true) then return end
if mobs:protect(self, clicker) then return end
if self.child then
return
@ -139,7 +137,6 @@ mooshroom_def.on_rightclick = function(self, clicker)
minetest.add_item(pos, {name = mobs_mc.items.mushroom_stew})
end
end
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
end
mobs:register_mob("mobs_mc:mooshroom", mooshroom_def)

View File

@ -12,6 +12,8 @@ local S = minetest.get_translator("mobs_mc")
mobs:register_mob("mobs_mc:creeper", {
type = "monster",
spawn_class = "hostile",
hostile = true,
rotate = 270,
hp_min = 20,
hp_max = 20,
xp_min = 5,
@ -33,20 +35,21 @@ mobs:register_mob("mobs_mc:creeper", {
explode = "tnt_explode",
distance = 16,
},
makes_footstep_sound = true,
makes_footstep_sound = false,
walk_velocity = 1.05,
run_velocity = 2.1,
run_velocity = 3.25,
runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" },
attack_type = "explode",
eye_height = 1.25,
--hssssssssssss
explosion_strength = 3,
explosion_radius = 3.5,
explosion_damage_radius = 3.5,
explosion_strength = 10,
explosion_radius = 4,
explosion_damage_radius = 6,
explosiontimer_reset_radius = 6,
reach = 3,
explosion_timer = 1.5,
reach = 1.5,
defuse_reach = 4,
explosion_timer = 0.3,
allow_fuse_reset = true,
stop_to_explode = true,
@ -148,6 +151,7 @@ mobs:register_mob("mobs_mc:creeper_charged", {
"mobs_mc_creeper_charge.png"},
},
visual_size = {x=3, y=3},
rotate = 270,
sounds = {
attack = "tnt_ignite",
death = "mobs_mc_creeper_death",
@ -156,18 +160,19 @@ mobs:register_mob("mobs_mc:creeper_charged", {
explode = "tnt_explode",
distance = 16,
},
makes_footstep_sound = true,
makes_footstep_sound = false,
walk_velocity = 1.05,
run_velocity = 2.1,
runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" },
attack_type = "explode",
explosion_strength = 6,
explosion_radius = 8,
explosion_damage_radius = 8,
explosiontimer_reset_radius = 6,
reach = 3,
explosion_timer = 1.5,
explosion_strength = 24,
explosion_radius = 12,
explosion_damage_radius = 18,
explosiontimer_reset_radius = 10,
reach = 1.5,
defuse_reach = 4,
explosion_timer = 0.3,
allow_fuse_reset = true,
stop_to_explode = true,

View File

@ -46,7 +46,7 @@ mobs:register_mob("mobs_mc:enderdragon", {
lava_damage = 0,
fire_damage = 0,
on_rightclick = nil,
attack_type = "dogshoot",
attack_type = "projectile",
arrow = "mobs_mc:dragon_fireball",
shoot_interval = 0.5,
shoot_offset = -1.0,

View File

@ -8,12 +8,15 @@ mobs:register_mob("mobs_mc:endermite", {
type = "monster",
spawn_class = "hostile",
passive = false,
rotate = 270,
hostile = true,
hp_min = 8,
hp_max = 8,
xp_min = 3,
xp_max = 3,
armor = {fleshy = 100, arthropod = 100},
group_attack = true,
attack_type = "punch",
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.29, 0.2},
visual = "mesh",
mesh = "mobs_mc_endermite.b3d",

View File

@ -13,13 +13,16 @@ local S = minetest.get_translator("mobs_mc")
mobs:register_mob("mobs_mc:ghast", {
type = "monster",
spawn_class = "hostile",
pathfinding = 1,
group_attack = true,
hostile = true,
hp_min = 10,
hp_max = 10,
rotate = 270,
xp_min = 5,
xp_max = 5,
collisionbox = {-2, 5, -2, 2, 9, 2},
reach = 20,
eye_height = 2.5,
collisionbox = {-2, 0, -2, 2, 4, 2},
visual = "mesh",
mesh = "mobs_mc_ghast.b3d",
textures = {
@ -35,8 +38,10 @@ mobs:register_mob("mobs_mc:ghast", {
-- TODO: damage
-- TODO: better death
},
walk_velocity = 1.6,
run_velocity = 3.2,
drops = {
{name = mobs_mc.items.gunpowder, chance = 1, min = 0, max = 2, looting = "common"},
{name = mobs_mc.items.ghast_tear, chance = 10/6, min = 0, max = 1, looting = "common", looting_ignore_chance = true},
@ -47,22 +52,21 @@ mobs:register_mob("mobs_mc:ghast", {
walk_start = 0, walk_end = 40,
run_start = 0, run_end = 40,
},
fall_damage = 0,
view_range = 100,
attack_type = "dogshoot",
view_range = 28,
attack_type = "projectile",
arrow = "mobs_mc:fireball",
shoot_interval = 3.5,
shoot_offset = -5,
dogshoot_switch = 1,
dogshoot_count_max =1,
passive = false,
jump = true,
jump_height = 4,
floats=1,
fly = true,
makes_footstep_sound = false,
instant_death = true,
fire_resistant = true,
shoot_arrow = function(self, pos, dir)
-- 2-4 damage per arrow
local dmg = math.random(2,4)
mcl_bows.shoot_arrow("mobs_mc:fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
end,
--[[
do_custom = function(self)
if self.firing == true then
self.base_texture = {"mobs_mc_ghast_firing.png"}
@ -72,6 +76,7 @@ mobs:register_mob("mobs_mc:ghast", {
self.object:set_properties({textures=self.base_texture})
end
end,
]]--
})
@ -102,11 +107,14 @@ mobs:register_arrow("mobs_mc:fireball", {
if rawget(_G, "armor") and armor.last_damage_types then
armor.last_damage_types[player:get_player_name()] = "fireball"
end
--[[
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 6},
}, nil)
mobs:boom(self, self.object:get_pos(), 1, true)
]]--
--mobs:boom(self, self.object:get_pos(), 1, true)
mcl_explosions.explode(self.object:get_pos(), 3,{ drop_chance = 1.0 })
end,
hit_mob = function(self, mob)
@ -114,11 +122,13 @@ mobs:register_arrow("mobs_mc:fireball", {
full_punch_interval = 1.0,
damage_groups = {fleshy = 6},
}, nil)
mobs:boom(self, self.object:get_pos(), 1, true)
--mobs:boom(self, self.object:get_pos(), 1, true)
mcl_explosions.explode(self.object:get_pos(), 3,{ drop_chance = 1.0 })
end,
hit_node = function(self, pos, node)
mobs:boom(self, pos, 1, true)
--mobs:boom(self, pos, 1, true)
mcl_explosions.explode(self.object:get_pos(), 3,{ drop_chance = 1.0 })
end
})

View File

@ -13,7 +13,7 @@ mobs:register_mob("mobs_mc:guardian", {
xp_max = 10,
breath_max = -1,
passive = false,
attack_type = "dogfight",
attack_type = "punch",
pathfinding = 1,
view_range = 16,
walk_velocity = 2,

View File

@ -15,7 +15,7 @@ mobs:register_mob("mobs_mc:guardian_elder", {
xp_max = 10,
breath_max = -1,
passive = false,
attack_type = "dogfight",
attack_type = "punch",
pathfinding = 1,
view_range = 16,
walk_velocity = 2,

View File

@ -281,10 +281,6 @@ local horse = {
return
end
if mobs:protect(self, clicker) then
return
end
-- Make sure tamed horse is mature and being clicked by owner only
if self.tamed and not self.child and self.owner == clicker:get_player_name() then
@ -356,9 +352,6 @@ local horse = {
self.object:set_properties({stepheight = 1.1})
mobs.attach(self, clicker)
-- Used to capture horse
elseif not self.driver and iname ~= "" then
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
end
end
end,

View File

@ -133,7 +133,6 @@ mobs:register_mob("mobs_mc:llama", {
-- Feed with anything else
if mobs:feed_tame(self, clicker, 1, false, true) then return end
end
if mobs:protect(self, clicker) then return end
-- Make sure tamed llama is mature and being clicked by owner only
if self.tamed and not self.child and self.owner == clicker:get_player_name() then
@ -183,9 +182,6 @@ mobs:register_mob("mobs_mc:llama", {
mobs.attach(self, clicker)
end
-- Used to capture llama
elseif not self.driver and clicker:get_wielded_item():get_name() ~= "" then
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
end
end,

View File

@ -1,6 +1,6 @@
name = mobs_mc
author = maikerumine
description = Adds Minecraft-like monsters and animals.
depends = mcl_init, mcl_particles, mcl_mobs, mcl_wip, mcl_colors
depends = mcl_init, mcl_particles, mcl_mobs, mcl_wip
optional_depends = default, mcl_tnt, mcl_bows, mcl_throwing, mcl_fishing, bones, mesecons_materials, mobs_mc_gameconfig, doc_items

View File

@ -0,0 +1 @@
Ghast fixed by epCode - Thanks!

View File

@ -121,8 +121,6 @@ cat.sounds = {
}
cat.on_rightclick = function(self, clicker)
if mobs:feed_tame(self, clicker, 1, true, false) then return end
if mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end
if mobs:protect(self, clicker) then return end
if self.child then return end

View File

@ -19,11 +19,13 @@ mobs:register_mob("mobs_mc:parrot", {
hp_max = 6,
xp_min = 1,
xp_max = 3,
tilt_fly = true,
collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.89, 0.25},
visual = "mesh",
mesh = "mobs_mc_parrot.b3d",
textures = {{"mobs_mc_parrot_blue.png"},{"mobs_mc_parrot_green.png"},{"mobs_mc_parrot_grey.png"},{"mobs_mc_parrot_red_blue.png"},{"mobs_mc_parrot_yellow_blue.png"}},
visual_size = {x=3, y=3},
rotate = 270,
walk_velocity = 3,
run_velocity = 5,
sounds = {
@ -84,8 +86,6 @@ mobs:register_mob("mobs_mc:parrot", {
-- Feed to tame, but not breed
if mobs:feed_tame(self, clicker, 1, false, true) then return end
if mobs:protect(self, clicker) then return end
if mobs:capture_mob(self, clicker, 0, 50, 80, false, nil) then return end
end,
})

View File

@ -6,6 +6,7 @@ mobs:register_mob("mobs_mc:pig", {
type = "animal",
spawn_class = "passive",
runaway = true,
rotate = 270,
hp_min = 10,
hp_max = 10,
xp_min = 1,
@ -95,7 +96,6 @@ mobs:register_mob("mobs_mc:pig", {
if wielditem:get_name() ~= mobs_mc.items.carrot_on_a_stick then
if mobs:feed_tame(self, clicker, 1, true, true) then return end
end
if mobs:protect(self, clicker) then return end
if self.child then
return
@ -163,10 +163,6 @@ mobs:register_mob("mobs_mc:pig", {
inv:set_stack("main",self.driver:get_wield_index(), wielditem)
end
return
-- Capture pig
elseif not self.driver and clicker:get_wielded_item():get_name() ~= "" then
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
end
end,

View File

@ -30,7 +30,7 @@ mobs:register_mob("mobs_mc:polar_bear", {
walk_velocity = 1.2,
run_velocity = 2.4,
group_attack = true,
attack_type = "dogfight",
attack_type = "punch",
drops = {
-- 3/4 chance to drop raw fish (poor approximation)
{name = mobs_mc.items.fish_raw,

View File

@ -61,8 +61,6 @@ local rabbit = {
on_rightclick = function(self, clicker)
-- Feed, tame protect or capture
if mobs:feed_tame(self, clicker, 1, true, true) then return end
if mobs:protect(self, clicker) then return end
if mobs:capture_mob(self, clicker, 0, 50, 80, false, nil) then return end
end,
do_custom = function(self)
-- Easter egg: Change texture if rabbit is named “Toast”

View File

@ -63,7 +63,7 @@ mobs:register_mob("mobs_mc:sheep", {
xp_min = 1,
xp_max = 3,
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.29, 0.45},
rotate = 270,
visual = "mesh",
visual_size = {x=3, y=3},
mesh = "mobs_mc_sheepfur.b3d",
@ -195,7 +195,6 @@ mobs:register_mob("mobs_mc:sheep", {
local item = clicker:get_wielded_item()
if mobs:feed_tame(self, clicker, 1, true, true) then return end
if mobs:protect(self, clicker) then return end
if item:get_name() == mobs_mc.items.shears and not self.gotten and not self.child then
self.gotten = true
@ -251,7 +250,6 @@ mobs:register_mob("mobs_mc:sheep", {
end
return
end
if mobs:capture_mob(self, clicker, 0, 5, 70, false, nil) then return end
end,
on_breed = function(parent1, parent2)
-- Breed sheep and choose a fur color for the child.

View File

@ -14,7 +14,7 @@ local S = minetest.get_translator("mobs_mc")
mobs:register_mob("mobs_mc:shulker", {
type = "monster",
spawn_class = "hostile",
attack_type = "shoot",
attack_type = "projectile",
shoot_interval = 0.5,
arrow = "mobs_mc:shulkerbullet",
shoot_offset = 0.5,

View File

@ -43,7 +43,7 @@ mobs:register_mob("mobs_mc:silverfish", {
run_start = 0, run_end = 20,
},
view_range = 16,
attack_type = "dogfight",
attack_type = "punch",
damage = 1,
reach = 1,
})

View File

@ -15,11 +15,15 @@ local mod_bows = minetest.get_modpath("mcl_bows") ~= nil
local skeleton = {
type = "monster",
spawn_class = "hostile",
hostile = true,
rotate = 270,
hp_min = 20,
hp_max = 20,
xp_min = 6,
xp_max = 6,
breath_max = -1,
eye_height = 1.5,
projectile_cooldown = 1.5,
armor = {undead = 100, fleshy = 100},
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.98, 0.3},
pathfinding = 1,
@ -42,7 +46,7 @@ local skeleton = {
walk_velocity = 1.2,
run_velocity = 2.4,
damage = 2,
reach = 2,
reach = 3,
drops = {
{name = mobs_mc.items.arrow,
chance = 1,
@ -74,6 +78,8 @@ local skeleton = {
walk_speed = 15,
walk_start = 40,
walk_end = 60,
run_start = 40,
run_end = 60,
run_speed = 30,
shoot_start = 70,
shoot_end = 90,
@ -85,12 +91,12 @@ local skeleton = {
ignited_by_sunlight = true,
view_range = 16,
fear_height = 4,
attack_type = "dogshoot",
attack_type = "projectile",
arrow = "mcl_bows:arrow_entity",
shoot_arrow = function(self, pos, dir)
if mod_bows then
-- 2-4 damage per arrow
local dmg = math.max(4, math.random(2, 8))
local dmg = math.random(2,4)
mcl_bows.shoot_arrow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
end
end,

View File

@ -86,7 +86,7 @@ mobs:register_mob("mobs_mc:witherskeleton", {
fire_damage = 0,
light_damage = 0,
view_range = 16,
attack_type = "dogfight",
attack_type = "punch",
dogshoot_switch = 1,
dogshoot_count_max =0.5,
fear_height = 4,

View File

@ -64,6 +64,7 @@ local slime_big = {
hp_max = 16,
xp_min = 4,
xp_max = 4,
rotate = 270,
collisionbox = {-1.02, -0.01, -1.02, 1.02, 2.03, 1.02},
visual_size = {x=12.5, y=12.5},
textures = {{"mobs_mc_slime.png"}},
@ -98,8 +99,9 @@ local slime_big = {
},
fall_damage = 0,
view_range = 16,
attack_type = "dogfight",
attack_type = "jump_punch",
passive = false,
jump_only = true,
jump = true,
walk_velocity = 2.5,
run_velocity = 2.5,
@ -311,6 +313,7 @@ local magma_cube_big = {
},
walk_velocity = 4,
run_velocity = 4,
rotate = 270,
damage = 6,
reach = 3,
armor = 53,
@ -341,8 +344,9 @@ local magma_cube_big = {
light_damage = 0,
fall_damage = 0,
view_range = 16,
attack_type = "dogfight",
attack_type = "jump_punch",
passive = false,
jump_only = true,
jump = true,
jump_height = 8,
walk_chance = 0,

View File

@ -17,7 +17,7 @@ local spider = {
spawn_class = "hostile",
passive = false,
docile_by_day = true,
attack_type = "dogfight",
attack_type = "punch",
pathfinding = 1,
damage = 2,
reach = 2,

View File

@ -16,6 +16,8 @@ mobs:register_mob("mobs_mc:squid", {
xp_min = 1,
xp_max = 3,
armor = 100,
rotate = 270,
tilt_swim = true,
-- FIXME: If the squid is near the floor, it turns black
collisionbox = {-0.4, 0.0, -0.4, 0.4, 0.9, 0.4},
visual = "mesh",
@ -47,8 +49,7 @@ mobs:register_mob("mobs_mc:squid", {
},
visual_size = {x=3, y=3},
makes_footstep_sound = false,
fly = true,
fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source },
swim = true,
breathes_in_water = true,
jump = false,
view_range = 16,

View File

@ -14,7 +14,7 @@ mobs:register_mob("mobs_mc:vex", {
spawn_class = "hostile",
pathfinding = 1,
passive = false,
attack_type = "dogfight",
attack_type = "punch",
physical = false,
hp_min = 14,
hp_max = 14,

View File

@ -516,7 +516,7 @@ local function show_trade_formspec(playername, trader, tradenum)
"size[9,8.75]"
.."background[-0.19,-0.25;9.41,9.49;mobs_mc_trading_formspec_bg.png]"
..disabled_img
.."label[4,0;"..F(minetest.colorize(mcl_colors.DARK_GRAY, S(profession))).."]"
.."label[4,0;"..F(minetest.colorize("#313131", S(profession))).."]"
.."list[current_player;main;0,4.5;9,3;9]"
.."list[current_player;main;0,7.74;9,1;]"
..b_prev..b_next

View File

@ -34,7 +34,7 @@ mobs:register_mob("mobs_mc:evoker", {
walk_velocity = 0.2,
run_velocity = 1.4,
group_attack = true,
attack_type = "dogfight",
attack_type = "punch",
-- Summon vexes
custom_attack = function(self, to_attack)
local r = pr:next(2,4)

View File

@ -9,7 +9,7 @@ local mod_bows = minetest.get_modpath("mcl_bows") ~= nil
mobs:register_mob("mobs_mc:illusioner", {
type = "monster",
spawn_class = "hostile",
attack_type = "shoot",
attack_type = "projectile",
shoot_interval = 2.5,
shoot_offset = 1.5,
arrow = "mcl_bows:arrow_entity",

View File

@ -36,7 +36,7 @@ mobs:register_mob("mobs_mc:vindicator", {
reach = 2,
walk_velocity = 1.2,
run_velocity = 2.4,
attack_type = "dogfight",
attack_type = "punch",
drops = {
{name = mobs_mc.items.emerald,
chance = 1,

View File

@ -28,6 +28,9 @@ local professions = {
mobs:register_mob("mobs_mc:villager_zombie", {
type = "monster",
spawn_class = "hostile",
hostile = true,
rotate = 270,
eye_height = 1.65,
hp_min = 20,
hp_max = 20,
xp_min = 5,
@ -50,8 +53,8 @@ mobs:register_mob("mobs_mc:villager_zombie", {
damage = 3,
reach = 2,
walk_velocity = 1.2,
run_velocity = 2.4,
attack_type = "dogfight",
run_velocity = 3.5,
attack_type = "punch",
group_attack = true,
drops = {
{name = mobs_mc.items.rotten_flesh,

View File

@ -33,7 +33,7 @@ mobs:register_mob("mobs_mc:witch", {
run_velocity = 2.4,
pathfinding = 1,
group_attack = true,
attack_type = "dogshoot",
attack_type = "projectile",
arrow = "mobs_mc:potion_arrow",
shoot_interval = 2.5,
shoot_offset = 1,

View File

@ -52,7 +52,7 @@ mobs:register_mob("mobs_mc:wither", {
},
lava_damage = 0,
fire_damage = 0,
attack_type = "dogshoot",
attack_type = "projectile",
explosion_strength = 8,
dogshoot_stop = true,
arrow = "mobs_mc:wither_skull",

View File

@ -147,11 +147,7 @@ dog.specific_attack = nil
dog.on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()
if mobs:protect(self, clicker) then
return
elseif item:get_name() ~= "" and mobs:capture_mob(self, clicker, 0, 2, 80, false, nil) then
return
elseif is_food(item:get_name()) then
if is_food(item:get_name()) then
-- Feed to increase health
local hp = self.health
local hp_add = 0

View File

@ -48,6 +48,8 @@ table.insert(drops_zombie, {
local zombie = {
type = "monster",
spawn_class = "hostile",
hostile = true,
rotate = 270,
hp_min = 20,
hp_max = 20,
xp_min = 5,
@ -73,8 +75,9 @@ local zombie = {
damage = "mobs_mc_zombie_hurt",
distance = 16,
},
walk_velocity = .8,
run_velocity = 1.6,
eye_height = 1.65,
walk_velocity = 1,
run_velocity = 3.5,
damage = 3,
reach = 2,
fear_height = 4,
@ -92,7 +95,8 @@ local zombie = {
ignited_by_sunlight = true,
sunlight_damage = 2,
view_range = 16,
attack_type = "dogfight",
attack_type = "punch",
punch_timer_cooloff = 0.5,
harmed_by_heal = true,
}

View File

@ -14,13 +14,16 @@ local pigman = {
-- type="animal", passive=false: This combination is needed for a neutral mob which becomes hostile, if attacked
type = "animal",
passive = false,
neutral = true,
rotate = 270,
spawn_class = "passive",
hostile_cooldown = 15, --seconds
hp_min = 20,
hp_max = 20,
xp_min = 6,
xp_max = 6,
armor = {undead = 90, fleshy = 90},
attack_type = "dogfight",
attack_type = "punch",
group_attack = { "mobs_mc:pigman", "mobs_mc:baby_pigman" },
damage = 9,
reach = 2,

View File

@ -35,10 +35,10 @@ doc.FORMSPEC.ENTRY_HEIGHT = doc.FORMSPEC.ENTRY_END_Y - doc.FORMSPEC.ENTRY_START_
-- Internal helper variables
local DOC_INTRO = S("This is the help.")
local COLOR_NOT_VIEWED = mcl_colors.AQUA
local COLOR_VIEWED = mcl_colors.WHITE
local COLOR_HIDDEN = mcl_colors.GRAY
local COLOR_ERROR = mcl_colors.RED
local COLOR_NOT_VIEWED = "#00FFFF" -- cyan
local COLOR_VIEWED = "#FFFFFF" -- white
local COLOR_HIDDEN = "#999999" -- gray
local COLOR_ERROR = "#FF0000" -- red
local CATEGORYFIELDSIZE = {
WIDTH = math.ceil(doc.FORMSPEC.WIDTH / 4),
@ -770,7 +770,7 @@ function doc.generate_entry_list(cid, playername)
if name == nil or name == "" then
name = S("Nameless entry (@1)", eid)
if doc.entry_viewed(playername, cid, eid) then
viewedprefix = mcl_colors.RED
viewedprefix = "#FF4444"
else
viewedprefix = COLOR_ERROR
end

View File

@ -2,4 +2,3 @@ name = doc
author = Wuzzy
description = A simple in-game documentation system which enables mods to add help entries based on templates.
optional_depends = unified_inventory, sfinv_buttons, central_message, inventory_plus
depends = mcl_colors

View File

@ -667,7 +667,7 @@ local function make_formspec(name)
fs[#fs + 1] = fmt("label[%f,%f;%s]",
sfinv_only and 6.3 or data.iX - 2.2,
0.22,
ESC(colorize(mcl_colors.DARK_GRAY, fmt("%s / %u", data.pagenum, data.pagemax))))
ESC(colorize("#383838", fmt("%s / %u", data.pagenum, data.pagemax))))
fs[#fs + 1] = fmt([[
image_button[%f,0.12;0.8,0.8;craftguide_prev_icon.png;prev;]

View File

@ -447,7 +447,7 @@ function awards.getFormspec(name, to, sid)
first = false
if def.secret and not award.got then
formspec = formspec .. mcl_colors.DARK_GRAY..minetest.formspec_escape(S("(Secret Award)"))
formspec = formspec .. "#707070" .. minetest.formspec_escape(S("(Secret Award)"))
else
local title = award.name
if def and def.title then
@ -456,7 +456,7 @@ function awards.getFormspec(name, to, sid)
if award.got then
formspec = formspec .. minetest.formspec_escape(title)
else
formspec = formspec .. mcl_colors.GRAY.. minetest.formspec_escape(title)
formspec = formspec .. "#ACACAC" .. minetest.formspec_escape(title)
end
end
end

View File

@ -222,7 +222,7 @@ minetest.register_on_dieplayer(function(player, reason)
end
hittersubtype = hitter:get_luaentity().name
if hittername then
msg = dmsg("murder", name, hittername)
msg = dmsg("murder_hand", name, hittername)
elseif hittersubtype ~= nil and hittersubtype ~= "" then
msg = mmsg(hittersubtype, name)
else

View File

@ -442,7 +442,7 @@ mcl_inventory.set_creative_formspec = function(player, start_i, pagenum, inv_siz
end
local caption = ""
if name ~= "inv" and filtername[name] then
caption = "label[0,1.2;"..F(minetest.colorize(mcl_colors.DARK_GRAY, filtername[name])).."]"
caption = "label[0,1.2;"..F(minetest.colorize("#313131", filtername[name])).."]"
end
formspec = "size[10,9.3]"..

View File

@ -109,10 +109,10 @@ local function set_inventory(player, armor_change_only)
mcl_formspec.get_itemslot_bg(0,3,1,1)..
armor_slot_imgs..
-- craft and inventory
"label[0,4;"..F(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,4;"..F(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..
"label[4,0.5;"..F(minetest.colorize(mcl_colors.DARK_GRAY, S("Crafting"))).."]"..
"label[4,0.5;"..F(minetest.colorize("#313131", S("Crafting"))).."]"..
"list[current_player;craft;4,1;2,2]"..
"list[current_player;craftpreview;7,1.5;1,1;]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..

View File

@ -1,6 +1,6 @@
name = mcl_inventory
author = BlockMen
description = Adds the player inventory and creative inventory.
depends = mcl_init, mcl_formspec, mcl_colors
depends = mcl_init, mcl_formspec
optional_depends = mcl_player, _mcl_autogroup, mcl_armor, mcl_brewing, mcl_potions, mcl_enchanting

View File

@ -13,12 +13,12 @@ local S = minetest.get_translator("mcl_dispensers")
local setup_dispenser = function(pos)
-- Set formspec and inventory
local form = "size[9,8.75]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[3,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Dispenser"))).."]"..
"label[3,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Dispenser"))).."]"..
"list[current_name;main;3,0.5;3,3;]"..
mcl_formspec.get_itemslot_bg(3,0.5,3,3)..
"listring[current_name;main]"..

View File

@ -1,3 +1,3 @@
name = mcl_dispensers
depends = mcl_init, mcl_formspec, mesecons, mcl_sounds, mcl_tnt, mcl_worlds, mcl_core, mcl_nether, mcl_armor_stand, mcl_armor, mcl_colors
depends = mcl_init, mcl_formspec, mesecons, mcl_sounds, mcl_tnt, mcl_worlds, mcl_core, mcl_nether, mcl_armor_stand, mcl_armor
optional_depends = doc, screwdriver

View File

@ -14,12 +14,12 @@ local S = minetest.get_translator("mcl_droppers")
local setup_dropper = function(pos)
-- Set formspec and inventory
local form = "size[9,8.75]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[3,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Dropper"))).."]"..
"label[3,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Dropper"))).."]"..
"list[current_name;main;3,0.5;3,3;]"..
mcl_formspec.get_itemslot_bg(3,0.5,3,3)..
"listring[current_name;main]"..

View File

@ -15,10 +15,10 @@ local setup_dropper = function(pos)
-- Set formspec and inventory
local form = "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;crafting_inventory_9_slots.png]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
"list[current_player;main;0,7.74;9,1;]"..
"label[3,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Dropper"))).."]"..
"label[3,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Dropper"))).."]"..
"list[current_name;main;3,0.5;3,3;]"..
"listring[current_name;main]"..
"listring[current_player;main]"

View File

@ -1,3 +1,3 @@
name = mcl_droppers
depends = mcl_init, mcl_formspec, mesecons, mcl_util, mcl_colors
depends = mcl_init, mcl_formspec, mesecons, mcl_util
optional_depends = doc, screwdriver

View File

@ -16,7 +16,7 @@ local function get_anvil_formspec(set_name)
end
return "size[9,8.75]"..
"background[-0.19,-0.25;9.41,9.49;mcl_anvils_inventory.png]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
@ -27,7 +27,7 @@ local function get_anvil_formspec(set_name)
mcl_formspec.get_itemslot_bg(4,2.5,1,1)..
"list[context;output;8,2.5;1,1;]"..
mcl_formspec.get_itemslot_bg(8,2.5,1,1)..
"label[3,0.1;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Repair and Name"))).."]"..
"label[3,0.1;"..minetest.formspec_escape(minetest.colorize("#313131", S("Repair and Name"))).."]"..
"field[3.25,1;4,1;name;;"..minetest.formspec_escape(set_name).."]"..
"field_close_on_enter[name;false]"..
"button[7,0.7;2,1;name_button;"..minetest.formspec_escape(S("Set Name")).."]"..

View File

@ -1,5 +1,5 @@
name = mcl_anvils
author = Wuzzy
description = Anvils mods for MCL2
depends = mcl_init, mcl_formspec, mcl_sounds, tt, mcl_enchanting, mcl_colors
depends = mcl_init, mcl_formspec, mcl_sounds, tt, mcl_enchanting
optional_depends = mcl_core, screwdriver

View File

@ -1,79 +1,132 @@
# Blender v2.73 (sub 0) OBJ File: '3d_armor_entity_3.blend'
# Blender v2.92.0 OBJ File: ''
# www.blender.org
mtllib 3d_armor_entity.mtl
o Cube
v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 1.000000
vt 0.625000 0.500000
vt 0.875000 0.500000
vt 0.875000 0.750000
vt 0.625000 0.750000
vt 0.375000 0.750000
vt 0.625000 1.000000
vt 0.375000 1.000000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.250000
vt 0.125000 0.500000
vt 0.375000 0.500000
vt 0.125000 0.750000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
usemtl Material
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/3 7/9/3 5/10/3 6/11/3
f 6/12/4 2/13/4 4/5/4 8/14/4
f 2/13/5 1/1/5 3/4/5 4/5/5
f 6/11/6 5/10/6 1/1/6 2/13/6
o Player_Cube
v 2.200000 9.763893 1.200000
v 2.200000 9.763893 -1.200000
v 2.200000 9.763893 1.200001
v 2.200000 2.663871 1.200000
v 2.200000 2.663871 -1.200000
v 2.200000 9.763893 -1.200000
v -2.200000 9.763893 -1.200000
v -2.200000 9.763893 1.200000
v -2.200000 2.663871 -1.200000
v -2.200000 9.763893 1.200001
v -2.200000 2.663871 1.200000
v 2.300000 13.863962 2.300000
v 2.300000 13.863962 -2.300000
v -2.200000 2.663871 -1.200000
v 2.300000 13.863962 2.300001
v 2.300000 9.263885 2.300000
v 2.300000 9.263885 -2.300000
v -2.300000 13.863962 -2.300000
v -2.300000 13.863962 2.300000
v -2.300000 9.263885 -2.300000
v 2.300000 9.263885 -2.299999
v 2.300000 13.863962 -2.299999
v -2.300000 13.863962 -2.299999
v -2.300000 13.863962 2.300001
v -2.300000 9.263885 2.300000
v -2.300000 9.263885 -2.299999
v -2.322686 2.473175 -1.300000
v -2.322686 2.473175 1.300000
v -4.713554 2.682348 1.300000
v -4.713554 2.682348 -1.300000
v -1.686446 9.745432 -1.300000
v -1.686446 9.745432 1.300000
v -4.077313 9.954605 -1.299999
v -4.077313 9.954605 1.300000
v -4.077313 9.954605 -1.300000
v 4.077313 9.954605 -1.300000
v 4.077313 9.954605 1.300000
v -1.686446 9.745432 1.300000
v -1.686446 9.745432 -1.299999
v 1.686446 9.745432 1.300000
v 1.686446 9.745432 -1.300000
v 4.713554 2.682348 -1.300000
v 4.713554 2.682348 1.300000
v 2.322686 2.473175 1.300000
v 4.713554 2.682348 1.300000
v 4.077313 9.954605 1.300000
v 1.686446 9.745432 -1.299999
v 2.322686 2.473175 -1.300000
v 4.077313 9.954605 -1.299999
v 4.713554 2.682348 -1.300000
v 2.538733 2.980834 -1.210000
v 0.139099 2.938947 -1.200000
v 0.139099 2.938947 1.200000
v 0.261266 -4.059988 1.200000
v 0.261266 -4.059988 -1.200000
v 2.660901 -4.018101 1.190000
v 2.660901 -4.018101 -1.210000
v 2.538733 2.980834 1.190000
v 2.538733 2.980834 -1.210000
v -0.139099 2.938947 -1.200000
v -0.139099 2.938947 1.200000
v -0.261266 -4.059988 1.200000
v -0.261266 -4.059988 -1.200000
v 0.261266 -4.059988 -1.200000
v 2.660901 -4.018101 -1.210000
v 2.660901 -4.018101 1.190000
v 0.261266 -4.059988 1.200000
v -2.538734 2.980834 -1.210000
v -2.538734 2.980834 1.190000
v -0.139099 2.938947 1.200000
v -0.139099 2.938947 -1.200000
v -0.261266 -4.059988 1.200000
v -0.261266 -4.059988 -1.200000
v -2.660901 -4.018101 -1.210000
v -2.660901 -4.018101 1.190000
v 0.000000 -4.387500 -1.400000
v 0.000000 -4.387500 1.400000
v -2.799999 -4.387500 1.390000
v -2.799999 -4.387500 -1.410000
v -2.800000 -0.812499 1.390000
v -2.800000 -0.812499 -1.410000
v -0.000000 -4.387500 -1.400000
v -0.000000 -4.387500 1.400000
v -0.000000 -0.812499 1.400000
v -0.000000 -0.812499 -1.400000
v 2.800000 -0.812499 -1.410000
v 2.800000 -0.812499 1.390000
v 2.799999 -4.387500 -1.410000
v 2.799999 -4.387500 1.390000
v 0.000000 -0.812499 1.400000
v 0.000000 -0.812499 -1.400000
v 0.000000 -0.812499 -1.400000
v 0.000000 -4.387500 -1.400000
v 0.000000 -4.387500 1.400000
v 0.000000 -0.812499 1.400000
v 0.000000 -0.812499 -1.400000
v 2.267006 13.830965 2.267006
v 2.267006 13.830965 -2.267006
v 2.800000 -0.812499 -1.410000
v 2.799999 -4.387500 -1.410000
v 2.799999 -4.387500 1.390000
v 2.800000 -0.812499 1.390000
v 2.267006 13.830965 2.267007
v 2.267006 13.830965 -2.267005
v 2.267006 9.296881 -2.267005
v 2.267006 9.296881 2.267006
v 2.267006 9.296881 -2.267006
v -2.267006 13.830965 -2.267006
v -2.267006 13.830965 2.267006
v -2.267006 9.296881 -2.267006
v -2.267006 13.830965 -2.267005
v -2.267006 13.830965 2.267007
v -2.267006 9.296881 -2.267005
v -2.267006 9.296881 2.267006
v -4.168111 10.060661 1.681621
v 1.741822 -5.305762 4.169018
v 1.718504 -5.438008 3.407457
v -6.641035 -3.963995 3.407457
v 4.191429 8.586647 1.681621
v -6.617718 -3.831752 4.169018
v 4.168111 8.454401 0.920061
v -4.191429 9.928415 0.920061
v -4.191429 8.586648 1.681620
v 6.617716 -3.831752 4.169018
v 6.641035 -3.963997 3.407457
v -1.718504 -5.438006 3.407457
v 4.168111 10.060658 1.681621
v -1.741822 -5.305762 4.169018
v 4.191429 9.928414 0.920061
v -4.168111 8.454404 0.920061
vt 0.250000 0.375000
vt 0.250000 0.000000
vt 0.312500 0.000000
@ -81,6 +134,8 @@ vt 0.312500 0.375000
vt 0.437500 0.375000
vt 0.437500 0.500000
vt 0.312500 0.500000
vt 0.437500 0.500000
vt 0.437500 0.375000
vt 0.562500 0.375000
vt 0.562500 0.500000
vt 0.437500 0.000000
@ -97,97 +152,308 @@ vt 0.750000 1.000000
vt 0.625000 1.000000
vt 0.875000 0.750000
vt 0.875000 1.000000
vt 0.750000 1.000000
vt 0.750000 0.750000
vt 0.750000 0.500000
vt 0.875000 0.750000
vt 0.875000 0.500000
vt 1.000000 0.750000
vt 1.000000 0.500000
vt 0.750000 0.375000
vt 0.750000 0.500000
vt 0.812500 0.500000
vt 0.812500 0.375000
vt 0.687500 0.375000
vt 0.687500 0.500000
vt 0.750000 0.500000
vt 0.750000 0.375000
vt 0.687500 0.375000
vt 0.625000 0.375000
vt 0.625000 0.000000
vt 0.687500 0.000000
vt 0.750000 0.000000
vt 0.687500 0.000000
vt 0.812500 0.375000
vt 0.812500 0.000000
vt 0.875000 0.375000
vt 0.875000 0.000000
vt 0.812500 0.375000
vt 0.812500 0.000000
vt 0.875000 0.000000
vt 0.875000 0.375000
vt 0.750000 0.375000
vt 0.750000 0.000000
vt 0.687500 0.375000
vt 0.687500 0.000000
vt 0.687500 0.375000
vt 0.687500 0.000000
vt 0.625000 0.000000
vt 0.625000 0.375000
vt 0.750000 0.500000
vt 0.687500 0.500000
vt 0.750000 0.375000
vt 0.812500 0.375000
vt 0.812500 0.500000
vt 0.750000 0.500000
vt 0.125000 0.375000
vt 0.062500 0.375000
vt 0.062500 0.500000
vt 0.125000 0.500000
vt 0.187500 0.375000
vt 0.125000 0.375000
vt 0.125000 0.500000
vt 0.187500 0.500000
vt 0.000000 0.375000
vt 0.000000 0.000000
vt 0.062500 0.000000
vt 0.062500 0.375000
vt 0.250000 0.375000
vt 0.250000 0.000000
vt 0.187500 0.000000
vt 0.187500 0.375000
vt 0.125000 0.000000
vt 0.062500 0.000000
vt 0.187500 0.375000
vt 0.187500 0.000000
vt 0.125000 0.000000
vt 0.437500 0.875000
vt 0.437500 1.000000
vt 0.375000 1.000000
vt 0.375000 0.875000
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.656250
vt 0.250000 0.656250
vt 0.500000 0.875000
vt 0.437500 0.656250
vt 0.500000 0.656250
vt 0.375000 0.656250
vt 0.312500 1.000000
usemtl Armor
vt 0.125000 0.375000
vt 0.125000 0.375000
vt 0.125000 0.500000
vt 0.062500 0.500000
vt 0.062500 0.375000
vt 0.187500 0.375000
vt 0.125000 0.375000
vt 0.125000 0.000000
vt 0.187500 0.000000
vt 0.062500 0.000000
vt 0.125000 0.000000
vt 0.250000 0.375000
vt 0.187500 0.375000
vt 0.187500 0.000000
vt 0.250000 0.000000
vt 0.000000 0.375000
vt 0.062500 0.375000
vt 0.062500 0.000000
vt 0.000000 0.000000
vt 0.187500 0.375000
vt 0.187500 0.500000
vt 0.125000 0.500000
vt 0.125000 0.375000
vt 0.381250 0.832812
vt 0.381250 0.845312
vt 0.375000 0.845312
vt 0.375000 0.832812
vt 0.362500 0.832812
vt 0.368750 0.832812
vt 0.368750 0.810938
vt 0.362500 0.810938
vt 0.387500 0.832812
vt 0.381250 0.832812
vt 0.381250 0.810938
vt 0.387500 0.810938
vt 0.375000 0.832812
vt 0.368750 0.832812
vt 0.368750 0.810938
vt 0.375000 0.810938
vt 0.381250 0.832812
vt 0.375000 0.832812
vt 0.375000 0.810938
vt 0.381250 0.810938
vt 0.375000 0.845312
vt 0.368750 0.845312
vt 0.381250 0.832812
vt 0.381250 0.810938
vt 0.375000 0.810938
vt 0.375000 0.832812
vt 0.375000 0.832812
vt 0.375000 0.810938
vt 0.368750 0.810938
vt 0.368750 0.832812
vt 0.387500 0.832812
vt 0.387500 0.810938
vt 0.381250 0.810938
vt 0.381250 0.832812
vt 0.362500 0.832812
vt 0.362500 0.810938
vt 0.368750 0.810938
vt 0.368750 0.832812
vt 0.381250 0.832812
vt 0.375000 0.832812
vt 0.375000 0.845312
vt 0.381250 0.845312
vt 0.368750 0.845312
vt 0.375000 0.845312
vt 0.500000 0.750000
vt 0.625000 0.750000
vt 0.625000 0.500000
vt 0.500000 0.500000
vt 0.750000 0.750000
vt 0.625000 1.000000
vt 0.750000 1.000000
vt 0.875000 0.750000
vt 0.750000 0.750000
vt 0.750000 1.000000
vt 0.875000 1.000000
vt 0.750000 0.500000
vt 0.875000 0.750000
vt 0.875000 0.500000
vt 1.000000 0.750000
vt 1.000000 0.500000
vt 0.032859 0.558649
vt 0.032859 0.998468
vt 0.362724 0.998468
vt 0.362724 0.558649
vt 0.032859 0.558649
vt 0.362724 0.558649
vt 0.362724 0.998468
vt 0.032859 0.998468
vt 0.039157 0.992309
vt 0.039157 0.656118
vt 0.060169 0.656118
vt 0.060169 0.992309
vt -0.003415 0.501261
vt 0.368238 0.501261
vt 0.368238 0.563203
vt -0.003415 0.563203
vt 0.368238 0.996797
vt -0.003415 0.996797
vt -0.003415 0.934855
vt 0.368238 0.934855
vt 0.394691 0.498800
vt 0.394691 0.994336
vt 0.363720 0.994336
vt 0.363720 0.498800
vt 0.032859 0.998468
vt 0.032859 0.558649
vt 0.362724 0.558649
vt 0.362724 0.998468
vt 0.032859 0.998468
vt 0.362724 0.998468
vt 0.362724 0.558649
vt 0.032859 0.558649
vt 0.039157 0.656118
vt 0.039157 0.992309
vt 0.060169 0.992309
vt 0.060169 0.656118
vt -0.003415 0.996797
vt 0.368238 0.996797
vt 0.368238 0.934855
vt -0.003415 0.934855
vt 0.368238 0.501261
vt -0.003415 0.501261
vt -0.003415 0.563203
vt 0.368238 0.563203
vt 0.394691 0.994336
vt 0.394691 0.498800
vt 0.363720 0.498800
vt 0.363720 0.994336
vn 1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -0.0000 1.0000
vn -0.0872 -0.9962 0.0000
vn 0.0872 0.9962 0.0000
vn -0.9962 0.0872 0.0000
vn 0.9962 -0.0872 0.0000
vn -0.9962 -0.0872 0.0000
vn 0.9962 0.0872 0.0000
vn -0.0872 0.9962 0.0000
vn 0.0872 -0.9962 0.0000
vn -0.0175 0.9998 0.0000
vn 0.0175 -0.9998 0.0000
vn 0.9998 0.0175 0.0000
vn 0.0042 0.0001 1.0000
vn -0.0042 -0.0001 -1.0000
vn -0.9998 -0.0175 0.0000
vn 0.0175 0.9998 0.0000
vn 0.9998 -0.0175 0.0000
vn 0.0042 -0.0001 -1.0000
vn -0.0042 0.0001 1.0000
vn -0.9998 0.0175 0.0000
vn -0.0175 -0.9998 0.0000
vn -0.0036 -0.0000 1.0000
vn 0.0036 0.0000 -1.0000
vn -0.0036 0.0000 -1.0000
vn 0.0036 -0.0000 1.0000
vn 0.0302 0.1710 0.9848
vn -0.0302 -0.1710 -0.9848
vn 0.1710 0.9698 -0.1737
vn 0.9848 -0.1736 0.0000
vn -0.9848 0.1736 -0.0000
vn -0.1710 -0.9698 0.1736
vn -0.0302 0.1710 0.9848
vn 0.0302 -0.1710 -0.9848
vn -0.1710 0.9698 -0.1736
vn 0.9848 0.1736 0.0000
vn -0.9848 -0.1736 -0.0000
vn 0.1710 -0.9698 0.1736
usemtl None
s off
f 1/1 3/2 4/3 2/4
f 5/5 6/6 1/7 2/4
f 8/6 7/5 4/8 3/9
f 5/5 2/4 4/3 7/10
f 7/10 8/11 6/12 5/5
f 8/11 3/13 1/14 6/12
f 9/15 11/16 12/17 10/18
f 13/19 14/20 9/21 10/18
f 12/22 11/23 16/20 15/19
f 13/19 10/18 12/17 15/24
f 14/22 13/19 15/24 16/25
f 9/26 14/22 16/25 11/27
f 17/28 18/24 19/29 20/30
f 24/31 23/32 22/24 21/28
f 23/31 24/14 20/13 19/33
f 24/31 21/28 17/34 20/33
f 21/28 22/30 18/35 17/34
f 22/30 23/36 19/37 18/35
f 27/30 31/35 30/37 26/36
f 28/28 32/34 31/35 27/30
f 25/31 29/33 32/34 28/28
f 26/31 30/33 29/13 25/14
f 25/31 28/28 27/24 26/32
f 32/28 29/30 30/29 31/24
f 40/38 33/39 34/40 39/41
f 36/42 38/38 37/41 35/43
f 39/44 37/45 38/46 40/39
f 34/1 35/2 37/47 39/42
f 40/38 38/48 36/46 33/39
f 33/42 36/47 35/48 34/38
f 45/38 46/41 42/40 41/39
f 41/42 42/38 43/48 44/47
f 45/38 41/39 44/46 47/48
f 42/1 46/42 48/47 43/2
f 46/44 45/39 47/46 48/45
f 44/42 43/43 48/41 47/38
f 53/49 54/50 49/51 50/52
f 51/53 52/54 50/55 49/56
f 55/57 51/49 49/58 54/59
f 52/52 56/54 53/55 50/60
f 56/49 55/52 54/60 53/58
f 52/52 51/51 55/61 56/54
f 64/49 61/58 62/60 63/52
f 57/52 59/60 61/55 64/54
f 63/57 62/59 60/58 58/49
f 58/53 60/56 59/55 57/54
f 61/49 59/52 60/51 62/50
f 57/52 64/54 63/61 58/51
f 65/15 66/18 68/17 67/16
f 69/19 66/18 65/21 70/20
f 68/22 71/19 72/20 67/23
f 69/19 71/24 68/17 66/18
f 70/22 72/25 71/24 69/19
f 65/26 67/27 72/25 70/22
f 9/15/7 10/16/7 11/17/7 12/18/7
f 13/19/8 14/20/8 9/21/8 12/18/8
f 15/22/9 16/23/9 11/24/9 10/25/9
f 13/19/10 12/18/10 11/17/10 16/26/10
f 16/26/11 15/27/11 14/28/11 13/19/11
f 15/27/12 10/29/12 9/30/12 14/28/12
f 17/31/7 18/32/7 19/33/7 20/34/7
f 21/35/8 22/36/8 17/37/8 20/34/8
f 19/38/9 18/39/9 23/40/9 24/41/9
f 21/35/10 20/34/10 19/33/10 24/42/10
f 22/43/11 21/35/11 24/42/11 23/44/11
f 17/45/12 22/43/12 23/44/12 18/46/12
f 25/47/13 26/48/13 27/49/13 28/50/13
f 29/51/14 30/52/14 31/53/14 32/54/14
f 30/55/15 29/56/15 28/57/15 27/58/15
f 29/51/10 32/54/10 25/59/10 28/60/10
f 32/54/16 31/61/16 26/62/16 25/59/16
f 31/61/12 30/63/12 27/64/12 26/62/12
f 33/65/12 34/66/12 35/67/12 36/68/12
f 37/69/17 38/70/17 34/66/17 33/65/17
f 39/71/10 40/72/10 38/70/10 37/69/10
f 36/73/18 35/74/18 40/75/18 39/76/18
f 39/71/19 37/69/19 33/77/19 36/78/19
f 38/79/20 40/80/20 35/81/20 34/82/20
f 41/83/21 42/84/21 43/85/21 44/86/21
f 45/87/22 46/88/22 47/89/22 48/90/22
f 44/91/23 47/92/23 46/93/23 41/94/23
f 43/95/24 48/96/24 47/97/24 44/98/24
f 41/83/25 46/99/25 45/100/25 42/84/25
f 42/101/26 45/102/26 48/103/26 43/104/26
f 49/105/27 50/106/27 51/107/27 52/108/27
f 52/109/28 51/110/28 53/111/28 54/112/28
f 49/105/29 52/108/29 54/113/29 55/114/29
f 51/115/30 50/116/30 56/117/30 53/118/30
f 50/119/31 49/120/31 55/121/31 56/122/31
f 54/123/32 53/124/32 56/125/32 55/126/32
f 57/127/9 58/128/9 59/129/9 60/130/9
f 61/131/11 62/132/11 60/133/11 59/134/11
f 63/135/33 61/136/33 59/137/33 58/138/33
f 62/139/34 64/140/34 57/141/34 60/142/34
f 64/143/7 63/144/7 58/145/7 57/146/7
f 62/139/8 61/147/8 63/148/8 64/140/8
f 65/149/11 66/150/11 67/151/11 68/152/11
f 69/153/35 70/154/35 66/155/35 65/156/35
f 68/157/36 67/158/36 71/159/36 72/160/36
f 72/161/7 71/162/7 70/163/7 69/164/7
f 66/165/9 70/166/9 71/167/9 67/168/9
f 69/153/8 65/156/8 68/169/8 72/170/8
f 73/171/11 74/172/11 75/173/11 76/174/11
f 77/175/9 74/172/9 73/176/9 78/177/9
f 75/178/8 79/179/8 80/180/8 76/181/8
f 77/175/12 79/182/12 75/173/12 74/172/12
f 78/183/7 80/184/7 79/182/7 77/175/7
f 73/185/10 76/186/10 80/184/10 78/183/10
f 85/187/37 81/188/37 86/189/37 82/190/37
f 87/191/38 83/192/38 84/193/38 88/194/38
f 81/195/39 85/196/39 87/197/39 88/198/39
f 85/199/40 82/200/40 83/201/40 87/202/40
f 86/203/41 81/204/41 88/205/41 84/206/41
f 82/207/42 86/208/42 84/209/42 83/210/42
f 93/211/43 89/212/43 94/213/43 90/214/43
f 95/215/44 91/216/44 92/217/44 96/218/44
f 89/219/45 93/220/45 95/221/45 96/222/45
f 93/223/46 90/224/46 91/225/46 95/226/46
f 94/227/47 89/228/47 96/229/47 92/230/47
f 90/231/48 94/232/48 92/233/48 91/234/48

View File

@ -1,23 +1,95 @@
local S = minetest.get_translator("mcl_beds")
local function destruct_bed(pos, oldnode)
local node = oldnode or minetest.get_node(pos)
local minetest_get_node = minetest.get_node
local minetest_get_node_or_nil = minetest.get_node_or_nil
local minetest_remove_node = minetest.remove_node
local minetest_facedir_to_dir = minetest.facedir_to_dir
local minetest_add_item = minetest.add_item
local vector_add = vector.add
local vector_subtract = vector.subtract
local function get_bed_next_node(pos, node)
local node = node or minetest_get_node_or_nil(pos)
if not node then return end
local dir = minetest.facedir_to_dir(node.param2)
local pos2, node2
local dir = minetest_facedir_to_dir(node.param2)
local pos2, bottom
if string.sub(node.name, -4) == "_top" then
pos2 = vector.subtract(pos, dir)
node2 = minetest.get_node(pos2)
if node2 and string.sub(node2.name, -7) == "_bottom" then
minetest.remove_node(pos2)
pos2 = vector_subtract(pos, dir)
else
pos2 = vector_add(pos, dir)
bottom = true
end
minetest.check_for_falling(pos)
elseif string.sub(node.name, -7) == "_bottom" then
minetest.add_item(pos, node.name)
pos2 = vector.add(pos, dir)
node2 = minetest.get_node(pos2)
local node2 = minetest_get_node(pos2)
return pos2, node2, bottom, dir
end
local function rotate(pos, node, user, mode, new_param2)
if mode ~= screwdriver.ROTATE_FACE then
return false
end
local p, node2, bottom = get_bed_next_node(pos, node)
if not node2 then return end
local name = node2.name
if not minetest.get_item_group(name, "bed") == 2 or not node.param2 == node2.param2 then return false end
if bottom then
name = string.sub(name, 1, -5)
else
name = string.sub(name, 1, -8)
end
if minetest.is_protected(p, user:get_player_name()) then
minetest.record_protection_violation(p, user:get_player_name())
return false
end
local new_dir, newp = minetest_facedir_to_dir(new_param2)
if bottom then
newp = vector_add(pos, new_dir)
else
newp = vector_subtract(pos, new_dir)
end
local node3 = minetest_get_node_or_nil(newp)
if not node3 then return false end
local node_def = minetest.registered_nodes[node3.name]
if not node_def or not node_def.buildable_to then return false end
if minetest.is_protected(newp, user:get_player_name()) then
minetest.record_protection_violation(newp, user:get_player_name())
return false
end
node.param2 = new_param2
-- do not remove_node here - it will trigger destroy_bed()
minetest.swap_node(p, {name = "air"})
minetest.swap_node(pos, node)
minetest.swap_node(newp, {name = name .. (bottom and "_top" or "_bottom"), param2 = new_param2})
return true
end
local function destruct_bed(pos, oldnode)
local node = oldnode or minetest_get_node_or_nil(pos)
if not node then return end
local pos2, node2, bottom = get_bed_next_node(pos, oldnode)
if bottom then
minetest_add_item(pos, node.name)
if node2 and string.sub(node2.name, -4) == "_top" then
minetest.remove_node(pos2)
minetest_remove_node(pos2)
end
else
if node2 and string.sub(node2.name, -7) == "_bottom" then
minetest_remove_node(pos2)
end
end
end
@ -94,7 +166,7 @@ function mcl_beds.register_bed(name, def)
local under = pointed_thing.under
-- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node(under)
local node = minetest_get_node(under)
if placer and not placer:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
@ -102,7 +174,7 @@ function mcl_beds.register_bed(name, def)
end
local pos
local undername = minetest.get_node(under).name
local undername = minetest_get_node(under).name
if minetest.registered_items[undername] and minetest.registered_items[undername].buildable_to then
pos = under
else
@ -115,13 +187,13 @@ function mcl_beds.register_bed(name, def)
return itemstack
end
local node_def = minetest.registered_nodes[minetest.get_node(pos).name]
local node_def = minetest.registered_nodes[minetest_get_node(pos).name]
if not node_def or not node_def.buildable_to then
return itemstack
end
local dir = minetest.dir_to_facedir(placer:get_look_dir())
local botpos = vector.add(pos, minetest.facedir_to_dir(dir))
local botpos = vector_add(pos, minetest_facedir_to_dir(dir))
if minetest.is_protected(botpos, placer:get_player_name()) and
not minetest.check_player_privs(placer, "protection_bypass") then
@ -129,7 +201,7 @@ function mcl_beds.register_bed(name, def)
return itemstack
end
local botdef = minetest.registered_nodes[minetest.get_node(botpos).name]
local botdef = minetest.registered_nodes[minetest_get_node(botpos).name]
if not botdef or not botdef.buildable_to then
return itemstack
end
@ -152,38 +224,7 @@ function mcl_beds.register_bed(name, def)
return itemstack
end,
on_rotate = function(pos, node, user, mode, new_param2)
local dir = minetest.facedir_to_dir(node.param2)
local p = vector.add(pos, dir)
local node2 = minetest.get_node_or_nil(p)
if not node2 or not minetest.get_item_group(node2.name, "bed") == 2 or
not node.param2 == node2.param2 then
return false
end
if minetest.is_protected(p, user:get_player_name()) then
minetest.record_protection_violation(p, user:get_player_name())
return false
end
if mode ~= screwdriver.ROTATE_FACE then
return false
end
local newp = vector.add(pos, minetest.facedir_to_dir(new_param2))
local node3 = minetest.get_node_or_nil(newp)
local node_def = node3 and minetest.registered_nodes[node3.name]
if not node_def or not node_def.buildable_to then
return false
end
if minetest.is_protected(newp, user:get_player_name()) then
minetest.record_protection_violation(newp, user:get_player_name())
return false
end
node.param2 = new_param2
-- do not remove_node here - it will trigger destroy_bed()
minetest.set_node(p, {name = "air"})
minetest.set_node(pos, node)
minetest.set_node(newp, {name = name .. "_top", param2 = new_param2})
return true
end,
on_rotate = rotate,
})
local node_box_top, selection_box_top, collision_box_top
@ -217,7 +258,7 @@ function mcl_beds.register_bed(name, def)
mcl_beds.on_rightclick(pos, clicker, true)
return itemstack
end,
on_rotate = false,
on_rotate = rotate,
after_destruct = destruct_bed,
})

View File

@ -301,7 +301,11 @@ function mcl_beds.on_rightclick(pos, player, is_top)
local dim = mcl_worlds.pos_to_dimension(pos)
if dim == "nether" or dim == "end" then
-- Bed goes BOOM in the Nether or End.
local node = minetest.get_node(pos)
local dir = minetest.facedir_to_dir(node.param2)
minetest.remove_node(pos)
minetest.remove_node(string.sub(node.name, -4) == "_top" and vector.subtract(pos, dir) or vector.add(pos, dir))
if explosions_mod then
mcl_explosions.explode(pos, 5, {drop_chance = 1.0, fire = true})
end

View File

@ -45,7 +45,7 @@ local alldirs = {{x=0,y=0,z=1}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=-1,y=0,z=0}, {
minetest.register_node("mcl_blackstone:blackstone", {
description = S("Blackstone"),
tiles = {"mcl_blackstone.png"},
tiles = {"mcl_blackstone_top.png", "mcl_blackstone_top.png", "mcl_blackstone_side.png"},
sounds = mcl_sounds.node_sound_stone_defaults(),
is_ground_content = false,
groups = {cracky = 3, pickaxey=2, material_stone=1},
@ -55,7 +55,7 @@ minetest.register_node("mcl_blackstone:blackstone", {
minetest.register_node("mcl_blackstone:blackstone_gilded", {
description = S("Gilded Blackstone"),
tiles = {"mcl_blackstone.png^mcl_blackstone_gilded_side.png"},
tiles = {"mcl_blackstone_side.png^mcl_blackstone_gilded_side.png"},
sounds = mcl_sounds.node_sound_stone_defaults(),
is_ground_content = false,
groups = {cracky = 3, pickaxey=2, material_stone=1, xp=1},

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -147,8 +147,8 @@ minetest.register_on_player_receive_fields(function ( player, formname, fields )
local formspec = "size[8,9]"..
header..
"background[-0.5,-0.5;9,10;mcl_books_book_bg.png]"..
"field[0.75,1;7.25,1;title;"..minetest.formspec_escape(minetest.colorize(mcl_colors.BLACK, S("Enter book title:")))..";]"..
"label[0.75,1.5;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("by @1", name))).."]"..
"field[0.75,1;7.25,1;title;"..minetest.formspec_escape(minetest.colorize("#000000", S("Enter book title:")))..";]"..
"label[0.75,1.5;"..minetest.formspec_escape(minetest.colorize("#404040", S("by @1", name))).."]"..
"button_exit[0.75,7.95;3,1;sign;"..minetest.formspec_escape(S("Sign and Close")).."]"..
"tooltip[sign;"..minetest.formspec_escape(S("Note: The book will no longer be editable after signing")).."]"..
"button[4.25,7.95;3,1;cancel;"..minetest.formspec_escape(S("Cancel")).."]"

View File

@ -4,8 +4,8 @@ local function active_brewing_formspec(fuel_percent, brew_percent)
return "size[9,8.75]"..
"background[-0.19,-0.25;9.5,9.5;mcl_brewing_inventory.png]"..
"label[4,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Brewing Stand"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[4,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Brewing Stand"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.75;9,1;]"..
@ -35,8 +35,8 @@ end
local brewing_formspec = "size[9,8.75]"..
"background[-0.19,-0.25;9.5,9.5;mcl_brewing_inventory.png]"..
"label[4,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Brewing Stand"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[4,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Brewing Stand"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.75;9,1;]"..

View File

@ -1,4 +1,4 @@
name = mcl_brewing
author = bzoss
depends = mcl_init, mcl_formspec, mcl_sounds, mcl_potions, mcl_mobitems, mcl_colors
depends = mcl_init, mcl_formspec, mcl_sounds, mcl_potions, mcl_mobitems
optional_depends = mcl_core, doc, screwdriver

View File

@ -475,10 +475,10 @@ minetest.register_node(small_name, {
minetest.show_formspec(clicker:get_player_name(),
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
"size[9,8.75]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, name)).."]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
@ -624,12 +624,12 @@ minetest.register_node(left_name, {
minetest.show_formspec(clicker:get_player_name(),
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
"size[9,11.5]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, name)).."]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]"..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,3.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,3.5,9,3)..
"label[0,7;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,7.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,7.5,9,3)..
"list[current_player;main;0,10.75;9,1;]"..
@ -773,12 +773,12 @@ minetest.register_node("mcl_chests:"..basename.."_right", {
"mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z,
"size[9,11.5]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, name)).."]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]"..
"list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,3.5,9,3)..
"label[0,7;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,7;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,7.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,7.5,9,3)..
"list[current_player;main;0,10.75;9,1;]"..
@ -986,10 +986,10 @@ minetest.register_node("mcl_chests:ender_chest", {
})
local formspec_ender_chest = "size[9,8.75]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Ender Chest"))).."]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Ender Chest"))).."]"..
"list[current_player;enderchest;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
@ -1107,10 +1107,10 @@ local function formspec_shulker_box(name)
name = S("Shulker Box")
end
return "size[9,8.75]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, name)).."]"..
"label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]"..
"list[current_name;main;0,0.5;9,3;]"..
mcl_formspec.get_itemslot_bg(0,0.5,9,3)..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..

View File

@ -1,3 +1,3 @@
name = mcl_chests
depends = mcl_init, mcl_formspec, mcl_core, mcl_sounds, mcl_end, mesecons, mcl_colors
depends = mcl_init, mcl_formspec, mcl_core, mcl_sounds, mcl_end, mesecons
optional_depends = doc, screwdriver

View File

@ -8,7 +8,7 @@ if mod_screwdriver then
end
-- Register tree trunk (wood) and bark
local register_tree_trunk = function(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark)
local register_tree_trunk = function(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_varient)
minetest.register_node("mcl_core:"..subname, {
description = description_trunk,
_doc_items_longdesc = longdesc,
@ -22,6 +22,7 @@ local register_tree_trunk = function(subname, description_trunk, description_bar
on_rotate = on_rotate,
_mcl_blast_resistance = 2,
_mcl_hardness = 2,
_mcl_stripped_varient = stripped_varient,
})
minetest.register_node("mcl_core:"..subname.."_bark", {
@ -37,6 +38,7 @@ local register_tree_trunk = function(subname, description_trunk, description_bar
on_rotate = on_rotate,
_mcl_blast_resistance = 2,
_mcl_hardness = 2,
_mcl_stripped_varient = stripped_varient.."_bark",
})
minetest.register_craft({
@ -214,12 +216,12 @@ end
---------------------
register_tree_trunk("tree", S("Oak Wood"), S("Oak Bark"), S("The trunk of an oak tree."), "default_tree_top.png", "default_tree.png")
register_tree_trunk("darktree", S("Dark Oak Wood"), S("Dark Oak Bark"), S("The trunk of a dark oak tree."), "mcl_core_log_big_oak_top.png", "mcl_core_log_big_oak.png")
register_tree_trunk("acaciatree", S("Acacia Wood"), S("Acacia Bark"), S("The trunk of an acacia."), "default_acacia_tree_top.png", "default_acacia_tree.png")
register_tree_trunk("sprucetree", S("Spruce Wood"), S("Spruce Bark"), S("The trunk of a spruce tree."), "mcl_core_log_spruce_top.png", "mcl_core_log_spruce.png")
register_tree_trunk("birchtree", S("Birch Wood"), S("Birch Bark"), S("The trunk of a birch tree."), "mcl_core_log_birch_top.png", "mcl_core_log_birch.png")
register_tree_trunk("jungletree", S("Jungle Wood"), S("Jungle Bark"), S("The trunk of a jungle tree."), "default_jungletree_top.png", "default_jungletree.png")
register_tree_trunk("tree", S("Oak Wood"), S("Oak Bark"), S("The trunk of an oak tree."), "default_tree_top.png", "default_tree.png", "mcl_core:stripped_oak")
register_tree_trunk("darktree", S("Dark Oak Wood"), S("Dark Oak Bark"), S("The trunk of a dark oak tree."), "mcl_core_log_big_oak_top.png", "mcl_core_log_big_oak.png", "mcl_core:stripped_dark_oak")
register_tree_trunk("acaciatree", S("Acacia Wood"), S("Acacia Bark"), S("The trunk of an acacia."), "default_acacia_tree_top.png", "default_acacia_tree.png", "mcl_core:stripped_acacia")
register_tree_trunk("sprucetree", S("Spruce Wood"), S("Spruce Bark"), S("The trunk of a spruce tree."), "mcl_core_log_spruce_top.png", "mcl_core_log_spruce.png", "mcl_core:stripped_spruce")
register_tree_trunk("birchtree", S("Birch Wood"), S("Birch Bark"), S("The trunk of a birch tree."), "mcl_core_log_birch_top.png", "mcl_core_log_birch.png", "mcl_core:stripped_birch")
register_tree_trunk("jungletree", S("Jungle Wood"), S("Jungle Bark"), S("The trunk of a jungle tree."), "default_jungletree_top.png", "default_jungletree.png", "mcl_core:stripped_jungle")
register_stripped_trunk("stripped_oak", S("Stripped Oak Log"), S("Stripped Oak Wood"), S("The stripped trunk of an oak tree."), "mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_side.png")
register_stripped_trunk("stripped_acacia", S("Stripped Acacia Log"), S("Stripped Acacia Wood"), S("The stripped trunk of an acacia tree."), "mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_side.png")

View File

@ -2,7 +2,7 @@ local S = minetest.get_translator("mcl_crafting_table")
local formspec_escape = minetest.formspec_escape
local show_formspec = minetest.show_formspec
local C = minetest.colorize
local text_color = mcl_colors.DARK_GRAY
local text_color = "#313131"
local itemslot_bg = mcl_formspec.get_itemslot_bg
mcl_crafting_table = {}

View File

@ -469,13 +469,13 @@ function mcl_enchanting.show_enchanting_formspec(player)
local formspec = ""
.. "size[9.07,8.6;]"
.. "formspec_version[3]"
.. "label[0,0;" .. C(mcl_colors.DARK_GRAY) .. F(table_name) .. "]"
.. "label[0,0;" .. C("#313131") .. F(table_name) .. "]"
.. mcl_formspec.get_itemslot_bg(0.2, 2.4, 1, 1)
.. "list[current_player;enchanting_item;0.2,2.4;1,1]"
.. mcl_formspec.get_itemslot_bg(1.1, 2.4, 1, 1)
.. "image[1.1,2.4;1,1;mcl_enchanting_lapis_background.png]"
.. "list[current_player;enchanting_lapis;1.1,2.4;1,1]"
.. "label[0,4;" .. C(mcl_colors.DARK_GRAY) .. F(S("Inventory")).."]"
.. "label[0,4;" .. C("#313131") .. F(S("Inventory")).."]"
.. mcl_formspec.get_itemslot_bg(0, 4.5, 9, 3)
.. mcl_formspec.get_itemslot_bg(0, 7.74, 9, 1)
.. "list[current_player;main;0,4.5;9,3;9]"
@ -502,11 +502,11 @@ function mcl_enchanting.show_enchanting_formspec(player)
local hover_ending = (can_enchant and "_hovered" or "_off")
formspec = formspec
.. "container[3.2," .. y .. "]"
.. (slot and "tooltip[button_" .. i .. ";" .. C(mcl_colors.GRAY) .. ((slot.description and F(slot.description)) or "") .. " " .. C(mcl_colors.WHITE) .. " . . . ?\n\n" .. (enough_levels and C(enough_lapis and mcl_colors.GRAY or mcl_colors.RED) .. F(S("@1 Lapis Lazuli", i)) .. "\n" .. C(mcl_colors.GRAY) .. F(S("@1 Enchantment Levels", i)) or C(mcl_colors.RED) .. F(S("Level requirement: @1", slot.level_requirement))) .. "]" or "")
.. (slot and "tooltip[button_" .. i .. ";" .. C("#818181") .. ((slot.description and F(slot.description)) or "") .. " " .. C("#FFFFFF") .. " . . . ?\n\n" .. (enough_levels and C(enough_lapis and "#818181" or "#FC5454") .. F(S("@1 Lapis Lazuli", i)) .. "\n" .. C("#818181") .. F(S("@1 Enchantment Levels", i)) or C("#FC5454") .. F(S("Level requirement: @1", slot.level_requirement))) .. "]" or "")
.. "style[button_" .. i .. ";bgimg=mcl_enchanting_button" .. ending .. ".png;bgimg_hovered=mcl_enchanting_button" .. hover_ending .. ".png;bgimg_pressed=mcl_enchanting_button" .. hover_ending .. ".png]"
.. "button[0,0;7.5,1.3;button_" .. i .. ";]"
.. (slot and "image[0,0;1.3,1.3;mcl_enchanting_number_" .. i .. ending .. ".png]" or "")
.. (slot and "label[7.2,1.1;" .. C(can_enchant and mcl_colors.GREEN or mcl_colors.DARK_GREEN) .. slot.level_requirement .. "]" or "")
.. (slot and "label[7.2,1.1;" .. C(can_enchant and "#80FF20" or "#407F10") .. slot.level_requirement .. "]" or "")
.. (slot and slot.glyphs or "")
.. "container_end[]"
y = y + 1.35

View File

@ -15,7 +15,9 @@ local function register_rocket(n, duration, force)
local elytra = mcl_playerplus.elytra[user]
if elytra.active and elytra.rocketing <= 0 then
elytra.rocketing = duration
if not minetest.is_creative_enabled(user:get_player_name()) then
itemstack:take_item()
end
minetest.sound_play("mcl_fireworks_rocket", {pos = user:get_pos()})
end
return itemstack

View File

@ -9,12 +9,12 @@ local LIGHT_ACTIVE_FURNACE = 13
local function active_formspec(fuel_percent, item_percent)
return "size[9,8.75]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Furnace"))).."]"..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Furnace"))).."]"..
"list[current_name;src;2.75,0.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.75,0.5,1,1)..
"list[current_name;fuel;2.75,2.5;1,1;]"..
@ -38,12 +38,12 @@ local function active_formspec(fuel_percent, item_percent)
end
local inactive_formspec = "size[9,8.75]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))).."]"..
"label[0,4;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]"..
"list[current_player;main;0,4.5;9,3;9]"..
mcl_formspec.get_itemslot_bg(0,4.5,9,3)..
"list[current_player;main;0,7.74;9,1;]"..
mcl_formspec.get_itemslot_bg(0,7.74,9,1)..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Furnace"))).."]"..
"label[2.75,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Furnace"))).."]"..
"list[current_name;src;2.75,0.5;1,1;]"..
mcl_formspec.get_itemslot_bg(2.75,0.5,1,1)..
"list[current_name;fuel;2.75,2.5;1,1;]"..

Some files were not shown because too many files have changed in this diff Show More