My inventory System Cant tell the difference between Items being equipped to the player and being in the Inventory

Godot Version

4,2

Question

Hello, I’ve been scrapping together an Inventory system for my game and have run into an issue. The Inventory System registers when an item is equipped and unequipped and adjusts the character’s stats correctly, but if Items are moved around in the inventory grid without being equipped then that also affects the stats of the character as if the character was equipping and unequipping items.

Code:

class_name InventorySlot
extends PanelContainer

@export var type: ItemData.Type
var player


func _ready():
	player = get_tree().get_nodes_in_group("Player")

func init(t: ItemData.Type, cms: Vector2) -> void:
	type = t
	custom_minimum_size = cms
	
	
func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
	if data is InventoryItem:
		if type == ItemData.Type.MAIN:
			if get_child_count() == 0:
				return true
			else:
				if type == data.get_parent().type:
					return true
				return get_child(0).data.type == data.data.type
		else:
			return data.data.type == type
	return false

#handles dropping the item into inventory
func _drop_data(at_position: Vector2, data: Variant) -> void:
	if get_child_count() > 0:
		var item := get_child(0)
		#removes Item equiped stats
		player[0].damage -= item.data.item_damage
		player[0].defense -= item.data.item_defense
		if item == data:
			return
		item.reparent(data.get_parent())
	#Supplies new Item equiped stats
	if type != ItemData.Type.MAIN:
		player[0].damage += data.data.item_damage
		player[0].defense += data.data.item_defense
	else:
		#removes item from equip and places it in inventory
		player[0].damage -= data.data.item_damage
		player[0].defense -= data.data.item_defense
	data.reparent(self)

I am pretty sure the problem area Lies where I am trying to have it remove Item-equipped stats when dropping an item in the inventory but for the life of me, I can’t figure out how to fix it. If anybody has any ideas I’d appreciate the help. Thank you.