Remove all ENTITIES

This commit is contained in:
Nathan Fritzler 2022-06-09 21:49:56 -06:00
parent d3320bd20a
commit afb28e6f95
Signed by: Lazerbeak12345
GPG Key ID: 736DE8D7C58AD7FE
24 changed files with 0 additions and 751 deletions

View File

@ -1,65 +0,0 @@
-- Dripping Water Mod
-- by kddekadenz
local math = math
-- License of code, textures & sounds: CC0
local function register_drop(liquid, glow, sound, nodes)
minetest.register_entity("mcl_dripping:drop_" .. liquid, {
hp_max = 1,
physical = true,
collide_with_objects = false,
collisionbox = {-0.01, 0.01, -0.01, 0.01, 0.01, 0.01},
glow = glow,
pointable = false,
visual = "sprite",
visual_size = {x = 0.1, y = 0.1},
textures = {""},
spritediv = {x = 1, y = 1},
initial_sprite_basepos = {x = 0, y = 0},
static_save = false,
_dropped = false,
on_activate = function(self)
self.object:set_properties({
textures = {"[combine:2x2:" .. -math.random(1, 16) .. "," .. -math.random(1, 16) .. "=default_" .. liquid .. "_source_animated.png"}
})
end,
on_step = function(self, dtime)
local k = math.random(1, 222)
local ownpos = self.object:get_pos()
if k == 1 then
self.object:set_acceleration(vector.new(0, -5, 0))
end
if minetest.get_node(vector.offset(ownpos, 0, 0.5, 0)).name == "air" then
self.object:set_acceleration(vector.new(0, -5, 0))
end
if minetest.get_node(vector.offset(ownpos, 0, -0.1, 0)).name ~= "air" then
local ent = self.object:get_luaentity()
if not ent._dropped then
ent._dropped = true
minetest.sound_play({name = "drippingwater_" .. sound .. "drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true)
end
if k < 3 then
self.object:remove()
end
end
end,
})
minetest.register_abm({
label = "Create drops",
nodenames = nodes,
neighbors = {"group:" .. liquid},
interval = 2,
chance = 22,
action = function(pos)
if minetest.get_item_group(minetest.get_node(vector.offset(pos, 0, 1, 0)).name, liquid) ~= 0
and minetest.get_node(vector.offset(pos, 0, -1, 0)).name == "air" then
local x, z = math.random(-45, 45) / 100, math.random(-45, 45) / 100
minetest.add_entity(vector.offset(pos, x, -0.520, z), "mcl_dripping:drop_" .. liquid)
end
end,
})
end
register_drop("water", 1, "", {"group:opaque", "group:leaves"})

View File

@ -1,4 +0,0 @@
name = mcl_dripping
author = kddekadenz
description = Drops are generated rarely under solid nodes
depends = mcl_core

View File

@ -1,29 +0,0 @@
Dripping Mod
by kddekadenz
modified for MineClone 2 by Wuzzy and NO11
Installing instructions:
1. Copy the mcl_dripping mod folder into games/gamemode/mods
2. Start game and enjoy :)
Manual:
-> drops are generated rarely under solid nodes
-> they will stay some time at the generated block and than they fall down
-> when they collide with the ground, a sound is played and they are destroyed
License:
code & sounds: CC0
Changelog:
16.04.2012 - first release
28.04.2012 - drops are now 3D; added lava drops; fixed generating of drops (not at edges now)

View File

@ -1,255 +0,0 @@
local function get_falling_depth(self)
if not self._startpos then
-- Fallback
self._startpos = self.object:get_pos()
end
return self._startpos.y - vector.round(self.object:get_pos()).y
end
local function deal_falling_damage(self, dtime)
if minetest.get_item_group(self.node.name, "falling_node_damage") == 0 then
return
end
-- Cause damage to any entity it hits.
-- Algorithm based on MC anvils.
local pos = self.object:get_pos()
if not self._startpos then
-- Fallback
self._startpos = pos
end
self._hit = self._hit or {}
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
local entity = obj:get_luaentity()
if entity and entity.name == "__builtin:item" then
obj:remove()
elseif mcl_util.get_hp(obj) > 0 and not self._hit[obj] then
self._hit[obj] = true
local way = self._startpos.y - pos.y
local damage = (way - 1) * 2
damage = math.min(40, math.max(0, damage))
if damage >= 1 then
-- Reduce damage if wearing a helmet
local inv = mcl_util.get_inventory(obj)
if inv then
local helmet = inv:get_stack("armor", 2)
if minetest.get_item_group(helmet:get_name(), "combat_armor") > 0 then
damage = damage / 4 * 3
mcl_util.use_item_durability(helmet, 1)
inv:set_stack("armor", 2, helmet)
end
end
local dmg_type
if minetest.get_item_group(self.node.name, "anvil") ~= 0 then
dmg_type = "anvil"
else
dmg_type = "falling_node"
end
mcl_util.deal_damage(obj, damage, {type = dmg_type})
end
end
end
end
minetest.register_entity(":__builtin:falling_node", {
initial_properties = {
visual = "wielditem",
visual_size = {x = 0.667, y = 0.667},
textures = {},
physical = true,
is_visible = false,
collide_with_objects = false,
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
node = {},
meta = {},
set_node = function(self, node, meta)
local def = minetest.registered_nodes[node.name]
-- Change falling node if definition tells us to
if def and def._mcl_falling_node_alternative then
node.name = def._mcl_falling_node_alternative
end
local glow
self.node = node
self.meta = meta or {}
-- Set correct entity yaw
if def and node.param2 ~= 0 then
if (def.paramtype2 == "facedir" or def.paramtype2 == "colorfacedir") then
self.object:set_yaw(minetest.dir_to_yaw(minetest.facedir_to_dir(node.param2)))
elseif (def.paramtype2 == "wallmounted" or def.paramtype2 == "colorwallmounted") then
self.object:set_yaw(minetest.dir_to_yaw(minetest.wallmounted_to_dir(node.param2)))
end
if def.light_source then
glow = def.light_source
end
end
self.object:set_properties({
is_visible = true,
textures = {node.name},
glow = glow,
})
end,
get_staticdata = function(self)
local meta = self.meta
-- Workaround: Save inventory seperately from metadata.
-- Because Minetest crashes when a node with inventory gets deactivated
-- (GitHub issue #7020).
-- FIXME: Remove the _inv workaround when it is no longer needed
local inv
if meta then
inv = meta.inv
meta.inventory = nil
end
local ds = {
node = self.node,
meta = self.meta,
_inv = inv,
_startpos = self._startpos,
_hit_players = self._hit_players,
}
return minetest.serialize(ds)
end,
on_activate = function(self, staticdata)
self.object:set_armor_groups({immortal = 1})
local ds = minetest.deserialize(staticdata)
if ds then
self._startpos = ds._startpos
self._hit_players = ds._hit_players
if ds.node then
local meta = ds.meta
meta.inventory = ds._inv
self:set_node(ds.node, meta)
else
self:set_node(ds)
end
elseif staticdata ~= "" then
self:set_node({name = staticdata})
end
if not self._startpos then
self._startpos = self.object:get_pos()
end
self._startpos = vector.round(self._startpos)
end,
on_step = function(self, dtime)
-- Set gravity
local acceleration = self.object:get_acceleration()
if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then
self.object:set_acceleration({x = 0, y = -10, z = 0})
end
-- Turn to actual node when colliding with ground, or continue to move
local pos = self.object:get_pos()
-- Portal check
local np = {x = pos.x, y = pos.y + 0.3, z = pos.z}
local n2 = minetest.get_node(np)
if n2.name == "mcl_portals:portal_end" then
-- TODO: Teleport falling node.
self.object:remove()
return
end
-- Position of bottom center point
local bcp = {x = pos.x, y = pos.y - 0.7, z = pos.z}
-- Avoid bugs caused by an unloaded node below
local bcn = minetest.get_node_or_nil(bcp)
local bcd = bcn and minetest.registered_nodes[bcn.name]
-- TODO: At this point, we did 2 get_nodes in 1 tick.
-- Figure out how to improve that (if it is a problem).
if bcn and (not bcd or bcd.walkable or
(minetest.get_item_group(self.node.name, "float") ~= 0 and
bcd.liquidtype ~= "none")) then
if bcd and bcd.leveled and
bcn.name == self.node.name then
local addlevel = self.node.level
if not addlevel or addlevel <= 0 then
addlevel = bcd.leveled
end
if minetest.add_node_level(bcp, addlevel) == 0 then
if minetest.registered_nodes[self.node.name]._mcl_after_falling then
minetest.registered_nodes[self.node.name]._mcl_after_falling(bcp, get_falling_depth(self))
end
deal_falling_damage(self, dtime)
self.object:remove()
return
end
elseif bcd and bcd.buildable_to and
(minetest.get_item_group(self.node.name, "float") == 0 or
bcd.liquidtype == "none") then
minetest.remove_node(bcp)
return
end
local nd = minetest.registered_nodes[n2.name]
--if n2.name == "mcl_portals:portal_end" then
-- TODO: Teleport falling node.
if (nd and nd.buildable_to == true) or minetest.get_item_group(self.node.name, "crush_after_fall") ~= 0 then
-- Replace destination node if it's buildable to
minetest.remove_node(np)
-- Run script hook
for _, callback in pairs(minetest.registered_on_dignodes) do
callback(np, n2)
end
local def = minetest.registered_nodes[self.node.name]
if def then
minetest.add_node(np, self.node)
if def._mcl_after_falling then
def._mcl_after_falling(np, get_falling_depth(self))
end
if self.meta then
local meta = minetest.get_meta(np)
meta:from_table(self.meta)
end
if def.sounds and def.sounds.place and def.sounds.place.name then
minetest.sound_play(def.sounds.place, {pos = np}, true)
end
end
else
-- Drop the *falling node* as an item if the destination node is NOT buildable to
local drops = minetest.get_node_drops(self.node.name, "")
for _, dropped_item in pairs(drops) do
minetest.add_item(np, dropped_item)
end
end
deal_falling_damage(self, dtime)
self.object:remove()
minetest.check_for_falling(np)
return
end
local vel = self.object:get_velocity()
-- Fix position if entity does not move
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
local npos = vector.round(self.object:get_pos())
local npos2 = table.copy(npos)
npos2.y = npos2.y - 2
local lownode = minetest.get_node(npos2)
-- Special check required for fences and walls, because of their overhigh collision box.
if minetest.get_item_group(lownode.name, "fence") == 1 or minetest.get_item_group(lownode.name, "wall") == 1 then
-- Instantly stop the node if it is above a fence/wall. This is needed
-- because the falling node collides early with a fence/wall node.
-- Hacky, because the falling node will teleport a short distance, instead
-- of smoothly fall on the fence post.
local npos3 = table.copy(npos)
npos3.y = npos3.y - 1
minetest.add_node(npos3, self.node)
local def = minetest.registered_nodes[self.node.name]
if def then
if def._mcl_after_falling then
def._mcl_after_falling(npos3, get_falling_depth(self))
end
if def.sounds and def.sounds.place and def.sounds.place.name then
minetest.sound_play(def.sounds.place, {pos = np}, true)
end
end
deal_falling_damage(self, dtime)
self.object:remove()
minetest.check_for_falling(npos3)
return
else
-- Normal position fix (expected case)
self.object:set_pos(npos)
end
end
deal_falling_damage(self, dtime)
end
})

View File

@ -1,3 +0,0 @@
# textdomain: mcl_falling_nodes
@1 was smashed by a falling anvil.=@1 została zmiażdżona przez spadające kowadło.
@1 was smashed by a falling block.=@1 została zmiażdżona przez spadający blok.

View File

@ -1,3 +0,0 @@
# textdomain: mcl_falling_nodes
@1 was smashed by a falling anvil.=@1 被鐵砧壓扁了。
@1 was smashed by a falling block.=@1 被掉下來的方塊壓扁了。

View File

@ -1,3 +0,0 @@
name = mcl_falling_nodes
author = Wuzzy
description = Falling node entities, Minecraft-style

View File

@ -1,317 +0,0 @@
mcl_paintings = {}
local modname = minetest.get_current_modname()
dofile(minetest.get_modpath(modname).."/paintings.lua")
local S = minetest.get_translator(modname)
local math = math
local wood = "[combine:16x16:-192,0=mcl_paintings_paintings.png"
local function is_protected(pos, name)
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return true
end
return false
end
-- Check if there's a painting for provided painting size.
-- If yes, returns the arguments.
-- If not, returns the next smaller available painting.
local function shrink_painting(x, y)
if x > 4 or y > 4 then
return nil
end
local xstart = x
local painting
while not painting do
painting = mcl_paintings.paintings[y] and mcl_paintings.paintings[y][x]
if type(painting) == "table" then
break
elseif type(painting) == "number" then
x = painting
painting = nil
else
x = xstart
y = y - 1
end
if y < 1 then
return nil
end
end
if type(painting) == "table" then
return x, y
end
end
local function get_painting(x, y, motive)
local painting = mcl_paintings.paintings[y] and mcl_paintings.paintings[y][x] and mcl_paintings.paintings[y][x][motive]
if not painting then
return nil
end
local px, py = -painting.cx, -painting.cy
local sx, sy = 16*x, 16*y
return "[combine:"..sx.."x"..sy..":"..px..","..py.."=mcl_paintings_paintings.png"
end
local function get_random_painting(x, y)
if not mcl_paintings.paintings[y] or not mcl_paintings.paintings[y][x] then
return nil
end
local max = #mcl_paintings.paintings[y][x]
if max < 1 then
return nil
end
local r = math.random(1, max)
return get_painting(x, y, r), r
end
--[[local function size_to_minmax(size)
local min, max
if size == 2 then
min = -0.5
max = 1.5
elseif size == 3 then
min = -1.5
max = 1.5
elseif size == 4 then
min = -1.5
max = 2.5
else
min = -0.5
max = 0.5
end
return min, max
end]]
local function size_to_minmax_entity(size)
return -size/2, size/2
end
local function set_entity(object)
local ent = object:get_luaentity()
local wallm = ent._facing
local xsize = ent._xsize
local ysize = ent._ysize
local exmin, exmax = size_to_minmax_entity(xsize)
local eymin, eymax = size_to_minmax_entity(ysize)
local visual_size = { x=xsize-0.0001, y=ysize-0.0001, z=1/32 }
if not ent._xsize or not ent._ysize or not ent._motive then
minetest.log("error", "[mcl_paintings] Painting loaded with missing painting values!")
return
end
local painting = get_painting(xsize, ysize, ent._motive)
if not painting then
minetest.log("error", "[mcl_paintings] No painting found for size "
..xsize..","..ysize..", motive number "..ent._motive.."!")
return
end
local box
if wallm == 2 then
box = { -3/128, eymin, exmin, 1/64, eymax, exmax }
elseif wallm == 3 then
box = { -1/64, eymin, exmin, 3/128, eymax, exmax }
elseif wallm == 4 then
box = { exmin, eymin, -3/128, exmax, eymax, 1/64 }
elseif wallm == 5 then
box = { exmin, eymin, -1/64, exmax, eymax, 3/128 }
end
object:set_properties({
selectionbox = box,
visual_size = visual_size,
textures = { wood, wood, wood, wood, painting, wood },
})
local dir = minetest.wallmounted_to_dir(wallm)
if not dir then
return
end
object:set_yaw(minetest.dir_to_yaw(dir))
end
minetest.register_entity("mcl_paintings:painting", {
visual = "cube",
visual_size = { x=0.999, y=0.999, z=1/32 },
selectionbox = { -1/64, -0.5, -0.5, 1/64, 0.5, 0.5 },
physical = false,
collide_with_objects = false,
textures = { wood, wood, wood, wood, wood, wood },
hp_max = 1,
_motive = 0,
_pos = nil,
_facing = 2,
_xsize = 1,
_ysize = 1,
on_activate = function(self, staticdata)
self.object:set_armor_groups({immortal = 1})
if staticdata and staticdata ~= "" then
local data = minetest.deserialize(staticdata)
if data then
self._facing = data._facing
self._pos = data._pos
self._motive = data._motive
self._xsize = data._xsize
self._ysize = data._ysize
end
end
set_entity(self.object)
end,
get_staticdata = function(self)
local data = {
_facing = self._facing,
_pos = self._pos,
_motive = self._motive,
_xsize = self._xsize,
_ysize = self._ysize,
}
return minetest.serialize(data)
end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
-- Drop as item on punch
if puncher and puncher:is_player() then
local kname = puncher:get_player_name()
local pos = self._pos
if not pos then
pos = self.object:get_pos()
end
if not minetest.is_protected(pos, kname) then
self.object:remove()
if not minetest.is_creative_enabled(kname) then
minetest.add_item(pos, "mcl_paintings:painting")
end
end
end
end,
})
minetest.register_craftitem("mcl_paintings:painting", {
description = S("Painting"),
inventory_image = "mcl_paintings_painting.png",
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local node = minetest.get_node(pointed_thing.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
end
end
local dir = vector.subtract(pointed_thing.above, pointed_thing.under)
dir = vector.normalize(dir)
if dir.y ~= 0 then
-- Ceiling/floor paintings are not supported
return itemstack
end
local wallm = minetest.dir_to_wallmounted(dir)
if wallm then
local ppos = pointed_thing.above
local xmax
local ymax = 4
local xmaxes = {}
local ymaxed = false
local negative = dir.x < 0 or dir.z > 0
-- Check maximum possible painting size
local t
for y=0,3 do
for x=0,3 do
local k = x
if negative then
k = -k
end
if dir.z ~= 0 then
t = {x=k,y=y,z=0}
else
t = {x=0,y=y,z=k}
end
local unode = minetest.get_node(vector.add(pointed_thing.under, t))
local anode = minetest.get_node(vector.add(ppos, t))
local udef = minetest.registered_nodes[unode.name]
local adef = minetest.registered_nodes[anode.name]
if (not (udef and udef.walkable)) or (not adef or adef.walkable) then
xmaxes[y+1] = x
if x == 0 and not ymaxed then
ymax = y
ymaxed = true
end
break
end
end
if not xmaxes[y] then
xmaxes[y] = 4
end
end
xmax = math.max(unpack(xmaxes))
local xsize, ysize = xmax, ymax
xsize, ysize = shrink_painting(xsize, ysize)
if not xsize then
return itemstack
end
local _, exmax = size_to_minmax_entity(xsize)
local _, eymax = size_to_minmax_entity(ysize)
local pposa = vector.subtract(ppos, vector.multiply(dir, 0.5-5/256))
local name = placer:get_player_name()
local pexmax
local peymax = eymax - 0.5
local n
if negative then
pexmax = -exmax + 0.5
n = -1
else
pexmax = exmax - 0.5
n = 1
end
if is_protected(ppos, name) then return itemstack end
local ppos2
if dir.z ~= 0 then
pposa = vector.add(pposa, {x=pexmax, y=peymax, z=0})
ppos2 = vector.add(ppos, {x = (xsize-1)*n, y = ysize-1, z = 0})
else
pposa = vector.add(pposa, {x=0, y=peymax, z=pexmax})
ppos2 = vector.add(ppos, {x = 0, y = ysize-1, z = (xsize-1)*n})
end
if is_protected(ppos2, name) then return itemstack end
local painting, pid = get_random_painting(xsize, ysize)
if not painting then
minetest.log("error", "[mcl_paintings] No painting found for size "..xsize..","..ysize.."!")
return itemstack
end
local staticdata = {
_facing = wallm,
_pos = ppos,
_motive = pid,
_xsize = xsize,
_ysize = ysize,
}
local obj = minetest.add_entity(pposa, "mcl_paintings:painting", minetest.serialize(staticdata))
if not obj then
return itemstack
end
else
return itemstack
end
if not minetest.is_creative_enabled(placer:get_player_name()) then
itemstack:take_item()
end
return itemstack
end,
})
mcl_wip.register_wip_item("mcl_paintings:painting")
minetest.register_craft({
output = "mcl_paintings:painting",
recipe = {
{ "mcl_core:stick", "mcl_core:stick", "mcl_core:stick" },
{ "mcl_core:stick", "group:wool", "mcl_core:stick" },
{ "mcl_core:stick", "mcl_core:stick", "mcl_core:stick" },
}
})

View File

@ -1,2 +0,0 @@
# textdomain:mcl_paintings
Painting=Gemälde

View File

@ -1,2 +0,0 @@
# textdomain:mcl_paintings
Painting=Peinture

View File

@ -1,2 +0,0 @@
# textdomain:mcl_paintings
Painting=Obraz

View File

@ -1,2 +0,0 @@
# textdomain:mcl_paintings
Painting=Рисование

View File

@ -1,2 +0,0 @@
# textdomain:mcl_paintings
Painting=畫

View File

@ -1,2 +0,0 @@
# textdomain:mcl_paintings
Painting=

View File

@ -1,5 +0,0 @@
name = mcl_paintings
author = Wuzzy
description = The paintings mod for MCL2
depends = mcl_wip

View File

@ -1,55 +0,0 @@
local TS = 16 -- texture size
mcl_paintings.paintings = {
[1] = {
[1] = {
{ cx = 0, cy = 0 },
{ cx = TS, cy = 0 },
{ cx = 2*TS, cy = 0 },
{ cx = 3*TS, cy = 0 },
{ cx = 4*TS, cy = 0 },
{ cx = 5*TS, cy = 0 },
{ cx = 6*TS, cy = 0 },
},
[2] = {
{ cx = 0, cy = 2*TS },
{ cx = 2*TS, cy = 2*TS },
{ cx = 4*TS, cy = 2*TS },
{ cx = 6*TS, cy = 2*TS },
{ cx = 8*TS, cy = 2*TS },
},
[3] = 2,
[4] = 2,
},
[2] = {
[1] = {
{ cx = 0, cy = 4*TS },
{ cx = TS, cy = 4*TS },
},
[2] = {
{ cx = 0, cy = 8*TS },
{ cx = 2*TS, cy = 8*TS },
{ cx = 4*TS, cy = 8*TS },
{ cx = 6*TS, cy = 8*TS },
{ cx = 8*TS, cy = 8*TS },
{ cx = 10*TS, cy = 8*TS },
},
[3] = 2,
[4] = {
{ cx = 0, cy = 6*TS },
},
},
[3] = {
[4] = {
{ cx = 12*TS, cy = 4*TS },
{ cx = 12*TS, cy = 7*TS },
},
},
[4] = {
[4] = {
{ cx = 0, cy = 12*TS },
{ cx = 4*TS, cy = 12*TS },
{ cx = 8*TS, cy = 12*TS },
},
},
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB