Skip to content

Commit

Permalink
Add tractors, fix scaled wheel rendering, add pineapple
Browse files Browse the repository at this point in the history
  • Loading branch information
FoundationGames committed Jul 4, 2021
1 parent bdd61b1 commit 36488a9
Show file tree
Hide file tree
Showing 21 changed files with 276 additions and 59 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lambdacontrols_version=1.7.1+1.17
myron_version=1.6.0
arrp_version=0.4.3

mod_version = 0.0.0+1.17
mod_version = 0.0.1+1.17
maven_group = io.github.foundationgames
archives_base_name = automobility

Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package io.github.foundationgames.automobility.automobile;

import io.github.foundationgames.automobility.Automobility;
import io.github.foundationgames.automobility.automobile.render.frame.CARRFrameModel;
import io.github.foundationgames.automobility.automobile.render.frame.DaBabyFrameModel;
import io.github.foundationgames.automobility.automobile.render.frame.ShoppingCartFrameModel;
import io.github.foundationgames.automobility.automobile.render.frame.StandardFrameModel;
import io.github.foundationgames.automobility.automobile.render.frame.*;
import io.github.foundationgames.automobility.util.SimpleMapContentRegistry;
import net.minecraft.client.model.Model;
import net.minecraft.client.render.entity.EntityRendererFactory;
Expand Down Expand Up @@ -37,6 +34,11 @@ public record AutomobileFrame(
public static final AutomobileFrame STANDARD_RED = REGISTRY.register(standard("red"));
public static final AutomobileFrame STANDARD_BLACK = REGISTRY.register(standard("black"));

public static final AutomobileFrame RED_TRACTOR = REGISTRY.register(tractor("red"));
public static final AutomobileFrame YELLOW_TRACTOR = REGISTRY.register(tractor("yellow"));
public static final AutomobileFrame GREEN_TRACTOR = REGISTRY.register(tractor("green"));
public static final AutomobileFrame BLUE_TRACTOR = REGISTRY.register(tractor("blue"));

public static final AutomobileFrame SHOPPING_CART = REGISTRY.register(
new AutomobileFrame(
Automobility.id("shopping_cart"),
Expand Down Expand Up @@ -69,6 +71,22 @@ public record AutomobileFrame(
)
);

public static final AutomobileFrame PINEAPPLE = REGISTRY.register(
new AutomobileFrame(
Automobility.id("pineapple"),
0.75f,
new FrameModel(
Automobility.id("textures/entity/automobile/frame/pineapple.png"),
PineappleFrameModel::new,
WheelBase.basic(10, 18),
12,
16,
8,
6
)
)
);

public static final AutomobileFrame DABABY = REGISTRY.register(
new AutomobileFrame(
Automobility.id("dababy"),
Expand Down Expand Up @@ -101,6 +119,27 @@ private static AutomobileFrame standard(String color) {
);
}

private static AutomobileFrame tractor(String color) {
return new AutomobileFrame(
Automobility.id(color+"_tractor"),
0.9f,
new FrameModel(
Automobility.id("textures/entity/automobile/frame/"+color+"_tractor.png"),
TractorFrameModel::new,
new WheelBase(
new WheelBase.WheelPos(-2, -7, 1.8f, 0, WheelBase.WheelEnd.BACK, WheelBase.WheelSide.LEFT),
new WheelBase.WheelPos(-2, 7, 1.8f, 180, WheelBase.WheelEnd.BACK, WheelBase.WheelSide.RIGHT),
new WheelBase.WheelPos(15, -1, 1, 0, WheelBase.WheelEnd.FRONT, WheelBase.WheelSide.LEFT),
new WheelBase.WheelPos(15, 1, 1, 180, WheelBase.WheelEnd.FRONT, WheelBase.WheelSide.RIGHT)
),
20,
9,
9,
8
)
);
}

@Override
public Identifier getId() {
return this.id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package io.github.foundationgames.automobility.automobile;

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

public static final AutomobileWheel TRACTOR = REGISTRY.register(
new AutomobileWheel(Automobility.id("tractor"), 1.05f, 0.69f, new WheelModel(3.625f, 3, Automobility.id("textures/entity/automobile/wheel/tractor.png"), TractorWheelModel::new))
);

// public static final AutomobileWheel INFLATABLE = REGISTRY.register(
// new AutomobileWheel(Automobility.id("inflatable"), 0.75f, new WheelModel(4, 4, TEMP_ID, EmptyModel::new), Ability.HYDROPLANE)
// );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ public static void render(
if (wheelModel != null) {
for (var pos : wPoses) {
float scale = pos.scale();
float wheelRadius = wheels.model().radius() * scale;
float wheelRadius = wheels.model().radius() - (wheels.model().radius() * (scale - 1));
matrices.push();
matrices.translate(-pos.forward() / 16, wheelRadius / 16, pos.right() / 16);
if (pos.end() == WheelBase.WheelEnd.FRONT) matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(automobile.getSteering(tickDelta) * 27));
matrices.translate(0, raise, 0);
matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(-wheelAngle));
matrices.scale(scale, scale, scale);
matrices.translate(0, -raise, 0);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(pos.yaw()));
matrices.scale(scale, scale, scale);
wheelModel.render(matrices, wheelBuffer, light, overlay, 1, 1, 1, 1);
matrices.pop();
}
Expand Down Expand Up @@ -137,11 +137,12 @@ public static void render(
for (var pos : wPoses) {
if (pos.end() == WheelBase.WheelEnd.BACK) {
float scale = pos.scale();
float heightOffset = wheels.model().radius();
float wheelRadius = wheels.model().radius() * scale;
float wheelWidth = (wheels.model().width() / 16) * scale;
float back = (wheelRadius / 16) - Math.max(0, ((wheelRadius / 16) - (3f / 16)) * 0.75f);
float back = (wheelRadius / 16) - Math.max(0, ((wheelRadius / 16) - (3f / 16)) * 0.45f);
matrices.push();
matrices.translate((-pos.forward() / 16) + back, wheelRadius / 16, (pos.right() / 16) + (wheelWidth * (pos.side() == WheelBase.WheelSide.RIGHT ? 1 : -1)));
matrices.translate((-pos.forward() / 16) + back, heightOffset / 16, (pos.right() / 16) + (wheelWidth * (pos.side() == WheelBase.WheelSide.RIGHT ? 1 : -1)));
matrices.scale(1, 1, pos.side() == WheelBase.WheelSide.RIGHT ? -1 : 1);
skidEffectModel.render(matrices, skidEffectBuffer, light, overlay, r, g, b, 0.6f);
matrices.pop();
Expand All @@ -153,8 +154,4 @@ public static void render(

matrices.pop();
}

public static void renderEngine() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.github.foundationgames.automobility.automobile.render.frame;

import io.github.foundationgames.automobility.Automobility;
import net.minecraft.client.model.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3f;

public class PineappleFrameModel extends Model {
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(Automobility.id("automobile/frame/pineapple"), "main");

private final ModelPart main;
private final ModelPart stem;

public PineappleFrameModel(EntityRendererFactory.Context ctx) {
super(RenderLayer::getEntityCutout);
this.main = ctx.getPart(MODEL_LAYER).getChild("main");
this.stem = this.main.getChild("stem");
setRotationAngle(stem, 0.0F, 0.0F, 0.0873F);
}

private void setRotationAngle(ModelPart bone, float x, float y, float z) {
bone.pitch = x;
bone.yaw = y;
bone.roll = z;
}

public static TexturedModelData createModelData() {
ModelData modelData = new ModelData();
ModelPartData root = modelData.getRoot();
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));
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));
return TexturedModelData.of(modelData,64,32);
}

@Override
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
matrices.push();
matrices.translate(0, -1.5, 0);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90));
matrices.scale(2, 2, 2);
this.main.render(matrices, vertices, light, overlay, red, green, blue, alpha);
matrices.pop();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package io.github.foundationgames.automobility.automobile.render.frame;

import io.github.foundationgames.automobility.Automobility;
import net.minecraft.client.model.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3f;

public class TractorFrameModel extends Model {
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(Automobility.id("automobile/frame/tractor"), "main");

private final ModelPart main;
private final ModelPart seat_back;
private final ModelPart pipe_tip;
private final ModelPart dashboard;

public TractorFrameModel(EntityRendererFactory.Context ctx) {
super(RenderLayer::getEntityCutout);
this.main = ctx.getPart(MODEL_LAYER).getChild("main");
this.dashboard = this.main.getChild("dashboard");
this.pipe_tip = this.main.getChild("pipe_tip");
this.seat_back = this.main.getChild("seat_back");
setRotationAngle(seat_back, -1.8326F, 0.0F, 0.0F);
setRotationAngle(pipe_tip, -0.1309F, 0.0F, 0.0F);
setRotationAngle(dashboard, 0.5672F, 0.0F, 0.0F);
}

private void setRotationAngle(ModelPart bone, float x, float y, float z) {
bone.pitch = x;
bone.yaw = y;
bone.roll = z;
}

public static TexturedModelData createModelData() {
ModelData modelData = new ModelData();
ModelPartData root = modelData.getRoot();
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));
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));
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));
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));
return TexturedModelData.of(modelData,64,64);
}

@Override
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
matrices.push();
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90));
this.main.render(matrices, vertices, light, overlay, red, green, blue, alpha);
matrices.pop();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package io.github.foundationgames.automobility.automobile.render.wheel;

import io.github.foundationgames.automobility.Automobility;
import net.minecraft.client.model.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.model.EntityModelLayer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3f;

public class TractorWheelModel extends Model {
public static final EntityModelLayer MODEL_LAYER = new EntityModelLayer(Automobility.id("automobile/wheel/tractor"), "main");

private final ModelPart main;
private final ModelPart tire_8;
private final ModelPart tire_7;
private final ModelPart tire_6;
private final ModelPart tire_5;
private final ModelPart tire_4;
private final ModelPart tire_3;
private final ModelPart tire_2;

public TractorWheelModel(EntityRendererFactory.Context ctx) {
super(RenderLayer::getEntityCutout);
this.main = ctx.getPart(MODEL_LAYER).getChild("main");
this.tire_2 = this.main.getChild("tire_2");
this.tire_3 = this.main.getChild("tire_3");
this.tire_4 = this.main.getChild("tire_4");
this.tire_5 = this.main.getChild("tire_5");
this.tire_6 = this.main.getChild("tire_6");
this.tire_7 = this.main.getChild("tire_7");
this.tire_8 = this.main.getChild("tire_8");
setRotationAngle(tire_8, -0.7854F, 0.0F, 0.0F);
setRotationAngle(tire_7, -1.5708F, 0.0F, 0.0F);
setRotationAngle(tire_6, -2.3562F, 0.0F, 0.0F);
setRotationAngle(tire_5, 3.1416F, 0.0F, 0.0F);
setRotationAngle(tire_4, 2.3562F, 0.0F, 0.0F);
setRotationAngle(tire_3, 1.5708F, 0.0F, 0.0F);
setRotationAngle(tire_2, 0.7854F, 0.0F, 0.0F);
}

private void setRotationAngle(ModelPart bone, float x, float y, float z) {
bone.pitch = x;
bone.yaw = y;
bone.roll = z;
}

public static TexturedModelData createModelData() {
ModelData modelData = new ModelData();
ModelPartData root = modelData.getRoot();
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));
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));
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));
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));
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));
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));
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));
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));
return TexturedModelData.of(modelData,16,16);
}

@Override
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
matrices.push();
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90));
main.render(matrices, vertices, light, overlay, red, green, blue, alpha);
matrices.pop();
}
}
Loading

0 comments on commit 36488a9

Please sign in to comment.