完善新伤害类型
This commit is contained in:
parent
062acc30db
commit
02a340fc64
15 changed files with 68 additions and 35 deletions
|
@ -252,7 +252,7 @@ public class KillMessageOverlay {
|
||||||
icon = null;
|
icon = null;
|
||||||
} else {
|
} 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;
|
icon = EXPLOSION;
|
||||||
} else if (record.damageType == DamageTypes.PLAYER_ATTACK) {
|
} else if (record.damageType == DamageTypes.PLAYER_ATTACK) {
|
||||||
icon = KNIFE;
|
icon = KNIFE;
|
||||||
|
|
|
@ -162,7 +162,8 @@ public class GunGrenadeEntity extends ThrowableItemProjectile {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void causeExplode() {
|
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);
|
7.5f, Explosion.BlockInteraction.KEEP);
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.mcreator.target.event;
|
package net.mcreator.target.event;
|
||||||
|
|
||||||
import net.mcreator.target.init.TargetModAttributes;
|
import net.mcreator.target.init.TargetModAttributes;
|
||||||
import net.mcreator.target.init.TargetModItems;
|
|
||||||
import net.mcreator.target.init.TargetModMobEffects;
|
import net.mcreator.target.init.TargetModMobEffects;
|
||||||
import net.mcreator.target.init.TargetModTags;
|
import net.mcreator.target.init.TargetModTags;
|
||||||
import net.mcreator.target.network.TargetModVariables;
|
import net.mcreator.target.network.TargetModVariables;
|
||||||
|
@ -254,7 +253,6 @@ public class ClientEventHandler {
|
||||||
double pitch = event.getPitch();
|
double pitch = event.getPitch();
|
||||||
double roll = event.getRoll();
|
double roll = event.getRoll();
|
||||||
|
|
||||||
double pose;
|
|
||||||
double amplitude;
|
double amplitude;
|
||||||
float fps = Minecraft.getInstance().getFps();
|
float fps = Minecraft.getInstance().getFps();
|
||||||
if (fps <= 0) {
|
if (fps <= 0) {
|
||||||
|
@ -375,12 +373,12 @@ public class ClientEventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onFovUpdate(ViewportEvent.ComputeFov event) {
|
public static void onFovUpdate(ViewportEvent.ComputeFov event) {
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
ItemStack stack = player.getMainHandItem();
|
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
if (stack.is(TargetModTags.Items.GUN)) {
|
if (stack.is(TargetModTags.Items.GUN)) {
|
||||||
if (!event.usedConfiguredFov()) {
|
if (!event.usedConfiguredFov()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -27,12 +27,12 @@ public class GunEventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||||
Player player = event.player;
|
Player player = event.player;
|
||||||
ItemStack stack = player.getMainHandItem();
|
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
if (event.phase == TickEvent.Phase.END && stack.is(TargetModTags.Items.GUN)) {
|
if (event.phase == TickEvent.Phase.END && stack.is(TargetModTags.Items.GUN)) {
|
||||||
handleGunFire(player);
|
handleGunFire(player);
|
||||||
handleMiniGunFire(player);
|
handleMiniGunFire(player);
|
||||||
|
|
|
@ -138,13 +138,14 @@ public class LivingEventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
var damagesource = event.getSource();
|
var damagesource = event.getSource();
|
||||||
var sourceEntity = damagesource.getDirectEntity();
|
var sourceEntity = damagesource.getEntity();
|
||||||
|
|
||||||
if (sourceEntity == null) {
|
if (sourceEntity == null) {
|
||||||
return;
|
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);
|
SoundTool.playLocalSound(player, TargetModSounds.INDICATION.get(), 1f, 1f);
|
||||||
|
|
||||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
|
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
|
||||||
|
|
|
@ -48,12 +48,12 @@ public class PlayerEventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||||
Player player = event.player;
|
Player player = event.player;
|
||||||
ItemStack stack = player.getMainHandItem();
|
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
if (event.phase == TickEvent.Phase.END && stack.is(TargetModTags.Items.GUN)) {
|
if (event.phase == TickEvent.Phase.END && stack.is(TargetModTags.Items.GUN)) {
|
||||||
handlePlayerProne(player);
|
handlePlayerProne(player);
|
||||||
handlePlayerSprint(player);
|
handlePlayerSprint(player);
|
||||||
|
@ -282,10 +282,9 @@ public class PlayerEventHandler {
|
||||||
Runnable recoilRunnable = () -> {
|
Runnable recoilRunnable = () -> {
|
||||||
while (recoilTimer[0] < recoilDuration) {
|
while (recoilTimer[0] < recoilDuration) {
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* 开火动画计时器
|
开火动画计时器
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).firing > 0) {
|
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).firing > 0) {
|
||||||
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
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;
|
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;
|
float rx, ry;
|
||||||
if (player.isShiftKeyDown() && player.getBbHeight() >= 1 && player.getPersistentData().getDouble("prone") == 0) {
|
if (player.isShiftKeyDown() && player.getBbHeight() >= 1 && player.getPersistentData().getDouble("prone") == 0) {
|
||||||
rx = 0.7f;
|
rx = 0.7f;
|
||||||
|
@ -345,10 +343,9 @@ public class PlayerEventHandler {
|
||||||
player.yRotO = player.getYRot();
|
player.yRotO = player.getYRot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* 计算散布
|
计算散布
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
double basic = stack.getOrCreateTag().getDouble("dev");
|
double basic = stack.getOrCreateTag().getDouble("dev");
|
||||||
|
|
|
@ -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> 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> 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> 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) {
|
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);
|
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);
|
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 {
|
private static class DamageMessages extends DamageSource {
|
||||||
public DamageMessages(Holder.Reference<DamageType> typeReference) {
|
public DamageMessages(Holder.Reference<DamageType> typeReference) {
|
||||||
super(typeReference);
|
super(typeReference);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.mcreator.target.mobeffect;
|
package net.mcreator.target.mobeffect;
|
||||||
|
|
||||||
import net.mcreator.target.TargetMod;
|
import net.mcreator.target.TargetMod;
|
||||||
import net.mcreator.target.entity.ClaymoreEntity;
|
|
||||||
import net.mcreator.target.init.TargetModDamageTypes;
|
import net.mcreator.target.init.TargetModDamageTypes;
|
||||||
import net.mcreator.target.init.TargetModMobEffects;
|
import net.mcreator.target.init.TargetModMobEffects;
|
||||||
import net.mcreator.target.init.TargetModSounds;
|
import net.mcreator.target.init.TargetModSounds;
|
||||||
|
@ -12,7 +11,6 @@ import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.util.RandomSource;
|
import net.minecraft.util.RandomSource;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.damagesource.DamageTypes;
|
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
import net.minecraft.world.effect.MobEffectCategory;
|
import net.minecraft.world.effect.MobEffectCategory;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
|
|
|
@ -56,6 +56,10 @@ public class CustomExplosion extends Explosion {
|
||||||
this(pLevel, pSource, null, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, 0, pBlockInteraction);
|
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) {
|
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);
|
this(pLevel, pSource, null, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, fireTime, pBlockInteraction);
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,6 +168,9 @@
|
||||||
"death.attack.shock": "%1$s was shocked",
|
"death.attack.shock": "%1$s was shocked",
|
||||||
"death.attack.shock.entity": "%1$s was shocked by %2$s",
|
"death.attack.shock.entity": "%1$s was shocked by %2$s",
|
||||||
"death.attack.shock.item": "%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.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",
|
"gui.target.gun_recycle_gui.button_dismantle": "Dismantle",
|
||||||
|
|
|
@ -168,6 +168,9 @@
|
||||||
"death.attack.shock": "%1$s被电麻了",
|
"death.attack.shock": "%1$s被电麻了",
|
||||||
"death.attack.shock.entity": "%1$s被%2$s电麻了",
|
"death.attack.shock.entity": "%1$s被%2$s电麻了",
|
||||||
"death.attack.shock.item": "%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.tooltip_if_guns_level_10you_will_get": "如果枪械熟练度大于10级,你将会获得魂钢粒",
|
||||||
"gui.target.gun_recycle_gui.button_dismantle": "拆解",
|
"gui.target.gun_recycle_gui.button_dismantle": "拆解",
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"replace": false,
|
||||||
|
"values": [
|
||||||
|
"target:projectile_boom"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"replace": false,
|
||||||
|
"values": [
|
||||||
|
"target:projectile_boom"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"replace": false,
|
||||||
|
"values": [
|
||||||
|
"target:projectile_boom"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"exhaustion": 0.1,
|
||||||
|
"message_id": "projectile_boom",
|
||||||
|
"scaling": "never"
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue