diff --git a/gradle.properties b/gradle.properties index f4fb195..1f94af6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/io/github/foundationgames/automobility/automobile/AutomobileFrame.java b/src/main/java/io/github/foundationgames/automobility/automobile/AutomobileFrame.java index 215496d..c00789f 100644 --- a/src/main/java/io/github/foundationgames/automobility/automobile/AutomobileFrame.java +++ b/src/main/java/io/github/foundationgames/automobility/automobile/AutomobileFrame.java @@ -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; @@ -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"), @@ -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"), @@ -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; diff --git a/src/main/java/io/github/foundationgames/automobility/automobile/AutomobileWheel.java b/src/main/java/io/github/foundationgames/automobility/automobile/AutomobileWheel.java index a12813f..26bafdf 100644 --- a/src/main/java/io/github/foundationgames/automobility/automobile/AutomobileWheel.java +++ b/src/main/java/io/github/foundationgames/automobility/automobile/AutomobileWheel.java @@ -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; @@ -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) // ); diff --git a/src/main/java/io/github/foundationgames/automobility/automobile/render/AutomobileRenderer.java b/src/main/java/io/github/foundationgames/automobility/automobile/render/AutomobileRenderer.java index 97e725c..c0a4497 100644 --- a/src/main/java/io/github/foundationgames/automobility/automobile/render/AutomobileRenderer.java +++ b/src/main/java/io/github/foundationgames/automobility/automobile/render/AutomobileRenderer.java @@ -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(); } @@ -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(); @@ -153,8 +154,4 @@ public static void render( matrices.pop(); } - - public static void renderEngine() { - - } } diff --git a/src/main/java/io/github/foundationgames/automobility/automobile/render/frame/PineappleFrameModel.java b/src/main/java/io/github/foundationgames/automobility/automobile/render/frame/PineappleFrameModel.java new file mode 100644 index 0000000..58e8675 --- /dev/null +++ b/src/main/java/io/github/foundationgames/automobility/automobile/render/frame/PineappleFrameModel.java @@ -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(); + } +} diff --git a/src/main/java/io/github/foundationgames/automobility/automobile/render/frame/TractorFrameModel.java b/src/main/java/io/github/foundationgames/automobility/automobile/render/frame/TractorFrameModel.java new file mode 100644 index 0000000..232bbcf --- /dev/null +++ b/src/main/java/io/github/foundationgames/automobility/automobile/render/frame/TractorFrameModel.java @@ -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(); + } +} diff --git a/src/main/java/io/github/foundationgames/automobility/automobile/render/wheel/TractorWheelModel.java b/src/main/java/io/github/foundationgames/automobility/automobile/render/wheel/TractorWheelModel.java new file mode 100644 index 0000000..fe82b9b --- /dev/null +++ b/src/main/java/io/github/foundationgames/automobility/automobile/render/wheel/TractorWheelModel.java @@ -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(); + } +} diff --git a/src/main/java/io/github/foundationgames/automobility/entity/AutomobileEntity.java b/src/main/java/io/github/foundationgames/automobility/entity/AutomobileEntity.java index 72243b5..11740bc 100644 --- a/src/main/java/io/github/foundationgames/automobility/entity/AutomobileEntity.java +++ b/src/main/java/io/github/foundationgames/automobility/entity/AutomobileEntity.java @@ -17,12 +17,10 @@ import net.minecraft.block.SideShapeType; import net.minecraft.client.model.Model; import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.MovementType; +import net.minecraft.entity.*; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.vehicle.BoatEntity; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.network.Packet; import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; @@ -255,7 +253,7 @@ public boolean automobileOnGround() { @Override public boolean debris() { - return offRoad && hSpeed > 0; + return offRoad && hSpeed != 0; } @Override @@ -295,7 +293,7 @@ public void baseTick() { } } } else { - clientTick(); + slopeAngleTick(); } } @@ -303,11 +301,23 @@ private void sync(ServerPlayerEntity player) { PayloadPackets.sendSyncAutomobileDataPacket(this, player); } + public ItemStack asItem() { + var stack = new ItemStack(AutomobilityItems.AUTOMOBILE); + var automobile = stack.getOrCreateSubTag("Automobile"); + automobile.putString("frame", frame.getId().toString()); + automobile.putString("wheels", wheels.getId().toString()); + automobile.putString("engine", engine.getId().toString()); + return stack; + } + + @Nullable + @Override + public ItemStack getPickBlockStack() { + return asItem(); + } + // witness me fighting against minecraft's collision/physics public void movementTick() { - //this.wasOnGround = automobileOnGround; - //this.automobileOnGround = (verticalSpeed < 0.2 && verticalSpeed > -0.2) || isOnGround(); - // Handle the small suspension bounce effect lastSusBounceTimer = suspensionBounceTimer; if (suspensionBounceTimer > 0) suspensionBounceTimer--; @@ -422,7 +432,7 @@ public void movementTick() { if (hSpeed > 0.2) { var frontBox = getBoundingBox().offset(cumulative.multiply(0.5)); var velAdd = cumulative.add(0, 0.1, 0).multiply(3); - for (var entity : world.getEntitiesByType(TypeFilter.instanceOf(Entity.class), frontBox, entity -> entity != this)) { + for (var entity : world.getEntitiesByType(TypeFilter.instanceOf(Entity.class), frontBox, entity -> entity != this && entity != getFirstPassenger())) { if (entity instanceof LivingEntity living) { living.damage(AutomobilityEntities.AUTOMOBILE_DAMAGE_SOURCE, hSpeed * 10); } @@ -465,8 +475,6 @@ public void movementTick() { // Handles gravity verticalSpeed = Math.max(verticalSpeed - 0.08f, !automobileOnGround ? TERMINAL_VELOCITY : -0.01f); - //if (verticalSpeed == 0) System.out.println("ZERO V SPEED"); - // Store previous y displacement to use when launching off slopes prevYDisplacements.push(yDisp); if (prevYDisplacements.size() > 2) { @@ -525,7 +533,7 @@ public void movementTick() { } } - public void clientTick() { + public void slopeAngleTick() { lastGroundSlopeX = groundSlopeX; lastGroundSlopeZ = groundSlopeZ; var below = new BlockPos(Math.floor(getX()), Math.floor(getY() - 0.06), Math.floor(getZ())); @@ -700,6 +708,8 @@ public Entity getPrimaryPassenger() { @Override public ActionResult interact(PlayerEntity player, Hand hand) { if (player.getStackInHand(hand).isOf(AutomobilityItems.CROWBAR)) { + var pos = getPos().add(0, 0.3, 0); + if (!player.isCreative()) world.spawnEntity(new ItemEntity(world, pos.x, pos.y, pos.z, asItem())); this.remove(RemovalReason.KILLED); return ActionResult.success(world.isClient); } diff --git a/src/main/java/io/github/foundationgames/automobility/entity/AutomobilityEntities.java b/src/main/java/io/github/foundationgames/automobility/entity/AutomobilityEntities.java index a7ce6b9..5c10730 100644 --- a/src/main/java/io/github/foundationgames/automobility/entity/AutomobilityEntities.java +++ b/src/main/java/io/github/foundationgames/automobility/entity/AutomobilityEntities.java @@ -7,12 +7,11 @@ import io.github.foundationgames.automobility.automobile.render.engine.CreativeEngineModel; import io.github.foundationgames.automobility.automobile.render.engine.GoldEngineModel; import io.github.foundationgames.automobility.automobile.render.engine.IronEngineModel; -import io.github.foundationgames.automobility.automobile.render.frame.CARRFrameModel; -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.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.TractorWheelModel; import io.github.foundationgames.automobility.entity.render.AutomobileEntityRenderer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -46,11 +45,14 @@ public static void initClient() { EntityRendererRegistry.INSTANCE.register(AUTOMOBILE, AutomobileEntityRenderer::new); EntityModelLayerRegistry.registerModelLayer(StandardFrameModel.MODEL_LAYER, StandardFrameModel::createModelData); + EntityModelLayerRegistry.registerModelLayer(TractorFrameModel.MODEL_LAYER, TractorFrameModel::createModelData); EntityModelLayerRegistry.registerModelLayer(ShoppingCartFrameModel.MODEL_LAYER, ShoppingCartFrameModel::createModelData); EntityModelLayerRegistry.registerModelLayer(CARRFrameModel.MODEL_LAYER, CARRFrameModel::createModelData); + EntityModelLayerRegistry.registerModelLayer(PineappleFrameModel.MODEL_LAYER, PineappleFrameModel::createModelData); EntityModelLayerRegistry.registerModelLayer(StandardWheelModel.MODEL_LAYER, StandardWheelModel::createModelData); EntityModelLayerRegistry.registerModelLayer(OffRoadWheelModel.MODEL_LAYER, OffRoadWheelModel::createModelData); + EntityModelLayerRegistry.registerModelLayer(TractorWheelModel.MODEL_LAYER, TractorWheelModel::createModelData); EntityModelLayerRegistry.registerModelLayer(SteelWheelModel.MODEL_LAYER, SteelWheelModel::createModelData); EntityModelLayerRegistry.registerModelLayer(IronEngineModel.MODEL_LAYER, IronEngineModel::createModelData); diff --git a/src/main/java/io/github/foundationgames/automobility/item/AutomobileItem.java b/src/main/java/io/github/foundationgames/automobility/item/AutomobileItem.java index 240997e..1dbf2d0 100644 --- a/src/main/java/io/github/foundationgames/automobility/item/AutomobileItem.java +++ b/src/main/java/io/github/foundationgames/automobility/item/AutomobileItem.java @@ -35,12 +35,14 @@ public AutomobileItem(Settings settings) { @Override public ActionResult useOnBlock(ItemUsageContext context) { if (!context.getWorld().isClient()) { - data.read(context.getStack().getOrCreateSubTag("Automobile")); + var stack = context.getStack(); + data.read(stack.getOrCreateSubTag("Automobile")); var e = new AutomobileEntity(AutomobilityEntities.AUTOMOBILE, context.getWorld()); var pos = context.getHitPos(); e.refreshPositionAndAngles(pos.x, pos.y, pos.z, context.getPlayerFacing().asRotation(), 0); e.setComponents(data.getFrame(), data.getWheel(), data.getEngine()); context.getWorld().spawnEntity(e); + stack.decrement(1); return ActionResult.PASS; } return ActionResult.SUCCESS; diff --git a/src/main/java/io/github/foundationgames/automobility/item/AutomobilityItems.java b/src/main/java/io/github/foundationgames/automobility/item/AutomobilityItems.java index 0f29345..7e3068d 100644 --- a/src/main/java/io/github/foundationgames/automobility/item/AutomobilityItems.java +++ b/src/main/java/io/github/foundationgames/automobility/item/AutomobilityItems.java @@ -16,8 +16,8 @@ import net.minecraft.util.registry.Registry; public enum AutomobilityItems {; - public static final Item CROWBAR = register("crowbar", new TooltipItem(new TranslatableText("tooltip.item.automobility.crowbar").formatted(Formatting.BLUE), new Item.Settings().group(Automobility.GROUP))); - public static final Item AUTOMOBILE = register("automobile", new AutomobileItem(new Item.Settings().group(Automobility.PREFABS))); + public static final Item CROWBAR = register("crowbar", new TooltipItem(new TranslatableText("tooltip.item.automobility.crowbar").formatted(Formatting.BLUE), new Item.Settings().maxCount(1).group(Automobility.GROUP))); + public static final Item AUTOMOBILE = register("automobile", new AutomobileItem(new Item.Settings().maxCount(1).group(Automobility.PREFABS))); public static void init() { AutomobileItem.addPrefabs( @@ -37,8 +37,13 @@ public static void init() { new AutomobilePrefab(Automobility.id("standard_green"), AutomobileFrame.STANDARD_GREEN, AutomobileWheel.STANDARD, AutomobileEngine.IRON), new AutomobilePrefab(Automobility.id("standard_red"), AutomobileFrame.STANDARD_RED, AutomobileWheel.STANDARD, AutomobileEngine.IRON), new AutomobilePrefab(Automobility.id("standard_black"), AutomobileFrame.STANDARD_BLACK, AutomobileWheel.STANDARD, AutomobileEngine.IRON), + new AutomobilePrefab(Automobility.id("red_tractor"), AutomobileFrame.RED_TRACTOR, AutomobileWheel.TRACTOR, AutomobileEngine.COPPER), + new AutomobilePrefab(Automobility.id("yellow_tractor"), AutomobileFrame.YELLOW_TRACTOR, AutomobileWheel.TRACTOR, AutomobileEngine.COPPER), + new AutomobilePrefab(Automobility.id("green_tractor"), AutomobileFrame.GREEN_TRACTOR, AutomobileWheel.TRACTOR, AutomobileEngine.COPPER), + new AutomobilePrefab(Automobility.id("blue_tractor"), AutomobileFrame.BLUE_TRACTOR, AutomobileWheel.TRACTOR, AutomobileEngine.COPPER), new AutomobilePrefab(Automobility.id("shopping_cart"), AutomobileFrame.SHOPPING_CART, AutomobileWheel.STEEL, AutomobileEngine.COPPER), - new AutomobilePrefab(Automobility.id("c_arr"), AutomobileFrame.C_ARR, AutomobileWheel.OFF_ROAD, AutomobileEngine.GOLD) + new AutomobilePrefab(Automobility.id("c_arr"), AutomobileFrame.C_ARR, AutomobileWheel.OFF_ROAD, AutomobileEngine.GOLD), + new AutomobilePrefab(Automobility.id("pineapple"), AutomobileFrame.PINEAPPLE, AutomobileWheel.TRACTOR, AutomobileEngine.GOLD) ); } diff --git a/src/main/resources/assets/automobility/lang/en_us.json b/src/main/resources/assets/automobility/lang/en_us.json index 7617612..5a3ab87 100644 --- a/src/main/resources/assets/automobility/lang/en_us.json +++ b/src/main/resources/assets/automobility/lang/en_us.json @@ -45,8 +45,13 @@ "prefab.automobility.standard_green": "Standard Green", "prefab.automobility.standard_red": "Standard Red", "prefab.automobility.standard_black": "Standard Black", + "prefab.automobility.red_tractor": "Red Tractor", + "prefab.automobility.yellow_tractor": "Yellow Tractor", + "prefab.automobility.green_tractor": "Green Tractor", + "prefab.automobility.blue_tractor": "Blue Tractor", "prefab.automobility.shopping_cart": "Shopping Cart", "prefab.automobility.c_arr": "c:arr:", + "prefab.automobility.pineapple": "Pineapple", "tooltip.automobility.frameLabel": "Frame: ", "tooltip.automobility.wheelLabel": "Wheels: ", @@ -73,12 +78,18 @@ "frame.automobility.standard_green": "Standard Green", "frame.automobility.standard_red": "Standard Red", "frame.automobility.standard_black": "Standard Black", + "frame.automobility.red_tractor": "Red Tractor", + "frame.automobility.yellow_tractor": "Yellow Tractor", + "frame.automobility.green_tractor": "Green Tractor", + "frame.automobility.blue_tractor": "Blue Tractor", "frame.automobility.shopping_cart": "Shopping Cart", "frame.automobility.c_arr": "c:arr:", "frame.automobility.dababy": "DaBaby", + "frame.automobility.pineapple": "Pineapple", "wheel.automobility.standard": "Standard", "wheel.automobility.off_road": "Off-Road", + "wheel.automobility.tractor": "Tractor", "wheel.automobility.steel": "Steel", "wheel.automobility.convertible": "Convertible", diff --git a/src/main/resources/assets/automobility/models/block/TEST_DELETE.json b/src/main/resources/assets/automobility/models/block/TEST_DELETE.json deleted file mode 100644 index 797b388..0000000 --- a/src/main/resources/assets/automobility/models/block/TEST_DELETE.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "credit": "Made with Blockbench", - "parent": "minecraft:block/thin_block", - "textures": { - "0": "automobility:block/snow_off_road", - "particle": "automobility:block/snow_off_road" - }, - "elements": [ - { - "from": [0, 0, 0], - "to": [16, 6, 16], - "faces": { - "north": {"uv": [0, 10, 16, 16], "texture": "#0"}, - "east": {"uv": [0, 10, 16, 16], "texture": "#0"}, - "south": {"uv": [0, 10, 16, 16], "texture": "#0"}, - "west": {"uv": [0, 10, 16, 16], "texture": "#0", "tintindex": 0}, - "up": {"uv": [0, 0, 16, 16], "texture": "#0"}, - "down": {"uv": [0, 0, 16, 16], "texture": "#0"} - } - } - ] -} \ No newline at end of file diff --git a/src/main/resources/assets/automobility/textures/entity/automobile/frame/blue_tractor.png b/src/main/resources/assets/automobility/textures/entity/automobile/frame/blue_tractor.png new file mode 100644 index 0000000..0a8fa3f Binary files /dev/null and b/src/main/resources/assets/automobility/textures/entity/automobile/frame/blue_tractor.png differ diff --git a/src/main/resources/assets/automobility/textures/entity/automobile/frame/green_tractor.png b/src/main/resources/assets/automobility/textures/entity/automobile/frame/green_tractor.png new file mode 100644 index 0000000..41400cc Binary files /dev/null and b/src/main/resources/assets/automobility/textures/entity/automobile/frame/green_tractor.png differ diff --git a/src/main/resources/assets/automobility/textures/entity/automobile/frame/pineapple.png b/src/main/resources/assets/automobility/textures/entity/automobile/frame/pineapple.png new file mode 100644 index 0000000..45390ec Binary files /dev/null and b/src/main/resources/assets/automobility/textures/entity/automobile/frame/pineapple.png differ diff --git a/src/main/resources/assets/automobility/textures/entity/automobile/frame/pineapple_src.png b/src/main/resources/assets/automobility/textures/entity/automobile/frame/pineapple_src.png new file mode 100644 index 0000000..95544a4 Binary files /dev/null and b/src/main/resources/assets/automobility/textures/entity/automobile/frame/pineapple_src.png differ diff --git a/src/main/resources/assets/automobility/textures/entity/automobile/frame/red_tractor.png b/src/main/resources/assets/automobility/textures/entity/automobile/frame/red_tractor.png new file mode 100644 index 0000000..523949e Binary files /dev/null and b/src/main/resources/assets/automobility/textures/entity/automobile/frame/red_tractor.png differ diff --git a/src/main/resources/assets/automobility/textures/entity/automobile/frame/tractor_green.png b/src/main/resources/assets/automobility/textures/entity/automobile/frame/tractor_green.png deleted file mode 100644 index 531a820..0000000 Binary files a/src/main/resources/assets/automobility/textures/entity/automobile/frame/tractor_green.png and /dev/null differ diff --git a/src/main/resources/assets/automobility/textures/entity/automobile/frame/yellow_tractor.png b/src/main/resources/assets/automobility/textures/entity/automobile/frame/yellow_tractor.png new file mode 100644 index 0000000..18fbb84 Binary files /dev/null and b/src/main/resources/assets/automobility/textures/entity/automobile/frame/yellow_tractor.png differ diff --git a/src/main/resources/assets/automobility/textures/entity/automobile/wheel/tractor.png b/src/main/resources/assets/automobility/textures/entity/automobile/wheel/tractor.png new file mode 100644 index 0000000..ccd5270 Binary files /dev/null and b/src/main/resources/assets/automobility/textures/entity/automobile/wheel/tractor.png differ