@@ -228,16 +228,27 @@ private void insertList(GroupCompound compound, List<PolygonWrapper> list, Strin
228228 CylinderWrapper cyl = (CylinderWrapper )wrapper ;
229229 String topoff = cyl .topoff .xCoord != 0f || cyl .topoff .yCoord != 0f || cyl .topoff .zCoord != 0 ?
230230 String .format ("new net.fexcraft.lib.common.math.Vec3f(%s, %s, %s)" , cyl .topoff .xCoord , cyl .topoff .yCoord , cyl .topoff .zCoord ) : "null" ;
231- if (cyl .radial || cyl .usesTopRotation ()){
231+ if (cyl .radius2 != 0f || cyl . radial || cyl .usesTopRotation () || cyl . cuv . anyCustom ()){
232232 String toprot = String .format (".setTopRotation(new net.fexcraft.lib.common.math.Vec3f(%s, %s, %s))" , cyl .toprot .xCoord , cyl .toprot .yCoord , cyl .toprot .zCoord );
233- String str = ".removePolygons(" + cyl .bools [0 ] + ", " + cyl .bools [1 ] + ", " + cyl .bools [2 ] + ", " + cyl .bools [3 ] + ")" ;
234233 shape .append (format (".newCylinderBuilder()\n " + tab3 + ".setPosition(%s, %s, %s).setRadius(%s, %s).setLength(%s).setSegments(%s, %s)" +
235- ".setScale(%s, %s).setDirection(%s)\n " + tab3 + ".setRadialTexture(%s, %s)" + str + " .setTopOffset(%s)" + toprot + ".build()" , topoff ,
234+ ".setScale(%s, %s).setDirection(%s)\n " + tab3 + ".setRadialTexture(%s, %s).setTopOffset(%s)" + toprot , topoff ,
236235 wrapper .off .xCoord , wrapper .off .yCoord , wrapper .off .zCoord ,
237236 cyl .radius , cyl .radius2 , cyl .length , cyl .segments , cyl .seglimit ,
238237 cyl .base , cyl .top , cyl .direction , cyl .seg_width , cyl .seg_height ));
238+ if (cyl .anySidesOff ()){
239+ String off = new String ();
240+ for (int i = 0 ; i < 6 ; i ++){
241+ if (cyl .bools [i ]){
242+ off += i + ", " ;
243+ }
244+ }
245+ off = off .substring (0 , off .length () - 2 );
246+ shape .append ("\n " + tab3 + ".removePolygons(" + off + ")" );
247+ }
248+ appendCustomUV (cyl , shape );
249+ shape .append (".build()" );
239250 }
240- else if (cyl .radius2 != 0f ){
251+ /* else if(cyl.radius2 != 0f){
241252 if(areAll(cyl.bools, false)){
242253 shape.append(format(".addHollowCylinder(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", topoff,
243254 wrapper.off.xCoord, wrapper.off.yCoord, wrapper.off.zCoord,
@@ -249,7 +260,7 @@ else if(cyl.radius2 != 0f){
249260 cyl.radius, cyl.radius2, cyl.length, cyl.segments, cyl.seglimit, cyl.base, cyl.top, cyl.direction);
250261 shape.append(str + format(", %s)", cyl.bools));
251262 }
252- }
263+ }*/
253264 else {
254265 shape .append (format (".addCylinder(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" , topoff ,
255266 wrapper .off .xCoord , wrapper .off .yCoord , wrapper .off .zCoord ,
@@ -286,25 +297,7 @@ else if(cyl.radius2 != 0f){
286297 off = off .substring (0 , off .length () - 2 );
287298 shape .append ("\n " + tab3 + ".removePolygons(" + off + ")" );
288299 }
289- for (UVCoords coord : wrapper .cuv .values ()){
290- if (coord .automatic () || !wrapper .isFaceActive (coord .side ())) continue ;
291- String arr = new String ();
292- for (int i = 0 ; i < coord .value ().length ; i ++){
293- arr += coord .value ()[i ] + "f, " ;
294- }
295- arr = arr .substring (0 , arr .length () - 2 );
296- shape .append ("\n " + tab3 + ".setPolygonUV(" + coord .side ().index () + ", new float[]{ " + arr + " })" );
297- }
298- if (wrapper .anyFaceUVAbsolute ()){
299- String det = new String ();
300- for (UVCoords coord : wrapper .cuv .values ()){
301- if (coord .absolute () && wrapper .isFaceActive (coord .side ())){
302- det += coord .side ().index () + ", " ;
303- }
304- }
305- det = det .substring (0 , det .length () - 2 );
306- shape .append ("\n " + tab3 + ".setDetachedUV(" + det + ")" );
307- }
300+ appendCustomUV (box , shape );
308301 shape .append (".build()" );
309302 }
310303 if (wrapper .pos .xCoord != 0f || wrapper .pos .yCoord != 0f || wrapper .pos .zCoord != 0f ||
@@ -343,6 +336,28 @@ else if(cyl.radius2 != 0f){
343336 if (append ) buffer .append (tab2 + "//\n " );
344337 }
345338
339+ private void appendCustomUV (PolygonWrapper wrapper , StringBuffer shape ){
340+ for (UVCoords coord : wrapper .cuv .values ()){
341+ if (coord .automatic () || !wrapper .isFaceActive (coord .side ())) continue ;
342+ String arr = new String ();
343+ for (int i = 0 ; i < coord .value ().length ; i ++){
344+ arr += coord .value ()[i ] + "f, " ;
345+ }
346+ arr = arr .substring (0 , arr .length () - 2 );
347+ shape .append ("\n " + tab3 + ".setPolygonUV(" + coord .side ().index () + ", new float[]{ " + arr + " })" );
348+ }
349+ if (wrapper .anyFaceUVAbsolute ()){
350+ String det = new String ();
351+ for (UVCoords coord : wrapper .cuv .values ()){
352+ if (coord .absolute () && wrapper .isFaceActive (coord .side ())){
353+ det += coord .side ().index () + ", " ;
354+ }
355+ }
356+ det = det .substring (0 , det .length () - 2 );
357+ shape .append ("\n " + tab3 + ".setDetachedUV(" + det + ")" );
358+ }
359+ }
360+
346361 private String format (String string , String add , double r0 , double r1 , double r2 ){
347362 return format (string , add , new float []{ (float )r0 , (float )r1 , (float )r2 });
348363 }
@@ -353,13 +368,6 @@ private String format(String string, String add, float... arr){
353368 if (add != null ) strs [arr .length ] = add ; return String .format (string , strs );
354369 }
355370
356- private String format (String string , boolean [] bools ){
357- String array = "new boolean[]{ %s }" , out = "" ;
358- for (int i = 0 ; i < bools .length ; i ++){
359- out += bools [i ]; if (i < bools .length - 1 ) out += ", " ;
360- } return String .format (string , String .format (array , out ));
361- }
362-
363371 protected String validateName (String name ){
364372 if (name == null || name .length () == 0 ) return "Unnamed" ; /*String[] art = name.split(" ");
365373 for(int i = 0; i < art.length; i++){
@@ -370,10 +378,6 @@ protected String validateName(String name){
370378 return name .trim ().replace (" " , "_" ).replaceAll ("[^a-zA-Z0-9 _]" , "" );
371379 }
372380
373- private boolean areAll (boolean [] bools , boolean same ){
374- for (boolean bool : bools ) if (bool != same ) return false ; return true ;
375- }
376-
377381
378382 @ Override
379383 public String getId (){
0 commit comments