Skip to content

Commit

Permalink
新增清明节相关内容
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Apr 3, 2024
1 parent 2f6feb9 commit 0e431e3
Show file tree
Hide file tree
Showing 21 changed files with 170 additions and 26 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* [X] 元宵节
* 修改灯笼、灵魂灯笼的模型为灯笼
* 修改甜菜汤物品的模型为汤圆
* [X] 清明
* 修改烤土豆的模型为青团
* 修改物品展示框、荧光物品展示框的模型为盘子
* 为部分食物添加了盘子中的3D模型
* [ ] 端午节
* [ ] 七夕节
* [X] 中秋节
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,30 @@ public class Features {
.create();
public static final Map<String, BiFunction<String, IFestival[], IFeature>> FEATURE_GENERATORS = new ConcurrentHashMap<>();
public static final Supplier<IFeature> COUPLETS = new FeatureGetter("couplets", Couplets::new);
public static final Supplier<IFeature> DUMPLINGS = new FeatureGetter("dumplings", Dumplings::new);
public static final Supplier<IFeature> JIAO_ZI = new FeatureGetter("jiao_zi", JiaoZi::new);
public static final Supplier<IFeature> FIREWORKS = new FeatureGetter("fireworks", Fireworks::new);
public static final Supplier<IFeature> FLOWER_CAKE = new FeatureGetter("flower_cake", FlowerCake::new);
public static final Supplier<IFeature> HOTPOTS = new FeatureGetter("hotpots", Hotpots::new);
public static final Supplier<IFeature> LABA_CONGEE = new FeatureGetter("laba_congee", LabaCongee::new);
public static final Supplier<IFeature> LANTERNS = new FeatureGetter("lanterns", Lanterns::new);
public static final Supplier<IFeature> MOONCAKES = new FeatureGetter("mooncakes", Mooncakes::new);
public static final Supplier<IFeature> PLATES = new FeatureGetter("plates", Plates::new);
public static final Supplier<IFeature> SWEET_DUMPLINGS = new FeatureGetter("sweet_dumplings", SweetDumplings::new);
public static final Supplier<IFeature> TANG_YUAN = new FeatureGetter("tang_yuan", TangYuan::new);
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 List<Supplier<IFeature>> FEATURES = new Vector<>() {{
add(COUPLETS);
add(DUMPLINGS);
add(JIAO_ZI);
add(FIREWORKS);
add(FLOWER_CAKE);
add(HOTPOTS);
add(LABA_CONGEE);
add(LANTERNS);
add(MOONCAKES);
add(PLATES);
add(SWEET_DUMPLINGS);
add(TANG_YUAN);
add(QING_TUAN);
add(THREE_D_FOOD);
}};

public static void refresh() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ default Map<Item, Supplier<Item>> getItemReplace() {
return Collections.emptyMap();
}

default Map<Item, Supplier<Item>> get3DFoodReplace() {
return Collections.emptyMap();
}

default ModelResourceLocation getBlockReplace(BlockState blockState) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;

public class Dumplings extends Feature {
public static final Supplier<Item> DUMPLINGS = IFeature.createItem("dumplings", new Item.Properties().food(Foods.RABBIT_STEW), Item::new);
public class JiaoZi extends Feature {
public static final Supplier<Item> DUMPLINGS = IFeature.createItem("jiao_zi", new Item.Properties().food(Foods.RABBIT_STEW), Item::new);

public Dumplings(String id, IFestival... enableTimes) {
public JiaoZi(String id, IFestival... enableTimes) {
super(id, Festivals.DONG_ZHI_FESTIVAL, Festivals.CHINESE_SPRING_FESTIVAL);
if (enableTimes.length > 0) {
super.enableTimes.clear();
Expand All @@ -34,7 +34,7 @@ public Map<Item, Supplier<Item>> getItemReplace() {
@Override
public Map<String, Supplier<String>> getTranslationReplace() {
Map<String, Supplier<String>> map = new ConcurrentHashMap<>();
map.put("item.minecraft.rabbit_stew", () -> "item.chinesefestivals.dumplings");
map.put("item.minecraft.rabbit_stew", () -> "item.chinesefestivals.jiao_zi");
return map;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
public class Plates extends Feature {
private static final ModelResourceLocation DARK_PLATE = IFeature.registerBlockModel(new BlockModelData("plate").property("dark", "true", BooleanProperty::create));
private static final ModelResourceLocation PLATE = IFeature.registerBlockModel(new BlockModelData("plate").property("dark", "false", BooleanProperty::create));

public Plates(String id, IFestival... enableTimes) {
super(id, Festivals.CHINESE_SPRING_FESTIVAL);
super(id, Festivals.CHINESE_SPRING_FESTIVAL, Festivals.QING_MING);
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
@@ -0,0 +1,41 @@
package dev.dubhe.chinesefestivals.features.impl;

import dev.dubhe.chinesefestivals.features.Feature;
import dev.dubhe.chinesefestivals.features.IFeature;
import dev.dubhe.chinesefestivals.festivals.Festivals;
import dev.dubhe.chinesefestivals.festivals.IFestival;
import net.minecraft.world.food.Foods;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;

public class QingTuan extends Feature {
public static final Supplier<Item> QING_TUAN = IFeature.createItem("qing_tuan", new Item.Properties().food(Foods.BAKED_POTATO), Item::new);

public QingTuan(String id, IFestival @NotNull ... enableTimes) {
super(id, Festivals.QING_MING);
if (enableTimes.length > 0) {
super.enableTimes.clear();
super.enableTimes.addAll(List.of(enableTimes));
}
}

@Override
public Map<Item, Supplier<Item>> getItemReplace() {
Map<Item, Supplier<Item>> map = new ConcurrentHashMap<>();
map.put(Items.BAKED_POTATO, QING_TUAN);
return map;
}

@Override
public Map<String, Supplier<String>> getTranslationReplace() {
Map<String, Supplier<String>> map = new ConcurrentHashMap<>();
map.put("item.minecraft.baked_potato", () -> "item.chinesefestivals.qing_tuan");
return map;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;

public class SweetDumplings extends Feature {
public static final Supplier<Item> SWEET_DUMPLINGS = IFeature.createItem("sweet_dumplings", new Item.Properties().food(Foods.RABBIT_STEW), Item::new);
public class TangYuan extends Feature {
public static final Supplier<Item> SWEET_DUMPLINGS = IFeature.createItem("tang_yuan", new Item.Properties().food(Foods.RABBIT_STEW), Item::new);

public SweetDumplings(String id, IFestival... enableTimes) {
public TangYuan(String id, IFestival ... enableTimes) {
super(id, Festivals.LABA_FESTIVAL, Festivals.CHINESE_SPRING_FESTIVAL, Festivals.LANTERN_FESTIVAL);
if (enableTimes.length > 0) {
super.enableTimes.clear();
Expand All @@ -35,7 +35,7 @@ public Map<Item, Supplier<Item>> getItemReplace() {
@Override
public Map<String, Supplier<String>> getTranslationReplace() {
Map<String, Supplier<String>> map = new ConcurrentHashMap<>();
map.put("item.minecraft.beetroot_soup", () -> "item.chinesefestivals.sweet_dumplings");
map.put("item.minecraft.beetroot_soup", () -> "item.chinesefestivals.tang_yuan");
return map;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package dev.dubhe.chinesefestivals.features.impl;

import dev.dubhe.chinesefestivals.ChineseFestivals;
import dev.dubhe.chinesefestivals.features.Feature;
import dev.dubhe.chinesefestivals.features.IFeature;
import dev.dubhe.chinesefestivals.festivals.Festivals;
import dev.dubhe.chinesefestivals.festivals.IFestival;
import net.minecraft.core.registries.Registries;
import net.minecraft.tags.TagKey;
import net.minecraft.world.food.Foods;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;

public class ThreeDFood extends Feature {
public static final TagKey<Item> HAS_PLATE = TagKey.create(Registries.ITEM, ChineseFestivals.of("has_plate"));
public static final Supplier<Item> APPLE_3D = IFeature.createItem("apple_3d", new Item.Properties().food(Foods.APPLE), Item::new);
public static final Supplier<Item> COOKIE_3D = IFeature.createItem("cookie_3d", new Item.Properties().food(Foods.COOKIE), Item::new);

public ThreeDFood(String id, IFestival @NotNull ... enableTimes) {
super(id, Festivals.QING_MING, Festivals.CHINESE_SPRING_FESTIVAL);
if (enableTimes.length > 0) {
super.enableTimes.clear();
super.enableTimes.addAll(List.of(enableTimes));
}
}

@Override
public Map<Item, Supplier<Item>> get3DFoodReplace() {
Map<Item, Supplier<Item>> map = new ConcurrentHashMap<>();
map.put(Items.APPLE, APPLE_3D);
map.put(Items.COOKIE, COOKIE_3D);
return map;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class Festivals {
public static final IFestival DONG_ZHI_FESTIVAL = new SolarTermFestival("dong_zhi", SolarTermFestival.SolarTerm.DONG_ZHI);
// 腊八节
public static final IFestival LABA_FESTIVAL = new LunarFestival("laba", 12, 8);
// 腊八节
public static final IFestival QING_MING = new SolarTermFestival("qing_ming", SolarTermFestival.SolarTerm.QING_MING);

public static final List<IFestival> FESTIVALS = new Vector<>() {{
this.add(CHINESE_SPRING_FESTIVAL);
Expand All @@ -31,6 +33,7 @@ public class Festivals {
this.add(DOUBLE_NINTH_FESTIVAL);
this.add(DONG_ZHI_FESTIVAL);
this.add(LABA_FESTIVAL);
this.add(QING_MING);
}};

public static void refresh() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@

import dev.dubhe.chinesefestivals.features.Features;
import dev.dubhe.chinesefestivals.features.IFeature;
import dev.dubhe.chinesefestivals.features.impl.ThreeDFood;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;

@Mixin(ItemFrameRenderer.class)
Expand All @@ -37,4 +45,27 @@ private void getRenderModel(ItemFrame itemFrame, ItemStack itemStack, CallbackIn
private RenderType frameToCutout() {
return Sheets.cutoutBlockSheet();
}

@Redirect(method = "render(Lnet/minecraft/world/entity/decoration/ItemFrame;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/decoration/ItemFrame;getItem()Lnet/minecraft/world/item/ItemStack;"))
private ItemStack render3DFood(ItemFrame instance) {
ItemStack itemStack = instance.getItem();
if (!Features.PLATES.get().isNow() || instance.getXRot() != -90.0) return itemStack;
for (Supplier<IFeature> feature : Features.FEATURES) {
if (!feature.get().isNow()) continue;
Map<Item, Supplier<Item>> itemSupplierMap = feature.get().get3DFoodReplace();
for (Map.Entry<Item, Supplier<Item>> entry : itemSupplierMap.entrySet()) {
if (!itemStack.is(entry.getKey())) continue;
itemStack = new ItemStack(Holder.direct(entry.getValue().get()), itemStack.getCount(), Optional.of(itemStack.getOrCreateTag()));
}
}
return itemStack;
}

@Redirect(method = "render(Lnet/minecraft/world/entity/decoration/ItemFrame;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/decoration/ItemFrame;isInvisible()Z"))
private boolean noRenderPlates(ItemFrame instance) {
if (Features.PLATES.get().isNow() && instance.getXRot() == -90.0 && instance.getItem().is(ThreeDFood.HAS_PLATE)) {
return true;
}
return instance.isInvisible();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
"festival.none.name": "None",
"festival.qixi.name": "Qixi Festival",
"festival.spring.name": "Spring Festival",
"item.chinesefestivals.dumplings": "Dumplings",
"festival.qing_ming.name": "Qing Ming",
"item.chinesefestivals.flower_cake": "Flower cake",
"item.chinesefestivals.hotpot_n": "Clear Soup Hot Pot",
"item.chinesefestivals.hotpot_s": "Jiugongge Hot Pot",
"item.chinesefestivals.laba_congee": "Laba Congee",
"item.chinesefestivals.mooncake": "Mooncake",
"item.chinesefestivals.sweet_dumplings": "Sweet Dumplings",
"item.chinesefestivals.jiao_zi": "Jiao Zi",
"item.chinesefestivals.tang_yuan": "Tang Yuan",
"item.chinesefestivals.qing_tuan": "Qing Tuan",
"item.firework_star.shape.dragon": "Dragon-shaped"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
"festival.none.name": "",
"festival.qixi.name": "乞巧",
"festival.spring.name": "春節",
"item.chinesefestivals.dumplings": "交子",
"festival.qing_ming.name": "清明",
"item.chinesefestivals.jiao_zi": "交子",
"item.chinesefestivals.flower_cake": "重陽糕",
"item.chinesefestivals.hotpot_n": "清湯古董羹",
"item.chinesefestivals.hotpot_s": "九宮格古董羹",
"item.chinesefestivals.laba_congee": "臘八粥",
"item.chinesefestivals.mooncake": "月團",
"item.chinesefestivals.sweet_dumplings": "浮圓子",
"item.chinesefestivals.tang_yuan": "浮圓子",
"item.chinesefestivals.qing_tuan": "青團",
"item.firework_star.shape.dragon": "龍狀"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
"festival.none.name": "",
"festival.qixi.name": "七夕",
"festival.spring.name": "春节",
"item.chinesefestivals.dumplings": "饺子",
"festival.qing_ming.name": "清明",
"item.chinesefestivals.jiao_zi": "饺子",
"item.chinesefestivals.flower_cake": "重阳糕",
"item.chinesefestivals.hotpot_n": "清汤火锅",
"item.chinesefestivals.hotpot_s": "九宫格火锅",
"item.chinesefestivals.laba_congee": "腊八粥",
"item.chinesefestivals.mooncake": "月饼",
"item.chinesefestivals.sweet_dumplings": "汤圆",
"item.chinesefestivals.tang_yuan": "汤圆",
"item.chinesefestivals.qing_tuan": "青团",
"item.firework_star.shape.dragon": "龙形"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
"festival.none.name": "",
"festival.qixi.name": "七夕",
"festival.spring.name": "春節",
"item.chinesefestivals.dumplings": "餃子",
"festival.qing_ming.name": "清明",
"item.chinesefestivals.jiao_zi": "餃子",
"item.chinesefestivals.flower_cake": "重陽糕",
"item.chinesefestivals.hotpot_n": "清湯火鍋",
"item.chinesefestivals.hotpot_s": "九宮格火鍋",
"item.chinesefestivals.laba_congee": "臘八粥",
"item.chinesefestivals.mooncake": "月餅",
"item.chinesefestivals.sweet_dumplings": "湯圓",
"item.chinesefestivals.tang_yuan": "湯圓",
"item.chinesefestivals.qing_tuan": "青團",
"item.firework_star.shape.dragon": "龍形"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
"festival.none.name": "",
"festival.qixi.name": "七夕",
"festival.spring.name": "春節",
"item.chinesefestivals.dumplings": "餃子",
"festival.qing_ming.name": "清明",
"item.chinesefestivals.jiao_zi": "餃子",
"item.chinesefestivals.flower_cake": "重陽糕",
"item.chinesefestivals.hotpot_n": "清湯火鍋",
"item.chinesefestivals.hotpot_s": "九宮格火鍋",
"item.chinesefestivals.laba_congee": "臘八粥",
"item.chinesefestivals.mooncake": "月餅",
"item.chinesefestivals.sweet_dumplings": "湯圓",
"item.chinesefestivals.tang_yuan": "湯圓",
"item.chinesefestivals.qing_tuan": "青團",
"item.firework_star.shape.dragon": "龍形"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "chinesefestivals:item/dumplings"
"layer0": "chinesefestivals:item/jiao_zi"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "chinesefestivals:item/sweet_dumplings"
"layer0": "chinesefestivals:item/qing_tuan"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "chinesefestivals:item/tang_yuan"
}
}
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx8G
minecraft_version=1.20.4

archives_base_name=ChineseFestivals
mod_version=1.0.0
mod_version=1.1.0
maven_group=dev.dubhe
build_number=undefined

Expand Down

0 comments on commit 0e431e3

Please sign in to comment.