From 9ebadeae9240912cfc216cde2833b79a660c0e3e Mon Sep 17 00:00:00 2001 From: tartaric_acid Date: Wed, 3 Jul 2024 20:16:02 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BF=AE=E6=94=B9=20-=20?= =?UTF-8?q?=E6=8A=B1=E8=B5=B7=E5=A5=B3=E4=BB=86=E6=97=B6=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E6=92=AD=E6=94=BE=20tacz=20=E5=8A=A8=E7=94=BB=20-=20=E5=A5=B3?= =?UTF-8?q?=E4=BB=86=E5=B0=84=E5=87=BA=E7=9A=84=E5=AD=90=E5=BC=B9=E4=B9=9F?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E4=BC=A4=E5=AE=B3=E5=A5=B9=E7=9A=84=E4=B8=BB?= =?UTF-8?q?=E4=BA=BA=20-=20=E5=A6=96=E7=B2=BE=E5=A5=B3=E4=BB=86=E6=9C=89?= =?UTF-8?q?=E9=9F=B3=E6=95=88=E4=BA=86=EF=BC=8C=E6=9A=82=E6=97=B6=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=85=94=E5=AD=90=E7=9A=84=EF=BC=9Afix=20#510?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compat/tacz/client/GunGeckoAnimation.java | 16 ++++++++-- .../compat/tacz/event/GunHurtMaidEvent.java | 28 +++++++++++++++++- .../entity/monster/EntityFairy.java | 18 +++++++++++ .../touhoulittlemaid/init/InitSounds.java | 7 +++-- .../assets/touhou_little_maid/lang/en_us.json | 3 ++ .../assets/touhou_little_maid/lang/zh_cn.json | 3 ++ .../assets/touhou_little_maid/sounds.json | 24 +++++++++++++++ .../textures/item/maid_backpack_big.png | Bin 343 -> 220 bytes 8 files changed, 94 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/tacz/client/GunGeckoAnimation.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/tacz/client/GunGeckoAnimation.java index 20ae6816b..48cbc2525 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/tacz/client/GunGeckoAnimation.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/tacz/client/GunGeckoAnimation.java @@ -8,6 +8,7 @@ import com.github.tartaricacid.touhoulittlemaid.geckolib3.core.builder.AnimationBuilder; import com.github.tartaricacid.touhoulittlemaid.geckolib3.core.builder.ILoopType; import com.github.tartaricacid.touhoulittlemaid.geckolib3.core.event.predicate.AnimationEvent; +import com.github.tartaricacid.touhoulittlemaid.geckolib3.file.AnimationFile; import com.github.tartaricacid.touhoulittlemaid.geckolib3.resource.GeckoLibCache; import com.tacz.guns.api.TimelessAPI; import com.tacz.guns.api.entity.IGunOperator; @@ -18,6 +19,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.Pose; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -44,8 +46,10 @@ public static PlayState playGrenadeAnimation(AnimationEvent eve */ public static PlayState playGunMainAnimation(AnimationEvent event, String animationName, ILoopType loopType) { String tacName = "tac:" + animationName; - ResourceLocation animation = event.getAnimatable().getAnimation(); - if (GeckoLibCache.getInstance().getAnimations().get(animation).animations().containsKey(tacName)) { + GeckoMaidEntity animatable = event.getAnimatable(); + ResourceLocation animation = animatable.getAnimation(); + AnimationFile animationFile = GeckoLibCache.getInstance().getAnimations().get(animation); + if (!isMaidCarrying(animatable.getMaid()) && animationFile.animations().containsKey(tacName)) { return playAnimation(event, tacName, loopType); } return playAnimation(event, animationName, loopType); @@ -74,6 +78,9 @@ public static PlayState playGunHoldAnimation(AnimationEvent eve if (maid == null) { return PlayState.STOP; } + if (isMaidCarrying(maid)) { + return PlayState.STOP; + } Mob entity = maid.asEntity(); IGunOperator operator = IGunOperator.fromLivingEntity(entity); long fireTick = operator.getSynShootCoolDown(); @@ -154,4 +161,9 @@ private static PlayState playAnimation(AnimationEvent event, String animation private static boolean isType(String type, GunTabType tabType) { return type.equals(tabType.name().toLowerCase(Locale.ENGLISH)); } + + private static boolean isMaidCarrying(IMaid maid) { + Mob entity = maid.asEntity(); + return entity.getVehicle() instanceof Player; + } } diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/tacz/event/GunHurtMaidEvent.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/tacz/event/GunHurtMaidEvent.java index cb9d754f4..0d68676ad 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/tacz/event/GunHurtMaidEvent.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/tacz/event/GunHurtMaidEvent.java @@ -5,9 +5,16 @@ import com.tacz.guns.entity.EntityKineticBullet; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.IndirectEntityDamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class GunHurtMaidEvent { + /** + * 不伤害自己 + */ @SubscribeEvent public void onMaidHurt(MaidHurtEvent event) { DamageSource source = event.getSource(); @@ -15,8 +22,27 @@ public void onMaidHurt(MaidHurtEvent event) { if (maid.getOwnerUUID() == null) { return; } - if (source instanceof IndirectEntityDamageSource damageSource && damageSource.getDirectEntity() instanceof EntityKineticBullet) { + if (isBulletDamage(source)) { event.setCanceled(true); } } + + /** + * 不伤害他人 + */ + @SubscribeEvent + public void onPlayerHurt(LivingAttackEvent event) { + LivingEntity entity = event.getEntity(); + DamageSource source = event.getSource(); + if (entity instanceof Player player && isBulletDamage(source)) { + Entity causingEntity = source.getEntity(); + if (causingEntity instanceof EntityMaid maid && maid.isOwnedBy(player)) { + event.setCanceled(true); + } + } + } + + private boolean isBulletDamage(DamageSource source) { + return source instanceof IndirectEntityDamageSource damageSource && damageSource.getDirectEntity() instanceof EntityKineticBullet; + } } diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/monster/EntityFairy.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/monster/EntityFairy.java index 25f920060..e49b56162 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/monster/EntityFairy.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/monster/EntityFairy.java @@ -4,11 +4,13 @@ import com.github.tartaricacid.touhoulittlemaid.entity.ai.goal.FairyAttackGoal; import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; import com.github.tartaricacid.touhoulittlemaid.entity.projectile.DanmakuShoot; +import com.github.tartaricacid.touhoulittlemaid.init.InitSounds; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.sounds.SoundEvent; import net.minecraft.world.Difficulty; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.damagesource.DamageSource; @@ -157,4 +159,20 @@ public void setFairyTypeOrdinal(int ordinal) { public boolean isFlying() { return !this.onGround; } + + @Nullable + @Override + protected SoundEvent getAmbientSound() { + return InitSounds.FAIRY_AMBIENT.get(); + } + + @Override + protected SoundEvent getHurtSound(DamageSource pDamageSource) { + return InitSounds.FAIRY_HURT.get(); + } + + @Override + protected SoundEvent getDeathSound() { + return InitSounds.FAIRY_DEATH.get(); + } } diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/init/InitSounds.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/init/InitSounds.java index 0de2a68a4..e7dad64dd 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/init/InitSounds.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/init/InitSounds.java @@ -42,10 +42,13 @@ public final class InitSounds { public static final RegistryObject CAMERA_USE = registerSound("item.camera_use"); public static final RegistryObject ALBUM_OPEN = registerSound("item.album_open"); public static final RegistryObject ALTAR_CRAFT = registerSound("block.altar_craft"); - public static final RegistryObject BOX_OPEN = registerSound("entity.box"); - public static final RegistryObject COMPASS_POINT = registerSound("item.compass"); public static final RegistryObject GOMOKU = registerSound("block.gomoku"); public static final RegistryObject GOMOKU_RESET = registerSound("block.gomoku_reset"); + public static final RegistryObject BOX_OPEN = registerSound("entity.box"); + public static final RegistryObject COMPASS_POINT = registerSound("item.compass"); + public static final RegistryObject FAIRY_AMBIENT = registerSound("entity.fairy.ambient"); + public static final RegistryObject FAIRY_DEATH = registerSound("entity.fairy.death"); + public static final RegistryObject FAIRY_HURT = registerSound("entity.fairy.hurt"); private static RegistryObject registerSound(String name) { return SOUNDS.register(name, () -> new SoundEvent(new ResourceLocation(TouhouLittleMaid.MOD_ID, name))); diff --git a/src/main/resources/assets/touhou_little_maid/lang/en_us.json b/src/main/resources/assets/touhou_little_maid/lang/en_us.json index c39dcb561..4759b716d 100644 --- a/src/main/resources/assets/touhou_little_maid/lang/en_us.json +++ b/src/main/resources/assets/touhou_little_maid/lang/en_us.json @@ -514,6 +514,9 @@ "subtitle.touhou_little_maid.block.gomoku_reset": "Gomoku Reset Sound", "subtitle.touhou_little_maid.entity.box": "Box Open Sound", "subtitle.touhou_little_maid.item.compass": "Compass Select Point Sound", + "touhou_little_maid.subtitles.entity.fairy.ambient": "Fairy Ambient Sound", + "touhou_little_maid.subtitles.entity.fairy.death": "Fairy Death Sound", + "touhou_little_maid.subtitles.entity.fairy.hurt": "Fairy Hurt Sound", "emi.category.touhou_little_maid.altar": "Altar Craft", "jei.touhou_little_maid.altar_craft.title": "Altar Craft", "jei.touhou_little_maid.altar_craft.result": "Result: %s", diff --git a/src/main/resources/assets/touhou_little_maid/lang/zh_cn.json b/src/main/resources/assets/touhou_little_maid/lang/zh_cn.json index 432bd5dd0..ab138707a 100644 --- a/src/main/resources/assets/touhou_little_maid/lang/zh_cn.json +++ b/src/main/resources/assets/touhou_little_maid/lang/zh_cn.json @@ -514,6 +514,9 @@ "subtitle.touhou_little_maid.block.gomoku_reset": "五子棋:重置", "subtitle.touhou_little_maid.entity.box": "盒子:打开", "subtitle.touhou_little_maid.item.compass": "罗盘:选择点", + "touhou_little_maid.subtitles.entity.fairy.ambient": "妖精女仆:吱吱", + "touhou_little_maid.subtitles.entity.fairy.death": "妖精女仆:死亡", + "touhou_little_maid.subtitles.entity.fairy.hurt": "妖精女仆:受伤", "emi.category.touhou_little_maid.altar": "祭坛合成", "jei.touhou_little_maid.altar_craft.title": "祭坛合成", "jei.touhou_little_maid.altar_craft.result": "结果:%s", diff --git a/src/main/resources/assets/touhou_little_maid/sounds.json b/src/main/resources/assets/touhou_little_maid/sounds.json index 5a2322e15..695d590e8 100644 --- a/src/main/resources/assets/touhou_little_maid/sounds.json +++ b/src/main/resources/assets/touhou_little_maid/sounds.json @@ -254,5 +254,29 @@ "sounds": [ "touhou_little_maid:item/point" ] + }, + "entity.fairy.ambient": { + "sounds": [ + "minecraft:mob/rabbit/idle1", + "minecraft:mob/rabbit/idle2", + "minecraft:mob/rabbit/idle3", + "minecraft:mob/rabbit/idle4" + ], + "subtitle": "touhou_little_maid.subtitles.entity.fairy.ambient" + }, + "entity.fairy.death": { + "sounds": [ + "minecraft:mob/rabbit/bunnymurder" + ], + "subtitle": "touhou_little_maid.subtitles.entity.fairy.death" + }, + "entity.fairy.hurt": { + "sounds": [ + "minecraft:mob/rabbit/hurt1", + "minecraft:mob/rabbit/hurt2", + "minecraft:mob/rabbit/hurt3", + "minecraft:mob/rabbit/hurt4" + ], + "subtitle": "touhou_little_maid.subtitles.entity.fairy.hurt" } } \ No newline at end of file diff --git a/src/main/resources/assets/touhou_little_maid/textures/item/maid_backpack_big.png b/src/main/resources/assets/touhou_little_maid/textures/item/maid_backpack_big.png index 2bba82dba6657f7f3714671b014b5b5843b870ea..2c86038d3780bd6055d021ffbb20ef297c5bd148 100644 GIT binary patch delta 193 zcmV;y06zcM0^9+RBYyy+Nkl*paqZ-;r)+}(beDtAjRAF9RcI`UCr4AKO`$cETDID#==LqL)+%`gnogzO5uhEQYxvft4S0cnP5#Ayh!?dS%f8(?T` zir)Zq+hGP0GyvUZm}`&?!)gFbGrA_2?dS%`D=1+afbMjd20C;;$abs-U{j1N1`9|G v&B%tp41y^JVPrN=&By>|5H5_ao?-w1Z(L3k1iN){00000NkvXXu0mjfq-{_l delta 317 zcmV-D0mA;=0oMYMBYy!NNklO-b8%!5GGNZ{>tz41WXu{rd;^d-+o?u(LBx zaDp+6jcx$UVtBy)|DW~$?KQjqub*rK+nSXY55^#NZ%5OA1AT2U*49)3W0)au0|NcL z;25OI+rt@*VQdf$G5|zlHQ@jMfd3zF;&wq=N+Q?*5RKh{*N&7K5EX0;#vsMWSWZ^z zzo(1cei88mj?8-bP>yl7txsVuK8T`5$K>!VDn=0}Vk{-X!>B P00000NkvXXu0mjf$ZLwa