修改击杀记录、伤害类型

This commit is contained in:
17146 2024-05-19 13:25:44 +08:00
parent a4cd9e40d9
commit ed35a0434a
7 changed files with 41 additions and 7 deletions

View file

@ -1,5 +1,6 @@
package net.mcreator.target.client.screens; package net.mcreator.target.client.screens;
import net.mcreator.target.TargetMod;
import net.mcreator.target.event.KillMessageHandler; import net.mcreator.target.event.KillMessageHandler;
import net.mcreator.target.item.gun.GunItem; import net.mcreator.target.item.gun.GunItem;
import net.mcreator.target.tools.PlayerKillRecord; import net.mcreator.target.tools.PlayerKillRecord;
@ -15,6 +16,7 @@ import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(value = Dist.CLIENT) @Mod.EventBusSubscriber(value = Dist.CLIENT)
public class KillMessageOverlay { public class KillMessageOverlay {
private static final ResourceLocation HEADSHOT = new ResourceLocation(TargetMod.MODID, "textures/screens/headshot.png");
@SubscribeEvent(priority = EventPriority.NORMAL) @SubscribeEvent(priority = EventPriority.NORMAL)
public static void eventHandler(RenderGuiEvent.Pre event) { public static void eventHandler(RenderGuiEvent.Pre event) {
@ -80,5 +82,18 @@ public class KillMessageOverlay {
record.target.getTeamColor(), record.target.getTeamColor(),
false false
); );
if (record.headshot) {
event.getGuiGraphics().blit(HEADSHOT,
w - targetNameWidth - 65 - attackerNameWidth,
h,
0,
0,
8,
8,
8,
8
);
}
} }
} }

View file

@ -224,12 +224,15 @@ public class LivingEntityEventHandler {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
DamageSource source = event.getSource(); DamageSource source = event.getSource();
if (!TargetModVariables.MapVariables.get(entity.level()).pvpMode) {
return;
}
if (source.getDirectEntity() instanceof ServerPlayer player) { if (source.getDirectEntity() instanceof ServerPlayer player) {
// TODO 修改发包 if (source.is(TargetModDamageTypes.GUN_FIRE) || source.is(TargetModDamageTypes.ARROW_IN_BRAIN)) {
if (source.is(TargetModDamageTypes.GUN_FIRE)) { TargetMod.PACKET_HANDLER.send(PacketDistributor.ALL.noArg(), new PlayerKillMessage(player.getId(), entity.getId(), false));
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new PlayerKillMessage(player.getId(), entity.getId(), false)); } else if (source.is(TargetModDamageTypes.GUN_FIRE_HEADSHOT) || source.is(TargetModDamageTypes.ARROW_IN_BRAIN_HEADSHOT)) {
} else if (source.is(TargetModDamageTypes.GUN_FIRE_HEADSHOT)) { TargetMod.PACKET_HANDLER.send(PacketDistributor.ALL.noArg(), new PlayerKillMessage(player.getId(), entity.getId(), true));
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new PlayerKillMessage(player.getId(), entity.getId(), true));
} }
} }
} }

View file

@ -19,6 +19,7 @@ public class TargetModDamageTypes {
public static final ResourceKey<DamageType> GUN_FIRE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "gunfire")); public static final ResourceKey<DamageType> GUN_FIRE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "gunfire"));
public static final ResourceKey<DamageType> GUN_FIRE_HEADSHOT = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "gunfire_headshot")); public static final ResourceKey<DamageType> GUN_FIRE_HEADSHOT = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "gunfire_headshot"));
public static final ResourceKey<DamageType> ARROW_IN_BRAIN = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "arrow_in_brain")); public static final ResourceKey<DamageType> ARROW_IN_BRAIN = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "arrow_in_brain"));
public static final ResourceKey<DamageType> ARROW_IN_BRAIN_HEADSHOT = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "arrow_in_brain_headshot"));
public static final ResourceKey<DamageType> MINE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "mine")); public static final ResourceKey<DamageType> MINE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "mine"));
@ -34,6 +35,10 @@ public class TargetModDamageTypes {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(ARROW_IN_BRAIN), entity); return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(ARROW_IN_BRAIN), entity);
} }
public static DamageSource causeArrowInBrainHeadshotDamage(RegistryAccess registryAccess, @Nullable Entity entity) {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(ARROW_IN_BRAIN_HEADSHOT), entity);
}
public static DamageSource causeMineDamage(RegistryAccess registryAccess, @Nullable Entity entity) { public static DamageSource causeMineDamage(RegistryAccess registryAccess, @Nullable Entity entity) {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(MINE), entity); return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(MINE), entity);
} }

View file

@ -157,8 +157,11 @@
"death.attack.gunfire_headshot.entity": "%1$s was headshot by %2$s", "death.attack.gunfire_headshot.entity": "%1$s was headshot by %2$s",
"death.attack.gunfire_headshot.item": "%1$s was headshot by %2$s using %3$s", "death.attack.gunfire_headshot.item": "%1$s was headshot by %2$s using %3$s",
"death.attack.arrow_in_brain": "%2$s's arrow shot into %1$s's brain", "death.attack.arrow_in_brain": "%2$s's arrow shot into %1$s's brain",
"death.attack.arrow_in_brain.item": "An arrow shot into %1$s's brain,murderer is %2$s used %3$s",
"death.attack.arrow_in_brain.entity": "An arrow shot into %1$s's brain whilst trying to escape %2$s", "death.attack.arrow_in_brain.entity": "An arrow shot into %1$s's brain whilst trying to escape %2$s",
"death.attack.arrow_in_brain.item": "%2$s used %3$s to make an arrow shot into %1$s's brain",
"death.attack.arrow_in_brain_headshot": "%1$s was headshot by an arrow from %2$s",
"death.attack.arrow_in_brain_headshot.entity": "%1$s was headshot by an arrow while escaping from %2$s",
"death.attack.arrow_in_brain_headshot.item": "%2$s used %3$s to let %1$s be headshot by an arrow",
"death.attack.beast_gun": "%1$s was killed by %2$s using BEAST guns", "death.attack.beast_gun": "%1$s was killed by %2$s using BEAST guns",
"Shell Estimated Range": "Estimated Range:", "Shell Estimated Range": "Estimated Range:",

View file

@ -157,8 +157,11 @@
"death.attack.gunfire_headshot.entity": "%1$s被%2$s射爆了脑袋", "death.attack.gunfire_headshot.entity": "%1$s被%2$s射爆了脑袋",
"death.attack.gunfire_headshot.item": "%1$s被%2$s用%3$s射爆了脑袋", "death.attack.gunfire_headshot.item": "%1$s被%2$s用%3$s射爆了脑袋",
"death.attack.arrow_in_brain": "%1$s的脑子进矢了凶手是%2$s", "death.attack.arrow_in_brain": "%1$s的脑子进矢了凶手是%2$s",
"death.attack.arrow_in_brain.item": "%1$s的脑子进矢了凶手%2$s使用了%3$s",
"death.attack.arrow_in_brain.entity": "%1$s在逃离%2$s的时候脑子进矢了", "death.attack.arrow_in_brain.entity": "%1$s在逃离%2$s的时候脑子进矢了",
"death.attack.arrow_in_brain.item": "%2$s用%3$s让%1$s的脑子进矢了",
"death.attack.arrow_in_brain_headshot": "%1$s被矢爆头了凶手是%2$s",
"death.attack.arrow_in_brain_headshot.entity": "%1$s在逃离%2$s的时候被矢爆头了",
"death.attack.arrow_in_brain_headshot.item": "%2$s用%3$s让%1$s被矢爆头了",
"death.attack.beast_gun": "%1$s被%2$s用BEAST枪械臭炸了", "death.attack.beast_gun": "%1$s被%2$s用BEAST枪械臭炸了",
"Shell Estimated Range": "炮弹预估射程:", "Shell Estimated Range": "炮弹预估射程:",

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

View file

@ -0,0 +1,5 @@
{
"exhaustion": 0,
"message_id": "arrow_in_brain_headshot",
"scaling": "never"
}