Topic category: Help with Minecraft modding (Java Edition)
I'm trying to make a book item that'll only glow under specific conditions. Specifically: In the proper biome, at or above cloud height, around midnight, with the sky visible. Reason I want those conditions specifically is cause those are the conditions you can actually use the item, and I think it glowing would be a good tell for the player to know it can be used (Main idea is that, when right clicked in the off-hand with a specific weapon in the main-hand, it'll give the weapon a special enchant only it can get and the book will be used up).
So far, my procedure is this (Doing it via text cause putting an image is kind of a hassle. Hopefully this makes sense):
No additional trigger
If: Is biome at x: x, y: y, z: z type CUSTOM:StellarMountain
AND: Get height of Event/target entity ≥ 128
AND: Can location at x: x, y: y, z: z see the sky
AND: Get current world time ≥ 17000
AND: Get current world time ≤ 19000
Do: Return true
Return false
But it glows despite not meeting any of those conditions. How do I get it to actually work the way I plan it to? Cause I was certain this would work, but it just isn't (And yes, the item glow condition is set in the item's mod element). Any help would be appreciated.
Update: Turns out it glowing was just MCreator being janky and undoing my settings despite me having saved again.
But now it doesn't glow even when it does meet the conditions, so I still need help, just for the opposite issue. Lol.
Update 2: It also won't function despite meeting the conditions. Idk what I did wrong. ;-;
Update 3: Turns out "AND: Get height of Event/target entity ≥ 128" is what was causing it all to break, so changing it to "Get world surface height at x: x, z: z" made it function properly, but it still doesn't glow even with that bit replaced, which is really weird.
Update 4: Ok, so I made the glowing TECHNICALLY function. The problem is that it only glows when all the conditions are met and... you're standing on a block you've smacked. What? How is that even a thing that's happening? I'm so confused. Lmao.
New procedure for reference:
No additional trigger
If: Is biome at x: x, y: y, z: z type CUSTOM:StellarMountain
AND: Can location at x: x, y: y, z: z see the sky
AND: Get current world time ≥ 17000
AND: Get current world time ≤ 19000
Do: If: Get World surface height at x: x, z: z ≥ 128
Do: Return true
Return false
Any ideas on what's causing this?
I really don't want to get rid of the glowing, cause it'd be a good QOL thing, but if it breaks like this, I might just have to. :/
...I guess I might just have to remove it... Either that or leave it in and give a warning or something? Idk.
Thing is, I know what's breaking it. It's the height detection. But idk what alternative I could use, cause height is very important for this feature... :/
You are using the return block wrong (a lot of people do, don't feel bad). Rather than putting the return block inside an if statement, the return block should contain all the conditions itself, something like this:
return <condition 1> and <condition 2> and <condition 3> etc.
Its also doing this because AND detects ONLY if both statements align
So it does return true is True AND True BUT it ALSO returns true is False AND False
Your code isn't necessarily wrong just a Logic error
Do them in nested IF statements instead to have it all function correctly
Example
If biome check
Else
I just want to add that the comment by @SirPogsalot helped me solve a similar issue.
to put what you need to do into text for anyone who wants to do anything similar (activate at certain time for the example shown below):
No additional trigger
Return Logic: ({[Get Current World Time] > [(time you want it to start)]} [AND] {[Get Current World Time] < [(time you want it to end)]} = [True])
Each bracket set is a block. The actual code only has one "line" of blocks, and you DO NOT need a [return false] block anywhere
(if my text looks confusing, all I did was make ( [Return Logic:] (conditions) = [True] ) and it worked.)