Topic category: Help with modding (Java Edition)
Not sure how to ask this question it is kind of complicated so please be patient as I try and explain one of my favorite data manipulation techniques. I've used this technique in many personally created game engines and other professional programming tasks I've ran into over the years.
Using a Bitwise operator on an Integer has helped me store directional information in a very compact format. Since processors don't look at numbers the way we do we can use the Binary data in an integer to help speed directional evaluations. For example take these "Magic Numbers" 1, 2, 4, 8, 16, and 32. This would use 6 bits in a 32 or 64 bit Integer:
|Real Number||Binary Version||Direction|
From this chart you can see how using Binary could be advantageous since instead of tracking 6 directions in six variables we could store all this in one variable. Yes I know this is only 8 bits but a 32 and 64 bit number would just be padded with 0. Anyways back to my problem in MCreator. When I try and store this in a number since all numbers are decimal the Java compile complains that something like if(3 & MCreatorDemoModVariable.WorldVariable.get(world).TEST_DIRECTION_1 == NORTH) you'll get the error message "bad operator types for binary operator &". In the code editor it would look something like this:
This is kind of expected since Java doesn't like to perform Bitwise operators on decimal numbers. Is there a way to tell the GUI programming to typecast the variable for this kind of bitwise operation?
I know we can just go modify the source code and fix this issue but once you open the modified procedure in the GUI code editor all those fixes will be wiped out. If you have any ideas please share I would appreciate it.