Burrower multiplayer fixes

* EmoteExpressionParticle no longer tries to request its texture on the server side, which had resulted in a null reference error being thrown and logged
* Burrower should no longer run its AI and throw a null reference error when searching for nearby targets
* Gave Burrower proper Multiplayer syncing cause it didn't have any and proved to be quite stuttery while testing it locally
* Burrower and BurrowerHitbox now use the LongRangedNetSync Attribute
This commit is contained in:
fryzahh committed 2026-07-29 01:54:01 -04:00
1 parent f0edce2920
commit 844c6be55d
2 files changed
+35 -21

No files matched your search

+30 -17
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Effects;
@@ -23,6 +24,7 @@ using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;
namespace CalamityMod.NPCs.Deconstructors
{
[LongDistanceNetSync(SyncWith = typeof(Burrower))]
public class BurrowerHitbox : BaseWormHitboxNPC
{
public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.Burrower.DisplayName");
@@ -58,13 +60,19 @@ namespace CalamityMod.NPCs.Deconstructors
public override void AI()
{
base.AI();
var headNPC = Main.npc[(int)NPC.ai[0]];
NPC.Calamity().DR = headNPC.Calamity().DR;
NPC.HitSound = headNPC.HitSound;
if (Main.npc.IndexInRange((int)NPC.ai[0]))
{
NPC headNPC = Main.npc[(int)NPC.ai[0]];
NPC.Calamity().DR = headNPC.Calamity().DR;
NPC.HitSound = headNPC.HitSound;
}
NPC.width = 38;
NPC.height = 38;
}
}
[LongDistanceNetSync]
public class Burrower : BaseWormNPC
{
public override string Texture => "CalamityMod/NPCs/Deconstructors/DeconstructorMK1Head";
@@ -174,23 +182,22 @@ namespace CalamityMod.NPCs.Deconstructors
set { NPC.ai[2] = value; }
}
public float StateChangeCounter
{
get { return NPC.ai[3]; }
set { NPC.ai[3] = value; }
}
public float VelocityRotation
{
get { return NPC.velocity.ToRotation(); }
set { NPC.velocity = value.ToRotationVector2() * NPC.velocity.Length(); }
}
public Vector2 TargetVector = Vector2.Zero;
public Vector2 SecondaryVector = Vector2.Zero;
public float StoredValue = 0;
#endregion
public override void SendExtraAI(BinaryWriter writer)
{
writer.WriteVector2(TargetVector);
writer.WriteVector2(SecondaryVector);
}
public override void ReceiveExtraAI(BinaryReader reader)
{
TargetVector = reader.ReadVector2();
SecondaryVector = reader.ReadVector2();
}
public void SwitchAttackState(AttackState State, float Substate = 0, bool resetVector = true)
{
ActiveAttackState = State;
@@ -198,6 +205,7 @@ namespace CalamityMod.NPCs.Deconstructors
MainTimer = 0;
if (resetVector)
TargetVector = Vector2.Zero;
NPC.ForceNetUpdate();
}
public override void AI()
@@ -316,9 +324,12 @@ namespace CalamityMod.NPCs.Deconstructors
public void HandleAIStates()
{
NPC.CalamityTargeting(CalamityTargetingParameters.BossDefaults);
if (!NPC.HasValidTarget)
{
NPC.CalamityTargeting(CalamityTargetingParameters.BossDefaults);
return;
}
Player player = Main.player[NPC.target];
SegmentMaxRotation = 0.65f;
SegmentRigidity = 0.2f;
@@ -356,9 +367,11 @@ namespace CalamityMod.NPCs.Deconstructors
veins.Remove(targetVein);
}
}
TargetVector = player.Center + Main.rand.NextVector2Circular(800, 800);
LowerTargetToGround();
MainTimer = 0;
NPC.netUpdate = true;
}
if (AttackSubstate <= 0 && noGravity)
{
+5 -4
View File
@@ -26,7 +26,7 @@ namespace CalamityMod.Particles
BigSmile
}
private Rectangle Frame;
private EmoteType Emote;
public EmoteExpressionParticle(Vector2 position, Vector2 velocity, float scale, Color color, int lifeTime, EmoteType emote)
{
@@ -35,7 +35,7 @@ namespace CalamityMod.Particles
Velocity = velocity;
Color = color;
Lifetime = lifeTime;
Frame = ModContent.Request<Texture2D>(Texture).Value.Frame(horizontalFrames: 8, verticalFrames: 1, frameX: (int)emote);
Emote = emote;
Rotation = velocity.ToRotation() + MathHelper.PiOver2;
}
@@ -48,10 +48,11 @@ namespace CalamityMod.Particles
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D emoteTexture = ModContent.Request<Texture2D>(Texture).Value;
Vector2 origin = new Vector2(Frame.Width / 2f, Frame.Height);
float opacity = 1 - (float)Math.Pow(LifetimeCompletion, 4f);
Rectangle frame = emoteTexture.Frame(horizontalFrames: 8, verticalFrames: 1, frameX: (int)Emote);
Vector2 origin = new Vector2(frame.Width / 2f, frame.Height);
spriteBatch.Draw(emoteTexture, Position - Main.screenPosition, Frame, Color * opacity, Rotation, origin, Scale, SpriteEffects.None, 0);
spriteBatch.Draw(emoteTexture, Position - Main.screenPosition, frame, Color * opacity, Rotation, origin, Scale, SpriteEffects.None, 0);
}
}
}