Flower pot conversion

We always plant a full size flower pot. If there are tile
entities, we translate those to blocks and attempt to plant
them on top of the flower pot.
This commit is contained in:
Auke Kok 2015-11-22 14:47:28 -08:00
parent 63afc25900
commit aad68da074
3 changed files with 75 additions and 3 deletions

View File

@ -281,7 +281,18 @@ class MTBlock:
if p2 != None:
param2[index] = p2
if meta != None:
self.metadata[(x&0xf, y&0xf, z&0xf)] = meta
try:
p = meta[0]["_plant"]
above = ((((y)&0xf)<<8)|((z&0xf)<<4)|(x&0xf)) + 256
if above < 4096 and blocks[above] == 0:
if p > 15:
content[above], param2[above] = conversion_table[941][p&0xf]
else:
content[above], param2[above] = conversion_table[940][p]
else:
print("can't pot plant in pot across block border, or not air")
except:
self.metadata[(x&0xf, y&0xf, z&0xf)] = meta
def save(self):
os = BytesIO()

View File

@ -554,7 +554,7 @@
139 1 default:mossycobble // FIXME: you may not want this
139 default:cobble // FIXME: you may not want this
140 homedecor:flower_pot_small
140 homedecor:flower_pot_terracotta // code will plant flowers on top
143 0 mesecons_button:button_off 8
143 1 mesecons_button:button_off 1
@ -668,6 +668,31 @@
931 3 default:grass_4
931 4 default:grass_5
// flower pot plants
940 0 air
940 1 flowers:mushroom_brown
940 2 flowers:mushroom_red
940 3 default:cactus
940 4 default:dry_shrub
940 5 flowers:rose
940 6 flowers:geranium
940 7 flowers:viola
940 8 flowers:geranium
940 9 flowers:rose
940 10 flowers:tulip
940 11 flowers:dandelion_white
940 12 flowers:viola
940 13 flowers:dandelion_white
940 14 default:sapling
940 15 moretrees:spruce_sapling
// overflow
941 0 moretrees:birch_sapling
941 1 moretrees:sequoia_sapling
941 2 default:acacia_sapling
941 3 moretrees:oak_sapling
941 4 ferns:tree_fern_leaves
941 5 flowers:dandelion_white
964 0 doors:door_wood_b_1 3
964 1 doors:door_wood_b_1 0
964 2 doors:door_wood_b_1 1

View File

@ -66,7 +66,43 @@ def convert_nodeblock(te):
pitch = te.get("note")
return None, int(pitch) % 12, None
def convert_pot(te):
c = str(te.get("Item"))+":"+str(te.get("Data"))
# translation table for flowers
# highly approximate, based on color only
t = {
":0" : 0, # air
"minecraft:brown_mushroom:0" : 1,
"minecraft:red_mushroom:0" : 2,
"minecraft:cactus:0" : 3,
"minecraft:deadbush:0" : 4,
"minecraft:red_flower:0" : 5,
"minecraft:red_flower:1" : 6,
"minecraft:red_flower:2" : 7,
"minecraft:red_flower:3" : 8,
"minecraft:red_flower:4" : 9,
"minecraft:red_flower:5" : 10,
"minecraft:red_flower:6" : 11,
"minecraft:red_flower:7" : 12,
"minecraft:red_flower:8" : 13,
"minecraft:sapling:0" : 14,
"minecraft:sapling:1" : 15,
"minecraft:sapling:2" : 16,
"minecraft:sapling:3" : 17,
"minecraft:sapling:4" : 18,
"minecraft:sapling:5" : 19,
"minecraft:tallgrass:2" : 20,
"minecraft:yellow_flower:0" : 21
}
try:
fields = { "_plant": t[c] }
return None, None, (fields, {})
except:
print('Unknown flower pot type: '+c)
return None, None, None
te_convert = {"chest": convert_chest,
"sign": convert_sign,
"furnace": convert_furnace,
"music": convert_nodeblock}
"music": convert_nodeblock,
"flowerpot": convert_pot}