完善新伤害类型
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;
|
||||
} 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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -38,9 +37,9 @@ public class ClientEventHandler {
|
|||
float yRotOffset = Mth.lerp(event.getPartialTick(), player.yBobO, player.yBob);
|
||||
float xRot = player.getViewXRot(event.getPartialTick()) - xRotOffset;
|
||||
float yRot = player.getViewYRot(event.getPartialTick()) - yRotOffset;
|
||||
data.putDouble("xRot", Mth.clamp(0.05 * xRot,-5,5) * (1 - 0.75 * data.getDouble("zoom_time")));
|
||||
data.putDouble("yRot", Mth.clamp(0.05 * yRot,-10,10) * (1 - 0.75 * data.getDouble("zoom_time")));
|
||||
data.putDouble("zRot", Mth.clamp(0.1 * yRot,-10,10) * (1 - data.getDouble("zoom_time")));
|
||||
data.putDouble("xRot", Mth.clamp(0.05 * xRot, -5, 5) * (1 - 0.75 * data.getDouble("zoom_time")));
|
||||
data.putDouble("yRot", Mth.clamp(0.05 * yRot, -10, 10) * (1 - 0.75 * data.getDouble("zoom_time")));
|
||||
data.putDouble("zRot", Mth.clamp(0.1 * yRot, -10, 10) * (1 - data.getDouble("zoom_time")));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -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) {
|
||||
|
@ -275,7 +273,7 @@ public class ClientEventHandler {
|
|||
data.putDouble("firepos2", 0.1);
|
||||
}
|
||||
|
||||
data.putDouble("firepos2", Mth.clamp(data.getDouble("firepos2") - 0.01 * times,0,0.6));
|
||||
data.putDouble("firepos2", Mth.clamp(data.getDouble("firepos2") - 0.01 * times, 0, 0.6));
|
||||
|
||||
if (0 < data.getDouble("firetime")) {
|
||||
data.putDouble("firetime", (data.getDouble("firetime") + 0.25 * (1.1 - data.getDouble("firetime")) * times));
|
||||
|
@ -296,15 +294,15 @@ public class ClientEventHandler {
|
|||
|
||||
if (0 < data.getDouble("fire_rotx_time") && data.getDouble("fire_rotx_time") < 1.732) {
|
||||
data.putDouble("fire_rot",
|
||||
(1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time") , 2)));
|
||||
(1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time"), 2)));
|
||||
if ((capability.orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
|
||||
event.setYaw((float) (yaw - 1.3 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time") , 2)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"),0,1) * (2 * Math.random() - 1)));
|
||||
event.setPitch((float) (pitch + 1.3 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time") , 2)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"),0,1) * (2 * Math.random() - 1)));
|
||||
event.setRoll((float) (roll + 4.2 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time") , 2)) + 3 * Mth.clamp(0.5 - data.getDouble("fire_rotx_time"),0,0.5) * (2 * Math.random() - 1)));
|
||||
event.setYaw((float) (yaw - 1.3 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time"), 2)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"), 0, 1) * (2 * Math.random() - 1)));
|
||||
event.setPitch((float) (pitch + 1.3 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time"), 2)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"), 0, 1) * (2 * Math.random() - 1)));
|
||||
event.setRoll((float) (roll + 4.2 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time"), 2)) + 3 * Mth.clamp(0.5 - data.getDouble("fire_rotx_time"), 0, 0.5) * (2 * Math.random() - 1)));
|
||||
} else if ((capability.orElse(new TargetModVariables.PlayerVariables())).recoilHorizon <= 0) {
|
||||
event.setYaw((float) (yaw + 1.3 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time") , 2)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"),0,1) * (2 * Math.random() - 1)));
|
||||
event.setPitch((float) (pitch - 1.3 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time") , 2)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"),0,1) * (2 * Math.random() - 1)));
|
||||
event.setRoll((float) (roll - 4.2 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time") , 2)) + 3 * Mth.clamp(0.5 - data.getDouble("fire_rotx_time"),0,0.5) * (2 * Math.random() - 1)));
|
||||
event.setYaw((float) (yaw + 1.3 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time"), 2)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"), 0, 1) * (2 * Math.random() - 1)));
|
||||
event.setPitch((float) (pitch - 1.3 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time"), 2)) + 1 * Mth.clamp(0.3 - data.getDouble("fire_rotx_time"), 0, 1) * (2 * Math.random() - 1)));
|
||||
event.setRoll((float) (roll - 4.2 * amplitude * (1 / 6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * Math.sin(6.3 * (data.getDouble("fire_rotx_time") - 0.5)) * (3 - Math.pow(data.getDouble("fire_rotx_time"), 2)) + 3 * Mth.clamp(0.5 - data.getDouble("fire_rotx_time"), 0, 0.5) * (2 * Math.random() - 1)));
|
||||
}
|
||||
}
|
||||
if (0 <= data.getDouble("firetime") && data.getDouble("firetime") <= 0.25) {
|
||||
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
@ -332,7 +332,7 @@ public class GunEventHandler {
|
|||
projectile.monster_multiple(monster_multiple);
|
||||
|
||||
projectile.setPos(player.getX() - 0.1 * player.getLookAngle().x, player.getEyeY() - 0.1 - 0.1 * player.getLookAngle().y, player.getZ() + -0.1 * player.getLookAngle().z);
|
||||
projectile.shoot(player.getLookAngle().x, player.getLookAngle().y + 0.0005f , player.getLookAngle().z, 1 * (float) heldItem.getOrCreateTag().getDouble("velocity"),
|
||||
projectile.shoot(player.getLookAngle().x, player.getLookAngle().y + 0.0005f, player.getLookAngle().z, 1 * (float) heldItem.getOrCreateTag().getDouble("velocity"),
|
||||
(float) player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()));
|
||||
player.level().addFreshEntity(projectile);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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": "拆解",
|
||||
|
|
|
@ -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