Skip to content

Commit

Permalink
config screen & localizations
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoLezury committed Jul 28, 2024
1 parent a665750 commit 19c552a
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 24 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ minecraft_version=1.21
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.21,1.21.1)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=21.0.114-beta
neo_version=21.0.140-beta
# The Neo version range can use any version of Neo as bounds
neo_version_range=[21.0.0-beta,)
# The loader version range can only use the major version of FML as bounds
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21 2024-07-26T12:24:41.9806098 Languages: zh_cn for mod: celebrations
d90c9b67ee5f1e2247323fe6eebc6ad9176d589e assets/celebrations/lang/zh_cn.json
// 1.21 2024-07-28T12:41:42.2679323 Languages: zh_cn for mod: celebrations
41a69f30d929b996cf86dac65b1e01f6796b4830 assets/celebrations/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21 2024-07-26T12:15:25.3539245 Languages: en_us for mod: celebrations
39c9a7a66dbf7f793cc681f0ea81e62c6103a51a assets/celebrations/lang/en_us.json
// 1.21 2024-07-28T12:41:42.2689501 Languages: en_us for mod: celebrations
def096f772a649bde461c0ea664485395b5c3d3e assets/celebrations/lang/en_us.json
10 changes: 10 additions & 0 deletions src/generated/resources/assets/celebrations/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
"block.celebrations.inverted_golden_fu_sticker": "Inverted Golden Fu Sticker",
"block.celebrations.japanese_styled_paper_lantern": "Japanese Styled Paper Lantern",
"block.celebrations.japanese_styled_red_lantern": "Japanese Styled Red Lantern",
"celebrations.configuration.celebration": "Celebrations",
"celebrations.configuration.celebrationDuration": "Celebration Duration",
"celebrations.configuration.celebrationInterval": "Celebration Interval",
"celebrations.configuration.lantern": "Lanterns",
"celebrations.configuration.lanternEffectRange": "Lantern Mob Effect Range",
"celebrations.configuration.lanternGiveEnemyBeneficialEffect": "Lanterns Give Enemies Beneficial Effects",
"celebrations.configuration.lanternGiveEnemyHarmfulEffect": "Lanterns Give Enemies Harmful Effects",
"celebrations.configuration.lanternGiveNonEnemyBeneficialEffect": "Lanterns Give Non-enemy Mobs Beneficial Effects",
"celebrations.configuration.lanternGiveNonEnemyHarmfulEffect": "Lanterns Give Non-enemy Mobs Harmful Effects",
"fml.menu.mods.info.description.celebrations": "A mod about celebrating!",
"item.celebrations.gold_powder": "Gold Powder",
"item.celebrations.party_hat": "Party Hat",
"item.celebrations.red_paper": "Red Paper",
Expand Down
10 changes: 10 additions & 0 deletions src/generated/resources/assets/celebrations/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
"block.celebrations.inverted_golden_fu_sticker": "金色倒福字",
"block.celebrations.japanese_styled_paper_lantern": "日式纸灯笼",
"block.celebrations.japanese_styled_red_lantern": "日式红灯笼",
"celebrations.configuration.celebration": "庆祝",
"celebrations.configuration.celebrationDuration": "庆祝时长",
"celebrations.configuration.celebrationInterval": "庆祝时间间隔",
"celebrations.configuration.lantern": "灯笼",
"celebrations.configuration.lanternEffectRange": "灯笼药水效果范围",
"celebrations.configuration.lanternGiveEnemyBeneficialEffect": "灯笼给予敌对生物增益效果",
"celebrations.configuration.lanternGiveEnemyHarmfulEffect": "灯笼给予敌对生物负面效果",
"celebrations.configuration.lanternGiveNonEnemyBeneficialEffect": "灯笼给予非敌对生物增益效果",
"celebrations.configuration.lanternGiveNonEnemyHarmfulEffect": "灯笼给予非敌对生物负面效果",
"fml.menu.mods.info.description.celebrations": "一个关于庆祝的模组!",
"item.celebrations.gold_powder": "金粉",
"item.celebrations.party_hat": "派对帽",
"item.celebrations.red_paper": "红纸",
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/team/leomc/celebrations/CelebrationsClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package team.leomc.celebrations;

import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.gui.ConfigurationScreen;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;

@OnlyIn(Dist.CLIENT)
@Mod(value = Celebrations.ID, dist = Dist.CLIENT)
public class CelebrationsClient {
public CelebrationsClient(IEventBus modBus, ModContainer container) {
container.registerExtensionPoint(IConfigScreenFactory.class, ConfigurationScreen::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.monster.Enemy;
Expand Down Expand Up @@ -156,10 +157,13 @@ public static void tick(Level level, BlockPos pos, BlockState state, LanternBloc
for (LivingEntity livingEntity : level.getEntitiesOfClass(LivingEntity.class, new AABB(pos).inflate(radius))) {
for (MobEffectInstance instance : entity.getEffects()) {
MobEffectInstance toGive = new MobEffectInstance(instance.getEffect(), 400, instance.getAmplifier());
if (livingEntity instanceof Enemy && ((instance.getEffect().value().isBeneficial() && giveEnemyBeneficialEffect) || (!instance.getEffect().value().isBeneficial() && giveEnemyHarmfulEffect))) {
if (livingEntity instanceof Enemy && ((instance.getEffect().value().isBeneficial() && giveEnemyBeneficialEffect) || (instance.getEffect().value().getCategory() == MobEffectCategory.HARMFUL && giveEnemyHarmfulEffect))) {
tryGiveEffect(toGive, livingEntity);
}
if (!(livingEntity instanceof Enemy) && ((instance.getEffect().value().isBeneficial() && giveNonEnemyBeneficialEffect) || (!instance.getEffect().value().isBeneficial() && giveNonEnemyHarmfulEffect))) {
if (!(livingEntity instanceof Enemy) && ((instance.getEffect().value().isBeneficial() && giveNonEnemyBeneficialEffect) || (instance.getEffect().value().getCategory() == MobEffectCategory.HARMFUL && giveNonEnemyHarmfulEffect))) {
tryGiveEffect(toGive, livingEntity);
}
if (instance.getEffect().value().getCategory() == MobEffectCategory.NEUTRAL) {
tryGiveEffect(toGive, livingEntity);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/team/leomc/celebrations/config/CCommonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class CCommonConfig {
CELEBRATION_DURATION = BUILDER.comment("The duration of the villagers' celebrations, in ticks (1 second = 20 ticks)").define("celebrationDuration", 12000 * 2 * 2);
BUILDER.pop();
BUILDER.push("lantern");
LANTERN_EFFECT_RADIUS = BUILDER.comment("This parameter determines the range of action of the lantern's potion effect").define("effectRange", 10d);
GIVE_NON_ENEMY_BENEFICIAL_EFFECT = BUILDER.comment("Enables lanterns with potion effects to give beneficial effects to non-enemy mobs").define("giveNonEnemyBeneficialEffect", true);
GIVE_NON_ENEMY_HARMFUL_EFFECT = BUILDER.comment("Enables lanterns with potion effects to give harmful effects to non-enemy mobs").define("giveNonEnemyHarmfulEffect", false);
GIVE_ENEMY_BENEFICIAL_EFFECT = BUILDER.comment("Enables lanterns with potion effects to give beneficial effects to enemy mobs").define("giveEnemyBeneficialEffect", false);
GIVE_ENEMY_HARMFUL_EFFECT = BUILDER.comment("Enables lanterns with potion effects to give harmful effects to enemy mobs").define("giveEnemyHarmfulEffect", true);
LANTERN_EFFECT_RADIUS = BUILDER.comment("This parameter determines the range of action of the lantern's potion effect").define("lanternEffectRange", 10d);
GIVE_NON_ENEMY_BENEFICIAL_EFFECT = BUILDER.comment("Enables lanterns with potion effects to give beneficial effects to non-enemy mobs").define("lanternGiveNonEnemyBeneficialEffect", true);
GIVE_NON_ENEMY_HARMFUL_EFFECT = BUILDER.comment("Enables lanterns with potion effects to give harmful effects to non-enemy mobs").define("lanternGiveNonEnemyHarmfulEffect", false);
GIVE_ENEMY_BENEFICIAL_EFFECT = BUILDER.comment("Enables lanterns with potion effects to give beneficial effects to enemy mobs").define("lanternGiveEnemyBeneficialEffect", false);
GIVE_ENEMY_HARMFUL_EFFECT = BUILDER.comment("Enables lanterns with potion effects to give harmful effects to enemy mobs").define("lanternGiveEnemyHarmfulEffect", true);
BUILDER.pop();
SPEC = BUILDER.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ public CChineseLanguageProvider(PackOutput output) {
@Override
protected void addTranslations() {
add("name." + Celebrations.ID, "欢庆");
add("fml.menu.mods.info.description." + Celebrations.ID, "一个关于庆祝的模组!");
add(Celebrations.ID + ".configuration.celebration", "庆祝");
add(Celebrations.ID + ".configuration.celebrationInterval", "庆祝时间间隔");
add(Celebrations.ID + ".configuration.celebrationDuration", "庆祝时长");
add(Celebrations.ID + ".configuration.lantern", "灯笼");
add(Celebrations.ID + ".configuration.lanternEffectRange", "灯笼药水效果范围");
add(Celebrations.ID + ".configuration.lanternGiveNonEnemyBeneficialEffect", "灯笼给予非敌对生物增益效果");
add(Celebrations.ID + ".configuration.lanternGiveNonEnemyHarmfulEffect", "灯笼给予非敌对生物负面效果");
add(Celebrations.ID + ".configuration.lanternGiveEnemyBeneficialEffect", "灯笼给予敌对生物增益效果");
add(Celebrations.ID + ".configuration.lanternGiveEnemyHarmfulEffect", "灯笼给予敌对生物负面效果");
add(CBlocks.CHINESE_STYLED_BAMBOO_LANTERN.get(), "中式竹灯笼");
add(CBlocks.CHINESE_STYLED_PAPER_LANTERN.get(), "中式纸灯笼");
add(CBlocks.CHINESE_STYLED_RED_LANTERN.get(), "中式红灯笼");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ public CEnglishLanguageProvider(PackOutput output) {
@Override
protected void addTranslations() {
add("name." + Celebrations.ID, "Celebrations");
add("fml.menu.mods.info.description." + Celebrations.ID, "A mod about celebrating!");
add(Celebrations.ID + ".configuration.celebration", "Celebrations");
add(Celebrations.ID + ".configuration.celebrationInterval", "Celebration Interval");
add(Celebrations.ID + ".configuration.celebrationDuration", "Celebration Duration");
add(Celebrations.ID + ".configuration.lantern", "Lanterns");
add(Celebrations.ID + ".configuration.lanternEffectRange", "Lantern Mob Effect Range");
add(Celebrations.ID + ".configuration.lanternGiveNonEnemyBeneficialEffect", "Lanterns Give Non-enemy Mobs Beneficial Effects");
add(Celebrations.ID + ".configuration.lanternGiveNonEnemyHarmfulEffect", "Lanterns Give Non-enemy Mobs Harmful Effects");
add(Celebrations.ID + ".configuration.lanternGiveEnemyBeneficialEffect", "Lanterns Give Enemies Beneficial Effects");
add(Celebrations.ID + ".configuration.lanternGiveEnemyHarmfulEffect", "Lanterns Give Enemies Harmful Effects");
add(CBlocks.CHINESE_STYLED_BAMBOO_LANTERN.get(), "Chinese Styled Bamboo Lantern");
add(CBlocks.CHINESE_STYLED_PAPER_LANTERN.get(), "Chinese Styled Paper Lantern");
add(CBlocks.CHINESE_STYLED_RED_LANTERN.get(), "Chinese Styled Red Lantern");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team.leomc.celebrations.mixin;
package team.leomc.celebrations.mixin.client;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team.leomc.celebrations.mixin;
package team.leomc.celebrations.mixin.client;

import net.minecraft.client.renderer.entity.AllayRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team.leomc.celebrations.mixin;
package team.leomc.celebrations.mixin.client;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.model.EntityModel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team.leomc.celebrations.mixin;
package team.leomc.celebrations.mixin.client;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.ItemInHandRenderer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team.leomc.celebrations.mixin;
package team.leomc.celebrations.mixin.client;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package team.leomc.celebrations.mixin;
package team.leomc.celebrations.mixin.client;

import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.VexRenderer;
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/celebrations.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"VillagerMixin"
],
"client": [
"AllayModelMixin",
"AllayRendererMixin",
"CustomHeadLayerMixin",
"ItemInHandRendererMixin",
"VexModelMixin",
"VexRendererMixin"
"client.AllayModelMixin",
"client.AllayRendererMixin",
"client.CustomHeadLayerMixin",
"client.ItemInHandRendererMixin",
"client.VexModelMixin",
"client.VexRendererMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 19c552a

Please sign in to comment.