Started by
mjiau
on
Topic category: Help with modding (Java Edition)
I want to make a block that changes into another block when stepped on, and then a third block when stepped on again. The problem is that if I just simply make a procedure to change the block into the next one when stepped on on the first two blocks, it immeadeatly turns into the third block. I want the player to have to step off the block and back on for it to change again.
You'll need to add an additional nbt logic tag to the block that tracks if a player is currently on it. (Making sure to use the 'replace block, keep NBT data' function.) Essentially:
great, but how exactly do I add an nbt tag?
ok well I was able to put something together although it doesn't work, here's all my code
Did you enable block entity for your custom block?
yes I did
Okay, the code should look something like this. The top section is for when the block is stepped on, the bottom section needs to be run on the block's update tick. The tag can be whatever you want to name it, as long as it's consistent:
Is this at all helpful? If this looks more or less like what you've got, I'd recommend double checking everything's linked properly, update tick's enabled, maybe reloading the gradle project if it looks like something's just bugged.
I copied your code pretty much exactly but it still doesn't work. When I step on the first block its quickly cycles through all the blocks and then turns into the second block and if I step on it again nothing happens. If I step on the second block (one that I placed myself) it turns into block three, just like it should.
I don't know If I've done the variable nbt whatever stuff correctly, that's probably the issue.
Right now I've got a variable called "snowpuzzle" with variable type "logic" and variable scope "GLOBAL_MAP" and initial value "false", I have no idea if that is correct or not.
Ah. That may be the issue- global map variables are true for the entire world, and would thus affect all the blocks. You need something that's specific to each block.
If NBT states really aren't working, you could technically make five distinct blocks instead of three. (Block 1, untriggered; Block 1 triggered; Block 2 untriggered, Block 2 triggered, and Block 3.) When a player steps on a block, change it to the triggered variant. When there's no longer a player on top of the block, change it to the next untriggered variant. Probably needlessly complicated, but I guess you'd get to make two additional textures if ya wanted.
ok well, after messing around for a while with variables and I've deduced that they're completely broken.
For whatever reason, absolutely randomly, they've changed to a different type of variable? I didn't change them?
If I change them back my mod doesn't compile anymore and everything breaks.
I give up...
If the mod doesn't compile when you change the variables, that means somewhere you've got a procedure that's trying to reference the old variable. (If you change a logic variable to a number variable, but don't change the procedure, the procedure will try to reference a number variable as if it were logic, which causes a compilation error.) If you click the red links in the error message, it should direct you to which procedures are still using the old one.
If you still want to give it a try, it might also be worth testing this in another workspace? Then you might be able to get some indication if the code itself is wrong, or if your workspace is corrupted.