diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs
index 14d74abe39..05afd9a0bc 100644
--- a/Items/CalamityGlobalItem.cs
+++ b/Items/CalamityGlobalItem.cs
@@ -125,11 +125,6 @@ namespace CalamityMod.Items
/// Adds "- Dev Item -" to the bottom of the item's tooltip.
///
public bool devItem = false;
- ///
- /// If set to a value greater than 1, applies a multiplier to the item's grab range.
- /// Used by coin items spawned from hitting ricoshot coins.
- ///
- public float grabRangeMultiplier = 1f;
public static readonly Color ExhumedTooltipColor = new Color(198, 27, 64);
@@ -168,7 +163,6 @@ namespace CalamityMod.Items
myClone.revengeanceItem = revengeanceItem;
myClone.donorItem = donorItem;
myClone.devItem = devItem;
- myClone.grabRangeMultiplier = grabRangeMultiplier;
return myClone;
}
@@ -1448,8 +1442,8 @@ namespace CalamityMod.Items
public override void GrabRange(Item item, Player player, ref int grabRange)
{
// First, apply the grab range multiplier.
- if (grabRangeMultiplier > 1f)
- grabRange = (int)(grabRangeMultiplier * grabRange);
+ if (item.TryGetGlobalItem(out var grabRangeItem) && grabRangeItem.grabRangeMultiplier > 1f)
+ grabRange = (int)(grabRangeItem.grabRangeMultiplier * grabRange);
// Then, apply flat grab range boosts.
if (player.Calamity().reaverExplore)
diff --git a/Items/GrabRangeGlobalItem.cs b/Items/GrabRangeGlobalItem.cs
new file mode 100644
index 0000000000..8236179656
--- /dev/null
+++ b/Items/GrabRangeGlobalItem.cs
@@ -0,0 +1,37 @@
+using Terraria;
+using Terraria.ID;
+using Terraria.ModLoader;
+
+namespace CalamityMod.Items;
+
+internal sealed class GrabRangeGlobalItem : GlobalItem
+{
+ ///
+ /// If set to a value greater than 1, applies a multiplier to the item's grab range.
+ /// Used by coin items spawned from hitting ricoshot coins.
+ ///
+ public float grabRangeMultiplier = 1f;
+
+ public override bool InstancePerEntity => true;
+
+ public override bool AppliesToEntity(Item entity, bool lateInstantiation)
+ {
+ return entity.type switch
+ {
+ ItemID.CopperCoin
+ or ItemID.SilverCoin
+ or ItemID.GoldCoin
+ or ItemID.PlatinumCoin => true,
+ _ => false,
+ };
+ }
+
+ public override GlobalItem Clone(Item item, Item itemClone)
+ {
+ GrabRangeGlobalItem myClone = (GrabRangeGlobalItem)base.Clone(item, itemClone);
+ myClone.grabRangeMultiplier = grabRangeMultiplier;
+ return myClone;
+ }
+
+ // GrabRange hook is Placed in CalamityGlobalItem for sake of ordering
+}
diff --git a/Projectiles/Ranged/RicoshotCoin.cs b/Projectiles/Ranged/RicoshotCoin.cs
index b8090108e7..f8f2a35d1e 100644
--- a/Projectiles/Ranged/RicoshotCoin.cs
+++ b/Projectiles/Ranged/RicoshotCoin.cs
@@ -1,4 +1,5 @@
using System;
+using CalamityMod.Items;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
@@ -243,7 +244,8 @@ namespace CalamityMod.Projectiles.Ranged
_ => ItemID.CopperCoin,
};
int coin = Item.NewItem(Projectile.GetSource_DropAsItem(), Projectile.Center, Vector2.One, itemID, noBroadcast: false);
- Main.item[coin].Calamity().grabRangeMultiplier = UsedCoinGrabRangeMultiplier;
+ if (Main.item[coin].TryGetGlobalItem(out var grabRangeItem))
+ grabRangeItem.grabRangeMultiplier = UsedCoinGrabRangeMultiplier;
// Sync this dropped coin in multiplayer.
if (Main.netMode == NetmodeID.MultiplayerClient)