Skip to content

Commit 36488a9

Browse files
Add tractors, fix scaled wheel rendering, add pineapple
1 parent bdd61b1 commit 36488a9

21 files changed

Lines changed: 276 additions & 59 deletions

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lambdacontrols_version=1.7.1+1.17
1212
myron_version=1.6.0
1313
arrp_version=0.4.3
1414

15-
mod_version = 0.0.0+1.17
15+
mod_version = 0.0.1+1.17
1616
maven_group = io.github.foundationgames
1717
archives_base_name = automobility
1818

src/main/java/io/github/foundationgames/automobility/automobile/AutomobileFrame.java

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package io.github.foundationgames.automobility.automobile;
22

33
import io.github.foundationgames.automobility.Automobility;
4-
import io.github.foundationgames.automobility.automobile.render.frame.CARRFrameModel;
5-
import io.github.foundationgames.automobility.automobile.render.frame.DaBabyFrameModel;
6-
import io.github.foundationgames.automobility.automobile.render.frame.ShoppingCartFrameModel;
7-
import io.github.foundationgames.automobility.automobile.render.frame.StandardFrameModel;
4+
import io.github.foundationgames.automobility.automobile.render.frame.*;
85
import io.github.foundationgames.automobility.util.SimpleMapContentRegistry;
96
import net.minecraft.client.model.Model;
107
import net.minecraft.client.render.entity.EntityRendererFactory;
@@ -37,6 +34,11 @@ public record AutomobileFrame(
3734
public static final AutomobileFrame STANDARD_RED = REGISTRY.register(standard("red"));
3835
public static final AutomobileFrame STANDARD_BLACK = REGISTRY.register(standard("black"));
3936

37+
public static final AutomobileFrame RED_TRACTOR = REGISTRY.register(tractor("red"));
38+
public static final AutomobileFrame YELLOW_TRACTOR = REGISTRY.register(tractor("yellow"));
39+
public static final AutomobileFrame GREEN_TRACTOR = REGISTRY.register(tractor("green"));
40+
public static final AutomobileFrame BLUE_TRACTOR = REGISTRY.register(tractor("blue"));
41+
4042
public static final AutomobileFrame SHOPPING_CART = REGISTRY.register(
4143
new AutomobileFrame(
4244
Automobility.id("shopping_cart"),
@@ -69,6 +71,22 @@ public record AutomobileFrame(
6971
)
7072
);
7173

74+
public static final AutomobileFrame PINEAPPLE = REGISTRY.register(
75+
new AutomobileFrame(
76+
Automobility.id("pineapple"),
77+
0.75f,
78+
new FrameModel(
79+
Automobility.id("textures/entity/automobile/frame/pineapple.png"),
80+
PineappleFrameModel::new,
81+
WheelBase.basic(10, 18),
82+
12,
83+
16,
84+
8,
85+
6
86+
)
87+
)
88+
);
89+
7290
public static final AutomobileFrame DABABY = REGISTRY.register(
7391
new AutomobileFrame(
7492
Automobility.id("dababy"),
@@ -101,6 +119,27 @@ private static AutomobileFrame standard(String color) {
101119
);
102120
}
103121

122+
private static AutomobileFrame tractor(String color) {
123+
return new AutomobileFrame(
124+
Automobility.id(color+"_tractor"),
125+
0.9f,
126+
new FrameModel(
127+
Automobility.id("textures/entity/automobile/frame/"+color+"_tractor.png"),
128+
TractorFrameModel::new,
129+
new WheelBase(
130+
new WheelBase.WheelPos(-2, -7, 1.8f, 0, WheelBase.WheelEnd.BACK, WheelBase.WheelSide.LEFT),
131+
new WheelBase.WheelPos(-2, 7, 1.8f, 180, WheelBase.WheelEnd.BACK, WheelBase.WheelSide.RIGHT),
132+
new WheelBase.WheelPos(15, -1, 1, 0, WheelBase.WheelEnd.FRONT, WheelBase.WheelSide.LEFT),
133+
new WheelBase.WheelPos(15, 1, 1, 180, WheelBase.WheelEnd.FRONT, WheelBase.WheelSide.RIGHT)
134+
),
135+
20,
136+
9,
137+
9,
138+
8
139+
)
140+
);
141+
}
142+
104143
@Override
105144
public Identifier getId() {
106145
return this.id;

src/main/java/io/github/foundationgames/automobility/automobile/AutomobileWheel.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package io.github.foundationgames.automobility.automobile;
22

33
import io.github.foundationgames.automobility.Automobility;
4-
import io.github.foundationgames.automobility.automobile.render.wheel.ConvertibleWheelModel;
5-
import io.github.foundationgames.automobility.automobile.render.wheel.OffRoadWheelModel;
6-
import io.github.foundationgames.automobility.automobile.render.wheel.StandardWheelModel;
7-
import io.github.foundationgames.automobility.automobile.render.wheel.SteelWheelModel;
4+
import io.github.foundationgames.automobility.automobile.render.wheel.*;
85
import io.github.foundationgames.automobility.util.SimpleMapContentRegistry;
96
import net.minecraft.client.model.Model;
107
import net.minecraft.client.render.entity.EntityRendererFactory;
@@ -34,6 +31,10 @@ public record AutomobileWheel(
3431
new AutomobileWheel(Automobility.id("steel"), 0.69f, 0.4f, new WheelModel(3.625f, 3, Automobility.id("textures/entity/automobile/wheel/steel.png"), SteelWheelModel::new))
3532
);
3633

34+
public static final AutomobileWheel TRACTOR = REGISTRY.register(
35+
new AutomobileWheel(Automobility.id("tractor"), 1.05f, 0.69f, new WheelModel(3.625f, 3, Automobility.id("textures/entity/automobile/wheel/tractor.png"), TractorWheelModel::new))
36+
);
37+
3738
// public static final AutomobileWheel INFLATABLE = REGISTRY.register(
3839
// new AutomobileWheel(Automobility.id("inflatable"), 0.75f, new WheelModel(4, 4, TEMP_ID, EmptyModel::new), Ability.HYDROPLANE)
3940
// );

src/main/java/io/github/foundationgames/automobility/automobile/render/AutomobileRenderer.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ public static void render(
9898
if (wheelModel != null) {
9999
for (var pos : wPoses) {
100100
float scale = pos.scale();
101-
float wheelRadius = wheels.model().radius() * scale;
101+
float wheelRadius = wheels.model().radius() - (wheels.model().radius() * (scale - 1));
102102
matrices.push();
103103
matrices.translate(-pos.forward() / 16, wheelRadius / 16, pos.right() / 16);
104104
if (pos.end() == WheelBase.WheelEnd.FRONT) matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(automobile.getSteering(tickDelta) * 27));
105105
matrices.translate(0, raise, 0);
106106
matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(-wheelAngle));
107+
matrices.scale(scale, scale, scale);
107108
matrices.translate(0, -raise, 0);
108109
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(pos.yaw()));
109-
matrices.scale(scale, scale, scale);
110110
wheelModel.render(matrices, wheelBuffer, light, overlay, 1, 1, 1, 1);
111111
matrices.pop();
112112
}
@@ -137,11 +137,12 @@ public static void render(
137137
for (var pos : wPoses) {
138138
if (pos.end() == WheelBase.WheelEnd.BACK) {
139139
float scale = pos.scale();
140+
float heightOffset = wheels.model().radius();
140141
float wheelRadius = wheels.model().radius() * scale;
141142
float wheelWidth = (wheels.model().width() / 16) * scale;
142-
float back = (wheelRadius / 16) - Math.max(0, ((wheelRadius / 16) - (3f / 16)) * 0.75f);
143+
float back = (wheelRadius / 16) - Math.max(0, ((wheelRadius / 16) - (3f / 16)) * 0.45f);
143144
matrices.push();
144-
matrices.translate((-pos.forward() / 16) + back, wheelRadius / 16, (pos.right() / 16) + (wheelWidth * (pos.side() == WheelBase.WheelSide.RIGHT ? 1 : -1)));
145+
matrices.translate((-pos.forward() / 16) + back, heightOffset / 16, (pos.right() / 16) + (wheelWidth * (pos.side() == WheelBase.WheelSide.RIGHT ? 1 : -1)));
145146
matrices.scale(1, 1, pos.side() == WheelBase.WheelSide.RIGHT ? -1 : 1);
146147
skidEffectModel.render(matrices, skidEffectBuffer, light, overlay, r, g, b, 0.6f);
147148
matrices.pop();
@@ -153,8 +154,4 @@ public static void render(
153154

154155
matrices.pop();
155156
}
156-
157-
public static void renderEngine() {
158-
159-
}
160157
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package io.github.foundationgames.automobility.automobile.render.frame;
2+
3+
import io.github.foundationgames.automobility.Automobility;
4+
import net.minecraft.client.model.*;
5+
import net.minecraft.client.render.RenderLayer;
6+
import net.minecraft.client.render.VertexConsumer;
7+
import net.minecraft.client.render.entity.EntityRendererFactory;
8+
import net.minecraft.client.render.entity.model.EntityModelLayer;
9+
import net.minecraft.client.util.math.MatrixStack;
10+
import net.minecraft.util.math.Vec3f;
11+
12+
public class PineappleFrameModel extends Model {
13+
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(Automobility.id("automobile/frame/pineapple"), "main");
14+
15+
private final ModelPart main;
16+
private final ModelPart stem;
17+
18+
public PineappleFrameModel(EntityRendererFactory.Context ctx) {
19+
super(RenderLayer::getEntityCutout);
20+
this.main = ctx.getPart(MODEL_LAYER).getChild("main");
21+
this.stem = this.main.getChild("stem");
22+
setRotationAngle(stem, 0.0F, 0.0F, 0.0873F);
23+
}
24+
25+
private void setRotationAngle(ModelPart bone, float x, float y, float z) {
26+
bone.pitch = x;
27+
bone.yaw = y;
28+
bone.roll = z;
29+
}
30+
31+
public static TexturedModelData createModelData() {
32+
ModelData modelData = new ModelData();
33+
ModelPartData root = modelData.getRoot();
34+
ModelPartData partData = root.addChild("main", ModelPartBuilder.create().uv(0,0).cuboid(-4.0F, -8.0F, -5.0F, 8.0F, 7.0F, 0.0F).uv(0,11).cuboid(-4.5F, -8.0F, -4.5F, 9.0F, 8.0F, 9.0F), ModelTransform.pivot(0.0F,24.0F,0.0F));
35+
partData.addChild("stem", ModelPartBuilder.create().uv(0,7).cuboid(-10.0F, -10.5F, -3.0F, 1.0F, 3.0F, 1.0F), ModelTransform.pivot(8.5F,0.5F,2.5F));
36+
return TexturedModelData.of(modelData,64,32);
37+
}
38+
39+
@Override
40+
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
41+
matrices.push();
42+
matrices.translate(0, -1.5, 0);
43+
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90));
44+
matrices.scale(2, 2, 2);
45+
this.main.render(matrices, vertices, light, overlay, red, green, blue, alpha);
46+
matrices.pop();
47+
}
48+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package io.github.foundationgames.automobility.automobile.render.frame;
2+
3+
import io.github.foundationgames.automobility.Automobility;
4+
import net.minecraft.client.model.*;
5+
import net.minecraft.client.render.RenderLayer;
6+
import net.minecraft.client.render.VertexConsumer;
7+
import net.minecraft.client.render.entity.EntityRendererFactory;
8+
import net.minecraft.client.render.entity.model.EntityModelLayer;
9+
import net.minecraft.client.util.math.MatrixStack;
10+
import net.minecraft.util.math.Vec3f;
11+
12+
public class TractorFrameModel extends Model {
13+
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(Automobility.id("automobile/frame/tractor"), "main");
14+
15+
private final ModelPart main;
16+
private final ModelPart seat_back;
17+
private final ModelPart pipe_tip;
18+
private final ModelPart dashboard;
19+
20+
public TractorFrameModel(EntityRendererFactory.Context ctx) {
21+
super(RenderLayer::getEntityCutout);
22+
this.main = ctx.getPart(MODEL_LAYER).getChild("main");
23+
this.dashboard = this.main.getChild("dashboard");
24+
this.pipe_tip = this.main.getChild("pipe_tip");
25+
this.seat_back = this.main.getChild("seat_back");
26+
setRotationAngle(seat_back, -1.8326F, 0.0F, 0.0F);
27+
setRotationAngle(pipe_tip, -0.1309F, 0.0F, 0.0F);
28+
setRotationAngle(dashboard, 0.5672F, 0.0F, 0.0F);
29+
}
30+
31+
private void setRotationAngle(ModelPart bone, float x, float y, float z) {
32+
bone.pitch = x;
33+
bone.yaw = y;
34+
bone.roll = z;
35+
}
36+
37+
public static TexturedModelData createModelData() {
38+
ModelData modelData = new ModelData();
39+
ModelPartData root = modelData.getRoot();
40+
ModelPartData partData = root.addChild("main", ModelPartBuilder.create().uv(0,0).cuboid(-4.0F, -13.0F, -19.0F, 8.0F, 9.0F, 15.0F).uv(0,24).cuboid(-7.0F, -8.0F, -4.0F, 14.0F, 7.0F, 12.0F).uv(31,9).cuboid(-1.0F, -17.0F, -16.0F, 2.0F, 4.0F, 2.0F).uv(0,0).cuboid(-1.0F, -4.0F, -16.0F, 2.0F, 5.0F, 2.0F).uv(0,43).cuboid(-3.0F, -9.0F, -3.0F, 6.0F, 1.0F, 7.0F).uv(26,43).cuboid(-5.0F, -8.0F, 8.0F, 10.0F, 6.0F, 4.0F).uv(0,0).cuboid(-1.0F, -9.0F, 5.0F, 1.0F, 1.0F, 1.0F), ModelTransform.pivot(0.0F,24.0F,0.0F));
41+
partData.addChild("seat_back", ModelPartBuilder.create().uv(0,43).cuboid(-3.0F, -1.0F, -7.0F, 6.0F, 1.0F, 7.0F), ModelTransform.pivot(0.0F,-9.0F,3.0F));
42+
partData.addChild("pipe_tip", ModelPartBuilder.create().uv(31,0).cuboid(-0.5F, -2.0F, 0.0F, 1.0F, 2.0F, 1.0F), ModelTransform.pivot(0.0F,-17.0F,-15.5F));
43+
partData.addChild("dashboard", ModelPartBuilder.create().uv(31,0).cuboid(-2.0F, -3.0F, -5.0F, 4.0F, 3.0F, 5.0F), ModelTransform.pivot(0.0F,-13.0F,-4.0F));
44+
return TexturedModelData.of(modelData,64,64);
45+
}
46+
47+
@Override
48+
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
49+
matrices.push();
50+
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90));
51+
this.main.render(matrices, vertices, light, overlay, red, green, blue, alpha);
52+
matrices.pop();
53+
}
54+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package io.github.foundationgames.automobility.automobile.render.wheel;
2+
3+
import io.github.foundationgames.automobility.Automobility;
4+
import net.minecraft.client.model.*;
5+
import net.minecraft.client.render.RenderLayer;
6+
import net.minecraft.client.render.VertexConsumer;
7+
import net.minecraft.client.render.entity.EntityRendererFactory;
8+
import net.minecraft.client.render.entity.model.EntityModelLayer;
9+
import net.minecraft.client.util.math.MatrixStack;
10+
import net.minecraft.util.math.Vec3f;
11+
12+
public class TractorWheelModel extends Model {
13+
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(Automobility.id("automobile/wheel/tractor"), "main");
14+
15+
private final ModelPart main;
16+
private final ModelPart tire_8;
17+
private final ModelPart tire_7;
18+
private final ModelPart tire_6;
19+
private final ModelPart tire_5;
20+
private final ModelPart tire_4;
21+
private final ModelPart tire_3;
22+
private final ModelPart tire_2;
23+
24+
public TractorWheelModel(EntityRendererFactory.Context ctx) {
25+
super(RenderLayer::getEntityCutout);
26+
this.main = ctx.getPart(MODEL_LAYER).getChild("main");
27+
this.tire_2 = this.main.getChild("tire_2");
28+
this.tire_3 = this.main.getChild("tire_3");
29+
this.tire_4 = this.main.getChild("tire_4");
30+
this.tire_5 = this.main.getChild("tire_5");
31+
this.tire_6 = this.main.getChild("tire_6");
32+
this.tire_7 = this.main.getChild("tire_7");
33+
this.tire_8 = this.main.getChild("tire_8");
34+
setRotationAngle(tire_8, -0.7854F, 0.0F, 0.0F);
35+
setRotationAngle(tire_7, -1.5708F, 0.0F, 0.0F);
36+
setRotationAngle(tire_6, -2.3562F, 0.0F, 0.0F);
37+
setRotationAngle(tire_5, 3.1416F, 0.0F, 0.0F);
38+
setRotationAngle(tire_4, 2.3562F, 0.0F, 0.0F);
39+
setRotationAngle(tire_3, 1.5708F, 0.0F, 0.0F);
40+
setRotationAngle(tire_2, 0.7854F, 0.0F, 0.0F);
41+
}
42+
43+
private void setRotationAngle(ModelPart bone, float x, float y, float z) {
44+
bone.pitch = x;
45+
bone.yaw = y;
46+
bone.roll = z;
47+
}
48+
49+
public static TexturedModelData createModelData() {
50+
ModelData modelData = new ModelData();
51+
ModelPartData root = modelData.getRoot();
52+
ModelPartData partData = root.addChild("main", ModelPartBuilder.create().uv(0,0).cuboid(0.0F, -2.0F, -1.5F, 3.0F, 2.0F, 3.0F).uv(0,5).cuboid(0.5F, -6.125F, -2.5F, 2.0F, 5.0F, 5.0F), ModelTransform.pivot(0.0F,24.0F,0.0F));
53+
partData.addChild("tire_8", ModelPartBuilder.create().uv(0,0).cuboid(0.5F, 1.625F, -1.5F, 3.0F, 2.0F, 3.0F), ModelTransform.pivot(-0.5F,-3.625F,0.0F));
54+
partData.addChild("tire_7", ModelPartBuilder.create().uv(0,0).cuboid(0.5F, 1.625F, -1.5F, 3.0F, 2.0F, 3.0F), ModelTransform.pivot(-0.5F,-3.625F,0.0F));
55+
partData.addChild("tire_6", ModelPartBuilder.create().uv(0,0).cuboid(0.5F, 1.625F, -1.5F, 3.0F, 2.0F, 3.0F), ModelTransform.pivot(-0.5F,-3.625F,0.0F));
56+
partData.addChild("tire_5", ModelPartBuilder.create().uv(0,0).cuboid(0.5F, 1.625F, -1.5F, 3.0F, 2.0F, 3.0F), ModelTransform.pivot(-0.5F,-3.625F,0.0F));
57+
partData.addChild("tire_4", ModelPartBuilder.create().uv(0,0).cuboid(0.5F, 1.625F, -1.5F, 3.0F, 2.0F, 3.0F), ModelTransform.pivot(-0.5F,-3.625F,0.0F));
58+
partData.addChild("tire_3", ModelPartBuilder.create().uv(0,0).cuboid(0.5F, 1.625F, -1.5F, 3.0F, 2.0F, 3.0F), ModelTransform.pivot(-0.5F,-3.625F,0.0F));
59+
partData.addChild("tire_2", ModelPartBuilder.create().uv(0,0).cuboid(0.5F, 1.625F, -1.5F, 3.0F, 2.0F, 3.0F), ModelTransform.pivot(-0.5F,-3.625F,0.0F));
60+
return TexturedModelData.of(modelData,16,16);
61+
}
62+
63+
@Override
64+
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
65+
matrices.push();
66+
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90));
67+
main.render(matrices, vertices, light, overlay, red, green, blue, alpha);
68+
matrices.pop();
69+
}
70+
}

0 commit comments

Comments
 (0)