33import com .mojang .nbt .tags .CompoundTag ;
44import com .mojang .nbt .tags .Tag ;
55import net .fabricmc .api .ModInitializer ;
6- import net .minecraft .core .Global ;
76import net .minecraft .core .block .Block ;
87import net .minecraft .core .block .BlockLogic ;
98import net .minecraft .core .block .Blocks ;
@@ -64,19 +63,19 @@ public void connectSignals() {
6463 DIMENSION_SAVE_SIGNAL .connect (NetworkManager .LoadSaveListener .INSTANCE );
6564 }
6665
67- public static <K ,V > Map <K ,V > mapOf (K [] keys , V [] values ){
68- if (keys .length != values .length ){
66+ public static <K , V > Map <K , V > mapOf (K [] keys , V [] values ) {
67+ if (keys .length != values .length ) {
6968 throw new IllegalArgumentException ("Arrays differ in size!" );
7069 }
71- HashMap <K ,V > map = new HashMap <>();
70+ HashMap <K , V > map = new HashMap <>();
7271 for (int i = 0 ; i < keys .length ; i ++) {
73- map .put (keys [i ],values [i ]);
72+ map .put (keys [i ], values [i ]);
7473 }
7574 return map ;
7675 }
7776
78- public static <T ,V > T [] arrayFill (T [] array ,V value ){
79- Arrays .fill (array ,value );
77+ public static <T , V > T [] arrayFill (T [] array , V value ) {
78+ Arrays .fill (array , value );
8079 return array ;
8180 }
8281
@@ -94,44 +93,44 @@ public static double map(double valueCoord,
9493 }
9594
9695 @ SafeVarargs
97- public static <T > List <T > listOf (T ... values ){
96+ public static <T > List <T > listOf (T ... values ) {
9897 return new ArrayList <>(Arrays .asList (values ));
9998 }
10099
101100 @ SafeVarargs
102- public static <T > Set <T > setOf (T ... values ){
101+ public static <T > Set <T > setOf (T ... values ) {
103102 return new HashSet <>(Arrays .asList (values ));
104103 }
105104
106- public static <T ,U > List <Pair <T ,U >> zip (List <T > first , List <U > second ){
107- List <Pair <T ,U >> list = new ArrayList <>();
105+ public static <T , U > List <Pair <T , U >> zip (List <T > first , List <U > second ) {
106+ List <Pair <T , U >> list = new ArrayList <>();
108107 List <?> shortest = first .size () < second .size () ? first : second ;
109108 for (int i = 0 ; i < shortest .size (); i ++) {
110- list .add (Pair .of (first .get (i ),second .get (i )));
109+ list .add (Pair .of (first .get (i ), second .get (i )));
111110 }
112111 return list ;
113112 }
114113
115- public static CompoundTag compoundOf (String [] keys , Object ... values ){
114+ public static CompoundTag compoundOf (String [] keys , Object ... values ) {
116115 CompoundTag tag = new CompoundTag ();
117116
118117 tag .setValue (
119118 mapOf (keys ,
120- zip (listOf (keys ),listOf (values ))
119+ zip (listOf (keys ), listOf (values ))
121120 .stream ()
122121 .map (pair -> tagOf (pair .getLeft (), pair .getRight ()))
123122 .toArray (Tag []::new ))
124123 );
125124 return tag ;
126125 }
127126
128- public static <T > Tag <T > tagOf (T value ){
127+ public static <T > Tag <T > tagOf (T value ) {
129128 Tag <T > tag = (Tag <T >) Tag .createTagOfType (value .getClass ());
130129 tag .setValue (value );
131130 return tag ;
132131 }
133132
134- public static <T > Tag <T > tagOf (String name , T value ){
133+ public static <T > Tag <T > tagOf (String name , T value ) {
135134 Tag <T > tag = (Tag <T >) Tag .createTagOfType (value .getClass ());
136135 tag .setValue (value );
137136 tag .setName (name );
@@ -142,10 +141,10 @@ public static <T> Tag<T> tagOf(String name, T value){
142141 * @param values The values to be checked
143142 * @return Returns the smallest of <code>values</code>
144143 */
145- public static long multiMin (long ... values ){
144+ public static long multiMin (long ... values ) {
146145 long min = Long .MAX_VALUE ;
147146 for (long value : values ) {
148- if (value < min ){
147+ if (value < min ) {
149148 min = value ;
150149 }
151150 }
@@ -163,62 +162,62 @@ public static ArrayList<ItemStack> condenseItemList(List<ItemStack> list) {
163162 found = true ;
164163 }
165164 }
166- if (!found ) stacks .add (stack .copy ());
165+ if (!found ) stacks .add (stack .copy ());
167166 }
168167 }
169168 return stacks ;
170169 }
171170
172- public static @ UnmodifiableView List <ItemStack > collectStacks (Container inv ){
173- if (inv == null ) return Collections .emptyList ();
171+ public static @ UnmodifiableView List <ItemStack > collectStacks (Container inv ) {
172+ if (inv == null ) return Collections .emptyList ();
174173 ArrayList <ItemStack > stacks = new ArrayList <>();
175174
176175 for (int i = 0 ; i < inv .getContainerSize (); i ++) {
177- stacks .add (i ,inv .getItem (i ));
176+ stacks .add (i , inv .getItem (i ));
178177 }
179178
180179 return Collections .unmodifiableList (stacks );
181180 }
182181
183- public static @ UnmodifiableView List <ItemStack > collectAndCondenseStacks (Container inv ){
182+ public static @ UnmodifiableView List <ItemStack > collectAndCondenseStacks (Container inv ) {
184183 return condenseItemList (collectStacks (inv ));
185184 }
186185
187- public static Pair <Direction , BlockSection > getBlockSurfaceClickPosition (World world , Player player , Side side , Vec2f clickPosition ){
186+ public static Pair <Direction , BlockSection > getBlockSurfaceClickPosition (World world , Player player , Side side , Vec2f clickPosition ) {
188187 Direction dir = Direction .getDirectionFromSide (side .getId ());
189- return Pair .of (dir ,BlockSection .getClosestBlockSection (clickPosition ));
188+ return Pair .of (dir , BlockSection .getClosestBlockSection (clickPosition ));
190189 }
191190
192191 public static Side calculatePlayerFacing (float rotation ) {
193192 return Side .values ()[(2 + ((MathHelper .floor ((double ) ((rotation * 4F ) / 360F ) + 0.5D ) + 2 ) & 3 ))];
194193 }
195194
196- public static void displayGui (Player player , Container inventory , int slotIndex , boolean isArmor , String id ){
197- ((IMpGui )player ).catalyst$displayCustomGUI (inventory , slotIndex , isArmor , id );
195+ public static void displayGui (Player player , Container inventory , int slotIndex , boolean isArmor , String id ) {
196+ ((IMpGui ) player ).catalyst$displayCustomGUI (inventory , slotIndex , isArmor , id );
198197 }
199198
200199
201- public static void displayGui (Player player , TileEntity tileEntity , String id ){
202- ((IMpGui )player ).catalyst$displayCustomGUI (tileEntity , id );
200+ public static void displayGui (Player player , TileEntity tileEntity , String id ) {
201+ ((IMpGui ) player ).catalyst$displayCustomGUI (tileEntity , id );
203202 }
204203
205- public static void displayGui (Player player , TileEntity tileEntity , String id , CompoundTag data ){
206- ((IMpGui )player ).catalyst$displayCustomGUI (tileEntity , id , data );
204+ public static void displayGui (Player player , TileEntity tileEntity , String id , CompoundTag data ) {
205+ ((IMpGui ) player ).catalyst$displayCustomGUI (tileEntity , id , data );
207206 }
208207
209- public static <T > T blockLogic (Block <? extends BlockLogic > block , Class <T > clazz ){
210- if (Block .hasLogicClass (block , clazz )) return (T ) block .getLogic ();
208+ public static <T > T blockLogic (Block <? extends BlockLogic > block , Class <T > clazz ) {
209+ if (Block .hasLogicClass (block , clazz )) return (T ) block .getLogic ();
211210 else return null ;
212211 }
213212
214- public static <T > T blockLogic (int id , Class <T > clazz ){
215- if (Block .hasLogicClass (Blocks .blocksList [id ], clazz )) return (T ) Blocks .blocksList [id ].getLogic ();
213+ public static <T > T blockLogic (int id , Class <T > clazz ) {
214+ if (Block .hasLogicClass (Blocks .blocksList [id ], clazz )) return (T ) Blocks .blocksList [id ].getLogic ();
216215 else return null ;
217216 }
218217
219- public static <T > boolean listContains (List <T > list , T o , BiFunction <T ,T , Boolean > equals ){
218+ public static <T > boolean listContains (List <T > list , T o , BiFunction <T , T , Boolean > equals ) {
220219 for (T obj : list ) {
221- if (equals .apply (o ,obj )){
220+ if (equals .apply (o , obj )) {
222221 return true ;
223222 }
224223 }
@@ -238,42 +237,42 @@ public static byte[] HSBtoRGB(float hue, float saturation, float brightness) {
238237 float f6 = brightness * (1.0F - saturation * f4 );
239238 float f7 = brightness * (1.0F - saturation * (1.0F - f4 ));
240239 switch ((int ) f3 ) {
241- case 0 :
240+ case 0 :
242241 red = (byte ) (brightness * 255F + 0.5F );
243242 green = (byte ) (f7 * 255F + 0.5F );
244243 blue = (byte ) (f5 * 255F + 0.5F );
245244 break ;
246- case 1 :
245+ case 1 :
247246 red = (byte ) (f6 * 255F + 0.5F );
248247 green = (byte ) (brightness * 255F + 0.5F );
249248 blue = (byte ) (f5 * 255F + 0.5F );
250249 break ;
251- case 2 :
250+ case 2 :
252251 red = (byte ) (f5 * 255F + 0.5F );
253252 green = (byte ) (brightness * 255F + 0.5F );
254253 blue = (byte ) (f7 * 255F + 0.5F );
255254 break ;
256- case 3 :
255+ case 3 :
257256 red = (byte ) (f5 * 255F + 0.5F );
258257 green = (byte ) (f6 * 255F + 0.5F );
259258 blue = (byte ) (brightness * 255F + 0.5F );
260259 break ;
261- case 4 :
260+ case 4 :
262261 red = (byte ) (f7 * 255F + 0.5F );
263262 green = (byte ) (f5 * 255F + 0.5F );
264263 blue = (byte ) (brightness * 255F + 0.5F );
265264 break ;
266- case 5 :
265+ case 5 :
267266 red = (byte ) (brightness * 255F + 0.5F );
268267 green = (byte ) (f5 * 255F + 0.5F );
269268 blue = (byte ) (f6 * 255F + 0.5F );
270269 break ;
271270 }
272271 }
273- return new byte []{red ,green ,blue };
272+ return new byte []{red , green , blue };
274273 }
275274
276- public static int random (Random random , int min , int max ){
277- return random .nextInt (max - min + 1 )+ min ;
275+ public static int random (Random random , int min , int max ) {
276+ return random .nextInt (max - min + 1 ) + min ;
278277 }
279278}
0 commit comments