Starchasers / OCGlasses

mod for minecraft and addon for Open Computers
zlib License
30 stars 17 forks source link

[API Bug] Incorrect document and error message of ModifierRotate #110

Open fan87 opened 2 years ago

fan87 commented 2 years ago

Describe the bug Please check To Reproduce

In which environment did the Bug appear? Server-side, but it will appear in every environment

To Reproduce Incorrect Error Message: Pass 3 arguments to ModifierRotate.set somehow, 4 will be fine, 2, 1, or 0 will return false and an error message, but 3 throws an exception. It should also return false and an error message instead of throwing an exception Incorrect document: Somehow get a ModifierRotate object, then tostring the method set, it shows function(Double:x, Double:y, Double:z):boolean -- sets new values, but it should be function(Double:deg, Double:x, Double:y, Double:z):boolean -- sets new values

Expected behavior Please check To Reproduce

Minecraft:

Additional context In the sourcecode of ModifierRotate.java:

    @Callback(doc = "function(Double:x, Double:y, Double:z):boolean -- sets new values", direct = true)
    public Object[] set(Context context, Arguments args){
        if(!args.isDouble(0) || !args.isDouble(1) || !args.isDouble(2))
            return new Object[]{ false, "4 values(Double) required! deg, x,y,z" };

        get().update(new float[]{ (float) args.checkDouble(0), (float) args.checkDouble(1), (float) args.checkDouble(2), (float) args.checkDouble(3) });

        markDirty();
        return new Object[]{ true };
    }

It seems to be requiring 4 doubles, but the doc only has 3, and the argument check (the check that returns false and the error message) only checks first 3 arguments.