完善新伤害类型

This commit is contained in:
17146 2024-06-26 01:37:26 +08:00
parent 062acc30db
commit 02a340fc64
15 changed files with 68 additions and 35 deletions

View file

@ -252,7 +252,7 @@ public class KillMessageOverlay {
icon = null;
} else {
// 如果是其他伤害则渲染对应图标
if (record.damageType == DamageTypes.EXPLOSION || record.damageType == DamageTypes.PLAYER_EXPLOSION) {
if (record.damageType == DamageTypes.EXPLOSION || record.damageType == DamageTypes.PLAYER_EXPLOSION || record.damageType == TargetModDamageTypes.PROJECTILE_BOOM) {
icon = EXPLOSION;
} else if (record.damageType == DamageTypes.PLAYER_ATTACK) {
icon = KNIFE;

View file

@ -162,7 +162,8 @@ public class GunGrenadeEntity extends ThrowableItemProjectile {
}
private void causeExplode() {
CustomExplosion explosion = new CustomExplosion(this.level(), this, 72f, this.getX(), this.getY(), this.getZ(),
CustomExplosion explosion = new CustomExplosion(this.level(), this,
TargetModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), 72f, this.getX(), this.getY(), this.getZ(),
7.5f, Explosion.BlockInteraction.KEEP);
explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);

View file

@ -1,7 +1,6 @@
package net.mcreator.target.event;
import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModMobEffects;
import net.mcreator.target.init.TargetModTags;
import net.mcreator.target.network.TargetModVariables;
@ -254,7 +253,6 @@ public class ClientEventHandler {
double pitch = event.getPitch();
double roll = event.getRoll();
double pose;
double amplitude;
float fps = Minecraft.getInstance().getFps();
if (fps <= 0) {
@ -375,12 +373,12 @@ public class ClientEventHandler {
@SubscribeEvent
public static void onFovUpdate(ViewportEvent.ComputeFov event) {
Player player = Minecraft.getInstance().player;
ItemStack stack = player.getMainHandItem();
if (player == null) {
return;
}
ItemStack stack = player.getMainHandItem();
if (stack.is(TargetModTags.Items.GUN)) {
if (!event.usedConfiguredFov()) {
return;

View file

@ -27,12 +27,12 @@ public class GunEventHandler {
@SubscribeEvent
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
Player player = event.player;
ItemStack stack = player.getMainHandItem();
if (player == null) {
return;
}
ItemStack stack = player.getMainHandItem();
if (event.phase == TickEvent.Phase.END && stack.is(TargetModTags.Items.GUN)) {
handleGunFire(player);
handleMiniGunFire(player);

View file

@ -138,13 +138,14 @@ public class LivingEventHandler {
}
var damagesource = event.getSource();
var sourceEntity = damagesource.getDirectEntity();
var sourceEntity = damagesource.getEntity();
if (sourceEntity == null) {
return;
}
if (sourceEntity instanceof ServerPlayer player && (damagesource.is(DamageTypes.EXPLOSION) || damagesource.is(DamageTypes.PLAYER_EXPLOSION) || damagesource.is(TargetModDamageTypes.MINE))) {
if (sourceEntity instanceof ServerPlayer player && (damagesource.is(DamageTypes.EXPLOSION) || damagesource.is(DamageTypes.PLAYER_EXPLOSION)
|| damagesource.is(TargetModDamageTypes.MINE) || damagesource.is(TargetModDamageTypes.PROJECTILE_BOOM))) {
SoundTool.playLocalSound(player, TargetModSounds.INDICATION.get(), 1f, 1f);
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));

View file

@ -48,12 +48,12 @@ public class PlayerEventHandler {
@SubscribeEvent
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
Player player = event.player;
ItemStack stack = player.getMainHandItem();
if (player == null) {
return;
}
ItemStack stack = player.getMainHandItem();
if (event.phase == TickEvent.Phase.END && stack.is(TargetModTags.Items.GUN)) {
handlePlayerProne(player);
handlePlayerSprint(player);
@ -282,10 +282,9 @@ public class PlayerEventHandler {
Runnable recoilRunnable = () -> {
while (recoilTimer[0] < recoilDuration) {
/**
* 开火动画计时器
/*
开火动画计时器
*/
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).firing > 0) {
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.firing = (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).firing - 0.1;
@ -298,10 +297,9 @@ public class PlayerEventHandler {
});
}
/**
* 计算后坐力
/*
计算后坐力
*/
float rx, ry;
if (player.isShiftKeyDown() && player.getBbHeight() >= 1 && player.getPersistentData().getDouble("prone") == 0) {
rx = 0.7f;
@ -345,10 +343,9 @@ public class PlayerEventHandler {
player.yRotO = player.getYRot();
}
/**
* 计算散布
/*
计算散布
*/
ItemStack stack = player.getMainHandItem();
double basic = stack.getOrCreateTag().getDouble("dev");

View file

@ -23,6 +23,7 @@ public class TargetModDamageTypes {
public static final ResourceKey<DamageType> MINE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "mine"));
public static final ResourceKey<DamageType> BEAST = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "beast"));
public static final ResourceKey<DamageType> SHOCK = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "shock"));
public static final ResourceKey<DamageType> PROJECTILE_BOOM = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(TargetMod.MODID, "projectile_boom"));
public static DamageSource causeGunFireDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(GUN_FIRE), directEntity, attacker);
@ -48,6 +49,10 @@ public class TargetModDamageTypes {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(SHOCK), attacker);
}
public static DamageSource causeProjectileBoomDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(PROJECTILE_BOOM), directEntity, attacker);
}
private static class DamageMessages extends DamageSource {
public DamageMessages(Holder.Reference<DamageType> typeReference) {
super(typeReference);

View file

@ -1,7 +1,6 @@
package net.mcreator.target.mobeffect;
import net.mcreator.target.TargetMod;
import net.mcreator.target.entity.ClaymoreEntity;
import net.mcreator.target.init.TargetModDamageTypes;
import net.mcreator.target.init.TargetModMobEffects;
import net.mcreator.target.init.TargetModSounds;
@ -12,7 +11,6 @@ import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffectInstance;

View file

@ -56,6 +56,10 @@ public class CustomExplosion extends Explosion {
this(pLevel, pSource, null, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, 0, pBlockInteraction);
}
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, Explosion.BlockInteraction pBlockInteraction) {
this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, 0, pBlockInteraction);
}
public CustomExplosion(Level pLevel, @Nullable Entity pSource, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, int fireTime, Explosion.BlockInteraction pBlockInteraction) {
this(pLevel, pSource, null, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, fireTime, pBlockInteraction);
}

View file

@ -168,6 +168,9 @@
"death.attack.shock": "%1$s was shocked",
"death.attack.shock.entity": "%1$s was shocked by %2$s",
"death.attack.shock.item": "%1$s was shocked by %2$s",
"death.attack.projectile_boom": "%1$s被轰上了天",
"death.attack.projectile_boom.entity": "%1$s被%2$s轰上了天",
"death.attack.projectile_boom.item": "%1$s被%2$s用%3$s轰上了天",
"gui.target.gun_recycle_gui.tooltip_if_guns_level_10you_will_get": "If gun\u0027s level \u003e 10,you will get soul nuggets",
"gui.target.gun_recycle_gui.button_dismantle": "Dismantle",

View file

@ -168,6 +168,9 @@
"death.attack.shock": "%1$s被电麻了",
"death.attack.shock.entity": "%1$s被%2$s电麻了",
"death.attack.shock.item": "%1$s被%2$s电麻了",
"death.attack.projectile_boom": "%1$s被轰上了天",
"death.attack.projectile_boom.entity": "%1$s被%2$s轰上了天",
"death.attack.projectile_boom.item": "%1$s被%2$s用%3$s轰上了天",
"gui.target.gun_recycle_gui.tooltip_if_guns_level_10you_will_get": "如果枪械熟练度大于10级你将会获得魂钢粒",
"gui.target.gun_recycle_gui.button_dismantle": "拆解",

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"target:projectile_boom"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"target:projectile_boom"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"target:projectile_boom"
]
}

View file

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