From 140e76438155f6e72b891dbf10575e81b23376cc Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Wed, 14 May 2025 00:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0BEAST=EF=BC=88=E5=96=9C?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../b69ee8a2655365569b979911c0440daa8c470ac2 | 3 +- .../superbwarfare/models/item/beast.json | 6 + .../datagen/ModItemModelProvider.java | 1 + .../entity/projectile/ProjectileEntity.java | 41 +---- .../superbwarfare/init/ModItems.java | 1 + .../atsuishio/superbwarfare/item/Beast.java | 155 ++++++++++++++++++ .../assets/superbwarfare/lang/en_us.json | 2 + .../assets/superbwarfare/lang/zh_cn.json | 2 + .../superbwarfare/textures/item/beast.png | Bin 0 -> 286 bytes 9 files changed, 171 insertions(+), 40 deletions(-) create mode 100644 src/generated/resources/assets/superbwarfare/models/item/beast.json create mode 100644 src/main/java/com/atsuishio/superbwarfare/item/Beast.java create mode 100644 src/main/resources/assets/superbwarfare/textures/item/beast.png diff --git a/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 b/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 index aa1c905e6..02ee3fc46 100644 --- a/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 +++ b/src/generated/resources/.cache/b69ee8a2655365569b979911c0440daa8c470ac2 @@ -1,4 +1,4 @@ -// 1.21.1 2025-05-13T23:25:47.0587486 Item Models: superbwarfare +// 1.21.1 2025-05-13T23:50:15.1356608 Item Models: superbwarfare 13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/aa_12_blueprint.json 0a9bfb695c2b5668863a2de4770f5bfca663c1dc assets/superbwarfare/models/item/agm.json 29ad5daadcdf7c10771fc45b649c527d16325cbb assets/superbwarfare/models/item/aircraft_catapult.json @@ -9,6 +9,7 @@ a5cf666a970906ba6ac0af9a4d5d52dd0e093dec assets/superbwarfare/models/item/annihi 4b8fe8fbe5e64c3449ad539317254e4ed7188411 assets/superbwarfare/models/item/ap_head.json 984c08ca6f6893a15721a85e30118f9e32c65c7f assets/superbwarfare/models/item/barbed_wire.json e8f16946c6f9429989d05e9ec250a72ffc64f9e1 assets/superbwarfare/models/item/beam_test.json +bda38dd5cb3ca4c3e289a012c0529609ac02ded2 assets/superbwarfare/models/item/beast.json 13ca8d5676888ff51f3308d88e4bf67691fa34f8 assets/superbwarfare/models/item/bocek_blueprint.json 140e04e98d9d1c0ee790ca43cb28ad549900ab44 assets/superbwarfare/models/item/cannon_core.json 1e5b4637c3787516305dd3d1598f401a5e78a954 assets/superbwarfare/models/item/cemented_carbide_action.json diff --git a/src/generated/resources/assets/superbwarfare/models/item/beast.json b/src/generated/resources/assets/superbwarfare/models/item/beast.json new file mode 100644 index 000000000..fbd038520 --- /dev/null +++ b/src/generated/resources/assets/superbwarfare/models/item/beast.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "superbwarfare:item/beast" + } +} \ No newline at end of file diff --git a/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java b/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java index 60f9ed812..86a94975d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java +++ b/src/main/java/com/atsuishio/superbwarfare/datagen/ModItemModelProvider.java @@ -71,6 +71,7 @@ public class ModItemModelProvider extends ItemModelProvider { simpleItem(ModItems.TRANSCRIPT); simpleItem(ModItems.RAW_SILVER); simpleItem(ModItems.SILVER_INGOT); + handheldItem(ModItems.BEAST.getId()); handheldItem(ModItems.CROWBAR.getId()); handheldItem(ModItems.DEFUSER.getId()); simpleItem(ModItems.FIRING_PARAMETERS); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java index 6d973d287..14b095e5f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java @@ -2,16 +2,15 @@ package com.atsuishio.superbwarfare.entity.projectile; import com.atsuishio.superbwarfare.block.BarbedWireBlock; import com.atsuishio.superbwarfare.component.ModDataComponents; -import com.atsuishio.superbwarfare.config.server.MiscConfig; import com.atsuishio.superbwarfare.config.server.ProjectileConfig; import com.atsuishio.superbwarfare.entity.DPSGeneratorEntity; import com.atsuishio.superbwarfare.entity.TargetEntity; import com.atsuishio.superbwarfare.entity.mixin.ICustomKnockback; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.init.*; +import com.atsuishio.superbwarfare.item.Beast; import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage; import com.atsuishio.superbwarfare.network.message.receive.ClientMotionSyncMessage; -import com.atsuishio.superbwarfare.network.message.receive.PlayerGunKillMessage; import com.atsuishio.superbwarfare.tools.*; import com.mojang.datafixers.util.Pair; import net.minecraft.core.BlockPos; @@ -45,7 +44,6 @@ import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.*; import net.minecraft.world.phys.shapes.VoxelShape; @@ -485,42 +483,7 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp } if (beast && entity instanceof LivingEntity living) { - if (living.isDeadOrDying()) return; - if (living instanceof TargetEntity) return; - if (living instanceof DPSGeneratorEntity dpsGeneratorEntity) { - dpsGeneratorEntity.beastCharge(); - return; - } - - if (this.shooter instanceof ServerPlayer player) { - PacketDistributor.sendToPlayer(player, new ClientIndicatorMessage(0, 5)); - var holder = Holder.direct(ModSounds.INDICATION.get()); - player.connection.send(new ClientboundSoundPacket(holder, SoundSource.PLAYERS, player.getX(), player.getY(), player.getZ(), 1f, 1f, player.level().random.nextLong())); - ((ServerLevel) this.level()).sendParticles(ParticleTypes.DAMAGE_INDICATOR, living.getX(), living.getY() + .5, living.getZ(), 1000, .4, .7, .4, 0); - - if (MiscConfig.SEND_KILL_FEEDBACK.get()) { - PacketDistributor.sendToAllPlayers(new PlayerGunKillMessage(player.getId(), living.getId(), false, ModDamageTypes.BEAST)); - } - } - - if (living instanceof ServerPlayer victim) { - living.setHealth(0); - living.level().players().forEach( - p -> p.sendSystemMessage( - Component.translatable("death.attack.beast_gun", - victim.getDisplayName(), - shooter == null ? "" : shooter.getDisplayName() - ) - ) - ); - } else { - living.setHealth(0); - living.level().broadcastEntityEvent(living, (byte) 60); - living.remove(RemovalReason.KILLED); - living.gameEvent(GameEvent.ENTITY_DIE); - } - - level().playSound(living, new BlockPos((int) living.getX(), (int) living.getY(), (int) living.getZ()), ModSounds.OUCH.get(), SoundSource.PLAYERS, 2.0F, 1.0F); + Beast.beastKill(this.shooter, living); return; } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java index 7cf5c6766..64a4a655b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModItems.java @@ -187,6 +187,7 @@ public class ModItems { public static final DeferredHolder SMALL_BATTERY_PACK = ITEMS.register("small_battery_pack", () -> new BatteryItem(500000, new Item.Properties())); public static final DeferredHolder MEDIUM_BATTERY_PACK = ITEMS.register("medium_battery_pack", () -> new BatteryItem(5000000, new Item.Properties())); public static final DeferredHolder LARGE_BATTERY_PACK = ITEMS.register("large_battery_pack", () -> new BatteryItem(20000000, new Item.Properties())); + public static final DeferredHolder BEAST = ITEMS.register("beast", Beast::new); public static final DeferredHolder TRANSCRIPT = ITEMS.register("transcript", Transcript::new); public static final DeferredHolder FIRING_PARAMETERS = ITEMS.register("firing_parameters", FiringParameters::new); diff --git a/src/main/java/com/atsuishio/superbwarfare/item/Beast.java b/src/main/java/com/atsuishio/superbwarfare/item/Beast.java new file mode 100644 index 000000000..2a84f7f61 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/item/Beast.java @@ -0,0 +1,155 @@ +package com.atsuishio.superbwarfare.item; + +import com.atsuishio.superbwarfare.config.server.MiscConfig; +import com.atsuishio.superbwarfare.entity.DPSGeneratorEntity; +import com.atsuishio.superbwarfare.entity.TargetEntity; +import com.atsuishio.superbwarfare.init.ModDamageTypes; +import com.atsuishio.superbwarfare.init.ModEnumExtensions; +import com.atsuishio.superbwarfare.init.ModSounds; +import com.atsuishio.superbwarfare.network.message.receive.ClientIndicatorMessage; +import com.atsuishio.superbwarfare.network.message.receive.PlayerGunKillMessage; +import com.atsuishio.superbwarfare.tools.TraceTool; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundSoundPacket; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.SwordItem; +import net.minecraft.world.item.Tiers; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.component.Unbreakable; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.phys.AABB; +import net.neoforged.neoforge.network.PacketDistributor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.List; + +public class Beast extends SwordItem { + + public Beast() { + super(Tiers.NETHERITE, new Properties() + .stacksTo(1) + .rarity(ModEnumExtensions.getLegendary()) + .setNoRepair() + .durability(114514) + .component(DataComponents.UNBREAKABLE, new Unbreakable(false)) + ); + } + + @Override + @ParametersAreNonnullByDefault + public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) { + beastKill(attacker, target); + return true; + } + + public static void beastKill(@Nullable Entity attacker, @NotNull Entity target) { + if (target.level().isClientSide || + (target instanceof LivingEntity living && living.isDeadOrDying()) + || target instanceof TargetEntity + ) return; + + if (target instanceof DPSGeneratorEntity generator) { + generator.beastCharge(); + return; + } + + if (attacker instanceof ServerPlayer player) { + PacketDistributor.sendToPlayer(player, new ClientIndicatorMessage(0, 5)); + var holder = Holder.direct(ModSounds.INDICATION.get()); + player.connection.send(new ClientboundSoundPacket(holder, SoundSource.PLAYERS, player.getX(), player.getY(), player.getZ(), 1f, 1f, player.level().random.nextLong())); + + var box = target.getBoundingBox(); + ((ServerLevel) attacker.level()).sendParticles(ParticleTypes.DAMAGE_INDICATOR, + target.getX(), target.getY() + .5, target.getZ(), + 1000, + box.getXsize() / 2.5, box.getYsize() / 3, box.getZsize() / 2.5, + 0 + ); + + if (MiscConfig.SEND_KILL_FEEDBACK.get()) { + PacketDistributor.sendToAllPlayers(new PlayerGunKillMessage(player.getId(), target.getId(), false, ModDamageTypes.BEAST)); + } + } + + if (target instanceof ServerPlayer victim) { + victim.setHealth(0); + victim.level().players().forEach( + p -> p.sendSystemMessage( + Component.translatable("death.attack.beast_gun", + victim.getDisplayName(), + attacker != null ? attacker.getDisplayName() : "" + ) + ) + ); + } else { + if (target instanceof LivingEntity living) { + living.setHealth(0); + } + target.level().broadcastEntityEvent(target, (byte) 60); + target.remove(Entity.RemovalReason.KILLED); + target.gameEvent(GameEvent.ENTITY_DIE); + } + + target.level().playSound(target, new BlockPos((int) target.getX(), (int) target.getY(), (int) target.getZ()), ModSounds.OUCH.get(), SoundSource.PLAYERS, 2.0F, 1.0F); + } + + @Override + @ParametersAreNonnullByDefault + public @NotNull AABB getSweepHitBox(ItemStack stack, Player player, Entity target) { + return super.getSweepHitBox(stack, player, target).inflate(3); + } + + @Override + @ParametersAreNonnullByDefault + public boolean canBeHurtBy(ItemStack stack, DamageSource source) { + return false; + } + + @Override + public boolean isEnchantable(@NotNull ItemStack stack) { + return false; + } + + @Override + @ParametersAreNonnullByDefault + public boolean onEntitySwing(ItemStack stack, LivingEntity entity, InteractionHand hand) { + var target = TraceTool.findMeleeEntity(entity, 50); + if (target != null) { + beastKill(entity, target); + } + return super.onEntitySwing(stack, entity, hand); + } + + @Override + @ParametersAreNonnullByDefault + public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) { + beastKill(player, entity); + return super.onLeftClickEntity(stack, player, entity); + } + + @Override + @ParametersAreNonnullByDefault + public boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker) { + return true; + } + + @Override + @ParametersAreNonnullByDefault + public void appendHoverText(ItemStack stack, TooltipContext context, List tooltipComponents, TooltipFlag tooltipFlag) { + tooltipComponents.add(Component.translatable("des.superbwarfare.beast").withColor(0xa56855)); + } +} diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index a5f9cfbd3..dff021a08 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -173,6 +173,8 @@ "item.superbwarfare.agm": "Air-to-ground Missile", "des.superbwarfare.agm": "Suitable for A-10 Thunderbolt II", + "item.superbwarfare.beast": "BEAST", + "des.superbwarfare.beast": "You are one one one...", "item.superbwarfare.firing_parameters": "Firing Parameters", "item.superbwarfare.ancient_cpu": "Ancient CPU", "item.superbwarfare.target_deployer": "Target", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index 7c16d95da..40ff09362 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -173,6 +173,8 @@ "item.superbwarfare.agm": "空对地导弹", "des.superbwarfare.agm": "适配A-10攻击机", + "item.superbwarfare.beast": "BEAST", + "des.superbwarfare.beast": "你是一个一个一个......", "item.superbwarfare.firing_parameters": "射击诸元", "item.superbwarfare.ancient_cpu": "古代处理器", "item.superbwarfare.target_deployer": "标靶", diff --git a/src/main/resources/assets/superbwarfare/textures/item/beast.png b/src/main/resources/assets/superbwarfare/textures/item/beast.png new file mode 100644 index 0000000000000000000000000000000000000000..b879fb56fbc63c91d1b9cf43120858ea20ca081c GIT binary patch literal 286 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}50G|-oxju>a4{QpSlR3M3&hn~~9aGzjJ#Cie#^ulBSEK+1lRaG=Lo|Xz`#psY zC~&Z_7o0xyf4{U#pt1N%vE^PbBqN@^U=*Csq+-wLbz~Q-3g>OZz=^?T?+$fO^m_Y7 zDS5Mf;{rB+#cubNqHMb}#IG0SY?(dPvghx!j}xayoK~)Qd}{G8M#&SLyPr>!{tC2? N!PC{xWt~$(696caY7_tf literal 0 HcmV?d00001