1
0
Fork 0

Merge branch 'master' of ssh://git.minetest.land:29418/MineClone2/MineClone2

This commit is contained in:
AFCMS 2021-09-29 19:59:33 +02:00
commit e40ed91674
8 changed files with 75 additions and 85 deletions

View File

@ -67,14 +67,9 @@ function mcl_burning.set_on_fire(obj, burn_time)
end end
if not storage.burn_time or burn_time >= storage.burn_time then if not storage.burn_time or burn_time >= storage.burn_time then
if obj:is_player() and not storage.fire_hud_id then if obj:is_player() then
storage.fire_hud_id = obj:hud_add({ mcl_burning.channels[obj]:send_all(tostring(mcl_burning.animation_frames))
hud_elem_type = "image", mcl_burning.channels[obj]:send_all("start")
position = {x = 0.5, y = 0.5},
scale = {x = -100, y = -100},
text = "mcl_burning_entity_flame_animated.png^[opacity:180^[verticalframe:" .. mcl_burning.animation_frames .. ":" .. 1,
z_index = 1000,
})
end end
storage.burn_time = burn_time storage.burn_time = burn_time
storage.fire_damage_timer = 0 storage.fire_damage_timer = 0
@ -95,7 +90,6 @@ function mcl_burning.set_on_fire(obj, burn_time)
fire_entity:set_properties({visual_size = size}) fire_entity:set_properties({visual_size = size})
fire_entity:set_attach(obj, "", offset, {x = 0, y = 0, z = 0}) fire_entity:set_attach(obj, "", offset, {x = 0, y = 0, z = 0})
local fire_luaentity = fire_entity:get_luaentity() local fire_luaentity = fire_entity:get_luaentity()
fire_luaentity:update_frame(obj, storage)
for _, other in pairs(minetest.get_objects_inside_radius(fire_entity:get_pos(), 0)) do for _, other in pairs(minetest.get_objects_inside_radius(fire_entity:get_pos(), 0)) do
local other_luaentity = other:get_luaentity() local other_luaentity = other:get_luaentity()
@ -111,9 +105,7 @@ function mcl_burning.extinguish(obj)
if mcl_burning.is_burning(obj) then if mcl_burning.is_burning(obj) then
local storage = mcl_burning.get_storage(obj) local storage = mcl_burning.get_storage(obj)
if obj:is_player() then if obj:is_player() then
if storage.fire_hud_id then mcl_burning.channels[obj]:send_all("stop")
obj:hud_remove(storage.fire_hud_id)
end
mcl_burning.storage[obj] = {} mcl_burning.storage[obj] = {}
else else
storage.burn_time = nil storage.burn_time = nil
@ -143,4 +135,4 @@ function mcl_burning.tick(obj, dtime, storage)
end end
end end
end end
end end

View File

@ -7,6 +7,7 @@ local get_item_group = minetest.get_item_group
mcl_burning = { mcl_burning = {
storage = {}, storage = {},
channels = {},
animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8 animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8
} }
@ -54,12 +55,11 @@ minetest.register_on_joinplayer(function(player)
end end
mcl_burning.storage[player] = storage mcl_burning.storage[player] = storage
mcl_burning.channels[player] = minetest.mod_channel_join("mcl_burning:" .. player:get_player_name())
end) end)
minetest.register_on_leaveplayer(function(player) minetest.register_on_leaveplayer(function(player)
local storage = mcl_burning.storage[player] player:get_meta():set_string("mcl_burning:data", minetest.serialize(mcl_burning.storage[player]))
storage.fire_hud_id = nil
player:get_meta():set_string("mcl_burning:data", minetest.serialize(storage))
mcl_burning.storage[player] = nil mcl_burning.storage[player] = nil
end) end)
@ -68,27 +68,28 @@ minetest.register_entity("mcl_burning:fire", {
initial_properties = { initial_properties = {
physical = false, physical = false,
collisionbox = {0, 0, 0, 0, 0, 0}, collisionbox = {0, 0, 0, 0, 0, 0},
visual = "cube", visual = "upright_sprite",
textures = {
name = "mcl_burning_entity_flame_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.0,
},
},
spritediv = {x = 1, y = mcl_burning.animation_frames},
pointable = false, pointable = false,
glow = -1, glow = -1,
backface_culling = false, backface_culling = false,
}, },
animation_frame = 0, animation_frame = 0,
animation_timer = 0, animation_timer = 0,
on_step = function(self, dtime) on_activate = function(self)
local parent, storage = self:sanity_check() self.object:set_sprite({x = 0, y = 0}, mcl_burning.animation_frames, 1.0 / mcl_burning.animation_frames)
end,
if parent then on_step = function(self)
self.animation_timer = self.animation_timer + dtime if not self:sanity_check() then
if self.animation_timer >= 0.1 then
self.animation_timer = 0
self.animation_frame = self.animation_frame + 1
if self.animation_frame > mcl_burning.animation_frames - 1 then
self.animation_frame = 0
end
self:update_frame(parent, storage)
end
else
self.object:remove() self.object:remove()
end end
end, end,
@ -96,23 +97,15 @@ minetest.register_entity("mcl_burning:fire", {
local parent = self.object:get_attach() local parent = self.object:get_attach()
if not parent then if not parent then
return return false
end end
local storage = mcl_burning.get_storage(parent) local storage = mcl_burning.get_storage(parent)
if not storage or not storage.burn_time then if not storage or not storage.burn_time then
return return false
end end
return parent, storage return true
end,
update_frame = function(self, parent, storage)
local frame_overlay = "^[opacity:180^[verticalframe:" .. mcl_burning.animation_frames .. ":" .. self.animation_frame
local fire_texture = "mcl_burning_entity_flame_animated.png" .. frame_overlay
self.object:set_properties({textures = {"blank.png", "blank.png", fire_texture, fire_texture, fire_texture, fire_texture}})
if parent:is_player() then
parent:hud_change(storage.fire_hud_id, "text", "mcl_burning_hud_flame_animated.png" .. frame_overlay)
end
end, end,
}) })

View File

@ -480,7 +480,7 @@ minetest.register_entity(":__builtin:item", {
end, end,
get_staticdata = function(self) get_staticdata = function(self)
return minetest.serialize({ local data = minetest.serialize({
itemstring = self.itemstring, itemstring = self.itemstring,
always_collect = self.always_collect, always_collect = self.always_collect,
age = self.age, age = self.age,
@ -488,6 +488,39 @@ minetest.register_entity(":__builtin:item", {
_flowing = self._flowing, _flowing = self._flowing,
_removed = self._removed, _removed = self._removed,
}) })
-- sfan5 guessed that the biggest serializable item
-- entity would have a size of 65530 bytes. This has
-- been experimentally verified to be still too large.
--
-- anon5 has calculated that the biggest serializable
-- item entity has a size of exactly 65487 bytes:
--
-- 1. serializeString16 can handle max. 65535 bytes.
-- 2. The following engine metadata is always saved:
-- • 1 byte (version)
-- • 2 byte (length prefix)
-- • 14 byte “__builtin:item”
-- • 4 byte (length prefix)
-- • 2 byte (health)
-- • 3 × 4 byte = 12 byte (position)
-- • 4 byte (yaw)
-- • 1 byte (version 2)
-- • 2 × 4 byte = 8 byte (pitch and roll)
-- 3. This leaves 65487 bytes for the serialization.
if #data > 65487 then -- would crash the engine
local stack = ItemStack(self.itemstring)
stack:get_meta():from_table(nil)
self.itemstring = stack:to_string()
minetest.log(
"warning",
"Overlong item entity metadata removed: “" ..
self.itemstring ..
"” had serialized length of " ..
#data
)
return self:get_staticdata()
end
return data
end, end,
on_activate = function(self, staticdata, dtime_s) on_activate = function(self, staticdata, dtime_s)

View File

@ -425,6 +425,7 @@ function hb.hide_hudbar(player, identifier)
local name = player:get_player_name() local name = player:get_player_name()
local hudtable = hb.get_hudtable(identifier) local hudtable = hb.get_hudtable(identifier)
if hudtable == nil then return false end if hudtable == nil then return false end
if hudtable.hudstate[name].hidden == true then return true end
if hb.settings.bar_type == "progress_bar" then if hb.settings.bar_type == "progress_bar" then
if hudtable.hudids[name].icon then if hudtable.hudids[name].icon then
player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0}) player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0})
@ -443,6 +444,7 @@ function hb.unhide_hudbar(player, identifier)
local name = player:get_player_name() local name = player:get_player_name()
local hudtable = hb.get_hudtable(identifier) local hudtable = hb.get_hudtable(identifier)
if hudtable == nil then return false end if hudtable == nil then return false end
if hudtable.hudstate[name].hidden == false then return true end
local value = hudtable.hudstate[name].value local value = hudtable.hudstate[name].value
local max = hudtable.hudstate[name].max local max = hudtable.hudstate[name].max
if hb.settings.bar_type == "progress_bar" then if hb.settings.bar_type == "progress_bar" then

View File

@ -93,7 +93,7 @@ minetest.register_craftitem("mcl_core:gold_ingot", {
minetest.register_craftitem("mcl_core:emerald", { minetest.register_craftitem("mcl_core:emerald", {
description = S("Emerald"), description = S("Emerald"),
_doc_items_longdesc = S("Emeralds are not very useful on their own, but they can exchanged for gold ingots by crafting."), _doc_items_longdesc = S("Emeralds are used in villager trades as currency."),
inventory_image = "mcl_core_emerald.png", inventory_image = "mcl_core_emerald.png",
stack_max = 64, stack_max = 64,
groups = { craftitem=1 }, groups = { craftitem=1 },

View File

@ -95,7 +95,7 @@ Dirt acts as a soil for a few plants. When in light, this block may grow a grass
Emerald= Emerald=
Emerald Ore= Emerald Ore=
Emerald ore is the ore of emeralds. It is very rare and can be found alone, not in clusters.= Emerald ore is the ore of emeralds. It is very rare and can be found alone, not in clusters.=
Emeralds are not very useful on their own, but they can exchanged for gold ingots by crafting.= Emeralds are used in villager trades as currency.=
Flint= Flint=
Flint is a raw material.= Flint is a raw material.=
Flowing Lava= Flowing Lava=

View File

@ -35,40 +35,6 @@ minetest.register_craft({
}, },
}) })
minetest.register_craft({
output = "mcl_armor:helmet_chain",
recipe = {
{ "xpanes:bar_flat", "mcl_core:iron_ingot", "xpanes:bar_flat" },
{ "xpanes:bar_flat", "", "xpanes:bar_flat" },
}
})
minetest.register_craft({
output = "mcl_armor:leggings_chain",
recipe = {
{ "xpanes:bar_flat", "mcl_core:iron_ingot", "xpanes:bar_flat" },
{ "xpanes:bar_flat", "", "xpanes:bar_flat" },
{ "xpanes:bar_flat", "", "xpanes:bar_flat" },
}
})
minetest.register_craft({
output = "mcl_armor:boots_chain",
recipe = {
{ "xpanes:bar_flat", "", "xpanes:bar_flat" },
{ "xpanes:bar_flat", "", "xpanes:bar_flat" },
}
})
minetest.register_craft({
output = "mcl_armor:chestplate_chain",
recipe = {
{ "xpanes:bar_flat", "", "xpanes:bar_flat" },
{ "xpanes:bar_flat", "mcl_core:iron_ingot", "xpanes:bar_flat" },
{ "xpanes:bar_flat", "xpanes:bar_flat", "xpanes:bar_flat" },
}
})
-- Make red sand, red sandstone and more craftable in v6 -- Make red sand, red sandstone and more craftable in v6
-- NOTE: When you change these, also update mcl_craftguide for the "v6" icon in -- NOTE: When you change these, also update mcl_craftguide for the "v6" icon in
-- the craft guide! -- the craft guide!

View File

@ -69,18 +69,19 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player
local controls = player:get_player_control() local controls = player:get_player_control()
if players[playerName] then if players[playerName] then
players[playerName].sprinting = sprinting players[playerName].sprinting = sprinting
local fov_old = players[playerName].fov
local fov_new = fov_old
local fade_time = .15
if sprinting == true if sprinting == true
or controls.RMB or controls.RMB
and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow")
and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then
if sprinting == true then if sprinting == true then
players[playerName].fov = math.min(players[playerName].fov + 0.05, 1.2) fov_new = math.min(players[playerName].fov + 0.05, 1.2)
players[playerName].fade_time = .15
else else
players[playerName].fov = .7 fov_new = .7
players[playerName].fade_time = .3 players[playerName].fade_time = .3
end end
player:set_fov(players[playerName].fov, true, players[playerName].fade_time)
if sprinting == true then if sprinting == true then
playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED) playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED)
end end
@ -88,12 +89,15 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player
and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0"
and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1"
and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then
players[playerName].fov = math.max(players[playerName].fov - 0.05, 1.0) fov_new = math.max(players[playerName].fov - 0.05, 1.0)
player:set_fov(players[playerName].fov, true, 0.15)
if sprinting == false then if sprinting == false then
playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint") playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint")
end end
end end
if fov_new ~= fov_old then
players[playerName].fov = fov_new
player:set_fov(fov_new, true, fade_time)
end
return true return true
end end
return false return false