Skip to content

Commit

Permalink
Merge pull request #670 from fexcraft-net/1.12.2-TiM
Browse files Browse the repository at this point in the history
[1.12.2] Update CylinderBuilder.java
  • Loading branch information
EternalBlueFlame authored May 22, 2023
2 parents 8e33fb9 + ac45f48 commit 1f277a8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/fexcraft/tmt/slim/CylinderBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class CylinderBuilder {

private ModelRendererTurbo root;
private float x, y, z, radius, radius2, length, base_scale, top_scale;
private float x, y, z, radius, radius2, radius3, radius4, length, base_scale, top_scale;
private int segments, seglimit, direction, texDiameterW, texDiameterH, texHeight;
private Vec3f topoff = new Vec3f();
private boolean[] togglesides = new boolean[]{false,false,false,false};
Expand All @@ -28,6 +28,11 @@ public CylinderBuilder setRadius(float first, float second){
this.radius = first; this.radius2 = second; texDiameterW = (int)Math.floor(radius * 2F); texDiameterH = (int)Math.floor(radius * 2F); return this;
}

public CylinderBuilder setRadius(float first_s, float first_c, float second_s, float second_c){
this.radius3 = first_c; this.radius4 = second_c;
return setRadius(first_s, second_s);
}

/** Use AFTER `setRadius`, else values will get overriden. */
public CylinderBuilder setTextureDiameter(int width, int height){
texDiameterW = width; texDiameterH = height; return this;
Expand Down Expand Up @@ -114,7 +119,9 @@ public CylinderBuilder removePolygons(boolean... sides){
}

public ModelRendererTurbo build(){
if(radius2 == 0f && toprot == null){
if(radius3 == 0f) radius3 = radius;
if(radius4 == 0f) radius4 = radius2;
if(radius2 == 0f && toprot == null && radius3 == radius){
return root.addCylinder(x, y, z, radius, length, segments, base_scale, top_scale, direction, texDiameterW, texDiameterH, texHeight, topoff);
}
if(radius < 1){ texDiameterW = 2; texDiameterH = 2; } if(length < 1){ texHeight = 2; }
Expand Down Expand Up @@ -152,7 +159,7 @@ public ModelRendererTurbo build(){
for(int repeat = 0; repeat < 2; repeat++){//top/base faces
for(int index = 0; index < segments; index++){
xSize = (float)((root.mirror ^ dirMirror ? -1 : 1) * Math.sin((ModelRendererTurbo.pi / segments) * index * 2F + ModelRendererTurbo.pi) * radius * sCur);
zSize = (float)(-Math.cos((ModelRendererTurbo.pi / segments) * index * 2F + ModelRendererTurbo.pi) * radius * sCur);
zSize = (float)(-Math.cos((ModelRendererTurbo.pi / segments) * index * 2F + ModelRendererTurbo.pi) * radius3 * sCur);
xPlace = xCur + (!dirSide ? xSize : 0);
yPlace = yCur + (!dirTop ? zSize : 0);
zPlace = zCur + (dirSide ? xSize : (dirTop ? zSize : 0));
Expand All @@ -162,7 +169,7 @@ public ModelRendererTurbo build(){
}
//
xSize = (float)((root.mirror ^ dirMirror ? -1 : 1) * Math.sin((ModelRendererTurbo.pi / segments) * index * 2F + ModelRendererTurbo.pi) * radius2 * sCur);
zSize = (float)(-Math.cos((ModelRendererTurbo.pi / segments) * index * 2F + ModelRendererTurbo.pi) * radius2 * sCur);
zSize = (float)(-Math.cos((ModelRendererTurbo.pi / segments) * index * 2F + ModelRendererTurbo.pi) * radius4 * sCur);
xPlace = xCur + (!dirSide ? xSize : 0);
yPlace = yCur + (!dirTop ? zSize : 0);
zPlace = zCur + (dirSide ? xSize : (dirTop ? zSize : 0));
Expand Down

0 comments on commit 1f277a8

Please sign in to comment.