修复二次灾变动画优先级bug,修复刺雷多次消耗bug,添加刺雷冲刺功能,修复加特林红温bug

This commit is contained in:
Atsuihsio 2025-01-12 01:59:27 +08:00
parent 3a0b17751b
commit 8c6ae814c9
17 changed files with 255 additions and 48 deletions

View file

@ -18,7 +18,7 @@ import software.bernie.geckolib.renderer.GeoRenderer;
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
public class MinigunHeatLayer extends GeoRenderLayer<MinigunItem> {
private static final ResourceLocation LAYER = new ResourceLocation(ModUtils.MODID, "textures/item/minigun_e.png");
private static final ResourceLocation LAYER = new ResourceLocation(ModUtils.MODID, "textures/item/minigun_heat_e.png");
public MinigunHeatLayer(GeoRenderer<MinigunItem> itemGeoRenderer) {
super(itemGeoRenderer);

View file

@ -13,7 +13,7 @@ import software.bernie.geckolib.renderer.GeoRenderer;
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
public class MinigunLayer extends GeoRenderLayer<MinigunItem> {
private static final ResourceLocation LAYER = new ResourceLocation(ModUtils.MODID, "textures/item/minigun_heat_e.png");
private static final ResourceLocation LAYER = new ResourceLocation(ModUtils.MODID, "textures/item/minigun_e.png");
public MinigunLayer(GeoRenderer<MinigunItem> entityRenderer) {
super(entityRenderer);

View file

@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.client.overlay;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity;
import com.atsuishio.superbwarfare.entity.vehicle.ICannonEntity;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModItems;
@ -118,7 +119,7 @@ public class CrossHairOverlay {
}
// 在开启伤害指示器时才进行渲染
if (DisplayConfig.KILL_INDICATION.get() && stack.is(ModTags.Items.GUN)) {
if (DisplayConfig.KILL_INDICATION.get() && !(player.getVehicle() instanceof Ah6Entity ah6Entity && ah6Entity.getFirstPassenger() == player)) {
renderKillIndicator(guiGraphics, w, h, moveX, moveY);
}

View file

@ -145,6 +145,8 @@ public class ClientEventHandler {
public static double vehicleFov = 1;
public static double vehicleFovLerp = 1;
public static int lungeAttack;
public static int lungeDraw;
public static int lungeSprint;
public static Entity entity;
public static int dismountCountdown = 0;
@ -248,21 +250,22 @@ public class ClientEventHandler {
}
public static void handleLungeAttack(Player player, ItemStack stack) {
if (stack.is(ModItems.LUNGE_MINE.get()) && lungeAttack == 0 && holdFire && !player.getCooldowns().isOnCooldown(stack.getItem())) {
if (stack.is(ModItems.LUNGE_MINE.get()) && lungeAttack == 0 && lungeDraw == 0 && holdFire) {
lungeAttack = 36;
holdFire = false;
player.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, 1f, 1);
}
if (stack.is(ModItems.LUNGE_MINE.get()) && lungeAttack >= 18 && lungeAttack <= 21) {
if (stack.is(ModItems.LUNGE_MINE.get()) && ((lungeAttack >= 18 && lungeAttack <= 21) || lungeSprint > 0)) {
boolean lookAtEntity = false;
Entity lookingEntity = TraceTool.findLookingEntity(player, 5);
Entity lookingEntity = TraceTool.findLookingEntity(player, 3.5);
BlockHitResult result = player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getLookAngle().scale(5)),
BlockHitResult result = player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getLookAngle().scale(3.5)),
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player));
Vec3 looking = Vec3.atLowerCornerOf(player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getLookAngle().scale(5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos());
Vec3 looking = Vec3.atLowerCornerOf(player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getLookAngle().scale(3.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos());
BlockState blockState = player.level().getBlockState(BlockPos.containing(looking.x(), looking.y(), looking.z()));
if (lookingEntity != null) {
@ -271,14 +274,28 @@ public class ClientEventHandler {
if (lookAtEntity) {
ModUtils.PACKET_HANDLER.sendToServer(new LungeMineAttackMessage(0, lookingEntity.getUUID(), result));
lungeSprint = 0;
lungeAttack = 0;
lungeDraw = 30;
} else if (blockState.canOcclude() || blockState.getBlock() instanceof DoorBlock || blockState.getBlock() instanceof CrossCollisionBlock || blockState.getBlock() instanceof BellBlock) {
ModUtils.PACKET_HANDLER.sendToServer(new LungeMineAttackMessage(1, player.getUUID(), result));
lungeSprint = 0;
lungeAttack = 0;
lungeDraw = 30;
}
}
if (lungeSprint > 0) {
lungeSprint--;
}
if (lungeAttack > 0) {
lungeAttack--;
}
if (lungeDraw > 0) {
lungeDraw--;
}
}
@SubscribeEvent

View file

@ -32,6 +32,7 @@ public class ModDamageTypes {
public static final ResourceKey<DamageType> LASER_HEADSHOT = ResourceKey.create(Registries.DAMAGE_TYPE, ModUtils.loc("laser_headshot"));
public static final ResourceKey<DamageType> VEHICLE_STRIKE = ResourceKey.create(Registries.DAMAGE_TYPE, ModUtils.loc("vehicle_strike"));
public static final ResourceKey<DamageType> AIR_CRASH = ResourceKey.create(Registries.DAMAGE_TYPE, ModUtils.loc("air_crash"));
public static final ResourceKey<DamageType> LUNGE_MINE = ResourceKey.create(Registries.DAMAGE_TYPE, ModUtils.loc("lunge_mine"));
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);
@ -93,6 +94,10 @@ public class ModDamageTypes {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(AIR_CRASH), directEntity, attacker);
}
public static DamageSource causeLungeMineDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(LUNGE_MINE), directEntity, attacker);
}
private static class DamageMessages extends DamageSource {
public DamageMessages(Holder.Reference<DamageType> typeReference) {

View file

@ -395,5 +395,6 @@ public class ModSounds {
public static final RegistryObject<SoundEvent> MISSILE_WARNING = REGISTRY.register("missile_warning", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("missile_warning")));
public static final RegistryObject<SoundEvent> DECOY_FIRE = REGISTRY.register("decoy_fire", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("decoy_fire")));
public static final RegistryObject<SoundEvent> DECOY_RELOAD = REGISTRY.register("decoy_reload", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("decoy_reload")));
public static final RegistryObject<SoundEvent> LUNGE_MINE_GROWL = REGISTRY.register("lunge_mine_growl", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("lunge_mine_growl")));
}

View file

@ -2,13 +2,19 @@ package com.atsuishio.superbwarfare.item;
import com.atsuishio.superbwarfare.client.renderer.item.LungeMineRenderer;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModSounds;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
@ -18,6 +24,7 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import org.jetbrains.annotations.NotNull;
import software.bernie.geckolib.animatable.GeoItem;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.core.animation.AnimatableManager;
@ -76,13 +83,19 @@ public class LungeMine extends Item implements GeoItem, AnimatedItem {
private PlayState idlePredicate(AnimationState<LungeMine> event) {
LocalPlayer player = Minecraft.getInstance().player;
if (player == null) return PlayState.STOP;
if (ClientEventHandler.lungeSprint > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lunge_mine.sprint"));
}
if (ClientEventHandler.lungeDraw > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lunge_mine.draw"));
}
if (ClientEventHandler.lungeAttack > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.lunge_mine.fire"));
}
if (player.isSprinting() && player.onGround()) {
if (player.isSprinting() && player.onGround() && ClientEventHandler.lungeDraw == 0) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.lunge_mine.run"));
}
@ -114,6 +127,21 @@ public class LungeMine extends Item implements GeoItem, AnimatedItem {
return false;
}
@Override
public @NotNull InteractionResultHolder<ItemStack> use(Level worldIn, Player playerIn, InteractionHand handIn) {
ItemStack stack = playerIn.getItemInHand(handIn);
if (playerIn instanceof ServerPlayer serverPlayer) {
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.LUNGE_MINE_GROWL.get(), SoundSource.PLAYERS, 2, 1);
}
if (!playerIn.level().isClientSide()) {
playerIn.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 100, (playerIn.hasEffect(MobEffects.MOVEMENT_SPEED) ? playerIn.getEffect(MobEffects.MOVEMENT_SPEED).getAmplifier() : 0) + 2));
} else {
ClientEventHandler.lungeSprint = 180;
}
playerIn.getCooldowns().addCooldown(stack.getItem(), 300);
return InteractionResultHolder.consume(stack);
}
@Override
public boolean canAttackBlock(BlockState p_41441_, Level p_41442_, BlockPos p_41443_, Player p_41444_) {
return false;

View file

@ -144,7 +144,14 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, AnimatedItem
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 && ClientEventHandler.drawTime < 0.01) {
if (player.isSprinting() && player.onGround()
&& player.getPersistentData().getDouble("noRun") == 0
&& !(stack.getOrCreateTag().getBoolean("is_empty_reloading"))
&& stack.getOrCreateTag().getInt("reload_stage") != 1
&& stack.getOrCreateTag().getInt("reload_stage") != 2
&& stack.getOrCreateTag().getInt("reload_stage") != 3
&& ClientEventHandler.drawTime < 0.01
&& !GunsTool.getGunBooleanTag(stack, "Reloading")) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sc.run_fast"));
} else {

View file

@ -51,17 +51,15 @@ public class LungeMineAttackMessage {
if (stack.is(ModItems.LUNGE_MINE.get())) {
if (message.type == 0) {
player.getCooldowns().addCooldown(stack.getItem(), 10);
if (!player.isCreative()) {
stack.shrink(1);
}
Entity lookingEntity = EntityFindUtil.findEntity(player.level(), String.valueOf(message.uuid));
if (lookingEntity != null) {
lookingEntity.hurt(ModDamageTypes.causeCannonFireDamage(player.level().registryAccess(), player, player), 150);
lookingEntity.hurt(ModDamageTypes.causeLungeMineDamage(player.level().registryAccess(), player, player), 150);
causeLungeMineExplode(player.level(), player, lookingEntity);
}
} else if (message.type == 1) {
player.getCooldowns().addCooldown(stack.getItem(), 10);
if (!player.isCreative()) {
stack.shrink(1);
}

View file

@ -3,7 +3,6 @@ package com.atsuishio.superbwarfare.tools;
import com.atsuishio.superbwarfare.ModUtils;
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos;
@ -12,11 +11,8 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.PrimedTnt;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.enchantment.ProtectionEnchantment;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.level.Level;
@ -133,7 +129,7 @@ public class CustomExplosion extends Explosion {
Optional<Float> optional = this.damageCalculator.getBlockExplosionResistance(this, this.level, blockpos, blockstate, fluidstate);
if (optional.isPresent()) {
f -= (optional.get() + 0.5F) * 0.15F;
f -= (optional.get() + 1F) * 0.3F;
}
if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockpos, blockstate, f)) {
@ -171,9 +167,6 @@ public class CustomExplosion extends Explosion {
double zDistance = entity.getZ() - this.z;
double distance = Math.sqrt(xDistance * xDistance + yDistance * yDistance + zDistance * zDistance);
if (distance != 0.0D) {
xDistance /= distance;
yDistance /= distance;
zDistance /= distance;
double seenPercent = Mth.clamp(getSeenPercent(position, entity), 0.01 * ExplosionConfig.EXPLOSION_PENETRATION_RATIO.get(), Double.POSITIVE_INFINITY);
double damagePercent = (1.0D - distanceRate) * seenPercent;
@ -183,35 +176,10 @@ public class CustomExplosion extends Explosion {
} else {
entity.hurt(this.damageSource, (float) damageFinal);
}
// if (entity instanceof LivingEntity) {
// entity.invulnerableTime = 0;
// }
if (fireTime > 0) {
entity.setSecondsOnFire(fireTime);
}
double d11;
if (entity instanceof LivingEntity livingentity) {
d11 = ProtectionEnchantment.getExplosionKnockbackAfterDampener(livingentity, damagePercent);
} else {
d11 = damagePercent;
}
xDistance *= d11;
yDistance *= d11;
zDistance *= d11;
Vec3 knockbackVec = new Vec3(0.2 * xDistance, 0.2 * yDistance, 0.2 * zDistance);
if (entity instanceof VehicleEntity vehicle) {
vehicle.setDeltaMovement(vehicle.getDeltaMovement().add(knockbackVec.scale(0.05f)));
} else {
entity.setDeltaMovement(entity.getDeltaMovement().add(knockbackVec));
}
if (entity instanceof Player player) {
if (!player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying)) {
this.getHitPlayers().put(player, knockbackVec);
}
}
}
}
}

View file

@ -4,6 +4,45 @@
"animation.lunge_mine.idle": {
"loop": true
},
"animation.lunge_mine.draw": {
"animation_length": 0.7417,
"bones": {
"bone": {
"rotation": {
"0.0": {
"post": [26.18822, -56.98899, 3.86091],
"lerp_mode": "catmullrom"
},
"0.3667": {
"post": [-2.95569, -6.46738, -5.26869],
"lerp_mode": "catmullrom"
},
"0.6": {
"post": [0, 0, 0],
"lerp_mode": "catmullrom"
}
},
"position": {
"0.0": {
"post": [1.1, -9.55, 0.8],
"lerp_mode": "catmullrom"
},
"0.2667": {
"post": [2.18, -1.99, 0.46],
"lerp_mode": "catmullrom"
},
"0.4583": {
"post": [-0.16, -2.77, 0.17],
"lerp_mode": "catmullrom"
},
"0.6": {
"post": [0, 0, 0],
"lerp_mode": "catmullrom"
}
}
}
}
},
"animation.lunge_mine.fire": {
"animation_length": 0.8083,
"bones": {
@ -298,6 +337,129 @@
}
}
}
},
"animation.lunge_mine.sprint": {
"animation_length": 5.25,
"bones": {
"bone": {
"rotation": {
"0.0": {
"post": [0, 0, 0],
"lerp_mode": "catmullrom"
},
"0.0833": {
"post": [20.67113, 4.11365, -1.59869],
"lerp_mode": "catmullrom"
},
"0.2667": {
"post": [26.15692, 29.69646, -7.29644],
"lerp_mode": "catmullrom"
},
"0.7083": {
"post": [26.39213, 28.79003, -7.38092],
"lerp_mode": "catmullrom"
},
"1.2167": {
"post": [25.41791, 27.98291, -7.33538],
"lerp_mode": "catmullrom"
},
"1.7917": {
"post": [27.49865, 28.37732, -7.38515],
"lerp_mode": "catmullrom"
},
"2.3167": {
"post": [26.39213, 28.79003, -7.38092],
"lerp_mode": "catmullrom"
},
"2.825": {
"post": [25.41791, 27.98291, -7.33538],
"lerp_mode": "catmullrom"
},
"3.4417": {
"post": [27.49865, 28.37732, -7.38515],
"lerp_mode": "catmullrom"
},
"3.925": {
"post": [26.39213, 28.79003, -7.38092],
"lerp_mode": "catmullrom"
},
"4.4333": {
"post": [25.41791, 27.98291, -7.33538],
"lerp_mode": "catmullrom"
},
"4.975": {
"post": [26.15692, 29.69646, -7.29644],
"lerp_mode": "catmullrom"
},
"5.15": {
"post": [20.67113, 4.11365, -1.59869],
"lerp_mode": "catmullrom"
},
"5.25": {
"post": [0, 0, 0],
"lerp_mode": "catmullrom"
}
},
"position": {
"0.0": {
"post": [0, 0, 0],
"lerp_mode": "catmullrom"
},
"0.175": {
"post": [-2.65, 0.65, 0.7],
"lerp_mode": "catmullrom"
},
"0.3167": {
"post": [-2.3, 0.65, 0.7],
"lerp_mode": "catmullrom"
},
"1.025": {
"post": [-1.98, 0.45, 0.7],
"lerp_mode": "catmullrom"
},
"1.3917": {
"post": [-2.14, 0.7, 0.7],
"lerp_mode": "catmullrom"
},
"1.7917": {
"post": [-2.16, 0.61, 0.7],
"lerp_mode": "catmullrom"
},
"2.6333": {
"post": [-1.98, 0.45, 0.7],
"lerp_mode": "catmullrom"
},
"3.0": {
"post": [-2.14, 0.7, 0.7],
"lerp_mode": "catmullrom"
},
"3.4417": {
"post": [-2.16, 0.61, 0.7],
"lerp_mode": "catmullrom"
},
"4.2417": {
"post": [-1.98, 0.45, 0.7],
"lerp_mode": "catmullrom"
},
"4.6083": {
"post": [-2.14, 0.7, 0.7],
"lerp_mode": "catmullrom"
},
"4.9417": {
"post": [-2.3, 0.65, 0.7],
"lerp_mode": "catmullrom"
},
"5.075": {
"post": [-2.65, 0.65, 0.7],
"lerp_mode": "catmullrom"
},
"5.25": {
"post": [0, 0, 0],
"lerp_mode": "catmullrom"
}
}
}
}
}
},
"geckolib_format_version": 2

View file

@ -363,6 +363,9 @@
"death.attack.air_crash": "%1$s坠机了",
"death.attack.air_crash.entity": "%1$s坠机了,凶手是%2$s",
"death.attack.air_crash.item": "%1$s坠机了,凶手是%2$s",
"death.attack.lunge_mine": "%1$s被突刺爆雷戳到了屁股",
"death.attack.lunge_mine.entity": "%1$s被%2$s用突刺爆雷戳到了屁股",
"death.attack.lunge_mine.item": "%1$s被%2$s用%3$s型突刺爆雷戳到了屁股",
"entity.superbwarfare.projectile": "Bullet",
"entity.superbwarfare.projectile_mortar_shell": "Mortar Shell",

View file

@ -361,6 +361,9 @@
"death.attack.air_crash": "%1$s坠机了",
"death.attack.air_crash.entity": "%1$s坠机了,凶手是%2$s",
"death.attack.air_crash.item": "%1$s坠机了,凶手是%2$s",
"death.attack.lunge_mine": "%1$s被突刺爆雷戳到了屁股",
"death.attack.lunge_mine.entity": "%1$s被%2$s用突刺爆雷戳到了屁股",
"death.attack.lunge_mine.item": "%1$s被%2$s用%3$s型突刺爆雷戳到了屁股",
"entity.superbwarfare.projectile": "子弹",
"entity.superbwarfare.projectile_mortar_shell": "迫击炮弹",

View file

@ -2696,5 +2696,13 @@
"stream": false
}
]
},
"lunge_mine_growl": {
"sounds": [
{
"name": "superbwarfare:lunge_mine_growl",
"stream": false
}
]
}
}

View file

@ -2,6 +2,7 @@
"replace": false,
"values": [
"superbwarfare:projectile_boom",
"superbwarfare:custom_explosion"
"superbwarfare:custom_explosion",
"superbwarfare:lunge_mine"
]
}

View file

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