// Instantiate val battery = EnergyComponent(100, 500) val copy = battery.copy(amount = 200) // Immutable copy with change

If player or world is null, nothing happens. No crash.