Skip to content

Commit a1a91a7

Browse files
committed
Format files from 254fa35
1 parent 7a0b65e commit a1a91a7

File tree

7 files changed

+365
-289
lines changed

7 files changed

+365
-289
lines changed

src/main/java/com/flansmod/client/model/AnimTankTrack.java

+39-41
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
import java.util.ArrayList;
44

5-
import net.minecraft.item.ItemStack;
6-
75
import com.flansmod.common.vector.Vector3f;
86

97

10-
public class AnimTankTrack {
8+
public class AnimTankTrack
9+
{
1110

12-
public ArrayList<Vector3f> points = new ArrayList<Vector3f>();
13-
public float trackLinkLength = 0;
11+
public ArrayList<Vector3f> points;
12+
public float trackLinkLength;
1413

15-
public AnimTankTrack (ArrayList<Vector3f> trackPoints, float linkLength)
14+
public AnimTankTrack(ArrayList<Vector3f> trackPoints, float linkLength)
1615
{
1716
points = trackPoints;
1817
trackLinkLength = linkLength;
@@ -29,71 +28,70 @@ public float distBetweenPoints(Vector3f p1, Vector3f p2)
2928

3029
float x = p1.x - p2.x;
3130
float y = p1.y - p2.y;
32-
distance = (float)Math.sqrt((x*x) + (y*y));
31+
distance = (float)Math.sqrt((x * x) + (y * y));
3332

3433
return distance;
3534
}
3635

3736
public float getTrackLength()
3837
{
3938
float length = 0;
40-
for(int i = 0; i < points.size(); i++)
41-
{
42-
length += distBetweenPoints(points.get(i), points.get((i == 0)? points.size()-1:i-1));
43-
}
39+
for(int i = 0; i < points.size(); i++)
40+
{
41+
length += distBetweenPoints(points.get(i), points.get((i == 0) ? points.size() - 1 : i - 1));
42+
}
4443
return length;
4544
}
4645

4746
public int getTrackPart(float distance)
4847
{
4948
float length = 0;
50-
for(int i = 0; i < points.size(); i++)
51-
{
52-
if(length >= distance)
53-
{
54-
return i;
55-
} else {
56-
length += distBetweenPoints(points.get(i), points.get((i == (points.size()-1))? 0:i+1));
57-
}
58-
}
49+
for(int i = 0; i < points.size(); i++)
50+
{
51+
if(length >= distance)
52+
{
53+
return i;
54+
}
55+
else
56+
{
57+
length += distBetweenPoints(points.get(i), points.get((i == (points.size() - 1)) ? 0 : i + 1));
58+
}
59+
}
5960
return 0;
6061
}
6162

62-
63+
6364
public float getProgressAlongTrackPart(float distance, int trackPart)
6465
{
6566
float length = 0;
66-
float lastLength = 0;
67-
for(int i = 0; i < trackPart + 1; i++)
68-
{
69-
if(i != 0)
70-
{
71-
length += distBetweenPoints(points.get(i-1), points.get(i));
72-
}
73-
}
67+
for(int i = 0; i < trackPart + 1; i++)
68+
{
69+
if(i != 0)
70+
{
71+
length += distBetweenPoints(points.get(i - 1), points.get(i));
72+
}
73+
}
7474
return length;
7575
}
76-
76+
7777
public Vector3f getPositionOnTrack(float distance)
7878
{
79-
79+
8080
int trackPart = getTrackPart(distance);
81-
Vector3f p2 = points.get((trackPart == 0)? points.size()-1:trackPart-1);
81+
Vector3f p2 = points.get((trackPart == 0) ? points.size() - 1 : trackPart - 1);
8282
Vector3f p1 = points.get(trackPart);
8383

8484
float partLength = distBetweenPoints(p2, p1);
85-
float prog = distance - (getProgressAlongTrackPart(distance,(trackPart == 0)? points.size()-1:trackPart-1));
86-
float progress = prog/partLength;
87-
Vector3f finalPos = new Vector3f(lerp(p2.x, p1.x, progress),lerp(p2.y, p1.y, progress), lerp(p2.z, p1.z, progress));
85+
float prog =
86+
distance - (getProgressAlongTrackPart(distance, (trackPart == 0) ? points.size() - 1 : trackPart - 1));
87+
float progress = prog / partLength;
8888

89-
return finalPos;
89+
return new Vector3f(lerp(p2.x, p1.x, progress), lerp(p2.y, p1.y, progress), lerp(p2.z, p1.z, progress));
9090
}
9191

92-
public float lerp(float a, float b, float f)
92+
public float lerp(float a, float b, float f)
9393
{
94-
float result = (a+ f*(b - a));
95-
96-
return result;
94+
return (a + f * (b - a));
9795
}
9896

99-
}
97+
}

src/main/java/com/flansmod/client/model/AnimTrackLink.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import com.flansmod.common.RotatedAxes;
44
import com.flansmod.common.vector.Vector3f;
55

6-
public class AnimTrackLink {
6+
public class AnimTrackLink
7+
{
78

89
public Vector3f position;
910
public Vector3f prevPosition;
1011
public float zRot = 0;
1112
public float prevZRot;
12-
public float progress = 0;
13+
public float progress;
1314
public RotatedAxes rot;
1415

1516
public AnimTrackLink(float prog)

src/main/java/com/flansmod/client/model/ModelVehicle.java

+41-32
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,37 @@
1212
//Extensible ModelVehicle class for rendering vehicle models
1313
public class ModelVehicle extends ModelDriveable
1414
{
15-
public ModelRendererTurbo turretModel[] = new ModelRendererTurbo[0]; //The turret (for tanks)
16-
public ModelRendererTurbo barrelModel[] = new ModelRendererTurbo[0]; //The barrel of the main turret
17-
public ModelRendererTurbo ammoModel[][] = new ModelRendererTurbo[0][0]; //Ammo models for the main turret. ammoModel[i] will render if the vehicle has less than 3 ammo slots or if slot i is full. Checks shell / missile inventory
18-
public ModelRendererTurbo frontWheelModel[] = new ModelRendererTurbo[0]; //Front and back wheels are for bicycles and motorbikes and whatnot
19-
public ModelRendererTurbo backWheelModel[] = new ModelRendererTurbo[0];
20-
public ModelRendererTurbo leftFrontWheelModel[] = new ModelRendererTurbo[0]; //This set of 4 wheels are for 4 or more wheeled things
21-
public ModelRendererTurbo rightFrontWheelModel[] = new ModelRendererTurbo[0]; //The front wheels will turn as the player steers, and the back ones will not
22-
public ModelRendererTurbo leftBackWheelModel[] = new ModelRendererTurbo[0]; //They will all turn as the car drives if the option to do so is set on
23-
public ModelRendererTurbo rightBackWheelModel[] = new ModelRendererTurbo[0]; //In the vehicle type file
24-
public ModelRendererTurbo rightTrackModel[] = new ModelRendererTurbo[0];
25-
public ModelRendererTurbo leftTrackModel[] = new ModelRendererTurbo[0];
26-
public ModelRendererTurbo rightTrackWheelModels[] = new ModelRendererTurbo[0]; //These go with the tracks but rotate
27-
public ModelRendererTurbo leftTrackWheelModels[] = new ModelRendererTurbo[0];
15+
public ModelRendererTurbo[] turretModel = new ModelRendererTurbo[0]; //The turret (for tanks)
16+
public ModelRendererTurbo[] barrelModel = new ModelRendererTurbo[0]; //The barrel of the main turret
17+
public ModelRendererTurbo[][] ammoModel = new ModelRendererTurbo[0][0]; //Ammo models for the main turret. ammoModel[i] will render if the vehicle has less than 3 ammo slots or if slot i is full. Checks shell / missile inventory
18+
public ModelRendererTurbo[] frontWheelModel = new ModelRendererTurbo[0]; //Front and back wheels are for bicycles and motorbikes and whatnot
19+
public ModelRendererTurbo[] backWheelModel = new ModelRendererTurbo[0];
20+
public ModelRendererTurbo[] leftFrontWheelModel = new ModelRendererTurbo[0]; //This set of 4 wheels are for 4 or more wheeled things
21+
public ModelRendererTurbo[] rightFrontWheelModel = new ModelRendererTurbo[0]; //The front wheels will turn as the player steers, and the back ones will not
22+
public ModelRendererTurbo[] leftBackWheelModel = new ModelRendererTurbo[0]; //They will all turn as the car drives if the option to do so is set on
23+
public ModelRendererTurbo[] rightBackWheelModel = new ModelRendererTurbo[0]; //In the vehicle type file
24+
public ModelRendererTurbo[] rightTrackModel = new ModelRendererTurbo[0];
25+
public ModelRendererTurbo[] leftTrackModel = new ModelRendererTurbo[0];
26+
public ModelRendererTurbo[] rightTrackWheelModels = new ModelRendererTurbo[0]; //These go with the tracks but rotate
27+
public ModelRendererTurbo[] leftTrackWheelModels = new ModelRendererTurbo[0];
2828

2929

30-
public ModelRendererTurbo fancyTrackModel[] = new ModelRendererTurbo[0];
30+
public ModelRendererTurbo[] fancyTrackModel = new ModelRendererTurbo[0];
3131

3232

33-
public ModelRendererTurbo leftAnimTrackModel[][] = new ModelRendererTurbo[0][0]; //Unlimited frame track animations
34-
public ModelRendererTurbo rightAnimTrackModel[][] = new ModelRendererTurbo[0][0];
33+
public ModelRendererTurbo[][] leftAnimTrackModel = new ModelRendererTurbo[0][0]; //Unlimited frame track animations
34+
public ModelRendererTurbo[][] rightAnimTrackModel = new ModelRendererTurbo[0][0];
3535

36-
public ModelRendererTurbo bodyDoorOpenModel[] = new ModelRendererTurbo[0];
37-
public ModelRendererTurbo bodyDoorCloseModel[] = new ModelRendererTurbo[0];
38-
public ModelRendererTurbo trailerModel[] = new ModelRendererTurbo[0];
39-
public ModelRendererTurbo steeringWheelModel[] = new ModelRendererTurbo[0];
36+
public ModelRendererTurbo[] bodyDoorOpenModel = new ModelRendererTurbo[0];
37+
public ModelRendererTurbo[] bodyDoorCloseModel = new ModelRendererTurbo[0];
38+
public ModelRendererTurbo[] trailerModel = new ModelRendererTurbo[0];
39+
public ModelRendererTurbo[] steeringWheelModel = new ModelRendererTurbo[0];
4040

41-
public ModelRendererTurbo drillHeadModel[] = new ModelRendererTurbo[0]; //Drill head. Rotates around
41+
public ModelRendererTurbo[] drillHeadModel = new ModelRendererTurbo[0]; //Drill head. Rotates around
4242
public Vector3f drillHeadOrigin = new Vector3f(); //this point
4343

4444
//recoiling barrel part
45-
public ModelRendererTurbo animBarrelModel[] = new ModelRendererTurbo[0];
45+
public ModelRendererTurbo[] animBarrelModel = new ModelRendererTurbo[0];
4646
public Vector3f barrelAttach = new Vector3f();
4747

4848
public int animFrame = 0;
@@ -225,7 +225,9 @@ public void render(float f5, EntityVehicle vehicle, float f)
225225
for(EntitySeat seat : vehicle.getSeats())
226226
{
227227
//If the seat has a gun model attached
228-
if(seat != null && seat.seatInfo != null && seat.seatInfo.gunName != null && gunModels.get(seat.seatInfo.gunName) != null && vehicle.isPartIntact(seat.seatInfo.part) && !vehicle.rotateWithTurret(seat.seatInfo))
228+
if(seat != null && seat.seatInfo != null && seat.seatInfo.gunName != null &&
229+
gunModels.get(seat.seatInfo.gunName) != null && vehicle.isPartIntact(seat.seatInfo.part) &&
230+
!vehicle.rotateWithTurret(seat.seatInfo))
229231
{
230232
float yaw = seat.prevLooking.getYaw() + (seat.looking.getYaw() - seat.prevLooking.getYaw()) * f;
231233
float pitch = seat.prevLooking.getPitch() + (seat.looking.getPitch() - seat.prevLooking.getPitch()) * f;
@@ -299,13 +301,17 @@ public void renderTurret(float f, float f1, float f2, float f3, float f4, float
299301
for(EntitySeat seat : vehicle.getSeats())
300302
{
301303
//If the seat has a gun model attached
302-
if(seat != null && seat.seatInfo != null && seat.seatInfo.gunName != null && gunModels.get(seat.seatInfo.gunName) != null && vehicle.isPartIntact(seat.seatInfo.part) && vehicle.rotateWithTurret(seat.seatInfo))
304+
if(seat != null && seat.seatInfo != null && seat.seatInfo.gunName != null &&
305+
gunModels.get(seat.seatInfo.gunName) != null && vehicle.isPartIntact(seat.seatInfo.part) &&
306+
vehicle.rotateWithTurret(seat.seatInfo))
303307
{
304308
EntitySeat driverSeat = vehicle.getSeat(0);
305309

306-
float driverYaw = driverSeat.prevLooking.getYaw() + (driverSeat.looking.getYaw() - driverSeat.prevLooking.getYaw()) * dt;
310+
float driverYaw = driverSeat.prevLooking.getYaw() +
311+
(driverSeat.looking.getYaw() - driverSeat.prevLooking.getYaw()) * dt;
307312
float yaw = seat.prevLooking.getYaw() + (seat.looking.getYaw() - seat.prevLooking.getYaw()) * dt;
308-
float pitch = seat.prevLooking.getPitch() + (seat.looking.getPitch() - seat.prevLooking.getPitch()) * dt;
313+
float pitch =
314+
seat.prevLooking.getPitch() + (seat.looking.getPitch() - seat.prevLooking.getPitch()) * dt;
309315

310316
float effectiveYaw = yaw - driverYaw;
311317

@@ -338,14 +344,16 @@ public void renderTurret(float f, float f1, float f2, float f3, float f4, float
338344
}
339345
}
340346

341-
public void renderAnimBarrel(float f, float f1, float f2, float f3, float f4, float f5, EntityVehicle vehicle, float dt)
347+
public void renderAnimBarrel(float f, float f1, float f2, float f3, float f4, float f5, EntityVehicle vehicle,
348+
float dt)
342349
{
343-
if(vehicle.isPartIntact(EnumDriveablePart.turret))
344-
{
345-
for (ModelRendererTurbo aAnimBarrelModel : animBarrelModel) {
350+
if(vehicle.isPartIntact(EnumDriveablePart.turret))
351+
{
352+
for(ModelRendererTurbo aAnimBarrelModel : animBarrelModel)
353+
{
346354
aAnimBarrelModel.render(f5, oldRotateOrder);
347355
}
348-
}
356+
}
349357
}
350358

351359
public void renderDrillBit(EntityVehicle vehicle, float f)
@@ -361,7 +369,8 @@ public void renderDrillBit(EntityVehicle vehicle, float f)
361369

362370
public void renderFancyTracks(EntityVehicle vehicle, float f)
363371
{
364-
for (ModelRendererTurbo adrillHeadModel : fancyTrackModel) {
372+
for(ModelRendererTurbo adrillHeadModel : fancyTrackModel)
373+
{
365374
adrillHeadModel.render(0.0625F, oldRotateOrder);
366375
}
367376
}

0 commit comments

Comments
 (0)