Wuzzy2 / MineClone2-Bugs

Bug tracker archive for MineClone 2 (no new posts allowed)
MIT License
7 stars 0 forks source link

Pumpkin-Redstone interactions #469

Closed Bu-Gee closed 6 years ago

Bu-Gee commented 6 years ago

So, there were a few issues with pumpkins and redstone:

  1. When a piston picked a pumpkin, the stem wouldn't update and as a result, it wouldn't grow a new pumpkin.
  2. Pumpkins would not conduct redstone energy as they do in Minecraft

In fixing the second item, I introduced a new problem where the piston would both dig and push the pumpkins. This only happens when the pumpkin is a redstone conductor, so I fixed that too.

Here is a patch to fix all that. It modifies mesecons code. I don't know if that is a no-no or not.

diff --git a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua
index 40d713eb..fbd68d4f 100644
--- a/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua
+++ b/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua
@@ -218,10 +218,12 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
                local is_dropper = mesecon.is_mvps_dropper(n.node, movedir, nodes, id)
                if is_dropper then
                        local drops = minetest.get_node_drops(n.node.name, "")
-                       local droppos = vector.add(n.pos, movedir)
-                       minetest.handle_node_drops(droppos, drops, nil)
+                       --local droppos = vector.add(n.pos, movedir)
+                       --minetest.handle_node_drops(droppos, drops, nil)
+                       minetest.dig_node(n.pos)
+               else
+                       minetest.remove_node(n.pos)
                end
-               minetest.remove_node(n.pos)
                if is_dropper then
                        first_dropper = id
                        break
@@ -256,6 +258,9 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
        local moved_nodes = {}
        local oldstack = mesecon.tablecopy(nodes)
        for i in ipairs(nodes) do
+               if first_dropper and i >= first_dropper then
+                        break
+                end
                moved_nodes[i] = {}
                moved_nodes[i].oldpos = nodes[i].pos
                nodes[i].pos = vector.add(nodes[i].pos, movedir)
diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua
index 09bb473e..3816f10e 100644
--- a/mods/ITEMS/mcl_farming/pumpkin.lua
+++ b/mods/ITEMS/mcl_farming/pumpkin.lua
@@ -89,6 +89,13 @@ local pumpkin_base_def = {
        sounds = mcl_sounds.node_sound_wood_defaults(),
        _mcl_blast_resistance = 5,
        _mcl_hardness = 1,
+       mesecons = {
+               conductor = {
+                       state = mesecon.state.on,
+                       onstate = "mcl_farming:pumpkin",
+                       offstate = "mcl_farming:pumpkin",
+               }
+       }
 }
 minetest.register_node("mcl_farming:pumpkin", pumpkin_base_def)

@@ -98,6 +105,13 @@ pumpkin_face_base_def._doc_items_longdesc = "A pumpkin can be worn as a helmet f
 pumpkin_face_base_def.tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face.png"}
 pumpkin_face_base_def.groups.armor_head=1
 pumpkin_face_base_def.groups.non_combat_armor=1
+pumpkin_face_base_def.mesecons = {
+       conductor = {
+                state = mesecon.state.on,
+                onstate = "mcl_farming:pumpkin_face",
+                offstate = "mcl_farming:pumpkin_face",
+        }
+}

 -- Register stem growth
 mcl_farming:add_plant("plant_pumpkin_stem", "mcl_farming:pumpkintige_unconnect", {"mcl_farming:pumpkin_1", "mcl_farming:pumpkin_2", "mcl_farming:pumpkin_3", "mcl_farming:pumpkin_4", "mcl_farming:pumpkin_5", "mcl_farming:pumpkin_6", "mcl_farming:pumpkin_7"}, 30, 5)
Wuzzy2 commented 6 years ago

Yes, all the mesecons mods are open to any form of changes. I cut all ties to the original Mesecons modpack. I just did not bother changing the mod name yet.

So. The first part of the patch is fine. Yeah, just calling minetest.dig_node seems to have been the trick. Good job in catching a place with a missing check. I have committed this under your name. There seem to be no problems. Thank you!

But the part where you changed the pumpkins is total nonsense. Pumpkins are not conductors! They never were. That's not how redstone power works. Your code actually made pumpkins power sources. Redstone dust would be powered by pumpkins! XD

You seem to confuse redstone conductors with opaque blocks. Any block which is opaque will transmit redstone power to the other side. The actual rules are a bit complicated, but the bottom line is that when you put a redstone power source next to an opaque block, the opaque block may also transmit that power to its neighbors. But this does not make them conductors! They differ from conductors like redstone trails in that they do not transmit redstone power recursively.. Would opaque blocks be conductors, then a single redstone torch would power on the entire world. :-)

So the real bug with pumpkins (and melons, too!) was that I made these blocks non-opaque some time ago for some reason. This was a mistake which I have fixed now. Redstone power now goes through like you expect. http://repo.or.cz/MineClone/MineClone2.git/commitdiff/e19271398d7759a597470d599dc01fada966d67b?hp=d73651424c7877ddc3916cd8d3ea8f0a5f3c522b http://repo.or.cz/MineClone/MineClone2.git/commitdiff/d2f01c68f520913b487096fc2549fe2648a32a33

Bu-Gee commented 6 years ago

Good to know about the conductors. Thanks for the info.