Topic category: Troubleshooting, bugs, and solutions
There are only a few times where I start questioning whether programming languages are actually unambiguous or not.
In this case I created a procedure:
On Player Tick Update.
"Some code"
If (condition) is true
do Sent to chat to all players "DebugMessage"
do Deal 1 damage to provided entity.
"More code"
So I basically debugged to check whether the procedure would reach the Deal Damage and as I play tested, yes it did! Every 5 seconds I got the message "DebugMessage". However no damage was dealt...
Inside of this procedure I'm mostly setting and checking NBT tags with somewhere a "Set Entity Health to 0" down the road that does not trigger under any normal circumstance.
To check whether it was possible to use Deal [] damage to entity in On Player Tick Update, I recreated it in a different workspace:
if number nbt tag Counter < 1000
increment nbt tag Counter
else
deal 1 damage to provided entity
send message to all
set nbt tag Counter to 0
And as I originally expected, but were now surprised by, it worked!
So in both cases, I know for a FACT that the if statement in which the deal x damage to entity has returned true as I received the chat message, yet in my original workspace it failed to do any damage.
Does anyone know how to solve this or is this a bug?
Probably a bug. Try remaking that mod element.
Try making another one and add back in it the custom code. If it works without the custom code, it should with it. Otherwise, your code might have an error somewhere in it or something that interferes with your procedure.
(You could look up packets in mc, I remember them being linked to stuff like this.)
Try swapping
do Sent to chat to all players "DebugMessage"
and
do Deal 1 damage to provided entity.
order and try if anything changes.
Works: https://pasteboard.co/IBabWln.png
Doesn't work: https://pasteboard.co/IBacd0C.png
I did some additional testing:
Inside of the crucial If statement I put:
1. Send to chat to all players "DebugMessage'
2. Send message to provided Entity "DebugMessagePrivate" (don't show in action bar)
3. Play at xyz sound, lvl pitch
4. Add 1 (item) to provided entityplayers inventory
5. Set food level of provided entity to 2
6. Deal 1 damage to provided entity (yet again)
7. Set entity number nbt tag to 0
8. Set entity health to entity health -1
Of the ones being executed were: 1, 4, 5, 7. All the other ones failed to do anything.
(Swapping it around or removing the debug message entirely didn't work as I originally tried it out without debug message.)
Could this possibly be a server, client side of issue? I'd be really confused as things worked inside the first picture linked above. But when it comes to sending the player a message, the "Send message to provided Entity "DebugMessagePrivate" (don't show in action bar)" doesn't work, but the global one does.
It also appears that it doesn't fail to get the player dependency, as it managed to put stuff in my inventory and set my food level to a lower value.
Why do I always run into the weird stuff xD
It could be that On Player Tick Update. is server side only, in fact I am quite sure it is. Sending chat to the player is client-side action, though.
The more that I think of it, the less server-side could have anything to do with it as deal damage to provided entity did work in the other procedure.
The only possible thing that I can think of causing this is: https://mcreator.net/forum/53067/safety-measure-or-bug-procedure-doesnt-execute-code
The procedure on player tick is twice the size of what is shown in the image. Additionally there's a second on player tick procedure that is the same size as it. Or at best, having 2 different player tick procedures may cause interference with certain code blocks, but I'm just guessing at that point
OMG KLEMEN I FOUND IT!!!!
Okey so it's definitely interference between having 2 player tick procedures. I created a new workspace and created 2 On Player Tick procedures:
Procedure Logic 1: Counter with the deal 1 damage.
Procedure Logic 2: Set a useless nbt tag to 0
If you put Procedure Logic 1 inside of the first created OnPlayerTick and the Procedure Logic 2 inside of the second created OnPlayerTick procedure mod element, then everything will work, however, if you place Procedure logic 2 inside of the 2nd OnPlayerTick procedure and Procedure logic 1 inside of the first created OnPlayerTick, the deal damage stops working!
YASSS
So the bug formulation:
Any replicas of a global trigger will cause selective Code Blocks to break that are placed inside of them, that would have worked had they been placed in the first created global trigger.
There's more to the issue:
1st Procedure = On Player Tick: Counter
2nd Procedure = On Player Tick: Useless
Damage does work
------------------------------------------------------------------------------------------------
Changing 1st Procedure to On Player joins world: Useless
Changing 2nd Procedure to On Player Tick: Counter (Thus making this the first On Player Tick)
Damage will NOT work!
------------------------------------------------------------------------------------------------
Deleting Procedure 1
Keeping 2nd Procedure to On Player Tick: Counter
Damage will NOT work!
------------------------------------------------------------------------------------------------
Having both deleted procedure 1 and 2, and creating a new procedure On Tick Update: Counter
Damage does work.
I'm so weirded out by this.
Additionally, if you create a procedure (On some global trigger) and then create the On Player Tick, it doesn't matter whether it's a replica or not. If the procedure is a global trigger and is not the first global trigger created inside of your workspace, specific Code Blocks of which some mentioned above will lose any functionality.
But I think I've caught on on how this bug behaved by now...
Thank you for your research on the bug!
I have made one procedure that prints aaa to chat and one that prints bbb to chat using player tick and both worked. Also this: https://www.minecraftforge.net/forum/topic/62662-1122-solved-is-it-okay-to-subscribe-to-same-event-twice/
So I am not sure yet why this is happening.
It could be that setting NBT of entity on tick cancels the current tick.
Hey, I forgot to add this because I had to go, but in my simplified version when testing the bug the "Send message to provided entity" also worked, just like it did for you. I'll try to make a short compact video showing all the strange behaviours and see if you manage to replicate the result.
I can replicate the result, but I think it has to do with NBT tag manipulation altering tick of entity.
Wait, so you managed to get it to fail certain procedure blocks?
Because I'd be damned, when I tried recreating the bug from a new workspace the second time... and nothing worked! And by that I mean, everything worked! I'm so confused. No matter what I do manages to break my new workspace. Even copying over my entire player tick from my main workspace works fine in the new one.
This is so strange as when I discovered the bug in my main workspace and tried replicating it in my second workspace, it exactly broke in the way I expected, and broke even further as described in my later comments.
So how on earth were you able to replicate my result if even I am unable to do so now xD