[Suggestion]: Better Vanilla integration
SylisMC opened this issue ยท 5 comments
What is your suggestion?
I'm currently developing a datapack that uses pehkui a lot. and I'm often finding myself having to create complex solutions to get around a few base game integrations features that are missing.
Selector variables
- IS tag @A[pehkui.scale=1] - added
- IS NOT @A[pehkui.scale=!1] - missing
- Greater than @A[pehkui.scale=1..] - missing
- Less than @A[pehkui.scale=..1] - missing
- Between x&y @A[pehkui.scale=1.2] - missing
Scoreboards
Scoreboards that are directly linked to a player's size. this would be a great way around selector variables because the scoreboard would inherit the default selector variables
/scoreboard objectives add BaseSize pehkui:Base
I'm using the latest Pehkui version and I can say that "greater than", "less than" and "between x&y" already exist.
And your suggestion about scoreboards is impossible because scoreboards uses integer values and player size is a float value. You can use something like
/execute as @a store result score @s scale run data get entity @s "pehkui:scale_data_types"."pehkui:base".scale
but it will only show you integer values e.g. 0 if it's anything between 0 and 1, 1 if it's anything between 1 and 2. This can't be changed because of the way how Minecraft works.
Scoreboards are 100% possible you can convert a float to an integer, you just need to round to the nearest predetermined float. say sets of 0.25
1.75=3
| 1.5=2
| 1.25=1
| 1=0
| 0.75=-1
| 0.5=-2
| 0.25=-1
Ideally, you would probably round to the nearest pixel. in this example p=pixel s=scale/size
if s=1 p=32
score is 32, if s=0.5 p=16
, if s=0.03125 p=1
If s=0.03125 p=1
then s=0.0625 = p=2
0.046875
is the magic halfway point
if i could use the pehkui variable to test between variables I could do this within the restrictions of commands. i see no reason why it couldnt be done within the mod. If there is something I've overlooked or done incorrectly please, let me know @ImSpaceLover
As for /execute as @a store
that's great. and if you added an "unless size=1" filter you could tell if a player was shrunk, but you still can't tell the difference between someone that is half or quarter-sized
your idea with storing floats like this is good but I just remembered /data get entity
has scale for /execute store
so you can divide stored number to get your original scale. For example I used
execute unless entity @p[pehkui.scale=1] as @a store result score @s scale run data get entity @s "pehkui:scale_data_types"."pehkui:base".scale 1000000
to store my scale in a scoreboard and then used
execute as @e[type=wolf] store result entity @s "pehkui:scale_data_types"."pehkui:base".scale float 0.000001 run scoreboard players get @p scale
to make every wolf copy my scale. I used only 1 million scoreboard scale so when my own scale is smaller than this every wolf, obviously, becomes 0 sized. You can use more to make scaling more accurate but I think this is enough.
Also I just used
scale reset @e[pehkui.scale=4..16]
in a command block and it worked fine
the wolf scaling is an interesting idea. i hadn't considered pets, i really like that idea, and id love to try and make it multiplayer friendly, ill have to figure out a way to make it only apply to pets you own. I need to play around with execute more because there is a lot i dont know about how it works.
Regarding scale reset @e[pehkui.scale=4..16]
reset is the only command that works with those parameters, but that gives me another idea, i just assumed that none of them work, but if reset works, i can convert the reset command into others based on my size scoreboard, thanks for that
I used wolf scaling just as an example, I hadn't considered scaling pets either. I think it's possible to make it multiplayer-friendly by matching wolves' (and other pets') Owner NBT tag and players' UUID NBT tag and scaling them only if they match
Also, do you have a discord account or something? I think our conversation is a bit off-topic now, would be nice to continue it in DMs