works for small maps
This commit is contained in:
parent
3f9dec3860
commit
d66a3ac74b
91
README.md
91
README.md
@ -1,2 +1,89 @@
|
||||
For now, this only contains a texture converter in textures/terrain2mt.sh
|
||||
The import mod works as such but does not handle large (>64x64x64 blocks) well yet. It will be uploaded when those problems are fixed.
|
||||
|
||||
==================================
|
||||
Import maps from Minecraft Classic
|
||||
==================================
|
||||
|
||||
WARNING: Importing maps (even relatively small ones like 256xc256x256 blocks) has drawbacks:
|
||||
- it takes a long time (several minutes; depends on machine)
|
||||
- client might not get updated without reconnect
|
||||
- you need a *lot* of free space (more than it looks like...turn coordinates on with f5 and
|
||||
check); without a flat map your buildings might end up in the next hill!
|
||||
Best thing is to get a flat map.
|
||||
- make sure the chunks the map is to be copied on do exist - otherwise it might take even
|
||||
longer if the map has to be generated first
|
||||
- mcimport makes some assumptions about the map which might not be true for *your* own maps:
|
||||
* offset in the file is 486 (that is where the block data startes); it might be diffrent
|
||||
for other classic servers
|
||||
* map is 2^nx2^nx2^n
|
||||
* the lower half of the map (up to 2^(n-1) in height) is filled with dirt
|
||||
* there is one layer of grass on the dirt
|
||||
* on top of the grass there is only air (well, except for the buildings)
|
||||
Maps with other dimensions cannot be detected automaticly. You have to change worldedit/mc2mt.lua
|
||||
for such a map. The assumptions about half-dirt-half-air-maps help reduce the amount of blocks
|
||||
that have to be inserted to a more reasonable number.
|
||||
[OUTDATED] Beneath the grass-level dirt blocks are NOT imported (only other block types);
|
||||
above the grass-level air is NOT imported (thus if you do have a forgotten mountain lying around
|
||||
there on your minetest world your buildings will end up embedded in it).
|
||||
CURRENTLY dirt (not that with grass on!) and air are completely ignored while copying.
|
||||
|
||||
|
||||
|
||||
|
||||
Mcimport uses its own blocks for imported buildings instead of the default ones
|
||||
(e.g. mcimport:stone instead of default:stone). This has several reasons:
|
||||
|
||||
- sand and gravel do not fall (thus your buildings out of sand blocks are safe)
|
||||
- leaves do not decay
|
||||
- flowers/mushrooms need nothing special (they just look like flowers)
|
||||
- grass stays green even though it is not lighted
|
||||
- grass is not the default one so flowers and mobs won't spawn unexpectedly
|
||||
- the above effects do not have to be turned off globally - they can still be used for default blocks
|
||||
- no need for a bunch of other mods (which may still be helpful for other reasons)
|
||||
- the blocks can be replaced with other ones later on with the worldedit-mod
|
||||
- textures from texturepacks can be used
|
||||
- handling of light (blocks emit light)
|
||||
- water does not flow
|
||||
|
||||
Imported blocks emit light like a torch. This may seem strange but is necessary for large
|
||||
buildings. You couldn't place as much torches as a huge epic building might need! Minecraft
|
||||
classic doesn't have lighting - Minetest does. If you are not happy with the "torch"-blocks
|
||||
and want to put torches manually (e.g. for smaller buildings) you can turn it off by setting
|
||||
LIGHT_BUILDING_BLOCK = 0 in mcimport/init.lua
|
||||
|
||||
Water is a special case and used in Minecraft classic for things like door replacement
|
||||
(like a plasma), kitchen sinks, showers, fountains, elevators (shwim up), swimming pools,
|
||||
decoration - and sometimes even for water. If that would be turned into a default:water_source
|
||||
the map might get flooded from the next "elevator". Instead, mcimport uses its own
|
||||
mcimport:stationary_water (same with lava). It is not a fluid so it does not allow swimming.
|
||||
|
||||
If you are not happy with any of the blocks/nodes you can either change the nodes directly in
|
||||
mcimport/nodes.lua or change the name the classic blocks are replaced with in mcimport/mc2mt.lua
|
||||
(look for block_transform and e.g. change mcimport:stationary_water to default:water_source if
|
||||
you are sure your map contains no water with air around/beneath it)
|
||||
|
||||
|
||||
How it works
|
||||
------------
|
||||
|
||||
level*.dat files contain compressed data. Mcimport doesn't decompress it. You have to gunzip your
|
||||
file manually. On unix this would be
|
||||
mv -i level_12345.dat level_12345.dat.gz
|
||||
gunzip level_12345.dat.gz
|
||||
mkdir worlds/NameOfYourWorld/schems/
|
||||
mv -i level_12345.dat worlds/NameOfYourWorld/schems/
|
||||
That is the same directory as that one used by worldedit.
|
||||
|
||||
To import your file load and run your world and
|
||||
1. type in the chat: /mcimport level 64x64x64 10:0:0
|
||||
That will import your unzipped Minecraft classic map
|
||||
worlds/NameOfYourWorld/schems/level.dat (which has the dimensions 64x64x64) to the
|
||||
coordinates 10,0,0 (second one: height) in your Minetest world.
|
||||
2. Have patience!
|
||||
3. If your building doesn't show up reconnect your client.
|
||||
4. Check if something like "Changed 113254 blocks." appears in bin/debug.text
|
||||
The actual number tells you how many blocks have been inserted (excluding non-imported blocks
|
||||
like dirt beneath grass-level and air above grass-level)
|
||||
5. Go and look for the content of your map. Make sure you have fly and fast privilege so you
|
||||
can reach them. Turn sight to far.
|
||||
|
||||
|
||||
|
95
init.lua
Normal file
95
init.lua
Normal file
@ -0,0 +1,95 @@
|
||||
minetest.register_privilege("mcimport", "Can import Minecraft Classic savefiles")
|
||||
|
||||
mcimport = {}
|
||||
|
||||
|
||||
-- node definitions (inactive blocks that represent those of MC classic)
|
||||
dofile(minetest.get_modpath("mcimport").."/nodes.lua");
|
||||
-- the actual import/conversion happens here
|
||||
dofile(minetest.get_modpath("mcimport").."/mc2mt.lua");
|
||||
|
||||
|
||||
minetest.register_chatcommand("mcimport", {
|
||||
params = "<file> <dimensions> <position>",
|
||||
description = "Import Minecraft classic map from <file> \"(world folder)/schems/<file>.dat\" "..
|
||||
"(you have to uncompress the level manually before) "..
|
||||
"with the dimensions <dimnnsions> to the given position/coordinates <position>. Example: "..
|
||||
"/mcimport my_map 256x256x512 100:15:35 will read the file (world folder)/schems/my_map.dat as a Minecraft "..
|
||||
"classic map of the size 256x256x512 and import it to your current Minetest world at coordinates x=100, y=15 (height!) "..
|
||||
"and z=35. Make sure the area you import to is loaded!",
|
||||
privs = {mcimport=true},
|
||||
func = function(name, param)
|
||||
|
||||
local params_expected = "<file> <dimension_x>x<dimension_y>x<dimension_z> <target_pos_x>:<target_pos_y>:<target_pos_z>";
|
||||
if( param == "" or param==nil) then
|
||||
minetest.chat_send_player(name, "Missing parameters: "..params_expected );
|
||||
return;
|
||||
end
|
||||
|
||||
local pos = {x=0; y=0; z=0};
|
||||
local dim = {x=0; y=0; z=0};
|
||||
local fname;
|
||||
for fn, dim_x, dim_y, dim_z, pos_x, pos_y, pos_z in param:gmatch("([^%s]+)%s+(%d+)x(%d+)x(%d+)%s+([+-]?%d+)\:([+-]?%d+)\:([+-]?%d+)") do
|
||||
|
||||
if( fn ~= nil and dim_x ~= nil and dim_y ~= nil and dim_z ~= nil and pos_x ~= nil and pos_y ~= nil and pos_z ~= nil ) then
|
||||
-- target position
|
||||
pos.x = tonumber( pos_x );
|
||||
pos.y = tonumber( pos_y );
|
||||
pos.z = tonumber( pos_z );
|
||||
-- map dimensions
|
||||
dim.x = tonumber( dim_x );
|
||||
dim.y = tonumber( dim_y );
|
||||
dim.z = tonumber( dim_z );
|
||||
-- ...and the file
|
||||
fname = fn;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if( dim.x == 0 ) then
|
||||
minetest.chat_send_player(name, "Missing/wrong parameters. Got: "..param.." Expected: "..params_expected );
|
||||
return;
|
||||
end
|
||||
|
||||
if( dim.x<1 or dim.y<1 or dim.z<1) then
|
||||
minetest.chat_send_player(name, "Impossible map dimensions." );
|
||||
return;
|
||||
end
|
||||
|
||||
if( pos.x> 30000 or pos.y> 30000 or pos.z> 30000
|
||||
or pos.x<-30000 or pos.y<-30000 or pos.z<-30000) then
|
||||
minetest.chat_send_player(name, "The target position is too far out. No coordinate shall exceed +/-30000." );
|
||||
return;
|
||||
end
|
||||
|
||||
if( ((dim.x%16) ~= 0) or ((dim.y%16) ~= 0) or ((dim.z%16) ~= 0)) then
|
||||
minetest.chat_send_player(name, "Warning: Your map dimensions seem unlikely. Usually they are multiples of 16 (e.g. 64, 128, 256, ...)." );
|
||||
end
|
||||
|
||||
|
||||
|
||||
local filename_mc;
|
||||
|
||||
filename_mc = minetest.get_worldpath().."/schems/"..fname.. ".dat";
|
||||
file, err = io.open(filename_mc, "rb");
|
||||
|
||||
if err ~= nil then
|
||||
minetest.chat_send_player(name, "Could not open file \""..filename_mc.."\".");
|
||||
return;
|
||||
end
|
||||
|
||||
local value = file:read("*a");
|
||||
file:close();
|
||||
|
||||
minetest.chat_send_player( name, "Map file \""..tostring( fname )..
|
||||
"\" with dimensions "..tostring( dim.x ).." x "..tostring( dim.y ).." x "..tostring( dim.z )..
|
||||
" will be imported to position "..tostring( pos.x ).." : "..tostring( pos.y ).." : "..tostring( pos.z )..".");
|
||||
|
||||
|
||||
local count;
|
||||
count = 0;
|
||||
count = mcimport.deserialize_mc(pos, value, dim, name );
|
||||
|
||||
minetest.chat_send_player(name, "MCimport finised. Status: "..count .. " nodes imported.");
|
||||
end,
|
||||
})
|
228
mc2mt.lua
Normal file
228
mc2mt.lua
Normal file
@ -0,0 +1,228 @@
|
||||
|
||||
-- TODO: use real water if the water-node is sourrounded by anything but air (what is on top doesn't matter)
|
||||
|
||||
|
||||
-- reads a level.dat file from minecraft classic and imports it
|
||||
-- based on worldedit:deserialize
|
||||
-- returns the number of nodes changed
|
||||
mcimport.deserialize_mc = function(originpos, value, dim, name)
|
||||
|
||||
local max_x = 0; -- can be set to override automatic detection
|
||||
local max_y;
|
||||
local max_z;
|
||||
|
||||
local grass_level = 0; -- z-value/heigth at which the grass is
|
||||
|
||||
local offset = 486; -- position where the block data starts in file
|
||||
|
||||
local block_transform = {
|
||||
[0] = "air", -- field 0 doesn't exist in LUA? anyway - air has to be handled differently (and ignored most of the time)
|
||||
[1] = "mcimport:stone",
|
||||
[2] = "mcimport:dirt_with_grass",
|
||||
[3] = "mcimport:dirt",
|
||||
[4] = "mcimport:cobble",
|
||||
[5] = "mcimport:wood",
|
||||
[6] = "mcimport:sapling",
|
||||
[7] = "mcimport:bedrock",
|
||||
[8] = "mcimport:stationary_water", -- water that does not flow
|
||||
[9] = "mcimport:stationary_water", -- stationary water
|
||||
[10] = "mcimport:stationary_lava", -- lava that does not flow
|
||||
[11] = "mcimport:stationary_lava", -- stationary lava
|
||||
[12] = "mcimport:sand",
|
||||
[13] = "mcimport:gravel",
|
||||
[14] = "mcimport:gold_ore",
|
||||
[15] = "mcimport:iron_ore",
|
||||
[16] = "mcimport:coal_ore",
|
||||
[17] = "mcimport:tree",
|
||||
[18] = "mcimport:leaves",
|
||||
[19] = "mcimport:sponge",
|
||||
[20] = "mcimport:glass",
|
||||
|
||||
[21] = "mcimport:wool_red",
|
||||
[22] = "mcimport:wool_orange",
|
||||
[23] = "mcimport:wool_yellow",
|
||||
[24] = "mcimport:wool_lime",
|
||||
[25] = "mcimport:wool_green",
|
||||
[26] = "mcimport:wool_aqua",
|
||||
[27] = "mcimport:wool_cyan",
|
||||
[28] = "mcimport:wool_blue",
|
||||
[29] = "mcimport:wool_purple",
|
||||
[30] = "mcimport:wool_indigo",
|
||||
[31] = "mcimport:wool_violet",
|
||||
[32] = "mcimport:wool_magenta",
|
||||
[33] = "mcimport:wool_pink",
|
||||
[34] = "mcimport:wool_black",
|
||||
[35] = "mcimport:wool_grey",
|
||||
[36] = "mcimport:wool_white",
|
||||
|
||||
[37] = "mcimport:flower_yellow",
|
||||
[38] = "mcimport:flower_red",
|
||||
[39] = "mcimport:brown_mushroom",
|
||||
[40] = "mcimport:red_mushroom",
|
||||
[41] = "mcimport:gold",
|
||||
[42] = "mcimport:steelblock",
|
||||
[43] = "mcimport:double_stairs",
|
||||
[44] = "mcimport:stairs",
|
||||
[45] = "mcimport:brick",
|
||||
[46] = "mcimport:tnt",
|
||||
[47] = "mcimport:bookshelf",
|
||||
[48] = "mcimport:mossycobble",
|
||||
[49] = "mcimport:obsidian",
|
||||
}
|
||||
|
||||
|
||||
-- for node changes
|
||||
local pos = {x=0, y=0, z=0}
|
||||
local node = {name="", param1=0, param2=0}
|
||||
local env = minetest.env;
|
||||
|
||||
local anz_transformed = 0;
|
||||
local i, x, y, z;
|
||||
local neuer_block;
|
||||
|
||||
-- the dimensions of the map have to be supplied by the user
|
||||
max_x = dim.x;
|
||||
max_y = dim.y;
|
||||
max_z = dim.z;
|
||||
anz_blocks = max_x * max_y * max_z;
|
||||
grass_level = max_x / 2;
|
||||
|
||||
print( "Reading information about "..
|
||||
tostring( offset+anz_blocks+2 ).." blocks.");
|
||||
|
||||
if( max_x<1 or max_y<1 or max_z<1 ) then
|
||||
print "Impossible map size.";
|
||||
return;
|
||||
end
|
||||
|
||||
if( offset+anz_blocks+2 > string.len( value )) then
|
||||
print( "Wrong map size. Found less blocks than expected.");
|
||||
return;
|
||||
end
|
||||
|
||||
if( offset+anz_blocks+2 < string.len( value )) then
|
||||
print( "Wrong map size. Found more blocks than expected.");
|
||||
return;
|
||||
end
|
||||
|
||||
print( "Importing them might take a while.");
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
|
||||
|
||||
-- check the tailing bytes (which are supposed to have the value 112)
|
||||
for i = (offset+anz_blocks), (offset+anz_blocks+2) do
|
||||
|
||||
nr = string.byte( value, i, i );
|
||||
|
||||
if (not(nr==112)) then
|
||||
print( "Warning: Byte at the end does not have expected value 70 (hex)");
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- move originpos as needed to avoid recalculation for each block
|
||||
originpos.x = originpos.x + max_x; -- somehow it got mirrored
|
||||
originpos.y = originpos.y - grass_level; -- grass ought to be on the same level as the sourrounding grass; half sink the level into the floor
|
||||
|
||||
-- -- dirt beneath the "water"-level is of no interest - but air is
|
||||
-- if( (y < grass_level and (nr ~= 3))
|
||||
--- -- on the water/floor level grass is of no interest
|
||||
-- or (y ==grass_level and (nr ~= 2))
|
||||
-- -- above that air is of no interest
|
||||
-- or (y > grass_level and (nr ~= 0))) then
|
||||
|
||||
|
||||
-- if( i-offset ~= ( z*(max_x*max_y)+ (max_x * y) + x )) then
|
||||
|
||||
|
||||
|
||||
sub_length = 16;
|
||||
|
||||
air_etc = 0;
|
||||
|
||||
local player;
|
||||
local target_coords;
|
||||
|
||||
for start_z = 0, math.floor(max_z/sub_length)-1 do
|
||||
for start_y = 0, math.floor(max_y/sub_length)-1 do
|
||||
for start_x = 0, math.floor(max_x/sub_length)-1 do
|
||||
|
||||
i = offset+( (max_x * max_y) * (start_z*sub_length) + (max_x * (start_y*sub_length)) + (start_x*sub_length) ) ;
|
||||
--print("Starting at "..tostring( i-offset ).." for offset "..tostring( start_x ).." "..tostring( start_y ).." "..tostring( start_z ));
|
||||
|
||||
-- move the player who issued the command around in order to make sure that that part of the world has been generated
|
||||
player = minetest.env:get_player_by_name( name );
|
||||
if( player ~= nil ) then
|
||||
target_coords = { x = (originpos.x - start_x + (sub_length/2)), y = (originpos.y+ start_z - (sub_length/2)), z = (originpos.z+ start_y - (sub_length/2))};
|
||||
player:moveto(target_coords, false);
|
||||
end
|
||||
|
||||
for z = (start_z*sub_length),(((start_z+1)*sub_length)-1) do
|
||||
for y = (start_y*sub_length),(((start_y+1)*sub_length)-1) do
|
||||
for x = (start_x*sub_length),(((start_x+1)*sub_length)-1) do
|
||||
|
||||
nr = string.byte( value, i, i );
|
||||
--if( nr ~= 0 ) then -- if( not( nr==3 ) and not( nr==0 )) then -- ignore air and dirt
|
||||
if( (nr ~= 3) and (nr ~= 0) ) then -- ignore air and dirt completely
|
||||
neuer_block = block_transform[ nr ];
|
||||
|
||||
-- print( i, (i-offset), nr, x, y, z, neuer_block );
|
||||
|
||||
-- actually place the block
|
||||
pos.x = originpos.x - x; -- somehow got mirrord; max_x has been added previously
|
||||
pos.y = originpos.y + z; -- otherwise it ends up sideways; grass_level has already been substracted
|
||||
pos.z = originpos.z + y;
|
||||
node.name = neuer_block;
|
||||
node.param1 = param1;
|
||||
node.param2 = param2;
|
||||
|
||||
if( pos ~= nil and node ~= nil and neuer_block ~= nil) then
|
||||
--print( "Placed "..tostring( neuer_block ).." at "..tostring( pos.x )..":"..tostring( pos.y )..":"..tostring( pos.z ));
|
||||
env:add_node(pos, node);
|
||||
else
|
||||
print( "Error: Could not place "..tostring( neuer_block ).." [Code:"..tostring( nr ).."] at "..
|
||||
tostring( pos.x )..":"..tostring( pos.y )..":"..tostring( pos.z ));
|
||||
end
|
||||
|
||||
anz_transformed = anz_transformed + 1;
|
||||
else
|
||||
air_etc = air_etc + 1;
|
||||
end
|
||||
i = i+1; -- next block
|
||||
end
|
||||
i = i + max_x - sub_length; -- next row; skip blocks inbetween
|
||||
end
|
||||
|
||||
i = i + ( (max_y - sub_length ) * max_x );
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print( "Changed "..tostring( anz_transformed ).." blocks. Ignored "..tostring( air_etc ).." blocks of air and dirt beneath grass_level.");
|
||||
return anz_transformed;
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
------ just for testing/debugging
|
||||
-- local filename = "level.dat";
|
||||
-- local file, err = io.open(filename, "rb");
|
||||
-- if err ~= nil then
|
||||
-- print "File not found.";
|
||||
-- return;
|
||||
-- end
|
||||
-- local value = file:read("*a");
|
||||
-- file:close();
|
||||
|
||||
-- local originpos = { x=0, y=0, z=0 };
|
||||
---- local dimension = { x=256, y=256, z=256 };
|
||||
-- local dimension = { x=16, y=16, z=16 };
|
||||
-- mcimport.deserialize_mc( originpos, value, dimension );
|
||||
|
526
nodes.lua
Normal file
526
nodes.lua
Normal file
@ -0,0 +1,526 @@
|
||||
-- Minetest 0.4 mod: default
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
WATER_ALPHA = 160
|
||||
WATER_VISC = 1
|
||||
LAVA_VISC = 7
|
||||
LIGHT_MAX = 14
|
||||
-- Yes, this blocks emit light. Otherwise huge buildings would be really dark!
|
||||
LIGHT_BUILDING_BLOCK = 0; --LIGHT_MAX-3
|
||||
|
||||
-- Definitions made by this mod that other mods can use too
|
||||
default = {}
|
||||
|
||||
--
|
||||
-- Nodes for "stairs" (slabs are used for quite a lot of things)
|
||||
--
|
||||
|
||||
|
||||
minetest.register_node("mcimport:double_stairs", {
|
||||
description = "Double stairs for buildings",
|
||||
tiles = { "mcimport_stair_top.png", "mcimport_stair_top.png", "mcimport_double_stair.png" },
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
drop = 'mcimport:stairs 2',
|
||||
})
|
||||
|
||||
-- TODO!
|
||||
--local node_mc_stairs = {};
|
||||
---- this is why it depends on stairs
|
||||
--for k,v in pairs( minetest.registered_nodes[ "stairs:slab_stone" ]) do
|
||||
-- node_mc_stairs[k] = v;
|
||||
--end
|
||||
|
||||
---- now we have to modify the slab so that it has a fitting name and emits light
|
||||
--node_mc_stairs.description = "Stairs etc. for building";
|
||||
--node_mc_stairs.tiles = { "mcimport_stair_top.png", "mcimport_stair_top.png", "mcimport_double_stair.png" };
|
||||
--node_mc_stairs.light_source = LIGHT_BUILDING_BLOCK;
|
||||
---- register the new node
|
||||
--minetest.register_node( "mcimport:stairs", node_mc_stairs );
|
||||
|
||||
-- TODO: is there no better way than cut&paste? :-(
|
||||
minetest.register_node("mcimport:stairs", {
|
||||
description = "Stairs etc. for building",
|
||||
drawtype = "nodebox",
|
||||
tiles = { "mcimport_stair_top.png", "mcimport_stair_top.png", "mcimport_double_stair.png" };
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
light_source = LIGHT_BUILDING_BLOCK;
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
||||
},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- If it's being placed on an another similar one, replace it with
|
||||
-- a full block
|
||||
local slabpos = nil
|
||||
local slabnode = nil
|
||||
local p0 = pointed_thing.under
|
||||
local p1 = pointed_thing.above
|
||||
local n0 = minetest.env:get_node(p0)
|
||||
local n1 = minetest.env:get_node(p1)
|
||||
if n0.name == "mcimport:stairs" then
|
||||
slabpos = p0
|
||||
slabnode = n0
|
||||
elseif n1.name == "mcimport:stairs" then
|
||||
slabpos = p1
|
||||
slabnode = n1
|
||||
end
|
||||
if slabpos then
|
||||
-- Remove the slab at slabpos
|
||||
minetest.env:remove_node(slabpos)
|
||||
-- Make a fake stack of a single item and try to place it
|
||||
local fakestack = ItemStack("mcimport:double_stairs")
|
||||
pointed_thing.above = slabpos
|
||||
fakestack = minetest.item_place(fakestack, placer, pointed_thing)
|
||||
-- If the item was taken from the fake stack, decrement original
|
||||
if not fakestack or fakestack:is_empty() then
|
||||
itemstack:take_item(1)
|
||||
-- Else put old node back
|
||||
else
|
||||
minetest.env:set_node(slabpos, slabnode)
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- Otherwise place regularly
|
||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Nodes for all the diffrent colors of wool
|
||||
--
|
||||
|
||||
-- just like wool:color - except that this is no wool
|
||||
local wool_colors = {"red", "orange","yellow","lime",
|
||||
"green","aqua","cyan","blue",
|
||||
"purple","indigo","magenta","pink","violet",
|
||||
"black","grey","white"};
|
||||
local i;
|
||||
|
||||
for i, color in ipairs( wool_colors ) do
|
||||
|
||||
minetest.register_node("mcimport:wool_"..color, {
|
||||
description = color.." wool for buildings",
|
||||
tiles = {"mcimport_wool_"..color..".png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
--
|
||||
-- Node definitions
|
||||
--
|
||||
|
||||
|
||||
|
||||
-- from water
|
||||
-- drawtype = "flowingliquid",
|
||||
-- liquidtype = "flowing",
|
||||
-- liquid_alternative_flowing = "default:water_flowing",
|
||||
-- liquid_alternative_source = "default:water_source",
|
||||
-- liquid_viscosity = WATER_VISC,
|
||||
|
||||
-- from telegate:plasma
|
||||
-- liquidtype = "flowing",
|
||||
-- liquid_alternative_flowing = "default:water_flowing",
|
||||
|
||||
-- water and lava which do not flow
|
||||
-- TODO: fancy effect...you can see throuh the floor and walls from the water-side
|
||||
minetest.register_node("mcimport:stationary_water", {
|
||||
description = "Stationary water for building",
|
||||
inventory_image = minetest.inventorycube( "mcimport_water.png" ),
|
||||
--drawtype = "flowingliquid",
|
||||
tiles ={"mcimport_water.png"},
|
||||
special_tiles = {
|
||||
{name="mcimport_water.png", backface_culling=false},
|
||||
{name="mcimport_water.png", backface_culling=true},
|
||||
},
|
||||
alpha = WATER_ALPHA,
|
||||
-- drawtype = "flowingliquid",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
-- climbable = true,
|
||||
-- post_effect_color = {a=64, r=100, g=100, b=200},
|
||||
post_effect_color = {a=80, r=50, g=200, b=50},
|
||||
groups = {},
|
||||
-- light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
|
||||
--minetest.register_node("mcimport:water_stationary", {
|
||||
-- description = "Flowing Water",
|
||||
-- inventory_image = minetest.inventorycube( "mcimport_water.png"),
|
||||
-- drawtype = "liquid",
|
||||
-- tiles = { "mcimport_water.png" },
|
||||
-- special_tiles = {
|
||||
-- {name="mcimport_water.png", backface_culling=false},
|
||||
-- {name= "mcimport_water.png", backface_culling=true},
|
||||
-- },
|
||||
-- alpha = WATER_ALPHA,
|
||||
-- paramtype = "light",
|
||||
-- walkable = false,
|
||||
-- pointable = false,
|
||||
-- diggable = false,
|
||||
-- buildable_to = true,
|
||||
-- liquidtype = "stationary", -- or "source"?
|
||||
-- liquid_alternative_flowing = "default:water_flowing",
|
||||
-- liquid_alternative_source = "default:water_source",
|
||||
-- liquid_viscosity = WATER_VISC,
|
||||
-- post_effect_color = {a=64, r=100, g=100, b=200},
|
||||
-- groups = {water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1},
|
||||
--})
|
||||
|
||||
-- this lava does no domage and does not flow (just for decorative use)
|
||||
minetest.register_node("mcimport:stationary_lava", {
|
||||
description = "Stationary lava for building",
|
||||
inventory_image = minetest.inventorycube( "mcimport_lava.png" ),
|
||||
--drawtype = "flowingliquid",
|
||||
tile_images = { "mcimport_lava.png"},
|
||||
alpha = 80,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
pointable = false,
|
||||
diggable = false,
|
||||
buildable_to = true,
|
||||
climbable = true,
|
||||
post_effect_color = {a=80, r=50, g=200, b=50},
|
||||
special_tiles = {
|
||||
{image="mcimport_lava.png", backface_culling=false},
|
||||
{image="mcimport_lava.png", backface_culling=true},
|
||||
},
|
||||
groups = {},
|
||||
-- light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
-- creates nodes for each minecraft classic block and takes care that
|
||||
-- sand/gravel do not fall, flowers/leves do not decay, grass stays green etc.
|
||||
|
||||
-- just like default:stone
|
||||
minetest.register_node("mcimport:stone", {
|
||||
description = "Stone for buildings",
|
||||
tiles = { "mcimport_stone.png" },
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
|
||||
-- like default:dirt_with_grass - except that it doesn't turn into dirt (mostly just renamed)
|
||||
minetest.register_node("mcimport:dirt_with_grass", {
|
||||
description = "Dirt with Grass that stays green for buildings",
|
||||
tiles = { "mcimport_grass.png", "mcimport_dirt.png", "mcimport_dirt.png^mcimport_grass_side.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
-- sounds = default.node_sound_dirt_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
--just like default:dirt
|
||||
minetest.register_node("mcimport:dirt", {
|
||||
description = "Dirt for buildings",
|
||||
tiles = { "mcimport_dirt.png" },
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
-- sounds = default.node_sound_dirt_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
|
||||
-- has a diffrent picture than normal cobble
|
||||
minetest.register_node("mcimport:cobble", {
|
||||
description = "Cobblestone for buildings",
|
||||
tiles = { "mcimport_cobble.png" },
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
|
||||
-- like default:wood
|
||||
minetest.register_node("mcimport:wood", {
|
||||
description = "Wooden Planks for buildings",
|
||||
tiles = { "mcimport_wood.png" },
|
||||
is_ground_content = true,
|
||||
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
|
||||
-- sounds = default.node_sound_wood_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
|
||||
-- like default:sapling but doesn't grow
|
||||
minetest.register_node("mcimport:sapling", {
|
||||
description = "Sapling for buildings",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = { "mcimport_sapling.png" },
|
||||
inventory_image = "mcimport_sapling.png",
|
||||
wield_image = "mcimport_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {snappy=2,flammable=2},
|
||||
-- sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
|
||||
|
||||
-- only looks like it but behaves like stone
|
||||
minetest.register_node("mcimport:bedrock", {
|
||||
description = "Bedrock for buildings",
|
||||
tiles = { "mcimport_bedrock.png" },
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
-- like default:sand but does not fall down
|
||||
minetest.register_node("mcimport:sand", {
|
||||
description = "Sandstone for buildings",
|
||||
tiles = { "mcimport_sand.png" },
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=3},
|
||||
-- sounds = default.node_sound_sand_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- like default:gravel but does not fall down
|
||||
minetest.register_node("mcimport:gravel", {
|
||||
description = "Gravel for buildings",
|
||||
tiles = { "mcimport_gravel.png"},
|
||||
is_ground_content = true,
|
||||
groups = {crumbly=2},
|
||||
-- sounds = default.node_sound_dirt_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
|
||||
-- no, this can't be mined!
|
||||
minetest.register_node("mcimport:gold_ore", {
|
||||
description = "Gold ore for buildings",
|
||||
tiles = { "mcimport_gold_ore.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- like default:iron_ore but can't be mined
|
||||
minetest.register_node("mcimport:iron_ore", {
|
||||
description = "Iron ore for buildings",
|
||||
tiles = { "mcimport_iron_ore.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- like default:coal_ore but can't be mined
|
||||
minetest.register_node("mcimport:coal_ore", {
|
||||
description = "Coal ore for buildings",
|
||||
tiles = { "mcimport_coal_ore.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- like default:tree
|
||||
minetest.register_node("mcimport:tree", {
|
||||
description = "Tree for buildings",
|
||||
tiles = { "mcimport_tree_top.png", "mcimport_tree_top.png", "mcimport_tree.png" },
|
||||
is_ground_content = true,
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
-- sounds = default.node_sound_wood_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- like default:leaves but do not decay
|
||||
minetest.register_node("mcimport:leaves", {
|
||||
description = "Leaves for buildings that do not decay",
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tiles = { "mcimport_leaves.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, flammable=2},
|
||||
-- sounds = default.node_sound_leaves_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- the sponge is purely for decoration
|
||||
minetest.register_node("mcimport:sponge", {
|
||||
description = "Sponge for buildings",
|
||||
tiles = { "mcimport_sponge.png" },
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- like default:glass
|
||||
minetest.register_node("mcimport:glass", {
|
||||
description = "Glass for buildings",
|
||||
drawtype = "glasslike",
|
||||
tiles = { "mcimport_glass.png" },
|
||||
inventory_image = minetest.inventorycube( "mcimport_glass.png"),
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
|
||||
-- sounds = default.node_sound_glass_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
|
||||
-- like flowers:dandelion_yellow but no flower
|
||||
minetest.register_node("mcimport:flower_yellow", {
|
||||
description = "Yellow flower for building",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "mcimport_flower_yellow.png" },
|
||||
inventory_image = "mcimport_flower_yellow.png",
|
||||
wield_image = "mcimport_flower_yellow.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = { snappy = 3,flammable=2 },
|
||||
-- sounds = default.node_sound_leaves_defaults()
|
||||
})
|
||||
|
||||
-- like flowers:rose but no flower
|
||||
minetest.register_node("mcimport:flower_red", {
|
||||
description = "Red rose for building",
|
||||
drawtype = "plantlike",
|
||||
tiles = { "mcimport_flower_rose.png" },
|
||||
inventory_image = "mcimport_flower_rose.png",
|
||||
wield_image = "mcimport_flower_rose.png",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = { snappy = 3,flammable=2 },
|
||||
-- sounds = default.node_sound_leaves_defaults()
|
||||
})
|
||||
|
||||
minetest.register_node("mcimport:brown_mushroom", {
|
||||
description = "Brown mushroom for buildings",
|
||||
tile_images = { "mcimport_mushroom_brown.png"},
|
||||
inventory_image = "mcimport_mushroom_brown.png",
|
||||
drawtype = "plantlike",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = { snappy = 3,flammable=2 },
|
||||
-- sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("mcimport:red_mushroom", {
|
||||
description = "Red mushroom for buildings",
|
||||
tile_images = { "mcimport_mushroom_red.png"},
|
||||
inventory_image = "mcimport_mushroom_red.png",
|
||||
drawtype = "plantlike",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = { snappy = 3,flammable=2 },
|
||||
-- sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
-- gold
|
||||
minetest.register_node("mcimport:gold", {
|
||||
description = "Gold Block for buildings",
|
||||
tiles = { "mcimport_gold_top.png", "mcimport_gold_bottom.png", "mcimport_gold_side.png" },
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_leaves_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
|
||||
-- like default:steelblock
|
||||
minetest.register_node("mcimport:steelblock", {
|
||||
description = "Metal Block for buildings",
|
||||
tiles = { "mcimport_metal_top.png", "mcimport_metal_bottom.png", "mcimport_metal_side.png" },
|
||||
is_ground_content = true,
|
||||
groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- just like default:brick
|
||||
minetest.register_node("mcimport:brick", {
|
||||
description = "Brick Block for buildings",
|
||||
tiles = { "mcimport_brick.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- tnt - not intendet for explosion
|
||||
minetest.register_node("mcimport:tnt", {
|
||||
description = "TNT for buildings",
|
||||
tiles = { "mcimport_tnt_top.png", "mcimport_tnt_bottom.png", "mcimport_tnt_side.png" },
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- like default:bookshelf
|
||||
minetest.register_node("mcimport:bookshelf", {
|
||||
description = "Bookshelf for buildings",
|
||||
tiles = {"mcimport_wood.png", "mcimport_wood.png", "mcimport_bookshelf.png"},
|
||||
is_ground_content = true,
|
||||
groups = {snappy=2,choppy=3,oddly_breakable_by_hand=2,flammable=3},
|
||||
-- sounds = default.node_sound_wood_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- like default:mossycobble
|
||||
minetest.register_node("mcimport:mossycobble", {
|
||||
description = "Mossy Cobblestone for buildings",
|
||||
tiles = {"mcimport_mossy_cobble.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
||||
-- obsidian (like obsidian:obsidian_block)
|
||||
minetest.register_node("mcimport:obsidian", {
|
||||
description = "Obsidian for buildings",
|
||||
tiles = {"mcimport_obsidian.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
-- sounds = default.node_sound_stone_defaults(),
|
||||
light_source = LIGHT_BUILDING_BLOCK,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user