Skip to content

Commit

Permalink
添加龙舟
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Jun 7, 2024
1 parent c1d4750 commit 05a6654
Show file tree
Hide file tree
Showing 18 changed files with 350 additions and 151 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
* 修改烤土豆的模型为青团
* 修改物品展示框、荧光物品展示框的模型为盘子
* 为部分食物添加了盘子中的3D模型
* [ ] 端午节
* [X] 端午节
* 修改南瓜派的模型为粽子
* 修改船/竹筏的模型为龙舟
* [ ] 七夕节
* [X] 中秋节
* 修改月亮贴图
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
package dev.dubhe.chinesefestivals.client.model;

import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.model.ListModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeDeformation;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.vehicle.Boat;
import org.jetbrains.annotations.NotNull;

public class LoongBoatModel extends ListModel<Boat> {
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation("chinesefestivals", "loong_boat"), "main");
private static final String BOTTOM = "bottom";
private static final String BACK = "back";
private static final String FRONT = "front";
private static final String RIGHT = "right";
private static final String LEFT = "left";
private final ModelPart front;
private final ModelPart back;
private final ModelPart left;
private final ModelPart right;
private final ModelPart bottom;
private final ModelPart bottom_no_water;
private final ModelPart paddle_left;
private final ModelPart paddle_left2;
private final ModelPart paddle_left3;
private final ModelPart paddle_right;
private final ModelPart paddle_right2;
private final ModelPart paddle_right3;
private final ImmutableList<ModelPart> parts;

public LoongBoatModel(ModelPart root) {
this.front = root.getChild("front");
this.back = root.getChild("back");
this.left = root.getChild("left");
this.right = root.getChild("right");
this.bottom = root.getChild("bottom");
this.bottom_no_water = root.getChild("bottom_no_water");
this.paddle_left = root.getChild("paddle_left");
this.paddle_left2 = root.getChild("paddle_left2");
this.paddle_left3 = root.getChild("paddle_left3");
this.paddle_right = root.getChild("paddle_right");
this.paddle_right2 = root.getChild("paddle_right2");
this.paddle_right3 = root.getChild("paddle_right3");
this.parts = this.createPartsBuilder(root).build();
}

protected ImmutableList.Builder<ModelPart> createPartsBuilder(ModelPart modelPart) {
ImmutableList.Builder<ModelPart> builder = new ImmutableList.Builder<ModelPart>();
builder.add(modelPart.getChild(BOTTOM), modelPart.getChild(BACK), modelPart.getChild(FRONT), modelPart.getChild(RIGHT), modelPart.getChild(LEFT), this.paddle_left, this.paddle_left2, this.paddle_left3, this.paddle_right, this.paddle_right2, this.paddle_right3);
return builder;
}

public static @NotNull LayerDefinition createBodyModel() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();
PartDefinition front = partdefinition.addOrReplaceChild("front", CubeListBuilder.create(), PartPose.offsetAndRotation(0.0F, 18.0F, -23.0F, 0.0F, -3.1416F, 0.0F));
front.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(94, 0).mirror().addBox(-6.5F, -1.0F, -3.0F, 4.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)).mirror(false)
.texOffs(94, 0).addBox(2.5F, -1.0F, -3.0F, 4.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -22.0F, 11.0F, 0.2618F, 0.0F, 0.0F));
front.addOrReplaceChild("cube_r2", CubeListBuilder.create().texOffs(88, 23).addBox(-5.0F, -3.0F, 1.0F, 9.0F, 3.0F, 11.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.5F, -14.0F, 11.0F, -0.1309F, 0.0F, 0.0F));
front.addOrReplaceChild("cube_r3", CubeListBuilder.create().texOffs(110, 0).addBox(-2.5F, -5.0F, 9.0F, 5.0F, 3.0F, 4.0F, new CubeDeformation(0.0F))
.texOffs(92, 9).addBox(-4.0F, -4.0F, 2.0F, 8.0F, 4.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -15.0F, 11.0F, 0.2618F, 0.0F, 0.0F));
front.addOrReplaceChild("cube_r4", CubeListBuilder.create().texOffs(75, 113).mirror().addBox(2.5F, -3.0F, 0.0F, 13.0F, 0.0F, 13.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(0.0F, -15.0F, 11.0F, 0.2467F, 0.0886F, -0.3381F));
front.addOrReplaceChild("cube_r5", CubeListBuilder.create().texOffs(75, 113).addBox(-15.5F, -3.0F, 0.0F, 13.0F, 0.0F, 13.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -15.0F, 11.0F, 0.2467F, -0.0886F, 0.3381F));
front.addOrReplaceChild("cube_r6", CubeListBuilder.create().texOffs(102, 86).mirror().addBox(4.0F, -7.0F, 4.0F, 13.0F, 15.0F, 0.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(0.0F, -19.0F, 12.0F, 0.6109F, 1.1026F, 0.5585F));
front.addOrReplaceChild("cube_r7", CubeListBuilder.create().texOffs(102, 86).addBox(-17.0F, -7.0F, 4.0F, 13.0F, 15.0F, 0.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -19.0F, 12.0F, 0.6109F, -1.1026F, -0.5585F));
front.addOrReplaceChild("cube_r8", CubeListBuilder.create().texOffs(104, 116).mirror().addBox(2.0F, -1.5F, -16.0F, 2.0F, 2.0F, 10.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(0.0F, -16.0F, 6.0F, -0.7024F, -0.1002F, 0.0844F));
front.addOrReplaceChild("cube_r9", CubeListBuilder.create().texOffs(109, 120).mirror().addBox(-3.0F, -1.0F, -16.0F, 1.0F, 1.0F, 6.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(0.0F, -16.0F, 6.0F, -0.8499F, -0.544F, 0.5323F));
front.addOrReplaceChild("cube_r10", CubeListBuilder.create().texOffs(109, 120).addBox(2.0F, -1.0F, -16.0F, 1.0F, 1.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -16.0F, 6.0F, -0.8499F, 0.544F, -0.5323F));
front.addOrReplaceChild("cube_r11", CubeListBuilder.create().texOffs(104, 116).addBox(-4.0F, -1.5F, -16.0F, 2.0F, 2.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -16.0F, 6.0F, -0.7024F, 0.1002F, -0.0844F));
front.addOrReplaceChild("cube_r12", CubeListBuilder.create().texOffs(84, 101).addBox(-8.0F, -7.5F, -8.0F, 16.0F, 0.0F, 12.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -16.0F, 6.0F, -0.1309F, 0.0F, 0.0F));
front.addOrReplaceChild("cube_r13", CubeListBuilder.create().texOffs(80, 37).addBox(-6.0F, -6.0F, -5.0F, 12.0F, 10.0F, 12.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -16.0F, 6.0F, 0.2618F, 0.0F, 0.0F));
front.addOrReplaceChild("cube_r14", CubeListBuilder.create().texOffs(52, 29).addBox(-5.0F, -10.0F, -6.0F, 10.0F, 13.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -6.0F, 4.0F, -0.3927F, 0.0F, 0.0F));
front.addOrReplaceChild("front_r1", CubeListBuilder.create().texOffs(0, 29).addBox(-8.0F, -5.0F, -5.0F, 16.0F, 10.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -2.0F, -1.0F, 0.3927F, 0.0F, 0.0F));
PartDefinition back = partdefinition.addOrReplaceChild("back", CubeListBuilder.create(), PartPose.offset(4.0F, 22.0F, 15.0F));
back.addOrReplaceChild("cube_r15", CubeListBuilder.create().texOffs(92, 56).addBox(0.0F, -5.5F, 1.0F, 0.0F, 12.0F, 18.0F, new CubeDeformation(0.0F))
.texOffs(40, 67).addBox(-2.0F, -1.5F, -4.0F, 4.0F, 4.0F, 11.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-4.0F, -13.0F, 13.0F, 1.1781F, 0.0F, 0.0F));
back.addOrReplaceChild("cube_r16", CubeListBuilder.create().texOffs(92, 59).addBox(-5.0F, -4.5F, -3.0F, 10.0F, 7.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-4.0F, -8.0F, 11.0F, 0.7854F, 0.0F, 0.0F));
back.addOrReplaceChild("back_r1", CubeListBuilder.create().texOffs(30, 49).addBox(-8.0F, -6.0F, -5.0F, 16.0F, 9.0F, 9.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-4.0F, -4.0F, 7.0F, 0.3927F, 0.0F, 0.0F));
partdefinition.addOrReplaceChild("left", CubeListBuilder.create().texOffs(0, 19).addBox(-22.0F, -7.0F, -1.0F, 44.0F, 8.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(9.0F, 22.0F, 0.0F, 0.0F, 1.5708F, 0.0F));
partdefinition.addOrReplaceChild("right", CubeListBuilder.create().texOffs(0, 19).mirror().addBox(-22.0F, -7.0F, -1.0F, 44.0F, 8.0F, 2.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(-9.0F, 22.0F, 0.0F, 0.0F, -1.5708F, 0.0F));
partdefinition.addOrReplaceChild("bottom", CubeListBuilder.create().texOffs(0, 0).addBox(-22.0F, -9.0F, -3.0F, 44.0F, 16.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(1.0F, 21.0F, 0.0F, 0.0F, 1.5708F, -1.5708F));
partdefinition.addOrReplaceChild("bottom_no_water", CubeListBuilder.create().texOffs(0, 106).addBox(-18.0F, -8.0F, -3.0F, 37.0F, 16.0F, 6.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 18.0F, 0.0F, 0.0F, 1.5708F, -1.5708F));
partdefinition.addOrReplaceChild("paddle_left", CubeListBuilder.create().texOffs(0, 64).addBox(-1.0F, 0.0F, -5.0F, 2.0F, 2.0F, 18.0F, new CubeDeformation(0.0F))
.texOffs(0, 64).addBox(-1.001F, -3.0F, 8.0F, 1.0F, 6.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(9.0F, 13.0F, -3.0F, 2.1642F, 0.8727F, 2.8798F));
partdefinition.addOrReplaceChild("paddle_left2", CubeListBuilder.create().texOffs(0, 64).addBox(-1.0F, 0.0F, -5.0F, 2.0F, 2.0F, 18.0F, new CubeDeformation(0.0F))
.texOffs(0, 64).addBox(-1.001F, -3.0F, 8.0F, 1.0F, 6.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(9.0F, 13.0F, 7.0F, 2.1642F, 0.8727F, 2.8798F));
partdefinition.addOrReplaceChild("paddle_left3", CubeListBuilder.create().texOffs(0, 64).addBox(-1.0F, 0.0F, -5.0F, 2.0F, 2.0F, 18.0F, new CubeDeformation(0.0F))
.texOffs(0, 64).addBox(-1.001F, -3.0F, 8.0F, 1.0F, 6.0F, 7.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(9.0F, 13.0F, -13.0F, 2.1642F, 0.8727F, 2.8798F));

PartDefinition paddle_right = partdefinition.addOrReplaceChild(
"paddle_right",
CubeListBuilder.create(),
PartPose.offsetAndRotation(-9.0F, 13.0F, -3.0F, 2.1642F, -0.8727F, -2.8798F)
);
paddle_right.addOrReplaceChild(
"paddle_right_r1",
CubeListBuilder.create()
.texOffs(0, 84)
.addBox(-0.2495F, -3.5F, 0.25F, 1.0F, 6.0F, 7.0F, new CubeDeformation(0.0F))
.texOffs(0, 84)
.addBox(-1.2505F, -0.5F, -12.75F, 2.0F, 2.0F, 18.0F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.2505F, 0.5F, 7.75F, 0.0F, 0.0F, -3.1416F)
);

PartDefinition paddle_right2 = partdefinition.addOrReplaceChild(
"paddle_right2",
CubeListBuilder.create(),
PartPose.offsetAndRotation(-9.0F, 13.0F, 7.0F, 2.1642F, -0.8727F, -2.8798F)
);
paddle_right2.addOrReplaceChild(
"paddle_right_r2",
CubeListBuilder.create()
.texOffs(0, 84)
.addBox(-0.2495F, -3.5F, 0.25F, 1.0F, 6.0F, 7.0F, new CubeDeformation(0.0F))
.texOffs(0, 84)
.addBox(-1.2505F, -0.5F, -12.75F, 2.0F, 2.0F, 18.0F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.2505F, 0.5F, 7.75F, 0.0F, 0.0F, -3.1416F)
);

PartDefinition paddle_right3 = partdefinition.addOrReplaceChild(
"paddle_right3",
CubeListBuilder.create(),
PartPose.offsetAndRotation(-9.0F, 13.0F, -13.0F, 2.1642F, -0.8727F, -2.8798F)
);
paddle_right3.addOrReplaceChild(
"paddle_right_r3",
CubeListBuilder.create()
.texOffs(0, 84)
.addBox(-0.2495F, -3.5F, 0.25F, 1.0F, 6.0F, 7.0F, new CubeDeformation(0.0F))
.texOffs(0, 84)
.addBox(-1.2505F, -0.5F, -12.75F, 2.0F, 2.0F, 18.0F, new CubeDeformation(0.0F)),
PartPose.offsetAndRotation(0.2505F, 0.5F, 7.75F, 0.0F, 0.0F, -3.1416F)
);

return LayerDefinition.create(meshdefinition, 128, 128);
}

@Override
public void setupAnim(Boat boat, float f, float g, float h, float i, float j) {
LoongBoatModel.animatePaddle(boat, 0, this.paddle_left, f);
LoongBoatModel.animatePaddle(boat, 0, this.paddle_left2, f);
LoongBoatModel.animatePaddle(boat, 0, this.paddle_left3, f);
LoongBoatModel.animatePaddle(boat, 1, this.paddle_right, f);
LoongBoatModel.animatePaddle(boat, 1, this.paddle_right2, f);
LoongBoatModel.animatePaddle(boat, 1, this.paddle_right3, f);
}

private static void animatePaddle(@NotNull Boat boat, int i, @NotNull ModelPart modelPart, float f) {
float g = -boat.getRowingTime(i, f);
modelPart.xRot = Mth.clampedLerp(-1.0471976f, -0.2617994f, (Mth.sin(g) + 1.0f) / 2.0f) + 1.0f;
modelPart.yRot = Mth.clampedLerp(-0.7853982f, 0.7853982f, (Mth.sin(g + 1.0f) + 1.0f) / 2.0f) + 1.0f;
if (i != 1) {
modelPart.xRot = (float) Math.PI - modelPart.xRot;
} else {
modelPart.yRot = (float) Math.PI - modelPart.yRot;
}
}

@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
front.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
back.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
left.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
right.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
bottom.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
bottom_no_water.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
paddle_left.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
paddle_left2.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
paddle_left3.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
paddle_right.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
paddle_right2.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
paddle_right3.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
}

@Override
public @NotNull Iterable<ModelPart> parts() {
return this.parts;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.dubhe.chinesefestivals.renderer;
package dev.dubhe.chinesefestivals.client.renderer;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Features {
public static final Supplier<IFeature> QING_TUAN = new FeatureGetter("qing_tuan", QingTuan::new);
public static final Supplier<IFeature> THREE_D_FOOD = new FeatureGetter("3d_food", ThreeDFood::new);
public static final Supplier<IFeature> ZONG_ZI = new FeatureGetter("zong_zi", ZongZi::new);
public static final Supplier<IFeature> LOONG_BOAT = new FeatureGetter("loong_boat", LoongBoat::new);
public static final List<Supplier<IFeature>> FEATURES = Collections.synchronizedList(new ArrayList<>() {{
add(COUPLETS);
add(JIAO_ZI);
Expand All @@ -48,6 +49,7 @@ public class Features {
add(QING_TUAN);
add(THREE_D_FOOD);
add(ZONG_ZI);
add(LOONG_BOAT);
}});

public static void refresh() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dev.dubhe.chinesefestivals.features.impl;

import dev.dubhe.chinesefestivals.features.Feature;
import dev.dubhe.chinesefestivals.festivals.Festivals;
import dev.dubhe.chinesefestivals.festivals.IFestival;
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

public class LoongBoat extends Feature {
public LoongBoat(String id, IFestival @NotNull ... enableTimes) {
super(id, Festivals.LOONG_BOAT_FESTIVAL);
if (enableTimes.length > 0) {
super.enableTimes.clear();
super.enableTimes.addAll(List.of(enableTimes));
}
}

@Override
public Map<String, Supplier<String>> getTranslationReplace() {
Map<String, Supplier<String>> map = Collections.synchronizedMap(new HashMap<>());
map.put("entity.minecraft.boat", () -> "entity.chinesefestivals.loong_boat");
return map;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ZongZi extends Feature {
public static final Supplier<Item> ZONG_ZI = IFeature.createItem("zong_zi", new Item.Properties().food(Foods.PUFFERFISH), Item::new);

public ZongZi(String id, IFestival @NotNull ... enableTimes) {
super(id, Festivals.DRAGON_BOAT_FESTIVAL);
super(id, Festivals.LOONG_BOAT_FESTIVAL);
if (enableTimes.length > 0) {
super.enableTimes.clear();
super.enableTimes.addAll(List.of(enableTimes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Festivals {
// 元宵节
public static final IFestival LANTERN_FESTIVAL = new LunarFestival("lantern", 1, 15);
// 端午节
public static final IFestival DRAGON_BOAT_FESTIVAL = new LunarFestival("dragon_boat", 5, 5);
public static final IFestival LOONG_BOAT_FESTIVAL = new LunarFestival("loong_boat", 5, 5);
// 七夕节
public static final IFestival QIXI_FESTIVAL = new LunarFestival("qixi", 7, 7);
// 中秋节
Expand All @@ -28,7 +28,7 @@ public class Festivals {
public static final List<IFestival> FESTIVALS = Collections.synchronizedList(new ArrayList<>() {{
this.add(CHINESE_SPRING_FESTIVAL);
this.add(LANTERN_FESTIVAL);
this.add(DRAGON_BOAT_FESTIVAL);
this.add(LOONG_BOAT_FESTIVAL);
this.add(QIXI_FESTIVAL);
this.add(MOON_FESTIVAL);
this.add(DOUBLE_NINTH_FESTIVAL);
Expand Down
Loading

0 comments on commit 05a6654

Please sign in to comment.