Describing what I want to do is fairly simple. I want to use this command but in code:
/data modify entity @e[type=minecraft:zombie,sort=nearest,limit=1] HandDropChances set value [0.0f, 0.0f]
The entity and the fact that it contains HandDropChances are already known, so ignore those parts of the issue
the specific part I am struggling with is making it accept [0.0f, 0.0f]
the following is part Java and part psuedocode of what I am looking to do.
void someVoid(Entity ent) {
CompoundTag compTag = ent.saveWithoutId(new CompoundTag());
String name = "HandDropChances";
if (compTag.contains(name)) {
//.setTag doesn't exist of course,
//and [0.0f, 0.0f] is nonsense,
//but I don't know how I ought to declare it in order to get it into the form I need to actually achieve this.
compTag.setTag(name, [0.0f, 0.0f]);
// What I've been trying to do to make this happen is below
ListTag tagList = (ListTag) compTag.get(name);
tagList.clear();
tagList.add(0.0f);
tagList.add(0.0f);
compTag.remove(name);
compTag.put(tagList);
//or something like that, anyway. but floats aren't Tags so this, of course, doesn't work
}
}